diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-08-28 21:56:25 +0200 |
---|---|---|
committer | Andy Scherzinger <info@andy-scherzinger.de> | 2024-09-02 20:22:48 +0200 |
commit | 577a5045e8e64e7e8800b1987898a972ae493550 (patch) | |
tree | 500833dc5be99da601135b994b7fca9f202066b6 | |
parent | 026efbad135d395ee88539677ca4e9bc5a8aae9e (diff) | |
download | nextcloud-server-577a5045e8e64e7e8800b1987898a972ae493550.tar.gz nextcloud-server-577a5045e8e64e7e8800b1987898a972ae493550.zip |
fix(settings): Hide forbidden UI elements for group managers
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>
-rw-r--r-- | apps/settings/src/components/UserList.vue | 11 | ||||
-rw-r--r-- | apps/settings/src/views/UserManagementNavigation.vue | 12 |
2 files changed, 17 insertions, 6 deletions
diff --git a/apps/settings/src/components/UserList.vue b/apps/settings/src/components/UserList.vue index 00289c6f84a..80689815bf2 100644 --- a/apps/settings/src/components/UserList.vue +++ b/apps/settings/src/components/UserList.vue @@ -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) { diff --git a/apps/settings/src/views/UserManagementNavigation.vue b/apps/settings/src/views/UserManagementNavigation.vue index 51a5744543d..61c85933089 100644 --- a/apps/settings/src/views/UserManagementNavigation.vue +++ b/apps/settings/src/views/UserManagementNavigation.vue @@ -26,7 +26,7 @@ </template> </NcAppNavigationItem> - <NcAppNavigationItem v-if="isAdmin" + <NcAppNavigationItem v-if="settings.isAdmin" id="admin" :exact="true" :name="t('settings', 'Admins')" @@ -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" /> @@ -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) |