diff --git a/ui/src/config/section/storage.js b/ui/src/config/section/storage.js index 0e2466ef5af..dcbaf1127a7 100644 --- a/ui/src/config/section/storage.js +++ b/ui/src/config/section/storage.js @@ -41,7 +41,8 @@ export default { listView: true, popup: true, component: () => import('@/views/storage/CreateVolume.vue') - }, { + }, + { api: 'getUploadParamsForVolume', icon: 'cloud-upload', label: 'Upload Local Volume', @@ -67,14 +68,14 @@ export default { label: 'Attach Volume', args: ['virtualmachineid'], dataView: true, - show: (record) => { return !('virtualmachineid' in record) } + show: (record) => { return record.type !== 'ROOT' && record.state !== 'Destroy' && !('virtualmachineid' in record) } }, { api: 'detachVolume', icon: 'link', label: 'Detach Volume', dataView: true, - show: (record) => { return 'virtualmachineid' in record && record.virtualmachineid } + show: (record) => { return record.type !== 'ROOT' && 'virtualmachineid' in record && record.virtualmachineid } }, { api: 'createSnapshot', @@ -108,6 +109,7 @@ export default { label: 'Resize Volume', dataView: true, popup: true, + show: (record) => { return record.state !== 'Destroy' }, component: () => import('@/views/storage/ResizeVolume.vue') }, { @@ -116,7 +118,7 @@ export default { label: 'Migrate Volume', args: ['volumeid', 'storageid', 'livemigrate'], dataView: true, - show: (record) => { return record && record.state === 'Ready' }, + show: (record, store) => { return record && record.state === 'Ready' && ['Admin', 'DomainAdmin'].includes(store.userInfo.roletype) }, popup: true, component: () => import('@/views/storage/MigrateVolume.vue'), mapping: { @@ -133,7 +135,7 @@ export default { icon: 'cloud-download', label: 'Download Volume', dataView: true, - show: (record) => { return record && record.state === 'Ready' }, + show: (record) => { return record && record.state === 'Ready' && (record.vmstate === 'Stopped' || record.virtualmachineid == null) && record.state !== 'Destroy' }, args: ['zoneid', 'mode'], mapping: { zoneid: { @@ -150,7 +152,7 @@ export default { icon: 'picture', label: 'Create Template from Volume', dataView: true, - show: (record) => { return record.type === 'ROOT' }, + show: (record) => { return (record.type === 'ROOT' && record.vmstate === 'Stopped') || (record.type !== 'ROOT' && !('virtualmachineid' in record) && !['Allocated', 'Uploaded', 'Destroy'].includes(record.state)) }, args: ['volumeid', 'name', 'displaytext', 'ostypeid', 'ispublic', 'isfeatured', 'isdynamicallyscalable', 'requireshvm', 'passwordenabled', 'sshkeyenabled'], mapping: { volumeid: { @@ -158,12 +160,37 @@ export default { } } }, + { + api: 'recoverVolume', + icon: 'medicine-box', + label: 'Recover Volume', + dataView: true, + show: (record, store) => { + return (['Admin', 'DomainAdmin'].includes(store.userInfo.roletype) || store.features.allowuserexpungerecovervolume) && record.state === 'Destroy' + } + }, { api: 'deleteVolume', icon: 'delete', label: 'Delete Volume', dataView: true, - groupAction: true + groupAction: true, + show: (record, store) => { + return ['Expunging', 'Expunged', 'UploadError'].includes(record.state) || + ((['Admin', 'DomainAdmin'].includes(store.userInfo.roletype) || store.features.allowuserexpungerecovervolume) && record.state === 'Destroy') + } + }, + { + api: 'destroyVolume', + icon: 'delete', + label: 'Destroy Volume', + dataView: true, + args: (record, store) => { + return (!['Admin', 'DomainAdmin'].includes(store.userInfo.roletype) && !store.features.allowuserexpungerecovervolumestore) ? [] : ['expunge'] + }, + show: (record, store) => { + return (!['Creating'].includes(record.state) && record.type !== 'ROOT' && !('virtualmachineid' in record) && record.state !== 'Destroy') + } } ] }, @@ -206,7 +233,8 @@ export default { api: 'revertSnapshot', icon: 'sync', label: 'Revert Snapshot', - dataView: true + dataView: true, + show: (record) => { return record.revertable } }, { api: 'deleteSnapshot', diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue index 452540d20c4..1db2b17b54b 100644 --- a/ui/src/views/AutogenView.vue +++ b/ui/src/views/AutogenView.vue @@ -556,12 +556,18 @@ export default { return 0 }) this.currentAction.paramFields = [] - if (action.args && action.args.length > 0) { - this.currentAction.paramFields = action.args.map(function (arg) { - return paramFields.filter(function (param) { - return param.name.toLowerCase() === arg.toLowerCase() - })[0] - }) + if ('args' in action) { + var args = action.args + if (typeof action.args === 'function') { + args = action.args(action.resource, this.$store.getters) + } + if (args.length > 0) { + this.currentAction.paramFields = args.map(function (arg) { + return paramFields.filter(function (param) { + return param.name.toLowerCase() === arg.toLowerCase() + })[0] + }) + } } this.showAction = true