Make resource deletion safer with name confirmation#13104
Make resource deletion safer with name confirmation#13104sudo87 wants to merge 2 commits intoapache:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an optional UI safety mechanism for destructive actions: when enabled per action (requireNameConfirmation: true), the user must type the exact resource name before a delete can proceed.
Changes:
- Added a
requireNameConfirmationflow toAutogenView.vue, including input capture, submit disabling, and a submit-time guard. - Enabled
requireNameConfirmationfor thedeleteProjectaction in the Project section config. - Added an English locale string explaining the confirmation requirement.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
ui/src/views/AutogenView.vue |
Adds the name-confirmation UI/logic and disables submission until the entered name matches. |
ui/src/config/section/project.js |
Enables the feature for deleteProject via requireNameConfirmation: true. |
ui/public/locales/en.json |
Adds the confirmation helper message text. |
Comments suppressed due to low confidence (1)
ui/src/views/AutogenView.vue:939
- The code now returns direct button props from
okButtonProps(e.g.{ type: 'primary' }), butgetCancelProps()still returns{ props: { type: ... } }. With ant-design-vue v3,ok-button-props/cancel-button-propsexpect plain button props, so the extrapropswrapper is likely ignored and makes behavior inconsistent. Consider updatinggetCancelProps()(and similar helpers elsewhere) to return plain button props.
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: {
getStyle () {
if (['snapshot', 'vmsnapshot', 'publicip'].includes(this.$route.name)) {
return 'table-cell'
}
return 'inline-flex'
},
getCancelProps () {
if (this.selectedRowKeys.length > 0 && this.currentAction?.groupAction) {
return { props: { type: 'primary' } }
} else {
return { props: { type: 'default' } }
}
},
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13104 +/- ##
============================================
- Coverage 18.08% 18.07% -0.01%
+ Complexity 16706 16700 -6
============================================
Files 6037 6037
Lines 542437 542440 +3
Branches 66420 66422 +2
============================================
- Hits 98088 98051 -37
- Misses 433333 433372 +39
- Partials 11016 11017 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@sudo87 a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress. |
|
UI build: ✔️ |
| :ok-button-props="getOkProps()" | ||
| :cancel-button-props="getCancelProps()" |
There was a problem hiding this comment.
This is not required as footer is set null.

Description
This PR will allow enforcing user to key in resource name before proceeding with Delete.
It can be enabled by adding a param "requireNameConfirmation: true" for the delete api section
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?