diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-08-28 21:56:25 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-08-30 21:32:03 +0200 |
commit | 9a8b3de2f0661a542fd8bc73ad1ff8bc3e52a8ba (patch) | |
tree | 1c9daac663ed780183ab24c046e56a5d89d5e8bd | |
parent | 7362ede426becc20e0f2285b72b8e5fec3edfb70 (diff) | |
download | nextcloud-server-9a8b3de2f0661a542fd8bc73ad1ff8bc3e52a8ba.tar.gz nextcloud-server-9a8b3de2f0661a542fd8bc73ad1ff8bc3e52a8ba.zip |
fix(settings): Hide forbidden UI elements for line managers
1. The "recent" accounts API only works for admin and delegated admin -> hide for line managers
2. Line managers can not create new groups -> Hide the UI to add a new group for them
3. Accounts created by line managers require one of the groups, which is managed by the line manager, assigned.
So if the line manager only manageres a single group, we should preselect that group.
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r-- | apps/settings/src/components/UserList.vue | 11 | ||||
-rw-r--r-- | apps/settings/src/views/UserManagementNavigation.vue | 17 |
2 files changed, 20 insertions, 8 deletions
diff --git a/apps/settings/src/components/UserList.vue b/apps/settings/src/components/UserList.vue index b417043a270..228ead554e2 100644 --- a/apps/settings/src/components/UserList.vue +++ b/apps/settings/src/components/UserList.vue @@ -357,7 +357,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) { diff --git a/apps/settings/src/views/UserManagementNavigation.vue b/apps/settings/src/views/UserManagementNavigation.vue index 93569e7d29a..47ecf877589 100644 --- a/apps/settings/src/views/UserManagementNavigation.vue +++ b/apps/settings/src/views/UserManagementNavigation.vue @@ -30,7 +30,7 @@ </template> </NcAppNavigationItem> - <NcAppNavigationItem v-if="isAdmin" + <NcAppNavigationItem v-if="settings.isAdmin" id="admin" :exact="true" :name="t('settings', 'Admins')" @@ -46,7 +46,8 @@ </template> </NcAppNavigationItem> - <NcAppNavigationItem id="recent" + <NcAppNavigationItem v-if="isAdminOrDelegatedAdmin" + id="recent" :exact="true" :name="t('settings', 'Recently active')" :to="{ name: 'group', params: { selectedGroup: '__nc_internal_recent' } }"> @@ -54,7 +55,7 @@ <NcIconSvgWrapper :path="mdiHistory" /> </template> <template #counter> - <NcCounterBubble v-if="recentGroup?.usercount > 0" + <NcCounterBubble v-if="recentGroup?.usercount" :type="selectedGroupDecoded === '__nc_internal_recent' ? 'highlighted' : undefined"> {{ recentGroup.usercount }} </NcCounterBubble> @@ -84,11 +85,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" /> @@ -171,8 +172,10 @@ const userCount = computed(() => store.getters.getUserCount) const groups = computed(() => store.getters.getSortedGroups) const { adminGroup, recentGroup, 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) |