Skip to content

Commit 1d3e374

Browse files
committed
Suggested fixes
1 parent eb5b254 commit 1d3e374

File tree

3 files changed

+52
-20
lines changed

3 files changed

+52
-20
lines changed

ui/public/locales/en.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"message.delete.account.not.disabled": "Please disable the account before attempting to delete it.",
3-
"label": {
4-
"warning": "Warning"
5-
},
63
"alert.service.domainrouter": "Domain router",
74
"error.dedicate.cluster.failed": "Failed to dedicate cluster.",
85
"error.dedicate.host.failed": "Failed to dedicate host.",

ui/src/config/section/account.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export default {
225225
message: 'message.delete.account',
226226
dataView: true,
227227
disabled: (record, store) => {
228-
return (record.id !== 'undefined' && store.userInfo.accountid === record.id)
228+
return store.userInfo.accountid === record?.id
229229
},
230230
popup: true,
231231
component: shallowRef(defineAsyncComponent(() => import('@/views/iam/DeleteAccountWrapper.vue')))

ui/src/views/iam/DeleteAccount.vue

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<script>
5757
import { ref, reactive } from 'vue'
5858
import { api } from '@/api'
59+
5960
export default {
6061
name: 'DeleteAccount',
6162
props: {
@@ -66,7 +67,8 @@ export default {
6667
},
6768
data () {
6869
return {
69-
error: ''
70+
error: '',
71+
isDeleting: false
7072
}
7173
},
7274
created () {
@@ -85,6 +87,7 @@ export default {
8587
},
8688
handleSubmit (e) {
8789
e.preventDefault()
90+
if (this.isDeleting) return // Prevent double submission
8891
this.formRef.value.validate().then(async () => {
8992
if (this.form.name !== this.resource.name) {
9093
this.error = `${this.$t('message.error.account.delete.name.mismatch')}`
@@ -93,22 +96,54 @@ export default {
9396
if (this.hasActiveResources) {
9497
return
9598
}
96-
api('deleteAccount', {
97-
id: this.resource.id
98-
}).then(response => {
99-
this.$pollJob({
100-
jobId: response.deleteaccountresponse.jobid,
101-
title: this.$t('label.action.delete.account'),
102-
description: this.resource.id,
103-
successMessage: `${this.$t('message.delete.account.success')} - ${this.resource.name}`,
104-
errorMessage: `${this.$t('message.delete.account.failed')} - ${this.resource.name}`,
105-
loadingMessage: `${this.$t('message.delete.account.processing')} - ${this.resource.name}`,
106-
catchMessage: this.$t('error.fetching.async.job.result')
99+
this.isDeleting = true
100+
// Store the account ID and name before we close the modal
101+
const accountId = this.resource.id
102+
const accountName = this.resource.name
103+
// Close the modal first
104+
this.closeModal()
105+
// Immediately navigate to the accounts page to avoid "unable to find account" errors
106+
this.$router.push({ path: '/account' })
107+
.then(() => {
108+
// After successful navigation, start the deletion job
109+
api('deleteAccount', {
110+
id: accountId
111+
}).then(response => {
112+
this.$pollJob({
113+
jobId: response.deleteaccountresponse.jobid,
114+
title: this.$t('label.action.delete.account'),
115+
description: accountId,
116+
successMessage: `${this.$t('message.delete.account.success')} - ${accountName}`,
117+
errorMessage: `${this.$t('message.delete.account.failed')} - ${accountName}`,
118+
loadingMessage: `${this.$t('message.delete.account.processing')} - ${accountName}`,
119+
catchMessage: this.$t('error.fetching.async.job.result')
120+
})
121+
}).catch(error => {
122+
this.$notifyError(error)
123+
this.isDeleting = false
124+
})
125+
})
126+
.catch(err => {
127+
console.error('Navigation failed:', err)
128+
this.isDeleting = false
129+
// If navigation fails, still try to delete the account
130+
// but don't navigate afterwards
131+
api('deleteAccount', {
132+
id: accountId
133+
}).then(response => {
134+
this.$pollJob({
135+
jobId: response.deleteaccountresponse.jobid,
136+
title: this.$t('label.action.delete.account'),
137+
description: accountId,
138+
successMessage: `${this.$t('message.delete.account.success')} - ${accountName}`,
139+
errorMessage: `${this.$t('message.delete.account.failed')} - ${accountName}`,
140+
loadingMessage: `${this.$t('message.delete.account.processing')} - ${accountName}`,
141+
catchMessage: this.$t('error.fetching.async.job.result')
142+
})
143+
}).catch(error => {
144+
this.$notifyError(error)
145+
})
107146
})
108-
this.closeModal()
109-
}).catch(error => {
110-
this.$notifyError(error)
111-
})
112147
}).catch((error) => {
113148
this.formRef.value.scrollToField(error.errorFields[0].name)
114149
})

0 commit comments

Comments
 (0)