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 ',
|
importSuccBegin: 'The import was successful,with ',
|
||||||
importSuccEnd: 'configuration items imported',
|
importSuccEnd: 'configuration items imported',
|
||||||
importFail: 'Import failed',
|
importFail: 'Import failed',
|
||||||
|
importFail403: 'Unauthorized!',
|
||||||
importDataValidationError: 'No legitimate data was read, please check the imported data file.',
|
importDataValidationError: 'No legitimate data was read, please check the imported data file.',
|
||||||
metadataIllegal: 'The imported metadata file is illegal',
|
metadataIllegal: 'The imported metadata file is illegal',
|
||||||
namespaceNotExist: 'namespace does not exist',
|
namespaceNotExist: 'namespace does not exist',
|
||||||
|
@ -280,6 +280,7 @@ const I18N_CONF = {
|
|||||||
importSuccBegin: '导入成功,导入了',
|
importSuccBegin: '导入成功,导入了',
|
||||||
importSuccEnd: '项配置',
|
importSuccEnd: '项配置',
|
||||||
importFail: '导入失败',
|
importFail: '导入失败',
|
||||||
|
importFail403: '没有权限!',
|
||||||
importDataValidationError: '未读取到合法数据,请检查导入的数据文件。',
|
importDataValidationError: '未读取到合法数据,请检查导入的数据文件。',
|
||||||
metadataIllegal: '导入的元数据文件非法',
|
metadataIllegal: '导入的元数据文件非法',
|
||||||
namespaceNotExist: 'namespace 不存在',
|
namespaceNotExist: 'namespace 不存在',
|
||||||
|
@ -256,6 +256,7 @@ class ConfigurationManagement extends React.Component {
|
|||||||
config_tags: this.state.config_tags.join(','),
|
config_tags: this.state.config_tags.join(','),
|
||||||
pageNo,
|
pageNo,
|
||||||
pageSize: this.state.pageSize,
|
pageSize: this.state.pageSize,
|
||||||
|
tenant: this.tenant,
|
||||||
};
|
};
|
||||||
if (this.dataId.indexOf('*') !== -1 || this.group.indexOf('*') !== -1) {
|
if (this.dataId.indexOf('*') !== -1 || this.group.indexOf('*') !== -1) {
|
||||||
params.search = 'blur';
|
params.search = 'blur';
|
||||||
@ -733,6 +734,7 @@ class ConfigurationManagement extends React.Component {
|
|||||||
self.openLoading();
|
self.openLoading();
|
||||||
},
|
},
|
||||||
success(data) {
|
success(data) {
|
||||||
|
self.closeLoading();
|
||||||
if (!data || data.code !== 200 || !data.data) {
|
if (!data || data.code !== 200 || !data.data) {
|
||||||
Dialog.alert({
|
Dialog.alert({
|
||||||
title: locale.getNamespaceFailed,
|
title: locale.getNamespaceFailed,
|
||||||
@ -891,9 +893,11 @@ class ConfigurationManagement extends React.Component {
|
|||||||
self.openLoading();
|
self.openLoading();
|
||||||
},
|
},
|
||||||
success(ret) {
|
success(ret) {
|
||||||
|
self.closeLoading();
|
||||||
self.processImportAndCloneResult(ret, locale, cloneConfirm, false);
|
self.processImportAndCloneResult(ret, locale, cloneConfirm, false);
|
||||||
},
|
},
|
||||||
error(data) {
|
error(data) {
|
||||||
|
self.closeLoading();
|
||||||
self.setState({
|
self.setState({
|
||||||
dataSource: [],
|
dataSource: [],
|
||||||
total: 0,
|
total: 0,
|
||||||
@ -928,6 +932,7 @@ class ConfigurationManagement extends React.Component {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
error(data) {
|
error(data) {
|
||||||
|
self.closeLoading();
|
||||||
self.setState({
|
self.setState({
|
||||||
dataSource: [],
|
dataSource: [],
|
||||||
total: 0,
|
total: 0,
|
||||||
@ -1019,9 +1024,20 @@ class ConfigurationManagement extends React.Component {
|
|||||||
const { locale = {} } = this.props;
|
const { locale = {} } = this.props;
|
||||||
const self = this;
|
const self = this;
|
||||||
self.field.setValue('sameConfigPolicy', 'ABORT');
|
self.field.setValue('sameConfigPolicy', 'ABORT');
|
||||||
|
let token = {};
|
||||||
|
try {
|
||||||
|
token = JSON.parse(localStorage.token);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
goLogin();
|
||||||
|
}
|
||||||
|
const { accessToken = '' } = token;
|
||||||
const uploadProps = {
|
const uploadProps = {
|
||||||
accept: 'application/zip',
|
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: {
|
data: {
|
||||||
policy: self.field.getValue('sameConfigPolicy'),
|
policy: self.field.getValue('sameConfigPolicy'),
|
||||||
},
|
},
|
||||||
@ -1035,10 +1051,18 @@ class ConfigurationManagement extends React.Component {
|
|||||||
self.processImportAndCloneResult(ret.response, locale, importConfirm, true);
|
self.processImportAndCloneResult(ret.response, locale, importConfirm, true);
|
||||||
},
|
},
|
||||||
onError(err) {
|
onError(err) {
|
||||||
Dialog.alert({
|
const { data = {}, status } = err.response;
|
||||||
title: locale.importFail,
|
if ([401, 403].includes(status)) {
|
||||||
content: locale.importDataValidationError,
|
Dialog.alert({
|
||||||
});
|
title: locale.importFail,
|
||||||
|
content: locale.importFail403,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Dialog.alert({
|
||||||
|
title: locale.importFail,
|
||||||
|
content: locale.importDataValidationError,
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const importConfirm = Dialog.confirm({
|
const importConfirm = Dialog.confirm({
|
||||||
|
Loading…
Reference in New Issue
Block a user