Skip to content

Commit de031fa

Browse files
davidjumaniyadvr
authored andcommitted
Disable users from creating public templates based on global setting (apache#693)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 160bb9e commit de031fa

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

ui/src/config/section/image.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ export default {
104104
icon: 'share-alt',
105105
label: 'label.action.template.share',
106106
dataView: true,
107-
args: ['ispublic', 'isfeatured', 'isextractable'],
107+
args: (record, store) => {
108+
const fields = ['isfeatured', 'isextractable']
109+
if (['Admin'].includes(store.userInfo.roletype) || store.features.userpublictemplateenabled) {
110+
fields.unshift('ispublic')
111+
}
112+
return fields
113+
},
108114
show: (record, store) => {
109115
return (['Admin'].includes(store.userInfo.roletype) || // If admin or owner or belongs to current project
110116
(record.domainid === store.userInfo.domainid && record.account === store.userInfo.account) ||
@@ -225,7 +231,13 @@ export default {
225231
icon: 'share-alt',
226232
label: 'label.action.iso.share',
227233
dataView: true,
228-
args: ['ispublic', 'isfeatured', 'isextractable'],
234+
args: (record, store) => {
235+
const fields = ['isfeatured', 'isextractable']
236+
if (['Admin'].includes(store.userInfo.roletype) || store.features.userpublictemplateenabled) {
237+
fields.unshift('ispublic')
238+
}
239+
return fields
240+
},
229241
show: (record, store) => {
230242
return (['Admin'].includes(store.userInfo.roletype) || // If admin or owner or belongs to current project
231243
(record.domainid === store.userInfo.domainid && record.account === store.userInfo.account) ||

ui/src/views/image/RegisterOrUploadIso.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@
131131
}]" />
132132
</a-form-item>
133133

134-
<a-form-item :label="$t('label.ispublic')">
134+
<a-form-item
135+
:label="$t('label.ispublic')"
136+
v-if="$store.getters.userInfo.roletype === 'Admin' || $store.getters.features.userpublictemplateenabled" >
135137
<a-switch
136138
v-decorator="['ispublic', {
137139
initialValue: false

ui/src/views/image/RegisterOrUploadTemplate.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,8 @@
339339
</a-checkbox>
340340
</a-col>
341341
<a-col :span="12">
342-
<a-checkbox value="ispublic">
343-
{{ $t('label.ispublic') }}
342+
<a-checkbox value="requireshvm">
343+
{{ $t('label.requireshvm') }}
344344
</a-checkbox>
345345
</a-col>
346346
</a-row>
@@ -351,8 +351,10 @@
351351
</a-checkbox>
352352
</a-col>
353353
<a-col :span="12">
354-
<a-checkbox value="requireshvm">
355-
{{ $t('label.requireshvm') }}
354+
<a-checkbox
355+
value="ispublic"
356+
v-if="$store.getters.userInfo.roletype === 'Admin' || $store.getters.features.userpublictemplateenabled" >
357+
{{ $t('label.ispublic') }}
356358
</a-checkbox>
357359
</a-col>
358360
</a-row>

0 commit comments

Comments
 (0)