From 58bb69c25230ed071421452fef2dc6df2dea6c69 Mon Sep 17 00:00:00 2001 From: zhaojisen <1301338853@qq.com> Date: Mon, 20 Jan 2025 11:05:48 +0800 Subject: [PATCH 1/3] Perf: Remove isPam item --- .../Apps/AccountCreateUpdateForm/const.js | 74 ++++++++++++++----- .../Apps/AccountCreateUpdateForm/index.vue | 11 +++ .../AccountListTable/UpdateSecretInfo.vue | 4 - .../Table/ListTable/TableAction/LeftSide.vue | 24 ------ 4 files changed, 66 insertions(+), 47 deletions(-) diff --git a/src/components/Apps/AccountCreateUpdateForm/const.js b/src/components/Apps/AccountCreateUpdateForm/const.js index 8e6c15c14..cddd0c623 100644 --- a/src/components/Apps/AccountCreateUpdateForm/const.js +++ b/src/components/Apps/AccountCreateUpdateForm/const.js @@ -6,8 +6,6 @@ import AutomationParamsForm from '@/views/assets/Platform/AutomationParamsSettin export const accountFieldsMeta = (vm) => { const defaultPrivilegedAccounts = ['root', 'administrator'] - const isPam = vm.$route.query.flag === 'copy' || vm.$route.query.flag === 'move' - return { assets: { component: Select2, @@ -30,7 +28,9 @@ export const accountFieldsMeta = (vm) => { component: Select2, rules: [Required], el: { - disabled: isPam, + get disabled() { + return vm.isDisabled + }, multiple: false, ajax: { url: '/api/v1/accounts/account-templates/', @@ -48,7 +48,9 @@ export const accountFieldsMeta = (vm) => { label: vm.$t('AccountPolicy'), helpTip: vm.$t('AccountPolicyHelpText'), el: { - disabled: isPam + get disabled() { + return vm.isDisabled + } }, hidden: () => { return vm.platform || vm.asset @@ -58,7 +60,9 @@ export const accountFieldsMeta = (vm) => { label: vm.$t('Name'), rules: [RequiredChange], el: { - disabled: isPam + get disabled() { + return vm.isDisabled + } }, on: { input: ([value], updateForm) => { @@ -79,7 +83,9 @@ export const accountFieldsMeta = (vm) => { }, username: { el: { - disabled: !!vm.account?.name || isPam + get disabled() { + return !!vm.account?.name || vm.isDisabled + } }, on: { input: ([value], updateForm) => { @@ -99,7 +105,9 @@ export const accountFieldsMeta = (vm) => { privileged: { label: vm.$t('Privileged'), el: { - disabled: isPam + get disabled() { + return vm.isDisabled + } }, hidden: () => { return vm.addTemplate @@ -113,7 +121,11 @@ export const accountFieldsMeta = (vm) => { el: { multiple: false, clearable: true, - disabled: isPam, + disabled: { + get disabled() { + return vm.isDisabled + } + }, ajax: { url: `/api/v1/accounts/accounts/su-from-accounts/?account=${vm.account?.id || ''}&asset=${vm.asset?.id || ''}`, transformOption: (item) => { @@ -124,7 +136,11 @@ export const accountFieldsMeta = (vm) => { }, su_from_username: { label: vm.$t('UserSwitchFrom'), - disabled: isPam, + el: { + get disabled() { + return vm.isDisabled + } + }, hidden: (formValue) => { return vm.platform || vm.asset || vm.addTemplate } @@ -133,7 +149,9 @@ export const accountFieldsMeta = (vm) => { label: vm.$t('Password'), component: UpdateToken, el: { - disabled: isPam + get disabled() { + return vm.isDisabled + } }, hidden: (formValue) => { return formValue.secret_type !== 'password' || vm.addTemplate @@ -143,7 +161,9 @@ export const accountFieldsMeta = (vm) => { label: vm.$t('PrivateKey'), component: UploadSecret, el: { - disabled: isPam + get disabled() { + return vm.isDisabled + } }, hidden: (formValue) => formValue.secret_type !== 'ssh_key' || vm.addTemplate }, @@ -151,7 +171,9 @@ export const accountFieldsMeta = (vm) => { label: vm.$t('Passphrase'), component: UpdateToken, el: { - disabled: isPam + get disabled() { + return vm.isDisabled + } }, hidden: (formValue) => formValue.secret_type !== 'ssh_key' || vm.addTemplate }, @@ -159,7 +181,9 @@ export const accountFieldsMeta = (vm) => { label: vm.$t('Token'), component: UploadSecret, el: { - disabled: isPam + get disabled() { + return vm.isDisabled + } }, hidden: (formValue) => formValue.secret_type !== 'token' || vm.addTemplate }, @@ -168,7 +192,9 @@ export const accountFieldsMeta = (vm) => { label: vm.$t('AccessKey'), component: UploadSecret, el: { - disabled: isPam + get disabled() { + return vm.isDisabled + } }, hidden: (formValue) => formValue.secret_type !== 'access_key' || vm.addTemplate }, @@ -177,7 +203,9 @@ export const accountFieldsMeta = (vm) => { label: vm.$t('ApiKey'), component: UploadSecret, el: { - disabled: isPam + get disabled() { + return vm.isDisabled + } }, hidden: (formValue) => formValue.secret_type !== 'api_key' || vm.addTemplate }, @@ -185,7 +213,9 @@ export const accountFieldsMeta = (vm) => { type: 'radio-group', options: [], el: { - disabled: isPam + get disabled() { + return vm.isDisabled + } }, hidden: () => { return vm.addTemplate @@ -223,19 +253,25 @@ export const accountFieldsMeta = (vm) => { is_active: { label: vm.$t('IsActive'), el: { - disabled: isPam + get disabled() { + return vm.isDisabled + } } }, comment: { label: vm.$t('Comment'), el: { - disabled: isPam + get disabled() { + return vm.isDisabled + } } }, secret_reset: { label: vm.$t('SecretReset'), el: { - disabled: isPam + get disabled() { + return vm.isDisabled + } } } } diff --git a/src/components/Apps/AccountCreateUpdateForm/index.vue b/src/components/Apps/AccountCreateUpdateForm/index.vue index 0973d3bb7..fc717ced4 100644 --- a/src/components/Apps/AccountCreateUpdateForm/index.vue +++ b/src/components/Apps/AccountCreateUpdateForm/index.vue @@ -45,6 +45,7 @@ export default { data() { return { loading: true, + isDisabled: false, usernameChanged: false, submitBtnText: this.$t('Confirm'), iPlatform: { @@ -74,6 +75,16 @@ export default { hasSaveContinue: false } }, + watch: { + '$route.query': { + handler(nv, ov) { + if (nv && (nv.flag === 'move' || nv.flag === 'copy')) { + this.isDisabled = true + } + }, + immediate: true + } + }, async mounted() { try { await this.getPlatform() diff --git a/src/components/Apps/AccountListTable/UpdateSecretInfo.vue b/src/components/Apps/AccountListTable/UpdateSecretInfo.vue index 44850c46f..c9f36c35a 100644 --- a/src/components/Apps/AccountListTable/UpdateSecretInfo.vue +++ b/src/components/Apps/AccountListTable/UpdateSecretInfo.vue @@ -99,7 +99,3 @@ export default { } } - - diff --git a/src/components/Table/ListTable/TableAction/LeftSide.vue b/src/components/Table/ListTable/TableAction/LeftSide.vue index 2793c1a99..d8e9602b6 100644 --- a/src/components/Table/ListTable/TableAction/LeftSide.vue +++ b/src/components/Table/ListTable/TableAction/LeftSide.vue @@ -96,8 +96,6 @@ export default { data() { const vm = this return { - showDrawer: false, - dynamicTemplateComponent: null, defaultMoreActions: [ { title: this.$t('DeleteSelected'), @@ -226,20 +224,9 @@ export default { const { href } = this.$router.resolve(route) window.open(href, '_blank') } else { - if (route.isPam) { - this.showDrawer = true - this.dynamicTemplateComponent = route.name - - return - } - this.$router.push(route) } }, - handleCloseDrawer() { - this.showDrawer = false - this.dynamicTemplateComponent = null - }, defaultBulkDeleteCallback({ selectedRows, reloadTable }) { const msg = this.$t('DeleteWarningMsg') + ' ' + selectedRows.length + ' ' + this.$t('Rows') + ' ?' const title = this.$tc('Info') @@ -280,15 +267,4 @@ export default { From 90050bf87dc9e331452c49391d83d39c13f7a9c3 Mon Sep 17 00:00:00 2001 From: feng <1304903146@qq.com> Date: Mon, 20 Jan 2025 16:36:41 +0800 Subject: [PATCH 2/3] perf: checkaccountautomation perm --- src/views/pam/RiskDetect/AccountCheckTaskList.vue | 2 +- src/views/pam/RiskDetect/index.vue | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/views/pam/RiskDetect/AccountCheckTaskList.vue b/src/views/pam/RiskDetect/AccountCheckTaskList.vue index b25eaff3b..63c7df8e8 100644 --- a/src/views/pam/RiskDetect/AccountCheckTaskList.vue +++ b/src/views/pam/RiskDetect/AccountCheckTaskList.vue @@ -9,7 +9,7 @@ import { GenericListTable } from '@/layout/components' import AmountFormatter from '@/components/Table/TableFormatters/AmountFormatter.vue' export default { - name: 'AccountPushList', + name: 'AccountCheckTaskList', components: { GenericListTable }, diff --git a/src/views/pam/RiskDetect/index.vue b/src/views/pam/RiskDetect/index.vue index dcb4a0280..f7bce8bf9 100644 --- a/src/views/pam/RiskDetect/index.vue +++ b/src/views/pam/RiskDetect/index.vue @@ -24,19 +24,19 @@ export default { { title: this.$t('DetectTasks'), name: 'AccountCheckTask', - hidden: !this.$hasPerm('accounts.view_accountcheckautomation'), + hidden: !this.$hasPerm('accounts.view_checkaccountautomation'), component: () => import('./AccountCheckTaskList.vue') }, { title: this.$t('Executions'), name: 'AccountCheckExecution', - hidden: !this.$hasPerm('accounts.view_accountcheckautomation'), + hidden: !this.$hasPerm('accounts.view_checkaccountautomation'), component: () => import('./AccountCheckExecutionList.vue') }, { title: this.$t('DetectEngines'), name: 'AccountCheckEngine', - hidden: !this.$hasPerm('accounts.view_accountcheckautomation'), + hidden: !this.$hasPerm('accounts.view_checkaccountautomation'), component: () => import('@/views/pam/RiskDetect/AccountCheckEngine.vue') } ] From 6dc7cc0b37ad41f7e2a6d99841750cd1780ab5a3 Mon Sep 17 00:00:00 2001 From: feng <1304903146@qq.com> Date: Mon, 20 Jan 2025 18:09:44 +0800 Subject: [PATCH 3/3] perf: pam perm --- src/router/pam/security.js | 2 +- src/views/pam/RiskDetect/AccountCheckTaskList.vue | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/router/pam/security.js b/src/router/pam/security.js index e5cb6e939..5b9504a13 100644 --- a/src/router/pam/security.js +++ b/src/router/pam/security.js @@ -13,7 +13,7 @@ export default [ app: 'accounts', name: 'BaseAccountRisk', icon: 'scan', - resource: 'accountcheckautomation' + resource: 'checkaccountautomation' }, children: [ { diff --git a/src/views/pam/RiskDetect/AccountCheckTaskList.vue b/src/views/pam/RiskDetect/AccountCheckTaskList.vue index 63c7df8e8..7448249e1 100644 --- a/src/views/pam/RiskDetect/AccountCheckTaskList.vue +++ b/src/views/pam/RiskDetect/AccountCheckTaskList.vue @@ -115,7 +115,7 @@ export default { type: 'primary', name: 'execute', can: ({ row }) => { - return row.is_active && vm.$hasPerm('accounts.add_accountcheckautomation') + return row.is_active && vm.$hasPerm('accounts.add_checkaccountautomation') }, callback: function({ row }) { this.$axios.post( @@ -139,7 +139,7 @@ export default { hasExport: false, hasImport: false, createRoute: 'AccountCheckCreateUpdate', - canCreate: vm.$hasPerm('accounts.add_accountcheckautomation') + canCreate: vm.$hasPerm('accounts.add_checkaccountautomation') } } }