diff --git a/ui/src/config/section/storage.js b/ui/src/config/section/storage.js index 269c1f81788..3c2bd30db9b 100644 --- a/ui/src/config/section/storage.js +++ b/ui/src/config/section/storage.js @@ -253,7 +253,14 @@ export default { ((record.type === 'ROOT' && record.vmstate === 'Stopped') || (record.type !== 'ROOT' && !record.virtualmachineid && !['Allocated', 'Uploaded'].includes(record.state))) }, - args: ['volumeid', 'name', 'displaytext', 'ostypeid', 'ispublic', 'isfeatured', 'isdynamicallyscalable', 'requireshvm', 'passwordenabled'], + args: (record, store) => { + var fields = ['volumeid', 'name', 'displaytext', 'ostypeid', 'ispublic', 'isfeatured', 'isdynamicallyscalable', 'requireshvm', 'passwordenabled'] + if (['Admin', 'DomainAdmin'].includes(store.userInfo.roletype)) { + fields.push('domainid') + fields.push('account') + } + return fields + }, mapping: { volumeid: { value: (record) => { return record.id } diff --git a/ui/src/views/storage/CreateTemplate.vue b/ui/src/views/storage/CreateTemplate.vue index 294abe330cb..13ce75777fb 100644 --- a/ui/src/views/storage/CreateTemplate.vue +++ b/ui/src/views/storage/CreateTemplate.vue @@ -69,6 +69,48 @@ + + + + + + + + {{ opt.path || opt.name || opt.description }} + + + + + + + + + {{ acc.name }} + + + + { + this.domains = json.listdomainsresponse.domain + }).finally(() => { + this.domainLoading = false + this.handleDomainChange(null) + }) + }, + handleDomainChange (domain) { + this.domainid = domain + this.form.account = null + this.account = null + if ('listAccounts' in this.$store.getters.apis) { + this.fetchAccounts() + } + }, + fetchAccounts () { + api('listAccounts', { + domainid: this.domainid + }).then(response => { + this.accounts = response.listaccountsresponse.account || [] + }).catch(error => { + this.$notifyError(error) + }) + }, + handleAccountChange (acc) { + if (acc) { + this.account = acc.name + } else { + this.account = acc + } + }, handleSubmit (e) { if (this.loading) return this.formRef.value.validate().then(() => { @@ -277,6 +364,9 @@ export default { }, closeModal () { this.$emit('close-action') + }, + isAdminOrDomainAdmin () { + return ['Admin', 'DomainAdmin'].includes(this.$store.getters.userInfo.roletype) } } }