refactor: NameSpaceList i18n #474

This commit is contained in:
王彦民 2019-01-06 10:09:30 +08:00 committed by Asa
parent 33e5e47832
commit fa57fa053d
6 changed files with 30 additions and 22 deletions

View File

@ -13,14 +13,18 @@
import React from 'react';
import PropTypes from 'prop-types';
import { ConfigProvider, Dialog } from '@alifd/next';
import { getParams, setParams, request } from '../../globalLib';
import './index.scss';
import { Dialog } from '@alifd/next';
import { getParams, setParams, request, aliwareIntl } from '../../globalLib';
/**
* 命名空间列表
*/
@ConfigProvider.config
class NameSpaceList extends React.Component {
static displayName = 'NameSpaceList';
static propTypes = {
setNowNameSpace: PropTypes.func,
namespaceCallBack: PropTypes.func,
@ -67,6 +71,7 @@ class NameSpaceList extends React.Component {
});
}
}
// if (!this.state.namespaceList || this.state.namespaceList.length === 0) {
// this.getNameSpaces();
// } else {
@ -74,8 +79,8 @@ class NameSpaceList extends React.Component {
// }
/**
切换namespace
* */
切换namespace
* */
changeNameSpace(ns, nsName) {
this.setnamespace(ns || '');
setParams({
@ -94,6 +99,7 @@ class NameSpaceList extends React.Component {
}
getNameSpaces() {
const { locale = {} } = this.props;
if (window.namespaceList) {
this.handleNameSpaces(window.namespaceList);
} else {
@ -105,8 +111,7 @@ class NameSpaceList extends React.Component {
this.handleNameSpaces(res.data);
} else {
Dialog.alert({
language: aliwareIntl.currentLanguageCode || 'zh-cn',
title: aliwareIntl.get('com.alibaba.nacos.component.NameSpaceList.Prompt'),
title: locale.notice,
content: res.message,
});
}

View File

@ -13,10 +13,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Button } from '@alifd/next';
import $ from 'jquery';
import { Button } from '@alifd/next';
import NameSpaceList from '../NameSpaceList';
import { setParams, request } from '../../globalLib';
import './index.scss';
class RegionGroup extends React.Component {
@ -53,7 +54,7 @@ class RegionGroup extends React.Component {
fontSize: '16px',
},
};
this.nameSpaceList = null;
this.nameSpaceList = React.createRef();
this.mainRef = null;
this.titleRef = null;
this.regionRef = null;
@ -76,7 +77,7 @@ class RegionGroup extends React.Component {
// this.setRegionWidth();
// this.handleRegionListStatus();
// });
this.nameSpaceList && this.nameSpaceList.getNameSpaces();
this.nameSpaceList.current.getInstance().getNameSpaces();
}
componentWillUnmount() {
@ -151,7 +152,7 @@ class RegionGroup extends React.Component {
this.handleRegionList(window._regionList);
} else {
// TODO
this.nameSpaceList && this.nameSpaceList.getNameSpaces();
this.nameSpaceList.current.getInstance().getNameSpaces();
request({
url: this.state.url,
@ -188,7 +189,7 @@ class RegionGroup extends React.Component {
setTimeout(() => {
this.changeRegionBarRegionId(this.currRegionId);
}, 1000);
this.nameSpaceList && this.nameSpaceList.getNameSpaces();
this.nameSpaceList.current.getInstance().getNameSpaces();
this.setState({
currRegionId: envcontent,
instanceData,
@ -302,15 +303,15 @@ class RegionGroup extends React.Component {
: this.state.right}
</div>
</div>
{this.props.namespaceCallBack ? (
{this.props.namespaceCallBack && (
<div>
<NameSpaceList
ref={ref => (this.nameSpaceList = ref)}
ref={this.nameSpaceList}
namespaceCallBack={this.props.namespaceCallBack}
setNowNameSpace={this.props.setNowNameSpace}
/>
</div>
) : null}
)}
</div>
</div>
);

View File

@ -355,6 +355,9 @@ const I18N_CONF = {
namespacenotnull: 'Namespace cannot be empty',
description: 'Description:',
},
NameSpaceList: {
notice: 'Notice',
},
};
export default I18N_CONF;

View File

@ -354,6 +354,9 @@ const I18N_CONF = {
namespacenotnull: '命名空间不能为空',
description: '描述:',
},
NameSpaceList: {
notice: '提示',
},
};
export default I18N_CONF;

View File

@ -300,10 +300,6 @@ class HistoryRollback extends React.Component {
left={locale.toConfigure}
namespaceCallBack={this.cleanAndGetData.bind(this)}
/>
{/** <div className={'namespacewrapper'}>
<NameSpaceList namespaceCallBack={this.cleanAndGetData.bind(this)} />
</div>* */}
<div>
<Form inline field={this.field}>
<Form.Item label="Data ID:" required>

File diff suppressed because one or more lines are too long