Skip to content

Commit

Permalink
fix(settings): Hide forbidden UI elements for group managers
Browse files Browse the repository at this point in the history
1. The "recent" accounts API only works for admin and delegated admin -> hide for group managers
2. Group managers can not create new groups -> Hide the UI to add a new group for them
3. Accounts created by group managers require one of the groups, which is managed by the group manager, assigned.
   So if the group manager only manageres a single group, we should preselect that group.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux authored and AndyScherzinger committed Sep 2, 2024
1 parent 026efba commit 577a504
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
11 changes: 10 additions & 1 deletion apps/settings/src/components/UserList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,16 @@ export default {
},

setNewUserDefaultGroup(value) {
if (value && value.length > 0) {
// Is no value set, but user is a line manager we set their group as this is a requirement for line manager
if (!value && !this.settings.isAdmin && !this.settings.isDelegatedAdmin) {
// if there are multiple groups we do not know which to add,
// so we cannot make the managers life easier by preselecting it.
if (this.groups.length === 1) {
value = this.groups[0].id
}
}

if (value) {
// setting new account default group to the current selected one
const currentGroup = this.groups.find(group => group.id === value)
if (currentGroup) {
Expand Down
12 changes: 7 additions & 5 deletions apps/settings/src/views/UserManagementNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</template>
</NcAppNavigationItem>

<NcAppNavigationItem v-if="isAdmin"
<NcAppNavigationItem v-if="settings.isAdmin"
id="admin"
:exact="true"
:name="t('settings', 'Admins')"
Expand Down Expand Up @@ -65,11 +65,11 @@
force-menu
is-heading
:open.sync="isAddGroupOpen">
<template #actionsTriggerIcon>
<template v-if="isAdminOrDelegatedAdmin" #actionsTriggerIcon>
<NcLoadingIcon v-if="loadingAddGroup" />
<NcIconSvgWrapper v-else :path="mdiPlus" />
</template>
<template #actions>
<template v-if="isAdminOrDelegatedAdmin" #actions>
<NcActionText>
<template #icon>
<AccountGroup :size="20" />
Expand Down Expand Up @@ -152,8 +152,10 @@ const userCount = computed(() => store.getters.getUserCount)
const groups = computed(() => store.getters.getSortedGroups)
const { adminGroup, disabledGroup, userGroups } = useFormatGroups(groups)
/** True if the current user is an administrator */
const isAdmin = computed(() => store.getters.getServerData.isAdmin)
/** Server settings for current user */
const settings = computed(() => store.getters.getServerData)
/** True if the current user is a (delegated) admin */
const isAdminOrDelegatedAdmin = computed(() => settings.value.isAdmin || settings.value.isDelegatedAdmin)
/** True if the 'add-group' dialog is open - needed to be able to close it when the group is created */
const isAddGroupOpen = ref(false)
Expand Down

0 comments on commit 577a504

Please sign in to comment.