Skip to content

Commit

Permalink
Merge pull request #47589 from nextcloud/fix/user-settings-admin
Browse files Browse the repository at this point in the history
fix(settings): Hide forbidden UI elements for group managers
  • Loading branch information
susnux authored Aug 30, 2024
2 parents 7362ede + 380b92c commit 558fbcd
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 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 @@ -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) {
Expand Down
17 changes: 10 additions & 7 deletions apps/settings/src/views/UserManagementNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</template>
</NcAppNavigationItem>

<NcAppNavigationItem v-if="isAdmin"
<NcAppNavigationItem v-if="settings.isAdmin"
id="admin"
:exact="true"
:name="t('settings', 'Admins')"
Expand All @@ -46,15 +46,16 @@
</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' } }">
<template #icon>
<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>
Expand Down Expand Up @@ -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" />
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions dist/settings-users-3239.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-users-3239.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-apps-users-management.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-apps-users-management.js.map

Large diffs are not rendered by default.

0 comments on commit 558fbcd

Please sign in to comment.