From bcc0626998c6716a42d01d7ba7048931648586d2 Mon Sep 17 00:00:00 2001 From: wangruidong <940853815@qq.com> Date: Fri, 6 Sep 2024 17:41:27 +0800 Subject: [PATCH] feat: Support playbook, adhoc share --- src/views/ops/Adhoc/AdhocOpenDialog.vue | 2 +- src/views/ops/Job/JobUpdateCreate.vue | 2 +- src/views/ops/Template/Adhoc.vue | 11 ++++++++--- src/views/ops/Template/Adhoc/AdhocUpdateCreate.vue | 2 +- src/views/ops/Template/Playbook.vue | 13 +++++++++---- .../ops/Template/Playbook/PlaybookCreateUpdate.vue | 2 +- .../Template/Playbook/PlaybookDetail/Workspace.vue | 9 +++++++-- 7 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/views/ops/Adhoc/AdhocOpenDialog.vue b/src/views/ops/Adhoc/AdhocOpenDialog.vue index a442732da..230da4327 100644 --- a/src/views/ops/Adhoc/AdhocOpenDialog.vue +++ b/src/views/ops/Adhoc/AdhocOpenDialog.vue @@ -32,7 +32,7 @@ export default { width: '60%', tableConfig: { hasSelection: false, - url: `/api/v1/ops/adhocs/`, + url: `/api/v1/ops/adhocs/?only_mine=true`, columns: ['name', 'module', 'args', 'comment', 'actions'], columnsMeta: { name: { diff --git a/src/views/ops/Job/JobUpdateCreate.vue b/src/views/ops/Job/JobUpdateCreate.vue index 19d5305e6..a99c94713 100644 --- a/src/views/ops/Job/JobUpdateCreate.vue +++ b/src/views/ops/Job/JobUpdateCreate.vue @@ -83,7 +83,7 @@ export default { multiple: false, value: [], ajax: { - url: '/api/v1/ops/playbooks/', + url: `/api/v1/ops/playbooks/?only_mine=true`, transformOption: (item) => { return { label: item.name, value: item.id } } diff --git a/src/views/ops/Template/Adhoc.vue b/src/views/ops/Template/Adhoc.vue index 29fff770d..af8ed91ca 100644 --- a/src/views/ops/Template/Adhoc.vue +++ b/src/views/ops/Template/Adhoc.vue @@ -11,12 +11,13 @@ export default { GenericListTable }, data() { + const currentUserID = this.$store.state.users.profile.id return { tableConfig: { url: '/api/v1/ops/adhocs/', columnsShow: { min: ['name', 'actions'], - default: ['name', 'module', 'args', 'comment', 'date_created', 'actions'] + default: ['name', 'module', 'args', 'comment', 'scope', 'date_created', 'actions'] }, columnsMeta: { name: { @@ -29,10 +30,14 @@ export default { formatter: ActionsFormatter, formatterArgs: { hasUpdate: true, - canUpdate: this.$hasPerm('ops.change_adhoc'), + canUpdate: ({ row }) => { + return this.$hasPerm('ops.change_adhoc') && row.creator === currentUserID + }, updateRoute: 'AdhocUpdate', hasDelete: true, - canDelete: this.$hasPerm('ops.delete_adhoc'), + canDelete: ({ row }) => { + return this.$hasPerm('ops.delete_adhoc') && row.creator === currentUserID + }, hasClone: false } } diff --git a/src/views/ops/Template/Adhoc/AdhocUpdateCreate.vue b/src/views/ops/Template/Adhoc/AdhocUpdateCreate.vue index ef024a9cf..5331f1240 100644 --- a/src/views/ops/Template/Adhoc/AdhocUpdateCreate.vue +++ b/src/views/ops/Template/Adhoc/AdhocUpdateCreate.vue @@ -14,7 +14,7 @@ export default { return { url: '/api/v1/ops/adhocs/', fields: [ - [this.$t('Basic'), ['name', 'module', 'args', 'comment']] + [this.$t('Basic'), ['name', 'module', 'args', 'comment', 'scope']] ], initial: { module: 'shell', diff --git a/src/views/ops/Template/Playbook.vue b/src/views/ops/Template/Playbook.vue index ce31d1ce2..51840df49 100644 --- a/src/views/ops/Template/Playbook.vue +++ b/src/views/ops/Template/Playbook.vue @@ -16,6 +16,7 @@ export default { GenericListTable }, data() { + const currentUserID = this.$store.state.users.profile.id return { createDialogVisible: false, uploadDialogVisible: false, @@ -23,7 +24,7 @@ export default { url: '/api/v1/ops/playbooks/', columnsShow: { min: ['name', 'actions'], - default: ['name', 'comment', 'date_created', 'actions'] + default: ['name', 'comment', 'scope', 'date_created', 'actions'] }, columnsMeta: { name: { @@ -36,11 +37,15 @@ export default { formatter: ActionsFormatter, formatterArgs: { hasUpdate: true, - canUpdate: this.$hasPerm('ops.change_playbook'), + canUpdate: ({ row }) => { + return this.$hasPerm('ops.change_playbook') && row.creator === currentUserID + }, updateRoute: 'PlaybookUpdate', hasDelete: true, - canDelete: this.$hasPerm('ops.delete_playbook'), - hasClone: false + canDelete: ({ row }) => { + return this.$hasPerm('ops.delete_playbook') && row.creator === currentUserID + }, + hasClone: true } } } diff --git a/src/views/ops/Template/Playbook/PlaybookCreateUpdate.vue b/src/views/ops/Template/Playbook/PlaybookCreateUpdate.vue index 5aef9f36d..ddcabed20 100644 --- a/src/views/ops/Template/Playbook/PlaybookCreateUpdate.vue +++ b/src/views/ops/Template/Playbook/PlaybookCreateUpdate.vue @@ -13,7 +13,7 @@ export default { return { url: '/api/v1/ops/playbooks/', fields: [ - [this.$t('Basic'), ['name', 'comment']] + [this.$t('Basic'), ['name', 'comment', 'scope']] ], createSuccessNextRoute: { name: 'Template' diff --git a/src/views/ops/Template/Playbook/PlaybookDetail/Workspace.vue b/src/views/ops/Template/Playbook/PlaybookDetail/Workspace.vue index 264e6641d..c5a71c671 100644 --- a/src/views/ops/Template/Playbook/PlaybookDetail/Workspace.vue +++ b/src/views/ops/Template/Playbook/PlaybookDetail/Workspace.vue @@ -2,7 +2,7 @@