refactor: clean code && Upgrade

This commit is contained in:
王彦民 2019-01-09 16:49:54 +08:00 committed by Asa
parent 8fdbf685a8
commit 829f538e9f
35 changed files with 8691 additions and 116 deletions

View File

@ -1,9 +1,20 @@
{ {
"presets": [ "presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "entry"
}
],
"react-app" "react-app"
], ],
"plugins": [ "plugins": [
"transform-decorators-legacy", [
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
[ [
"babel-plugin-import", "babel-plugin-import",
{ {

View File

@ -27,22 +27,21 @@
"url": "git+https://github.com/alibaba/nacos.git" "url": "git+https://github.com/alibaba/nacos.git"
}, },
"devDependencies": { "devDependencies": {
"babel-cli": "^6.26.0", "@babel/cli": "^7.2.3",
"babel-core": "^6.26.3", "@babel/core": "^7.2.2",
"@babel/plugin-proposal-decorators": "^7.2.3",
"@babel/preset-env": "^7.2.3",
"@babel/runtime": "^7.2.0",
"babel-eslint": "^10.0.1", "babel-eslint": "^10.0.1",
"babel-loader": "^7.1.5", "babel-loader": "^8.0.4",
"babel-plugin-import": "^1.10.0", "babel-plugin-import": "^1.11.0",
"babel-plugin-transform-decorators": "^6.24.1", "babel-preset-react-app": "^6.1.0",
"babel-plugin-transform-decorators-legacy": "^1.3.5",
"babel-preset-env": "^1.7.0",
"babel-preset-react-app": "^3.1.1",
"babel-runtime": "^6.23.0",
"clean-webpack-plugin": "^0.1.19", "clean-webpack-plugin": "^0.1.19",
"copy-webpack-plugin": "^4.6.0", "copy-webpack-plugin": "^4.6.0",
"cross-env": "^5.2.0", "cross-env": "^5.2.0",
"css-loader": "^1.0.0", "css-loader": "^2.0.2",
"eslint": "^5.9.0", "eslint": "^5.11.0",
"eslint-config-ali": "^4.0.0", "eslint-config-ali": "^4.1.0",
"eslint-config-prettier": "^3.3.0", "eslint-config-prettier": "^3.3.0",
"eslint-loader": "^2.1.1", "eslint-loader": "^2.1.1",
"eslint-plugin-import": "^2.14.0", "eslint-plugin-import": "^2.14.0",
@ -52,27 +51,27 @@
"html-webpack-plugin": "^3.2.0", "html-webpack-plugin": "^3.2.0",
"husky": "^1.1.4", "husky": "^1.1.4",
"lint-staged": "^8.0.4", "lint-staged": "^8.0.4",
"mini-css-extract-plugin": "^0.4.3", "mini-css-extract-plugin": "^0.5.0",
"node-sass": "^4.1.0", "node-sass": "^4.11.0",
"optimize-css-assets-webpack-plugin": "^5.0.1", "optimize-css-assets-webpack-plugin": "^5.0.1",
"prettier": "1.15.2", "prettier": "1.15.2",
"sass-loader": "^7.1.0", "sass-loader": "^7.1.0",
"style-loader": "^0.23.0", "style-loader": "^0.23.1",
"uglifyjs-webpack-plugin": "^2.0.1", "uglifyjs-webpack-plugin": "^2.1.0",
"url-loader": "^1.1.1", "url-loader": "^1.1.2",
"webpack": "^4.20.2", "webpack": "^4.28.2",
"webpack-cli": "^3.1.2", "webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.9" "webpack-dev-server": "^3.1.13"
}, },
"dependencies": { "dependencies": {
"@alifd/next": "^1.9.19", "@alifd/next": "^1.11.5",
"axios": "^0.18.0", "axios": "^0.18.0",
"jquery": "^3.3.1", "jquery": "^3.3.1",
"moment": "^2.22.2", "moment": "^2.23.0",
"prop-types": "^15.6.2", "prop-types": "^15.6.2",
"react": "^16.6.0", "react": "^16.7.0",
"react-dom": "^16.6.0", "react-dom": "^16.7.0",
"react-redux": "^5.1.0", "react-redux": "^5.1.1",
"react-router": "^4.3.1", "react-router": "^4.3.1",
"react-router-dom": "^4.3.1", "react-router-dom": "^4.3.1",
"react-router-redux": "^4.0.8", "react-router-redux": "^4.0.8",

View File

@ -12,6 +12,7 @@
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { Button, ConfigProvider, Dialog, Grid, Icon } from '@alifd/next'; import { Button, ConfigProvider, Dialog, Grid, Icon } from '@alifd/next';
import './index.scss'; import './index.scss';
@ -22,6 +23,10 @@ const { Row, Col } = Grid;
class DeleteDialog extends React.Component { class DeleteDialog extends React.Component {
static displayName = 'DeleteDialog'; static displayName = 'DeleteDialog';
static propTypes = {
locale: PropTypes.object,
};
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -35,6 +40,10 @@ class DeleteDialog extends React.Component {
} }
componentDidMount() { componentDidMount() {
this.initData();
}
initData() {
const { locale = {} } = this.props; const { locale = {} } = this.props;
this.setState({ title: locale.confManagement }); this.setState({ title: locale.confManagement });
} }

View File

@ -23,6 +23,10 @@ const { Row, Col } = Grid;
class DiffEditorDialog extends React.Component { class DiffEditorDialog extends React.Component {
static displayName = 'DiffEditorDialog'; static displayName = 'DiffEditorDialog';
static propTypes = {
locale: PropTypes.object,
};
static propTypes = { static propTypes = {
publishConfig: PropTypes.func, publishConfig: PropTypes.func,
}; };

View File

@ -12,6 +12,7 @@
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { request } from '../../globalLib'; import { request } from '../../globalLib';
import { Button, ConfigProvider, Dialog, Field, Form, Input, Loading } from '@alifd/next'; import { Button, ConfigProvider, Dialog, Field, Form, Input, Loading } from '@alifd/next';
@ -23,6 +24,11 @@ const FormItem = Form.Item;
class EditorNameSpace extends React.Component { class EditorNameSpace extends React.Component {
static displayName = 'EditorNameSpace'; static displayName = 'EditorNameSpace';
static propTypes = {
getNameSpaces: PropTypes.func,
locale: PropTypes.object,
};
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {

View File

@ -26,6 +26,7 @@ class NameSpaceList extends React.Component {
static displayName = 'NameSpaceList'; static displayName = 'NameSpaceList';
static propTypes = { static propTypes = {
locale: PropTypes.object,
setNowNameSpace: PropTypes.func, setNowNameSpace: PropTypes.func,
namespaceCallBack: PropTypes.func, namespaceCallBack: PropTypes.func,
title: PropTypes.string, title: PropTypes.string,

View File

@ -16,6 +16,7 @@ import { request } from '../../globalLib';
import { Button, ConfigProvider, Dialog, Field, Form, Input, Loading } from '@alifd/next'; import { Button, ConfigProvider, Dialog, Field, Form, Input, Loading } from '@alifd/next';
import './index.scss'; import './index.scss';
import PropTypes from 'prop-types';
const FormItem = Form.Item; const FormItem = Form.Item;
@ -28,6 +29,11 @@ const formItemLayout = {
class NewNameSpace extends React.Component { class NewNameSpace extends React.Component {
static displayName = 'NewNameSpace'; static displayName = 'NewNameSpace';
static propTypes = {
locale: PropTypes.object,
getNameSpaces: PropTypes.func,
};
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {

View File

@ -77,7 +77,10 @@ class RegionGroup extends React.Component {
// this.setRegionWidth(); // this.setRegionWidth();
// this.handleRegionListStatus(); // this.handleRegionListStatus();
// }); // });
this.nameSpaceList.current.getInstance().getNameSpaces(); const nameSpaceList = this.nameSpaceList.current;
if (nameSpaceList) {
nameSpaceList.getInstance().getNameSpaces();
}
} }
componentWillUnmount() { componentWillUnmount() {
@ -152,7 +155,10 @@ class RegionGroup extends React.Component {
this.handleRegionList(window._regionList); this.handleRegionList(window._regionList);
} else { } else {
// TODO // TODO
this.nameSpaceList.current.getInstance().getNameSpaces(); const nameSpaceList = this.nameSpaceList.current;
if (nameSpaceList) {
nameSpaceList.getInstance().getNameSpaces();
}
request({ request({
url: this.state.url, url: this.state.url,
@ -189,7 +195,10 @@ class RegionGroup extends React.Component {
setTimeout(() => { setTimeout(() => {
this.changeRegionBarRegionId(this.currRegionId); this.changeRegionBarRegionId(this.currRegionId);
}, 1000); }, 1000);
this.nameSpaceList.current.getInstance().getNameSpaces(); const nameSpaceList = this.nameSpaceList.current;
if (nameSpaceList) {
nameSpaceList.getInstance().getNameSpaces();
}
this.setState({ this.setState({
currRegionId: envcontent, currRegionId: envcontent,
instanceData, instanceData,

View File

@ -12,6 +12,7 @@
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { getParams } from '../../globalLib'; import { getParams } from '../../globalLib';
import { ConfigProvider, Dialog, Loading, Tab } from '@alifd/next'; import { ConfigProvider, Dialog, Loading, Tab } from '@alifd/next';
@ -23,6 +24,10 @@ const TabPane = Tab.Item;
class ShowCodeing extends React.Component { class ShowCodeing extends React.Component {
static displayName = 'ShowCodeing'; static displayName = 'ShowCodeing';
static propTypes = {
locale: PropTypes.object,
};
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {

View File

@ -24,6 +24,7 @@ class SuccessDialog extends React.Component {
static displayName = 'SuccessDialog'; static displayName = 'SuccessDialog';
static propTypes = { static propTypes = {
locale: PropTypes.object,
unpushtrace: PropTypes.bool, unpushtrace: PropTypes.bool,
}; };
@ -41,6 +42,10 @@ class SuccessDialog extends React.Component {
} }
componentDidMount() { componentDidMount() {
this.initData();
}
initData() {
const { locale = {} } = this.props; const { locale = {} } = this.props;
this.setState({ title: locale.title }); this.setState({ title: locale.title });
} }

View File

@ -16,3 +16,5 @@ export const LANGUAGE_SWITCH = 'LANGUAGE_SWITCH';
// TODO: 后端暂时没有统一成功失败标记 // TODO: 后端暂时没有统一成功失败标记
// export const SUCCESS_RESULT_CODE = 'SUCCESS'; // export const SUCCESS_RESULT_CODE = 'SUCCESS';
export const REDUX_DEVTOOLS = '__REDUX_DEVTOOLS_EXTENSION__';

View File

@ -27,7 +27,7 @@ import _menu from './menu';
import Layout from './layouts/MainLayout'; import Layout from './layouts/MainLayout';
import CookieHelp from './utils/cookie'; import CookieHelp from './utils/cookie';
import { LANGUAGE_KEY } from './constants'; import { LANGUAGE_KEY, REDUX_DEVTOOLS } from './constants';
import Namespace from './pages/NameSpace'; import Namespace from './pages/NameSpace';
import Newconfig from './pages/ConfigurationManagement/NewConfig'; import Newconfig from './pages/ConfigurationManagement/NewConfig';
@ -46,11 +46,12 @@ import reducers from './reducers';
import { changeLanguage } from './reducers/locale'; import { changeLanguage } from './reducers/locale';
import './index.scss'; import './index.scss';
import PropTypes from 'prop-types';
module.hot && module.hot.accept(); module.hot && module.hot.accept();
if (!CookieHelp.getValue(LANGUAGE_KEY)) { if (!localStorage.getItem(LANGUAGE_KEY)) {
CookieHelp.setValue(LANGUAGE_KEY, navigator.language === 'zh-CN' ? 'zh-cn' : 'en-us'); localStorage.setItem(LANGUAGE_KEY, navigator.language === 'zh-CN' ? 'zh-CN' : 'en-US');
} }
const reducer = combineReducers({ const reducer = combineReducers({
@ -62,15 +63,36 @@ const store = createStore(
reducer, reducer,
compose( compose(
applyMiddleware(thunk), applyMiddleware(thunk),
window.devToolsExtension ? window.devToolsExtension() : f => f window[REDUX_DEVTOOLS] ? window[REDUX_DEVTOOLS]() : f => f
) )
); );
const MENU = [
{ path: '/', exact: true, render: () => <Redirect to="/configurationManagement" /> },
{ path: '/namespace', component: Namespace },
{ path: '/newconfig', component: Newconfig },
{ path: '/configsync', component: Configsync },
{ path: '/configdetail', component: Configdetail },
{ path: '/configeditor', component: Configeditor },
{ path: '/historyDetail', component: HistoryDetail },
{ path: '/configRollback', component: ConfigRollback },
{ path: '/historyRollback', component: HistoryRollback },
{ path: '/listeningToQuery', component: ListeningToQuery },
{ path: '/configurationManagement', component: ConfigurationManagement },
{ path: '/serviceManagement', component: ServiceList },
{ path: '/serviceDetail', component: ServiceDetail },
];
@connect( @connect(
state => ({ ...state.locale }), state => ({ ...state.locale }),
{ changeLanguage } { changeLanguage }
) )
class App extends React.Component { class App extends React.Component {
static propTypes = {
locale: PropTypes.object,
changeLanguage: PropTypes.func,
};
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -81,28 +103,18 @@ class App extends React.Component {
} }
componentDidMount() { componentDidMount() {
const language = CookieHelp.getValue(LANGUAGE_KEY); const language = localStorage.getItem(LANGUAGE_KEY);
this.props.changeLanguage(language); this.props.changeLanguage(language);
} }
static generateRouter() { get router() {
return ( return (
<HashRouter> <HashRouter>
<Layout navList={_menu.data}> <Layout navList={_menu.data}>
<Switch> <Switch>
<Route path="/" exact render={() => <Redirect to="/configurationManagement" />} /> {MENU.map(item => (
<Route path="/namespace" component={Namespace} /> <Route key={item.path} {...item} />
<Route path="/newconfig" component={Newconfig} /> ))}
<Route path="/configsync" component={Configsync} />
<Route path="/configdetail" component={Configdetail} />
<Route path="/configeditor" component={Configeditor} />
<Route path="/historyDetail" component={HistoryDetail} />
<Route path="/configRollback" component={ConfigRollback} />
<Route path="/historyRollback" component={HistoryRollback} />
<Route path="/listeningToQuery" component={ListeningToQuery} />
<Route path="/configurationManagement" component={ConfigurationManagement} />
<Route path="/serviceManagement" component={ServiceList} />
<Route path="/serviceDetail" component={ServiceDetail} />
</Switch> </Switch>
</Layout> </Layout>
</HashRouter> </HashRouter>
@ -120,7 +132,7 @@ class App extends React.Component {
fullScreen fullScreen
{...this.state.nacosLoading} {...this.state.nacosLoading}
> >
<ConfigProvider locale={locale}>{App.generateRouter()}</ConfigProvider> <ConfigProvider locale={locale}>{this.router}</ConfigProvider>
</Loading> </Loading>
); );
} }

View File

@ -12,11 +12,11 @@
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { ConfigProvider } from '@alifd/next'; import { ConfigProvider } from '@alifd/next';
import siteConfig from '../config'; import siteConfig from '../config';
import { changeLanguage } from '@/reducers/locale'; import { changeLanguage } from '@/reducers/locale';
import { aliwareIntl } from '@/globalLib';
import './index.scss'; import './index.scss';
@ -28,45 +28,36 @@ import './index.scss';
class Header extends React.Component { class Header extends React.Component {
static displayName = 'Header'; static displayName = 'Header';
static propTypes = {
locale: PropTypes.object,
language: PropTypes.string,
changeLanguage: PropTypes.func,
};
switchLang = () => { switchLang = () => {
const { language = 'en-us', changeLanguage } = this.props; const { language = 'en-US', changeLanguage } = this.props;
const currentLanguage = language === 'en-us' ? 'zh-cn' : 'en-us'; const currentLanguage = language === 'en-US' ? 'zh-CN' : 'en-US';
changeLanguage(currentLanguage); changeLanguage(currentLanguage);
aliwareIntl.changeLanguage(currentLanguage);
document.cookie = `docsite_language=${currentLanguage}`;
window.location.reload();
}; };
render() { render() {
const { locale = {}, language = 'en-us' } = this.props; const { locale = {}, language = 'en-US' } = this.props;
const { home, docs, blog, community, languageSwitchButton } = locale; const { home, docs, blog, community, languageSwitchButton } = locale;
const BASE_URL = `https://nacos.io/${language}/`; const BASE_URL = `https://nacos.io/${language.toLocaleLowerCase()}/`;
const NAV_MENU = [ const NAV_MENU = [
{ { id: 1, title: home, link: BASE_URL },
id: 1, { id: 2, title: docs, link: `${BASE_URL}docs/what-is-nacos.html` },
title: home, { id: 3, title: blog, link: `${BASE_URL}blog/index.html` },
link: BASE_URL, { id: 4, title: community, link: `${BASE_URL}community/index.html` },
},
{
id: 2,
title: docs,
link: `${BASE_URL}docs/what-is-nacos.html`,
},
{
id: 3,
title: blog,
link: `${BASE_URL}blog/index.html`,
},
{
id: 4,
title: community,
link: `${BASE_URL}community/index.html`,
},
]; ];
return ( return (
<header className="header-container header-container-primary"> <header className="header-container header-container-primary">
<div className="header-body"> <div className="header-body">
<a href="https://nacos.io/zh-cn/" target="_blank" rel="noopener noreferrer"> <a
href={`https://nacos.io/${language.toLocaleLowerCase()}/`}
target="_blank"
rel="noopener noreferrer"
>
<img <img
src="img/TB118jPv_mWBKNjSZFBXXXxUFXa-2000-390.svg" src="img/TB118jPv_mWBKNjSZFBXXXxUFXa-2000-390.svg"
className="logo" className="logo"

View File

@ -29,6 +29,7 @@ class MainLayout extends React.Component {
static propTypes = { static propTypes = {
navList: PropTypes.array, navList: PropTypes.array,
history: PropTypes.object, history: PropTypes.object,
locale: PropTypes.object,
children: PropTypes.any, children: PropTypes.any,
}; };

View File

@ -16,6 +16,7 @@ import { Button, ConfigProvider, Dialog, Field, Form, Input, Loading, Tab } from
import { getParams, request } from '../../../globalLib'; import { getParams, request } from '../../../globalLib';
import './index.scss'; import './index.scss';
import PropTypes from 'prop-types';
const TabPane = Tab.Item; const TabPane = Tab.Item;
const FormItem = Form.Item; const FormItem = Form.Item;
@ -24,6 +25,11 @@ const FormItem = Form.Item;
class ConfigDetail extends React.Component { class ConfigDetail extends React.Component {
static displayName = 'ConfigDetail'; static displayName = 'ConfigDetail';
static propTypes = {
locale: PropTypes.object,
history: PropTypes.object,
};
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -48,13 +54,17 @@ class ConfigDetail extends React.Component {
} }
componentDidMount() { componentDidMount() {
this.initData();
this.getDataDetail();
}
initData() {
const { locale = {} } = this.props; const { locale = {} } = this.props;
if (this.dataId.startsWith('cipher-')) { if (this.dataId.startsWith('cipher-')) {
this.setState({ this.setState({
switchEncrypt: true, switchEncrypt: true,
}); });
} }
this.getDataDetail();
this.setState({ tag: [{ title: locale.official, key: 'normal' }] }); this.setState({ tag: [{ title: locale.official, key: 'normal' }] });
} }

View File

@ -11,8 +11,9 @@
* limitations under the License. * limitations under the License.
*/ */
import React from 'react';
import $ from 'jquery'; import $ from 'jquery';
import React from 'react';
import PropTypes from 'prop-types';
import { getParams, request } from '../../../globalLib'; import { getParams, request } from '../../../globalLib';
import DiffEditorDialog from '../../../components/DiffEditorDialog'; import DiffEditorDialog from '../../../components/DiffEditorDialog';
import SuccessDialog from '../../../components/SuccessDialog'; import SuccessDialog from '../../../components/SuccessDialog';
@ -43,6 +44,11 @@ const { Group: RadioGroup } = Radio;
class ConfigEditor extends React.Component { class ConfigEditor extends React.Component {
static displayName = 'ConfigEditor'; static displayName = 'ConfigEditor';
static propTypes = {
locale: PropTypes.object,
history: PropTypes.object,
};
constructor(props) { constructor(props) {
super(props); super(props);
this.diffEditorDialog = React.createRef(); this.diffEditorDialog = React.createRef();
@ -81,6 +87,13 @@ class ConfigEditor extends React.Component {
} }
componentDidMount() { componentDidMount() {
this.initData();
this.betaips = document.getElementById('betaips');
this.getDataDetail();
this.chontenttab = document.getElementById('chontenttab'); // diff标签
}
initData() {
const { locale = {} } = this.props; const { locale = {} } = this.props;
this.setState({ this.setState({
tag: [ tag: [
@ -91,13 +104,8 @@ class ConfigEditor extends React.Component {
], ],
}); });
if (this.dataId.startsWith('cipher-')) { if (this.dataId.startsWith('cipher-')) {
this.setState({ this.setState({ switchEncrypt: true });
switchEncrypt: true,
});
} }
this.betaips = document.getElementById('betaips');
this.getDataDetail();
this.chontenttab = document.getElementById('chontenttab'); // diff标签
} }
initMoacoEditor(language, value) { initMoacoEditor(language, value) {

View File

@ -12,6 +12,7 @@
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { getParams, request } from '../../../globalLib'; import { getParams, request } from '../../../globalLib';
import { Button, ConfigProvider, Dialog, Field, Form, Input } from '@alifd/next'; import { Button, ConfigProvider, Dialog, Field, Form, Input } from '@alifd/next';
@ -38,6 +39,11 @@ class ConfigRollback extends React.Component {
// this.params = window.location.hash.split('?')[1]||''; // this.params = window.location.hash.split('?')[1]||'';
} }
static propTypes = {
history: PropTypes.object,
locale: PropTypes.object,
};
componentDidMount() { componentDidMount() {
const { locale = {} } = this.props; const { locale = {} } = this.props;
this.typeMap = { this.typeMap = {

View File

@ -12,6 +12,7 @@
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { Button, Checkbox, ConfigProvider, Dialog, Field, Form, Input, Loading } from '@alifd/next'; import { Button, Checkbox, ConfigProvider, Dialog, Field, Form, Input, Loading } from '@alifd/next';
import SuccessDialog from '../../../components/SuccessDialog'; import SuccessDialog from '../../../components/SuccessDialog';
import { getParams, request } from '../../../globalLib'; import { getParams, request } from '../../../globalLib';
@ -22,6 +23,11 @@ import './index.scss';
class ConfigSync extends React.Component { class ConfigSync extends React.Component {
static displayName = 'ConfigSync'; static displayName = 'ConfigSync';
static propTypes = {
locale: PropTypes.object,
history: PropTypes.object,
};
constructor(props) { constructor(props) {
super(props); super(props);
this.successDialog = React.createRef(); this.successDialog = React.createRef();

View File

@ -38,6 +38,7 @@ import DashboardCard from './DashboardCard';
import { getParams, setParams, request, aliwareIntl } from '@/globalLib'; import { getParams, setParams, request, aliwareIntl } from '@/globalLib';
import './index.scss'; import './index.scss';
import { LANGUAGE_KEY } from '../../../constants';
const { Panel } = Collapse; const { Panel } = Collapse;
@ -46,6 +47,7 @@ class ConfigurationManagement extends React.Component {
static displayName = 'ConfigurationManagement'; static displayName = 'ConfigurationManagement';
static propTypes = { static propTypes = {
locale: PropTypes.object,
history: PropTypes.object, history: PropTypes.object,
}; };
@ -107,16 +109,7 @@ class ConfigurationManagement extends React.Component {
componentDidMount() { componentDidMount() {
const { locale = {} } = this.props; const { locale = {} } = this.props;
// this.getGroup(); // this.getGroup();
if (aliwareIntl.currentLanguageCode === 'zh-cn') { this.setIsCn();
// this.getContentList(); //在中文站获取概览页
this.setState({
isCn: true,
});
} else {
this.setState({
isCn: false,
});
}
if (window._getLink && window._getLink('isCn') === 'true') { if (window._getLink && window._getLink('isCn') === 'true') {
if (!this.checkQuestionnaire()) { if (!this.checkQuestionnaire()) {
if (window.location.host === 'acm.console.aliyun.com') { if (window.location.host === 'acm.console.aliyun.com') {
@ -145,6 +138,10 @@ class ConfigurationManagement extends React.Component {
} }
} }
setIsCn() {
this.setState({ isCn: localStorage.getItem(LANGUAGE_KEY) === 'zh-CN' });
}
/** /**
* 获取概览页数据 * 获取概览页数据
*/ */
@ -726,7 +723,7 @@ class ConfigurationManagement extends React.Component {
{this.state.nownamespace_id} {this.state.nownamespace_id}
</span> </span>
{locale.queryResults} {locale.queryResults}
<strong style={{ fontWeight: 'bold' }}> {this.state.total} </strong> <strong style={{ fontWeight: 'bold' }}> {this.state.total} </strong>
{locale.articleMeetRequirements} {locale.articleMeetRequirements}
</h3> </h3>
<div <div

View File

@ -12,12 +12,19 @@
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { ConfigProvider, Slider } from '@alifd/next'; import { ConfigProvider, Slider } from '@alifd/next';
@ConfigProvider.config @ConfigProvider.config
class DashboardCard extends React.Component { class DashboardCard extends React.Component {
static displayName = 'DashboardCard'; static displayName = 'DashboardCard';
static propTypes = {
locale: PropTypes.object,
data: PropTypes.object,
height: PropTypes.number,
};
render() { render() {
const { data = {}, height, locale = {} } = this.props; const { data = {}, height, locale = {} } = this.props;
return ( return (

View File

@ -23,6 +23,7 @@ class HistoryDetail extends React.Component {
static displayName = 'HistoryDetail'; static displayName = 'HistoryDetail';
static propTypes = { static propTypes = {
locale: PropTypes.object,
history: PropTypes.object, history: PropTypes.object,
}; };

View File

@ -12,6 +12,7 @@
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { ConfigProvider, Field, Form, Input, Loading, Pagination, Table } from '@alifd/next'; import { ConfigProvider, Field, Form, Input, Loading, Pagination, Table } from '@alifd/next';
import RegionGroup from 'components/RegionGroup'; import RegionGroup from 'components/RegionGroup';
import { getParams, setParams, request, aliwareIntl } from '@/globalLib'; import { getParams, setParams, request, aliwareIntl } from '@/globalLib';
@ -22,6 +23,11 @@ import './index.scss';
class HistoryRollback extends React.Component { class HistoryRollback extends React.Component {
static displayName = 'HistoryRollback'; static displayName = 'HistoryRollback';
static propTypes = {
locale: PropTypes.object,
history: PropTypes.object,
};
constructor(props) { constructor(props) {
super(props); super(props);

View File

@ -12,6 +12,7 @@
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import RegionGroup from '../../../components/RegionGroup'; import RegionGroup from '../../../components/RegionGroup';
import { getParams, request } from '../../../globalLib'; import { getParams, request } from '../../../globalLib';
import { import {
@ -35,6 +36,10 @@ const { Row, Col } = Grid;
class ListeningToQuery extends React.Component { class ListeningToQuery extends React.Component {
static displayName = 'ListeningToQuery'; static displayName = 'ListeningToQuery';
static propTypes = {
locale: PropTypes.object,
};
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {

View File

@ -11,8 +11,9 @@
* limitations under the License. * limitations under the License.
*/ */
import React from 'react';
import $ from 'jquery'; import $ from 'jquery';
import React from 'react';
import PropTypes from 'prop-types';
import SuccessDialog from '../../../components/SuccessDialog'; import SuccessDialog from '../../../components/SuccessDialog';
import { getParams, setParams, request, aliwareIntl } from '../../../globalLib'; import { getParams, setParams, request, aliwareIntl } from '../../../globalLib';
import { import {
@ -41,6 +42,11 @@ const { AutoComplete: Combobox } = Select;
class NewConfig extends React.Component { class NewConfig extends React.Component {
static displayName = 'NewConfig'; static displayName = 'NewConfig';
static propTypes = {
locale: PropTypes.object,
history: PropTypes.object,
};
constructor(props) { constructor(props) {
super(props); super(props);
this.successDialog = React.createRef(); this.successDialog = React.createRef();

View File

@ -12,6 +12,7 @@
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { Button, ConfigProvider, Dialog, Loading, Table } from '@alifd/next'; import { Button, ConfigProvider, Dialog, Loading, Table } from '@alifd/next';
import RegionGroup from '../../components/RegionGroup'; import RegionGroup from '../../components/RegionGroup';
import NewNameSpace from '../../components/NewNameSpace'; import NewNameSpace from '../../components/NewNameSpace';
@ -24,6 +25,10 @@ import './index.scss';
class NameSpace extends React.Component { class NameSpace extends React.Component {
static displayName = 'NameSpace'; static displayName = 'NameSpace';
static propTypes = {
locale: PropTypes.object,
};
constructor(props) { constructor(props) {
super(props); super(props);
this.editgroup = React.createRef(); this.editgroup = React.createRef();

View File

@ -12,6 +12,7 @@
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { request } from '../../../globalLib'; import { request } from '../../../globalLib';
import { Dialog, Form, Input, Switch, Select, Message, ConfigProvider } from '@alifd/next'; import { Dialog, Form, Input, Switch, Select, Message, ConfigProvider } from '@alifd/next';
import { DIALOG_FORM_LAYOUT } from './constant'; import { DIALOG_FORM_LAYOUT } from './constant';
@ -20,6 +21,13 @@ import { DIALOG_FORM_LAYOUT } from './constant';
class EditClusterDialog extends React.Component { class EditClusterDialog extends React.Component {
static displayName = 'EditClusterDialog'; static displayName = 'EditClusterDialog';
static propTypes = {
openLoading: PropTypes.func,
closeLoading: PropTypes.func,
getServiceDetail: PropTypes.func,
locale: PropTypes.object,
};
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {

View File

@ -12,6 +12,7 @@
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { request } from '../../../globalLib'; import { request } from '../../../globalLib';
import { Dialog, Form, Input, Switch, Message, ConfigProvider } from '@alifd/next'; import { Dialog, Form, Input, Switch, Message, ConfigProvider } from '@alifd/next';
import { DIALOG_FORM_LAYOUT } from './constant'; import { DIALOG_FORM_LAYOUT } from './constant';
@ -20,6 +21,15 @@ import { DIALOG_FORM_LAYOUT } from './constant';
class EditInstanceDialog extends React.Component { class EditInstanceDialog extends React.Component {
static displayName = 'EditInstanceDialog'; static displayName = 'EditInstanceDialog';
static propTypes = {
serviceName: PropTypes.string,
clusterName: PropTypes.string,
openLoading: PropTypes.string,
closeLoading: PropTypes.string,
getInstanceList: PropTypes.func,
locale: PropTypes.object,
};
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {

View File

@ -12,6 +12,7 @@
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { request } from '../../../globalLib'; import { request } from '../../../globalLib';
import { Dialog, Form, Input, Select, Message, ConfigProvider } from '@alifd/next'; import { Dialog, Form, Input, Select, Message, ConfigProvider } from '@alifd/next';
import { DIALOG_FORM_LAYOUT } from './constant'; import { DIALOG_FORM_LAYOUT } from './constant';
@ -20,6 +21,12 @@ import { DIALOG_FORM_LAYOUT } from './constant';
class EditServiceDialog extends React.Component { class EditServiceDialog extends React.Component {
static displayName = 'EditServiceDialog'; static displayName = 'EditServiceDialog';
static propTypes = {
queryServiceList: PropTypes.func,
getServiceDetail: PropTypes.func,
locale: PropTypes.object,
};
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -85,12 +92,10 @@ class EditServiceDialog extends React.Component {
}); });
} }
getFormItemLayout = () => { getFormItemLayout = () => ({
return {
labelCol: { span: 6 }, labelCol: { span: 6 },
wrapperCol: { span: 14 }, wrapperCol: { span: 14 },
}; });
};
render() { render() {
const { locale = {} } = this.props; const { locale = {} } = this.props;

View File

@ -23,6 +23,7 @@ class InstanceTable extends React.Component {
static displayName = 'InstanceTable'; static displayName = 'InstanceTable';
static propTypes = { static propTypes = {
locale: PropTypes.object,
clusterName: PropTypes.string, clusterName: PropTypes.string,
serviceName: PropTypes.string, serviceName: PropTypes.string,
}; };

View File

@ -12,6 +12,7 @@
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { request } from '@/globalLib'; import { request } from '@/globalLib';
import { Button, Card, ConfigProvider, Form, Loading } from '@alifd/next'; import { Button, Card, ConfigProvider, Form, Loading } from '@alifd/next';
import EditServiceDialog from './EditServiceDialog'; import EditServiceDialog from './EditServiceDialog';
@ -30,6 +31,12 @@ const pageFormLayout = {
class ServiceDetail extends React.Component { class ServiceDetail extends React.Component {
static displayName = 'ServiceDetail'; static displayName = 'ServiceDetail';
static propTypes = {
locale: PropTypes.object,
history: PropTypes.object,
location: PropTypes.object,
};
constructor(props) { constructor(props) {
super(props); super(props);
this.editServiceDialog = React.createRef(); this.editServiceDialog = React.createRef();

View File

@ -12,6 +12,7 @@
*/ */
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { import {
Button, Button,
Field, Field,
@ -39,6 +40,11 @@ const { Column } = Table;
class ServiceList extends React.Component { class ServiceList extends React.Component {
static displayName = 'ServiceList'; static displayName = 'ServiceList';
static propTypes = {
locale: PropTypes.object,
history: PropTypes.object,
};
constructor(props) { constructor(props) {
super(props); super(props);
this.editServiceDialog = React.createRef(); this.editServiceDialog = React.createRef();

View File

@ -26,9 +26,9 @@ const initialState = {
}; };
const changeLanguage = lang => dispatch => { const changeLanguage = lang => dispatch => {
const language = lang === 'zh-cn' ? 'zh-cn' : 'en-us'; const language = lang === 'zh-CN' ? 'zh-CN' : 'en-US';
CookieHelp.setValue(LANGUAGE_KEY, language); localStorage.setItem(LANGUAGE_KEY, language);
dispatch({ type: LANGUAGE_SWITCH, language, locale: language === 'zh-cn' ? zhCN : enUS }); dispatch({ type: LANGUAGE_SWITCH, language, locale: language === 'zh-CN' ? zhCN : enUS });
}; };
export default (state = initialState, action) => { export default (state = initialState, action) => {

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long