diff --git a/ui/src/config/section/storage.js b/ui/src/config/section/storage.js index 7e56d5c6eee..a869dfb6e80 100644 --- a/ui/src/config/section/storage.js +++ b/ui/src/config/section/storage.js @@ -258,25 +258,8 @@ export default { ((record.type === 'ROOT' && record.vmstate === 'Stopped') || (record.type !== 'ROOT' && !record.virtualmachineid && !['Allocated', 'Uploaded'].includes(record.state))) }, - args: (record, store) => { - var fields = ['volumeid', 'name', 'displaytext', 'ostypeid', 'isdynamicallyscalable', 'requireshvm', 'passwordenabled'] - if (['Admin', 'DomainAdmin'].includes(store.userInfo.roletype)) { - fields.push('domainid') - fields.push('account') - } - if (['Admin'].includes(store.userInfo.roletype) || store.features.userpublictemplateenabled) { - fields.push('ispublic') - } - if (['Admin'].includes(store.userInfo.roletype)) { - fields.push('isfeatured') - } - return fields - }, - mapping: { - volumeid: { - value: (record) => { return record.id } - } - } + popup: true, + component: shallowRef(defineAsyncComponent(() => import('@/views/storage/CreateTemplate.vue'))) }, { api: 'recoverVolume', diff --git a/ui/src/views/storage/CreateTemplate.vue b/ui/src/views/storage/CreateTemplate.vue index 13ce75777fb..65941d39a9d 100644 --- a/ui/src/views/storage/CreateTemplate.vue +++ b/ui/src/views/storage/CreateTemplate.vue @@ -43,7 +43,7 @@ v-model:value="form.displaytext" :placeholder="apiParams.displaytext.description" /> - + @@ -130,41 +130,40 @@ - - - - - - - {{ $t('label.passwordenabled') }} - - - - - {{ $t('label.isdynamicallyscalable') }} - - - - - {{ $t('label.requireshvm') }} - - - - - {{ $t('label.isfeatured') }} - - - - - {{ $t('label.ispublic') }} - - - - + + + + + + + + + + + + + + + + + + + +
@@ -234,7 +233,9 @@ export default { }, fetchData () { this.fetchOsTypes() - this.fetchSnapshotZones() + if (this.resource.intervaltype) { + this.fetchSnapshotZones() + } if ('listDomains' in this.$store.getters.apis) { this.fetchDomains() } @@ -300,21 +301,24 @@ export default { this.handleDomainChange(null) }) }, - handleDomainChange (domain) { + async handleDomainChange (domain) { this.domainid = domain this.form.account = null this.account = null if ('listAccounts' in this.$store.getters.apis) { - this.fetchAccounts() + await this.fetchAccounts() } }, fetchAccounts () { - api('listAccounts', { - domainid: this.domainid - }).then(response => { - this.accounts = response.listaccountsresponse.account || [] - }).catch(error => { - this.$notifyError(error) + return new Promise((resolve, reject) => { + api('listAccounts', { + domainid: this.domainid + }).then(response => { + this.accounts = response?.listaccountsresponse?.account || [] + resolve(this.accounts) + }).catch(error => { + this.$notifyError(error) + }) }) }, handleAccountChange (acc) { @@ -329,17 +333,22 @@ export default { this.formRef.value.validate().then(() => { const formRaw = toRaw(this.form) const values = this.handleRemoveFields(formRaw) - values.snapshotid = this.resource.id - if (values.groupenabled) { - const input = values.groupenabled - for (const index in input) { - const name = input[index] - values[name] = true + const params = {} + if (this.resource.intervaltype) { + params.snapshotid = this.resource.id + } else { + params.volumeid = this.resource.id + } + + for (const key in values) { + const input = values[key] + if (input === undefined) { + continue } - delete values.groupenabled + params[key] = input } this.loading = true - api('createTemplate', values).then(response => { + api('createTemplate', params).then(response => { this.$pollJob({ jobId: response.createtemplateresponse.jobid, title: this.$t('message.success.create.template'),