bernardodemarco commented on code in PR #10242: URL: https://github.com/apache/cloudstack/pull/10242#discussion_r1932631007
########## ui/src/views/iam/DeleteAccount.vue: ########## @@ -0,0 +1,140 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +<template> + <a-form + class="form" + :ref="formRef" + :model="form" + :rules="rules" + layout="vertical" + @finish="handleSubmit" + v-ctrl-enter="handleSubmit" + > + <div style="margin-bottom: 10px"> + <a-alert type="warning"> + <template #message> + <div v-html="$t('message.delete.account.warning')"></div> + </template> + </a-alert> + </div> + <div style="margin-bottom: 10px"> + <a-alert> + <template #message> + <div v-html="$t('message.delete.account.confirm')"></div> + </template> + </a-alert> + </div> + <a-form-item name="name" ref="name"> + <a-input + v-model:value="form.name" + :placeholder="$t('label.enter.account.name')" + style="width: auto"/> Review Comment: We could set the input width to `100%`, in order to fill all available space: ```suggestion style="width: 100%"/> ``` ![image](https://github.com/user-attachments/assets/7f989deb-0b05-4c5c-a855-3027e7b6b54f) ########## ui/src/views/iam/DeleteAccount.vue: ########## @@ -0,0 +1,140 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +<template> + <a-form + class="form" + :ref="formRef" + :model="form" + :rules="rules" + layout="vertical" + @finish="handleSubmit" + v-ctrl-enter="handleSubmit" + > + <div style="margin-bottom: 10px"> + <a-alert type="warning"> + <template #message> + <div v-html="$t('message.delete.account.warning')"></div> + </template> + </a-alert> + </div> + <div style="margin-bottom: 10px"> + <a-alert> + <template #message> + <div v-html="$t('message.delete.account.confirm')"></div> + </template> + </a-alert> + </div> + <a-form-item name="name" ref="name"> + <a-input + v-model:value="form.name" + :placeholder="$t('label.enter.account.name')" + style="width: auto"/> + </a-form-item> + <p v-if="error" class="error">{{ error }}</p> + <div :span="24" class="actions"> + <a-button @click="closeModal">{{ $t('label.cancel') }}</a-button> + <a-button type="primary" ref="submit" @click="handleSubmit">{{ $t('label.ok') }}</a-button> + </div> + </a-form> +</template> + +<script> +import { ref, reactive } from 'vue' +import { api } from '@/api' + +export default { + name: 'DeleteAccount', + props: { + resource: { + type: Object, + required: true + } + }, + data () { + return { + error: '' + } + }, + created () { + this.initForm() + }, + methods: { + initForm () { + this.formRef = ref() + this.form = reactive({ + }) + this.rules = reactive({ + name: [{ required: true, message: this.$t('label.required') }] + }) + }, + closeModal () { + this.$emit('close-action') + }, + handleSubmit (e) { + e.preventDefault() + this.formRef.value.validate().then(async () => { + if (this.form.name !== this.resource.name) { + this.error = `${this.$t('message.error.account.delete.name.mismatch')}` + return + } + api('deleteAccount', { + id: this.resource.id + }).then(response => { + this.$pollJob({ + jobId: response.deleteaccountresponse.jobid, + title: this.$t('label.action.delete.account'), + description: this.resource.id, + successMessage: `${this.$t('message.delete.account.success')} - ${this.resource.name}`, + errorMessage: `${this.$t('message.delete.account.failed')} - ${this.resource.name}`, + loadingMessage: `${this.$t('message.delete.account.processing')} - ${this.resource.name}`, + catchMessage: this.$t('error.fetching.async.job.result') + }) + this.closeModal() Review Comment: After deleting an account, the UI does not redirect the user to another page. As a consequence of that, the following errors are rendered on screen: ![image](https://github.com/user-attachments/assets/92e2b44e-89f1-4a60-8920-a4648e9172fb) It would be interesting to redirect the user to the accounts section ########## ui/src/config/section/account.js: ########## @@ -225,11 +225,10 @@ export default { message: 'message.delete.account', dataView: true, disabled: (record, store) => { - return record.id !== 'undefined' && store.userInfo.accountid === record.id Review Comment: It would be interesting to find a way to indicate to the users that the delete button will only become enabled when the account is disabled. One way of achieving this would be keep the `DeleteAccount` component always enabled. When accounts are not disabled, then the component could show a message explaining that the account needs first to be disabled in order to proceed with the deletion. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@cloudstack.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org