Skip to content

Commit

Permalink
Prevent editing and deleting read-only groups
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Apr 3, 2023
1 parent 31e0ea1 commit adf6e58
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<oc-icon name="information" fill-type="line" />
</oc-button>
<oc-button
v-if="!item.groupTypes.includes('ReadOnly')"
v-oc-tooltip="$gettext('Edit')"
appearance="raw"
class="oc-mr-xs quick-action-button oc-p-xs groups-table-btn-edit"
Expand All @@ -90,11 +91,6 @@
<slot name="contextMenu" :group="item" />
</template>
</context-menu-quick-action>
<!-- Editing groups is currently not supported by backend
<oc-button v-oc-tooltip="$gettext('Edit')" class="oc-ml-s" @click="$emit('clickEdit', item)">
<oc-icon size="small" name="pencil" />
</oc-button>
-->
</template>
<template #footer>
<div class="oc-text-nowrap oc-text-center oc-width-1-1 oc-my-s">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ export const useGroupActionsDelete = ({ store }: { store?: Store<any> }) => {
},
handler,
isEnabled: ({ resources }) => {
return !!resources.length
return (
!!resources.length && !resources.some((r) => (r as any).groupTypes.includes('ReadOnly'))
)
},
componentType: 'button',
class: 'oc-groups-actions-delete-trigger'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const useGroupActionsEdit = () => {
label: () => $gettext('Edit'),
handler: () => eventBus.publish(SideBarEventTopics.openWithPanel, 'EditPanel'),
isEnabled: ({ resources }) => {
return resources.length > 0
return resources.length === 1 && !(resources[0] as any).groupTypes.includes('ReadOnly')
},
componentType: 'button',
class: 'oc-groups-actions-edit-trigger'
Expand Down
4 changes: 3 additions & 1 deletion packages/web-app-admin-settings/src/views/Groups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ export default defineComponent({
title: this.$gettext('Edit group'),
component: EditPanel,
default: false,
enabled: this.selectedGroups.length === 1,
enabled:
this.selectedGroups.length === 1 &&
!(this.selectedGroups[0] as any).groupTypes.includes('ReadOnly'),
componentAttrs: {
group: this.selectedGroups.length === 1 ? this.selectedGroups[0] : null,
onConfirm: this.editGroup
Expand Down

0 comments on commit adf6e58

Please sign in to comment.