From b92d47e5ad820f2c2aebc1189fa1fb1d81e9459a Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 16 Jun 2020 11:28:08 +0800 Subject: [PATCH 1/2] fix remove user i18n msg --- src/i18n/langs/cn.json | 5 ++++- src/i18n/langs/en.json | 5 ++++- src/views/users/User/UserList.vue | 18 +++++++++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/i18n/langs/cn.json b/src/i18n/langs/cn.json index f2661137d..fe21c0db6 100644 --- a/src/i18n/langs/cn.json +++ b/src/i18n/langs/cn.json @@ -208,6 +208,8 @@ "activateSelected": "激活所选", "bulkDeleteErrorMsg": "批量删除失败: ", "bulkDeleteSuccessMsg": "批量删除成功", + "bulkRemoveErrorMsg": "批量移除失败: ", + "bulkRemoveSuccessMsg": "批量移除成功", "createBy": "创建者", "createErrorMsg": "创建失败", "createSuccessMsg": "创建成功", @@ -261,7 +263,8 @@ "updateSuccessMsg": "更新成功", "SelectProperties": "选择属性", "ObjectNotFoundOrDeletedMsg": "没有找到对应资源或者已被删除", - "removeSelected": "移除所选" + "removeSelected": "移除所选", + "removeWarningMsg": "你确定要移除" }, "dashboard": { "ActiveAsset": "近期被登录过", diff --git a/src/i18n/langs/en.json b/src/i18n/langs/en.json index 2927edb68..d940b86b1 100644 --- a/src/i18n/langs/en.json +++ b/src/i18n/langs/en.json @@ -209,6 +209,8 @@ "activateSelected": "Activate selected", "bulkDeleteErrorMsg": "Bulk delete failed: ", "bulkDeleteSuccessMsg": "Bulk delete success", + "bulkRemoveErrorMsg": "Bulk remove failed: ", + "bulkRemoveSuccessMsg": "Bulk remove success", "createBy": "Create by", "createErrorMsg": "Create error", "createSuccessMsg": "Create success", @@ -261,7 +263,8 @@ "updateSuccessMsg": "Update success", "SelectProperties": "Select properties", "ObjectNotFoundOrDeletedMsg": "Resource lost or deleted", - "removeSelected": "Remove selected" + "removeSelected": "Remove selected", + "removeWarningMsg": "Are you sure to remove " }, "dashboard": { "ActiveAsset": "Asset active", diff --git a/src/views/users/User/UserList.vue b/src/views/users/User/UserList.vue index 289cc2724..48d0863f9 100644 --- a/src/views/users/User/UserList.vue +++ b/src/views/users/User/UserList.vue @@ -197,7 +197,11 @@ export default { }) }, bulkDeleteCallback({ selectedRows, reloadTable }) { - const msg = this.$t('common.deleteWarningMsg') + ' ' + selectedRows.length + ' ' + this.$t('common.rows') + ' ?' + let msgPrefix = this.$t('common.deleteWarningMsg') + if (!this.currentOrgIsDefault) { + msgPrefix = this.$t('common.removeWarningMsg') + } + const msg = msgPrefix + ' ' + selectedRows.length + ' ' + this.$t('common.rows') + ' ?' const title = this.$t('common.Info') const performDelete = this.performBulkDelete this.$alert(msg, title, { @@ -211,9 +215,17 @@ export default { await performDelete(selectedRows) done() reloadTable() - this.$message.success(this.$t('common.bulkDeleteSuccessMsg')) + let successMsg = this.$t('common.bulkDeleteSuccessMsg') + if (!this.currentOrgIsDefault) { + successMsg = this.$t('common.bulkRemoveSuccessMsg') + } + this.$message.success(successMsg) } catch (error) { - this.$message.error(this.$t('common.bulkDeleteErrorMsg') + error) + let errorMsg = this.$t('common.bulkDeleteErrorMsg') + if (!this.currentOrgIsDefault) { + errorMsg = this.$t('common.bulkRemoveErrorMsg') + } + this.$message.error(errorMsg + error) } finally { instance.confirmButtonLoading = false } From bfddc20a1655e7f265d8365a1a2dc0ccb0499e54 Mon Sep 17 00:00:00 2001 From: xinwen Date: Tue, 16 Jun 2020 11:32:52 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[Update]=20=E6=9B=B4=E6=94=B9=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E4=B8=AD=E5=BF=83/=E4=BB=BB=E5=8A=A1=E5=88=97?= =?UTF-8?q?=E8=A1=A8=20=E5=8D=A1=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/ops/RunInfoCard/index.vue | 8 ++-- .../TaskDetail/AdhocDetail/AdhocDetail.vue | 37 ++++++------------- .../HistoryExecutionDetail.vue | 37 ++++++------------- src/views/ops/TaskDetail/TaskDetail.vue | 37 ++++++------------- src/views/ops/TaskDetail/business.js | 34 +++++++++++------ 5 files changed, 63 insertions(+), 90 deletions(-) diff --git a/src/views/ops/RunInfoCard/index.vue b/src/views/ops/RunInfoCard/index.vue index 3f4ed9bb0..27d932f5d 100644 --- a/src/views/ops/RunInfoCard/index.vue +++ b/src/views/ops/RunInfoCard/index.vue @@ -1,7 +1,7 @@ @@ -29,30 +29,17 @@ export default { } }, data() { - const last_success = toLastSucessDisplay(this.object.latest_execution) - const last_failure = toLastFailureDisplay(this.object.latest_execution) - return { - RunSuccessConfigs: last_success.map(host => { - return { - icon: 'fa-info', - title: this.$t('ops.lastRunSuccessHosts'), - content: { - hostname: host, - result: '' - } - } - }), - RunFailedConfigs: last_failure.map(([host, msg]) => { - return { - icon: 'fa-info', - title: this.$t('ops.lastRunFailedHosts'), - content: { - hostname: host, - result: msg - } - } - }) + RunSuccessConfig: { + icon: 'fa-info', + title: this.$t('ops.lastRunSuccessHosts'), + contents: toLastSucessDisplay(this.object.latest_execution) + }, + RunFailedConfig: { + icon: 'fa-info', + title: this.$t('ops.lastRunFailedHosts'), + contents: toLastFailureDisplay(this.object.latest_execution) + } } }, computed: { diff --git a/src/views/ops/TaskDetail/HistoryExecutionDetail/HistoryExecutionDetail.vue b/src/views/ops/TaskDetail/HistoryExecutionDetail/HistoryExecutionDetail.vue index 9bdf3259a..5cfe5bd55 100644 --- a/src/views/ops/TaskDetail/HistoryExecutionDetail/HistoryExecutionDetail.vue +++ b/src/views/ops/TaskDetail/HistoryExecutionDetail/HistoryExecutionDetail.vue @@ -4,8 +4,8 @@ - - + + @@ -29,30 +29,17 @@ export default { } }, data() { - const last_success = toLastSucessDisplay(this.object) - const last_failure = toLastFailureDisplay(this.object) - return { - RunSuccessConfigs: last_success.map(host => { - return { - icon: 'fa-info', - title: this.$t('ops.lastRunSuccessHosts'), - content: { - hostname: host, - result: '' - } - } - }), - RunFailedConfigs: last_failure.map(([host, msg]) => { - return { - icon: 'fa-info', - title: this.$t('ops.lastRunFailedHosts'), - content: { - hostname: host, - result: msg - } - } - }) + RunSuccessConfig: { + icon: 'fa-info', + title: this.$t('ops.lastRunSuccessHosts'), + contents: toLastSucessDisplay(this.object) + }, + RunFailedConfig: { + icon: 'fa-info', + title: this.$t('ops.lastRunFailedHosts'), + contents: toLastFailureDisplay(this.object) + } } }, computed: { diff --git a/src/views/ops/TaskDetail/TaskDetail.vue b/src/views/ops/TaskDetail/TaskDetail.vue index 8a053fae9..f385c7b17 100644 --- a/src/views/ops/TaskDetail/TaskDetail.vue +++ b/src/views/ops/TaskDetail/TaskDetail.vue @@ -4,8 +4,8 @@ - - + + @@ -28,30 +28,17 @@ export default { } }, data() { - const last_success = toLastSucessDisplay(this.object.latest_execution) - const last_failure = toLastFailureDisplay(this.object.latest_execution) - return { - RunSuccessConfigs: last_success.map(host => { - return { - icon: 'fa-info', - title: this.$t('ops.lastRunSuccessHosts'), - content: { - hostname: host, - result: '' - } - } - }), - RunFailedConfigs: last_failure.map(([host, msg]) => { - return { - icon: 'fa-info', - title: this.$t('ops.lastRunFailedHosts'), - content: { - hostname: host, - result: msg - } - } - }), + RunSuccessConfig: { + icon: 'fa-info', + title: this.$t('ops.lastRunSuccessHosts'), + contents: toLastSucessDisplay(this.object.latest_execution) + }, + RunFailedConfig: { + icon: 'fa-info', + title: this.$t('ops.lastRunFailedHosts'), + contents: toLastFailureDisplay(this.object.latest_execution) + }, taskData: {} } }, diff --git a/src/views/ops/TaskDetail/business.js b/src/views/ops/TaskDetail/business.js index 77bec6eac..0a775ef84 100644 --- a/src/views/ops/TaskDetail/business.js +++ b/src/views/ops/TaskDetail/business.js @@ -1,24 +1,36 @@ export const toLastSucessDisplay = function(object) { - if (!object) return [''] - const last_success = object.last_success - last_success.length || last_success.push('') - return last_success + const last_success = object && object.last_success + + if (!(last_success instanceof Array)) return [] + return last_success.map(host => { + return { + hostname: host, + result: '' + } + }) } export const toLastFailureDisplay = function(object) { - if (!object) return [['', '']] - const last_failure = [] - for (const host in object.last_failure) { - const task = object.last_failure[host] + const last_failure = object && object.last_failure + if (!(last_failure instanceof Object)) return [] + + const ret = [] + + for (const host in last_failure) { + const task = last_failure[host] const msgs = [] for (const name in task) { msgs.push(`${name} => ${task[name].msg}`) } - last_failure.push([host, msgs.join('\n')]) + ret.push( + { + hostname: host, + result: msgs.join('\n') + } + ) } - last_failure.length || last_failure.push(['', '']) - return last_failure + return ret }