From de031faf99fc8ef54e61e2bc75d4d7ed7715560c Mon Sep 17 00:00:00 2001 From: davidjumani Date: Fri, 11 Sep 2020 15:44:35 +0530 Subject: [PATCH] Disable users from creating public templates based on global setting (#693) Signed-off-by: Rohit Yadav --- ui/src/config/section/image.js | 16 ++++++++++++++-- ui/src/views/image/RegisterOrUploadIso.vue | 4 +++- ui/src/views/image/RegisterOrUploadTemplate.vue | 10 ++++++---- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ui/src/config/section/image.js b/ui/src/config/section/image.js index e36fafdea16..cba21248ded 100644 --- a/ui/src/config/section/image.js +++ b/ui/src/config/section/image.js @@ -104,7 +104,13 @@ export default { icon: 'share-alt', label: 'label.action.template.share', dataView: true, - args: ['ispublic', 'isfeatured', 'isextractable'], + args: (record, store) => { + const fields = ['isfeatured', 'isextractable'] + if (['Admin'].includes(store.userInfo.roletype) || store.features.userpublictemplateenabled) { + fields.unshift('ispublic') + } + return fields + }, show: (record, store) => { return (['Admin'].includes(store.userInfo.roletype) || // If admin or owner or belongs to current project (record.domainid === store.userInfo.domainid && record.account === store.userInfo.account) || @@ -225,7 +231,13 @@ export default { icon: 'share-alt', label: 'label.action.iso.share', dataView: true, - args: ['ispublic', 'isfeatured', 'isextractable'], + args: (record, store) => { + const fields = ['isfeatured', 'isextractable'] + if (['Admin'].includes(store.userInfo.roletype) || store.features.userpublictemplateenabled) { + fields.unshift('ispublic') + } + return fields + }, show: (record, store) => { return (['Admin'].includes(store.userInfo.roletype) || // If admin or owner or belongs to current project (record.domainid === store.userInfo.domainid && record.account === store.userInfo.account) || diff --git a/ui/src/views/image/RegisterOrUploadIso.vue b/ui/src/views/image/RegisterOrUploadIso.vue index 8b8d5ba2e3b..8c75a581462 100644 --- a/ui/src/views/image/RegisterOrUploadIso.vue +++ b/ui/src/views/image/RegisterOrUploadIso.vue @@ -131,7 +131,9 @@ }]" /> - + - - {{ $t('label.ispublic') }} + + {{ $t('label.requireshvm') }} @@ -351,8 +351,10 @@ - - {{ $t('label.requireshvm') }} + + {{ $t('label.ispublic') }}