Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update community #222

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/pages/ServiceManage/LeaderDistribution/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IDispatch, IRootState } from '@/store';
import { Chart } from '@antv/g2';
import { renderPieChartTpl } from '@/utils/chart/chart';
import { connect } from 'react-redux';
import { last, round } from 'lodash';
import { last } from 'lodash';
import { compare } from 'compare-versions';
import Modal from '@/components/Modal';
import PieChart from '@/components/Charts/PieChart';
Expand All @@ -14,8 +14,7 @@ import classnames from 'classnames';
import SelectSpace from '../SelectSpace';
import './index.less';
import { isCommunityVersion } from '@/utils';
import { DEFAULT_VERSION, formatVersion } from '@/utils/dashboard';
import { ICluster } from '@base/utils/interface';
import { formatVersion } from '@/utils/dashboard';

const mapDispatch: any = (dispatch: IDispatch) => ({
asyncGetHostsInfo: dispatch.nebula.asyncGetHostsInfo,
Expand All @@ -32,7 +31,7 @@ interface IProps
ReturnType<typeof mapDispatch> {
isOverview?: boolean;
baseRouter?: string;
cluster?: ICluster;
cluster?: any;
}

interface IChaerData {
Expand Down Expand Up @@ -97,7 +96,7 @@ const LeaderDistribution: React.FC<IProps> = (props: IProps) => {
};

const handleBalance = async () => {
if (compare(formatVersion(cluster?.version || DEFAULT_VERSION), 'v3.0.0', '<')) {
if (compare(formatVersion(cluster?.version), 'v3.0.0', '<')) {
const { code } = await props.asyncExecNGQL('BALANCE LEADER');
if (code === 0) {
message.success(intl.get('common.successDelay'));
Expand Down
7 changes: 3 additions & 4 deletions src/pages/ServiceManage/LongTermTask/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import { IDispatch, IRootState } from '@/store';
import intl from 'react-intl-universal';
import { TitleInstruction } from '@/components/Instruction';
import { DashboardSelect, Option } from '@/components/DashboardSelect';
import { compareVersion, DEFAULT_VERSION, getVersion } from '@/utils/dashboard';
import { compareVersion, getDefaultNebulaVersion, getVersion } from '@/utils/dashboard';

import './index.less';
import { ICluster } from 'src/utils/interface';

const mapState = (state: IRootState) => ({
loading: state.loading.effects.nebula.asyncGetJobs,
Expand All @@ -28,7 +27,7 @@ const mapDispatch: any = (dispatch: IDispatch) => ({
interface IProps
extends ReturnType<typeof mapState>,
ReturnType<typeof mapDispatch> {
cluster: ICluster;
cluster: any;
}

const LongTermTask: React.FC<IProps> = props => {
Expand All @@ -43,7 +42,7 @@ const LongTermTask: React.FC<IProps> = props => {

const init = async () => {
// HAKC: Compatible processing version 2.6.0
if (compareVersion(getVersion(cluster?.version || DEFAULT_VERSION), '2.6.0') >= 0) {
if (compareVersion(getVersion(cluster?.version || getDefaultNebulaVersion()), '2.6.0') >= 0) {
await props.asyncGetSpaces();
if (currentSpace) {
props.asyncGetJobs();
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ServiceManage/Overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { DashboardSelect, Option } from '@/components/DashboardSelect';
import { getVersionFeatures } from '@/utils/versionFeature';
import Modal from '@/components/Modal';
import { IDispatch, IRootState } from '@/store';
import { DEFAULT_VERSION, formatVersion } from '@/utils/dashboard';
import { formatVersion } from '@/utils/dashboard';

import styles from './index.module.less';
import { isCommunityVersion } from '@/utils';
Expand Down Expand Up @@ -158,7 +158,7 @@ const Overview: React.FC<IProps> = (props: IProps) => {
};

const versionFeature = useMemo(() => {
const version = formatVersion(cluster?.version || DEFAULT_VERSION);
const version = formatVersion(cluster?.version);
return getVersionFeatures(version, cluster?.nebulaType);
}, [cluster]);

Expand Down
11 changes: 6 additions & 5 deletions src/utils/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import cookies from 'js-cookie';
import { ILineChartMetric, IStatRangeItem, MetricScene } from '@/utils/interface';
import { VALUE_TYPE } from '@/utils/promQL';

// used in nightly version;
export const DEFAULT_VERSION = process.env.NEBULA_VERSION!;

export const DETAIL_DEFAULT_RANGE = 60 * 60 * 24 * 1000;
export const MAX_STEP_ALLOW = 11000;
export const TIME_INTERVAL_OPTIONS = [5, 60, 600, 3600];
Expand Down Expand Up @@ -473,14 +470,18 @@ export const getConfigData = (data) => {
return list;
}

export const getDefaultNebulaVersion = () => {
return (window as any).NIGHTLY_NEBULA_VERSION || process.env.NEBULA_VERSION!;
}

export function formatVersion(version?: string): string {
if (!version) {
version = cookies.get('version');
}
if (semver.valid(version)) {
return semver.clean(version!) ?? DEFAULT_VERSION;
return semver.clean(version!)!;
}
return DEFAULT_VERSION;
return getDefaultNebulaVersion();
}

export let getMachineRouterPath = (path: string, id?): string => `/clusters/${id}${path}`;
Expand Down