Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions ui/src/config/section/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } }) },
Comment thread
sudo87 marked this conversation as resolved.
args: (record, store) => {
const fields = []
Expand Down
48 changes: 39 additions & 9 deletions ui/src/views/AutogenView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
:footer="null"
style="top: 20px;"
:width="modalWidth"
:ok-button-props="getOkProps()"
:ok-button-props="okButtonProps"
:cancel-button-props="getCancelProps()"
Comment thread
sudo87 marked this conversation as resolved.
Outdated
:confirmLoading="actionLoading"
@cancel="cancelAction"
Expand Down Expand Up @@ -270,8 +270,18 @@
</a-table>
</div>
<br v-if="currentAction.paramFields.length > 0" />
</span>
<a-form
</span>
<div v-if="currentAction.requireNameConfirmation && !(currentAction.groupAction && selectedRowKeys.length > 0)" style="margin-bottom: 5px">
<a-form-item>
<a-input v-model:value="actionConfirmText" :placeholder="resource.name" />
</a-form-item>
Comment thread
sudo87 marked this conversation as resolved.
<a-alert type="info">
<template #message>
<div v-html="$t('label.delete.confirmation')"></div>
</template>
</a-alert>
</div>
<a-form
:ref="formRef"
:model="form"
:rules="rules"
Expand Down Expand Up @@ -526,6 +536,7 @@
type="primary"
@click="handleSubmit"
ref="submit"
:disabled="isSubmitDisabled"
>{{ $t('label.ok') }}</a-button>
</div>
</a-form>
Expand Down Expand Up @@ -686,6 +697,7 @@ export default {
confirmDirty: false,
firstIndex: 0,
modalWidth: '30vw',
actionConfirmText: '',
promises: []
}
},
Expand Down Expand Up @@ -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: {
Expand All @@ -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' } }
Expand Down Expand Up @@ -1303,6 +1325,7 @@ export default {
this.actionLoading = false
this.showAction = false
this.currentAction = {}
this.actionConfirmText = ''
},
cancelAction () {
eventBus.emit('action-closing', { action: this.currentAction })
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
}
Comment thread
sudo87 marked this conversation as resolved.
Comment thread
sudo87 marked this conversation as resolved.
this.promises = []
if (!this.dataView && this.currentAction.groupAction && this.selectedRowKeys.length > 0) {
if (this.selectedRowKeys.length > 0) {
Expand Down
Loading