diff --git a/src/App.tsx b/src/App.tsx index 5af290a2..21af1925 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -25,13 +25,14 @@ type IProps = RouteComponentProps; class App extends React.Component { currentLocale; + constructor(props: IProps) { super(props); const regx = /lang=(\w+)/g; const match = regx.exec(props.history.location.search); const lang = document.documentElement.getAttribute('lang'); - - if(!cookies.get('locale')){ + + if (!cookies.get('locale')) { if (match) { cookies.set('locale', match[1] === 'EN_US' ? 'EN_US' : 'ZH_CN'); } else { diff --git a/src/AuthorizedRoute.tsx b/src/AuthorizedRoute.tsx index 9595b79c..2f7fc909 100644 --- a/src/AuthorizedRoute.tsx +++ b/src/AuthorizedRoute.tsx @@ -1,6 +1,11 @@ import React from 'react'; import { connect } from 'react-redux'; -import { Redirect, Route, RouteComponentProps, withRouter } from 'react-router-dom'; +import { + Redirect, + Route, + RouteComponentProps, + withRouter, +} from 'react-router-dom'; import cookies from 'js-cookie'; import { IRootState } from '@/store'; @@ -25,10 +30,8 @@ const AuthorizedRoute = (props: IProps) => { ) : ( ); - } else { - return ; } + return ; }; - export default connect(mapState, mapDispatch)(withRouter(AuthorizedRoute)); diff --git a/src/components/MetricPopover/index.tsx b/src/components/MetricPopover/index.tsx index 02f4dbd8..c9312409 100644 --- a/src/components/MetricPopover/index.tsx +++ b/src/components/MetricPopover/index.tsx @@ -20,12 +20,18 @@ export const MetricPopover = (props: { list }) => { content={
-
+ {props.list.map(option => { - if(intl.get(`metric_description.${option.metric}`)){ - return - {intl.get(`metric_description.${option.metric}`)} - ; + if (intl.get(`metric_description.${option.metric}`)) { + return ( + + {intl.get(`metric_description.${option.metric}`)} + + ); } })}
diff --git a/src/components/Service/ServiceCardEdit/index.tsx b/src/components/Service/ServiceCardEdit/index.tsx index 4bdc6203..51a7abc3 100644 --- a/src/components/Service/ServiceCardEdit/index.tsx +++ b/src/components/Service/ServiceCardEdit/index.tsx @@ -27,13 +27,16 @@ class ServiceCardEdit extends React.Component { formRef = React.createRef(); handleUpdateMetricType = (value: string) => { - const { serviceMetric = { spaces: [], graphd: [], storaged:[], metad:[] }, editType } = this.props; + const { + serviceMetric = { spaces: [], graphd: [], storaged: [], metad: [] }, + editType, + } = this.props; const metric = serviceMetric[`${editType}d`].filter( item => item.metric === value, )[0]; this.formRef.current!.setFieldsValue({ metricFunction: metric?.metricType[0].value, - space: '' + space: '', }); }; @@ -61,7 +64,8 @@ class ServiceCardEdit extends React.Component { }; render() { - const { editIndex, editType, serviceMetric, panelConfig, onClose } = this.props; + const { editIndex, editType, serviceMetric, panelConfig, onClose } = + this.props; const editItem = panelConfig[editType][editIndex]; return (
@@ -101,13 +105,10 @@ class ServiceCardEdit extends React.Component { item => item.metric === metric, )[0]?.isSpaceMetric; return getFieldValue('metric') && isSpaceMetric ? ( - + {serviceMetric.spaces?.map(space => (