Merge pull request #2504 from KeRan213539/fixImportAuthorityBug

修复开启权限后导入失败的BUG
This commit is contained in:
Peter Zhu 2020-03-27 16:15:18 +08:00 committed by GitHub
commit f537ece5a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 5 deletions

View File

@ -281,6 +281,7 @@ const I18N_CONF = {
importSuccBegin: 'The import was successful,with ',
importSuccEnd: 'configuration items imported',
importFail: 'Import failed',
importFail403: 'Unauthorized!',
importDataValidationError: 'No legitimate data was read, please check the imported data file.',
metadataIllegal: 'The imported metadata file is illegal',
namespaceNotExist: 'namespace does not exist',

View File

@ -280,6 +280,7 @@ const I18N_CONF = {
importSuccBegin: '导入成功,导入了',
importSuccEnd: '项配置',
importFail: '导入失败',
importFail403: '没有权限!',
importDataValidationError: '未读取到合法数据请检查导入的数据文件',
metadataIllegal: '导入的元数据文件非法',
namespaceNotExist: 'namespace 不存在',

View File

@ -256,6 +256,7 @@ class ConfigurationManagement extends React.Component {
config_tags: this.state.config_tags.join(','),
pageNo,
pageSize: this.state.pageSize,
tenant: this.tenant,
};
if (this.dataId.indexOf('*') !== -1 || this.group.indexOf('*') !== -1) {
params.search = 'blur';
@ -733,6 +734,7 @@ class ConfigurationManagement extends React.Component {
self.openLoading();
},
success(data) {
self.closeLoading();
if (!data || data.code !== 200 || !data.data) {
Dialog.alert({
title: locale.getNamespaceFailed,
@ -891,9 +893,11 @@ class ConfigurationManagement extends React.Component {
self.openLoading();
},
success(ret) {
self.closeLoading();
self.processImportAndCloneResult(ret, locale, cloneConfirm, false);
},
error(data) {
self.closeLoading();
self.setState({
dataSource: [],
total: 0,
@ -928,6 +932,7 @@ class ConfigurationManagement extends React.Component {
});
},
error(data) {
self.closeLoading();
self.setState({
dataSource: [],
total: 0,
@ -1019,9 +1024,20 @@ class ConfigurationManagement extends React.Component {
const { locale = {} } = this.props;
const self = this;
self.field.setValue('sameConfigPolicy', 'ABORT');
let token = {};
try {
token = JSON.parse(localStorage.token);
} catch (e) {
console.log(e);
goLogin();
}
const { accessToken = '' } = token;
const uploadProps = {
accept: 'application/zip',
action: `v1/cs/configs?import=true&namespace=${getParams('namespace')}`,
action: `v1/cs/configs?import=true&namespace=${getParams(
'namespace'
)}&accessToken=${accessToken}`,
headers: Object.assign({}, {}, { accessToken }),
data: {
policy: self.field.getValue('sameConfigPolicy'),
},
@ -1035,10 +1051,18 @@ class ConfigurationManagement extends React.Component {
self.processImportAndCloneResult(ret.response, locale, importConfirm, true);
},
onError(err) {
const { data = {}, status } = err.response;
if ([401, 403].includes(status)) {
Dialog.alert({
title: locale.importFail,
content: locale.importFail403,
});
} else {
Dialog.alert({
title: locale.importFail,
content: locale.importDataValidationError,
});
}
},
};
const importConfirm = Dialog.confirm({