fix: HistoryDetail internationalization

This commit is contained in:
王彦民 2018-12-01 23:41:56 +08:00 committed by zhichen
parent d487f522b6
commit 941469af7f
3 changed files with 43 additions and 28 deletions

View File

@ -158,5 +158,17 @@ const I18N_CONF = {
lastUpdateTime: 'Last Modified At', lastUpdateTime: 'Last Modified At',
operation: 'Operation', operation: 'Operation',
}, },
HistoryDetail: {
historyDetails: 'History Details',
update: 'Update',
insert: 'Insert',
deleteAction: 'Delete',
recipientFrom: 'Collapse',
moreAdvancedOptions: 'Advanced Options',
home: 'Application:',
actionType: 'Action Type:',
configureContent: 'Configuration Content:',
back: 'Back',
},
}; };
export default I18N_CONF; export default I18N_CONF;

View File

@ -158,5 +158,17 @@ const I18N_CONF = {
lastUpdateTime: '最后更新时间', lastUpdateTime: '最后更新时间',
operation: '操作', operation: '操作',
}, },
HistoryDetail: {
historyDetails: '历史详情',
update: '更新',
insert: '插入',
deleteAction: '删除',
recipientFrom: '收起',
moreAdvancedOptions: '更多高级选项',
home: '归属应用:',
actionType: '操作类型:',
configureContent: '配置内容:',
back: '返回',
},
}; };
export default I18N_CONF; export default I18N_CONF;

View File

@ -13,12 +13,15 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Button, Field, Form, Input } from '@alifd/next'; import { Button, ConfigProvider, Field, Form, Input } from '@alifd/next';
import { getParams, request, aliwareIntl } from '../../../globalLib'; import { getParams, request } from '@/globalLib';
import './index.scss'; import './index.scss';
@ConfigProvider.config
class HistoryDetail extends React.Component { class HistoryDetail extends React.Component {
static displayName = 'HistoryDetail';
static propTypes = { static propTypes = {
history: PropTypes.object, history: PropTypes.object,
}; };
@ -38,11 +41,6 @@ class HistoryDetail extends React.Component {
this.nid = getParams('nid') || '123509854'; this.nid = getParams('nid') || '123509854';
this.tenant = getParams('namespace') || ''; // 为当前实例保存tenant参数 this.tenant = getParams('namespace') || ''; // 为当前实例保存tenant参数
// this.params = window.location.hash.split('?')[1]||''; // this.params = window.location.hash.split('?')[1]||'';
this.typeMap = {
U: aliwareIntl.get('com.alibaba.nacos.page.historyDetail.update'),
I: aliwareIntl.get('com.alibaba.nacos.page.historyDetail.insert'),
D: aliwareIntl.get('com.alibaba.nacos.page.historyDetail.delete'),
};
} }
componentDidMount() { componentDidMount() {
@ -56,8 +54,13 @@ class HistoryDetail extends React.Component {
} }
getDataDetail() { getDataDetail() {
const { locale = {} } = this.props;
const self = this; const self = this;
const typeMap = {
U: locale.update,
I: locale.insert,
D: locale.deleteAction,
};
request({ request({
url: `v1/cs/history?dataId=${this.dataId}&group=${this.group}&nid=${this.nid}`, url: `v1/cs/history?dataId=${this.dataId}&group=${this.group}&nid=${this.nid}`,
success(result) { success(result) {
@ -67,7 +70,7 @@ class HistoryDetail extends React.Component {
self.field.setValue('content', data.content); self.field.setValue('content', data.content);
self.field.setValue('appName', self.inApp ? self.edasAppName : data.appName); self.field.setValue('appName', self.inApp ? self.edasAppName : data.appName);
self.field.setValue('envs', self.serverId); self.field.setValue('envs', self.serverId);
self.field.setValue('opType', self.typeMap[data.opType.trim()]); self.field.setValue('opType', typeMap[data.opType.trim()]);
self.field.setValue('group', data.group); self.field.setValue('group', data.group);
self.field.setValue('md5', data.md5); self.field.setValue('md5', data.md5);
} }
@ -84,6 +87,7 @@ class HistoryDetail extends React.Component {
} }
render() { render() {
const { locale = {} } = this.props;
const { init } = this.field; const { init } = this.field;
const formItemLayout = { const formItemLayout = {
labelCol: { labelCol: {
@ -95,15 +99,13 @@ class HistoryDetail extends React.Component {
}; };
return ( return (
<div style={{ padding: 10 }}> <div style={{ padding: 10 }}>
<h1>{aliwareIntl.get('com.alibaba.nacos.page.historyDetail.history_details')}</h1> <h1>{locale.historyDetails}</h1>
<Form field={this.field}> <Form field={this.field}>
<Form.Item label="Data ID:" required {...formItemLayout}> <Form.Item label="Data ID:" required {...formItemLayout}>
<Input htmlType="text" readOnly {...init('dataId')} /> <Input htmlType="text" readOnly {...init('dataId')} />
<div style={{ marginTop: 10 }}> <div style={{ marginTop: 10 }}>
<a style={{ fontSize: '12px' }} onClick={this.toggleMore.bind(this)}> <a style={{ fontSize: '12px' }} onClick={this.toggleMore.bind(this)}>
{this.state.showmore {this.state.showmore ? locale.recipientFrom : locale.moreAdvancedOptions}
? aliwareIntl.get('com.alibaba.nacos.page.historyDetail.recipient_from')
: aliwareIntl.get('com.alibaba.nacos.page.historyDetail.more_advanced_options')}
</a> </a>
</div> </div>
</Form.Item> </Form.Item>
@ -111,33 +113,22 @@ class HistoryDetail extends React.Component {
<Form.Item label="Group:" required {...formItemLayout}> <Form.Item label="Group:" required {...formItemLayout}>
<Input htmlType="text" readOnly {...init('group')} /> <Input htmlType="text" readOnly {...init('group')} />
</Form.Item> </Form.Item>
<Form.Item <Form.Item label={locale.home} {...formItemLayout}>
label={aliwareIntl.get('com.alibaba.nacos.page.historyDetail.home')}
{...formItemLayout}
>
<Input htmlType="text" readOnly {...init('appName')} /> <Input htmlType="text" readOnly {...init('appName')} />
</Form.Item> </Form.Item>
</div> </div>
<Form.Item <Form.Item label={locale.actionType} required {...formItemLayout}>
label={aliwareIntl.get('com.alibaba.nacos.page.historyDetail.action_type')}
required
{...formItemLayout}
>
<Input htmlType="text" readOnly {...init('opType')} /> <Input htmlType="text" readOnly {...init('opType')} />
</Form.Item> </Form.Item>
<Form.Item label="MD5:" required {...formItemLayout}> <Form.Item label="MD5:" required {...formItemLayout}>
<Input htmlType="text" readOnly {...init('md5')} /> <Input htmlType="text" readOnly {...init('md5')} />
</Form.Item> </Form.Item>
<Form.Item <Form.Item label={locale.configureContent} required {...formItemLayout}>
label={aliwareIntl.get('com.alibaba.nacos.page.historyDetail.configure_content')}
required
{...formItemLayout}
>
<Input.TextArea htmlType="text" multiple rows={15} readOnly {...init('content')} /> <Input.TextArea htmlType="text" multiple rows={15} readOnly {...init('content')} />
</Form.Item> </Form.Item>
<Form.Item label=" " {...formItemLayout}> <Form.Item label=" " {...formItemLayout}>
<Button type="primary" onClick={this.goList.bind(this)}> <Button type="primary" onClick={this.goList.bind(this)}>
{aliwareIntl.get('com.alibaba.nacos.page.historyDetail.return')} {locale.back}
</Button> </Button>
</Form.Item> </Form.Item>
</Form> </Form>