diff --git a/console/src/main/resources/static/console-fe/src/locales/en-US.js b/console/src/main/resources/static/console-fe/src/locales/en-US.js index 5fbce47d1..47e1f2af7 100644 --- a/console/src/main/resources/static/console-fe/src/locales/en-US.js +++ b/console/src/main/resources/static/console-fe/src/locales/en-US.js @@ -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', diff --git a/console/src/main/resources/static/console-fe/src/locales/zh-CN.js b/console/src/main/resources/static/console-fe/src/locales/zh-CN.js index c83ccd136..9904f9a1f 100644 --- a/console/src/main/resources/static/console-fe/src/locales/zh-CN.js +++ b/console/src/main/resources/static/console-fe/src/locales/zh-CN.js @@ -280,6 +280,7 @@ const I18N_CONF = { importSuccBegin: '导入成功,导入了', importSuccEnd: '项配置', importFail: '导入失败', + importFail403: '没有权限!', importDataValidationError: '未读取到合法数据,请检查导入的数据文件。', metadataIllegal: '导入的元数据文件非法', namespaceNotExist: 'namespace 不存在', diff --git a/console/src/main/resources/static/console-fe/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js b/console/src/main/resources/static/console-fe/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js index 6ebd58e29..4173283ca 100644 --- a/console/src/main/resources/static/console-fe/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js +++ b/console/src/main/resources/static/console-fe/src/pages/ConfigurationManagement/ConfigurationManagement/ConfigurationManagement.js @@ -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({