From 60848cedf2166502b124446605fe6923ad0eb9ec Mon Sep 17 00:00:00 2001 From: Manoj Kumar Date: Tue, 5 May 2026 12:48:51 +0530 Subject: [PATCH 1/2] enable double confirmation in delete flow for resource --- ui/public/locales/en.json | 1 + ui/src/config/section/project.js | 1 + ui/src/views/AutogenView.vue | 48 ++++++++++++++++++++++++++------ 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/ui/public/locales/en.json b/ui/public/locales/en.json index e2045eba8dfe..dff8db3751e3 100644 --- a/ui/public/locales/en.json +++ b/ui/public/locales/en.json @@ -795,6 +795,7 @@ "label.delete.ciscoasa1000v": "Delete CiscoASA1000v", "label.delete.ciscovnmc.resource": "Delete CiscoVNMC resource", "label.delete.condition": "Delete condition", +"label.delete.confirmation": "Enter the exact resource name to proceed with deletion", "label.delete.custom.action": "Delete Custom Action", "label.delete.dedicated.vlan.range": "Deleted dedicated VLAN/VNI range.", "label.delete.domain": "Delete domain", diff --git a/ui/src/config/section/project.js b/ui/src/config/section/project.js index 5a1f5f71c81d..c08cb8dce4dc 100644 --- a/ui/src/config/section/project.js +++ b/ui/src/config/section/project.js @@ -162,6 +162,7 @@ export default { }, groupAction: true, popup: true, + requireNameConfirmation: true, groupMap: (selection, values) => { return selection.map(x => { return { id: x, cleanup: values.cleanup || null } }) }, args: (record, store) => { const fields = [] diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue index f4aa842d8f2b..4d958c0c9da8 100644 --- a/ui/src/views/AutogenView.vue +++ b/ui/src/views/AutogenView.vue @@ -195,7 +195,7 @@ :footer="null" style="top: 20px;" :width="modalWidth" - :ok-button-props="getOkProps()" + :ok-button-props="okButtonProps" :cancel-button-props="getCancelProps()" :confirmLoading="actionLoading" @cancel="cancelAction" @@ -270,8 +270,18 @@
- - +
+ + + + + + +
+ {{ $t('label.ok') }} @@ -686,6 +697,7 @@ export default { confirmDirty: false, firstIndex: 0, modalWidth: '30vw', + actionConfirmText: '', promises: [] } }, @@ -893,6 +905,22 @@ export default { return 'active' } return 'self' + }, + okButtonProps () { + if (this.currentAction?.requireNameConfirmation && !(this.currentAction.groupAction && this.selectedRowKeys.length > 0)) { + const isConfirmed = this.actionConfirmText.trim() === this.resource?.name?.trim() + return { type: 'primary', disabled: !isConfirmed } + } + if (this.selectedRowKeys.length > 0 && this.currentAction?.groupAction) { + return {} + } + return { type: 'primary' } + }, + isSubmitDisabled () { + if (this.currentAction?.requireNameConfirmation && !(this.currentAction.groupAction && this.selectedRowKeys.length > 0)) { + return this.actionConfirmText.trim() !== this.resource?.name?.trim() + } + return false } }, methods: { @@ -902,12 +930,6 @@ export default { } return 'inline-flex' }, - getOkProps () { - if (this.selectedRowKeys.length > 0 && this.currentAction?.groupAction) { - } else { - return { props: { type: 'primary' } } - } - }, getCancelProps () { if (this.selectedRowKeys.length > 0 && this.currentAction?.groupAction) { return { props: { type: 'primary' } } @@ -1303,6 +1325,7 @@ export default { this.actionLoading = false this.showAction = false this.currentAction = {} + this.actionConfirmText = '' }, cancelAction () { eventBus.emit('action-closing', { action: this.currentAction }) @@ -1360,6 +1383,7 @@ export default { this.currentAction = action this.currentAction.params = store.getters.apis[this.currentAction.api].params this.resource = action.resource + this.actionConfirmText = '' this.$emit('change-resource', this.resource) var paramFields = this.currentAction.params paramFields.sort(function (a, b) { @@ -1642,6 +1666,12 @@ export default { }, handleSubmit (e) { if (this.actionLoading) return + + if (this.currentAction?.requireNameConfirmation && !(this.currentAction.groupAction && this.selectedRowKeys.length > 0)) { + if (this.actionConfirmText.trim() !== this.resource?.name?.trim()) { + return + } + } this.promises = [] if (!this.dataView && this.currentAction.groupAction && this.selectedRowKeys.length > 0) { if (this.selectedRowKeys.length > 0) { From 9f44473219186b4ec07f1ac37e49191eb3d3a7c1 Mon Sep 17 00:00:00 2001 From: Manoj Kumar Date: Tue, 5 May 2026 14:56:28 +0530 Subject: [PATCH 2/2] address copilot comments --- ui/src/views/AutogenView.vue | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue index 4d958c0c9da8..272686910fdc 100644 --- a/ui/src/views/AutogenView.vue +++ b/ui/src/views/AutogenView.vue @@ -195,8 +195,6 @@ :footer="null" style="top: 20px;" :width="modalWidth" - :ok-button-props="okButtonProps" - :cancel-button-props="getCancelProps()" :confirmLoading="actionLoading" @cancel="cancelAction" centered @@ -906,16 +904,6 @@ export default { } return 'self' }, - okButtonProps () { - if (this.currentAction?.requireNameConfirmation && !(this.currentAction.groupAction && this.selectedRowKeys.length > 0)) { - const isConfirmed = this.actionConfirmText.trim() === this.resource?.name?.trim() - return { type: 'primary', disabled: !isConfirmed } - } - if (this.selectedRowKeys.length > 0 && this.currentAction?.groupAction) { - return {} - } - return { type: 'primary' } - }, isSubmitDisabled () { if (this.currentAction?.requireNameConfirmation && !(this.currentAction.groupAction && this.selectedRowKeys.length > 0)) { return this.actionConfirmText.trim() !== this.resource?.name?.trim() @@ -930,13 +918,6 @@ export default { } return 'inline-flex' }, - getCancelProps () { - if (this.selectedRowKeys.length > 0 && this.currentAction?.groupAction) { - return { props: { type: 'primary' } } - } else { - return { props: { type: 'default' } } - } - }, switchProject (projectId) { if (!projectId || !projectId.length || projectId.length !== 36) { return