From e82892f9b0225ba321d94e8540a277d03e115cb6 Mon Sep 17 00:00:00 2001 From: rivery Date: Tue, 21 Mar 2023 14:34:46 +0800 Subject: [PATCH] feat: update community --- src/pages/ServiceManage/LeaderDistribution/index.tsx | 9 ++++----- src/pages/ServiceManage/LongTermTask/index.tsx | 7 +++---- src/pages/ServiceManage/Overview/index.tsx | 4 ++-- src/utils/dashboard.ts | 11 ++++++----- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/pages/ServiceManage/LeaderDistribution/index.tsx b/src/pages/ServiceManage/LeaderDistribution/index.tsx index 0481a228..56bfa1d1 100644 --- a/src/pages/ServiceManage/LeaderDistribution/index.tsx +++ b/src/pages/ServiceManage/LeaderDistribution/index.tsx @@ -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'; @@ -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, @@ -32,7 +31,7 @@ interface IProps ReturnType { isOverview?: boolean; baseRouter?: string; - cluster?: ICluster; + cluster?: any; } interface IChaerData { @@ -97,7 +96,7 @@ const LeaderDistribution: React.FC = (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')); diff --git a/src/pages/ServiceManage/LongTermTask/index.tsx b/src/pages/ServiceManage/LongTermTask/index.tsx index 8d4e7548..7004f54a 100644 --- a/src/pages/ServiceManage/LongTermTask/index.tsx +++ b/src/pages/ServiceManage/LongTermTask/index.tsx @@ -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, @@ -28,7 +27,7 @@ const mapDispatch: any = (dispatch: IDispatch) => ({ interface IProps extends ReturnType, ReturnType { - cluster: ICluster; + cluster: any; } const LongTermTask: React.FC = props => { @@ -43,7 +42,7 @@ const LongTermTask: React.FC = 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(); diff --git a/src/pages/ServiceManage/Overview/index.tsx b/src/pages/ServiceManage/Overview/index.tsx index 2bba63e3..ae81c59c 100644 --- a/src/pages/ServiceManage/Overview/index.tsx +++ b/src/pages/ServiceManage/Overview/index.tsx @@ -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'; @@ -158,7 +158,7 @@ const Overview: React.FC = (props: IProps) => { }; const versionFeature = useMemo(() => { - const version = formatVersion(cluster?.version || DEFAULT_VERSION); + const version = formatVersion(cluster?.version); return getVersionFeatures(version, cluster?.nebulaType); }, [cluster]); diff --git a/src/utils/dashboard.ts b/src/utils/dashboard.ts index 9f18ff1a..54d13e7f 100644 --- a/src/utils/dashboard.ts +++ b/src/utils/dashboard.ts @@ -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]; @@ -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}`;