Merge pull request #2504 from KeRan213539/fixImportAuthorityBug
修复开启权限后导入失败的BUG
This commit is contained in:
commit
f537ece5a4
@ -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',
|
||||
|
@ -280,6 +280,7 @@ const I18N_CONF = {
|
||||
importSuccBegin: '导入成功,导入了',
|
||||
importSuccEnd: '项配置',
|
||||
importFail: '导入失败',
|
||||
importFail403: '没有权限!',
|
||||
importDataValidationError: '未读取到合法数据,请检查导入的数据文件。',
|
||||
metadataIllegal: '导入的元数据文件非法',
|
||||
namespaceNotExist: 'namespace 不存在',
|
||||
|
@ -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) {
|
||||
Dialog.alert({
|
||||
title: locale.importFail,
|
||||
content: locale.importDataValidationError,
|
||||
});
|
||||
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({
|
||||
|
Loading…
Reference in New Issue
Block a user