Fix permission to manipulate VMs and templates settings through UI (#8778)

This commit is contained in:
Bernardo De Marco Gonçalves 2024-04-23 06:46:10 -03:00 committed by GitHub
parent 6502dde8c3
commit 582249c1f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,7 +26,7 @@
<a-button <a-button
type="dashed" type="dashed"
style="width: 100%" style="width: 100%"
:disabled="!('updateTemplate' in $store.getters.apis && 'updateVirtualMachine' in $store.getters.apis && isAdminOrOwner())" :disabled="!(isAdminOrOwner() && hasSettingUpdatePermission())"
@click="onShowAddDetail"> @click="onShowAddDetail">
<template #icon><plus-outlined /></template> <template #icon><plus-outlined /></template>
{{ $t('label.add.setting') }} {{ $t('label.add.setting') }}
@ -96,8 +96,7 @@
</a-list-item-meta> </a-list-item-meta>
<template #actions> <template #actions>
<div <div
v-if="!disableSettings && 'updateTemplate' in $store.getters.apis && v-if="!disableSettings && isAdminOrOwner() && allowEditOfDetail(item.name) && hasSettingUpdatePermission()">
'updateVirtualMachine' in $store.getters.apis && isAdminOrOwner() && allowEditOfDetail(item.name)">
<tooltip-button <tooltip-button
:tooltip="$t('label.edit')" :tooltip="$t('label.edit')"
icon="edit-outlined" icon="edit-outlined"
@ -106,8 +105,7 @@
@onClick="showEditDetail(index)" /> @onClick="showEditDetail(index)" />
</div> </div>
<div <div
v-if="!disableSettings && 'updateTemplate' in $store.getters.apis && v-if="!disableSettings && isAdminOrOwner() && allowEditOfDetail(item.name) && hasSettingUpdatePermission()">
'updateVirtualMachine' in $store.getters.apis && isAdminOrOwner() && allowEditOfDetail(item.name)">
<a-popconfirm <a-popconfirm
:title="`${$t('label.delete.setting')}?`" :title="`${$t('label.delete.setting')}?`"
@confirm="deleteDetail(index)" @confirm="deleteDetail(index)"
@ -342,6 +340,12 @@ export default {
this.newValue = '' this.newValue = ''
this.error = false this.error = false
this.showAddDetail = false this.showAddDetail = false
},
hasSettingUpdatePermission () {
return (
(this.resourceType === 'Template' && 'updateTemplate' in this.$store.getters.apis) ||
(this.resourceType === 'UserVm' && 'updateVirtualMachine' in this.$store.getters.apis)
)
} }
} }
} }