Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/settings/src/components/Users/UserFormGroups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import NcSelect from '@nextcloud/vue/components/NcSelect'
import logger from '../../logger.ts'
import { searchGroups } from '../../service/groups.ts'
import { isSelectableGroup } from './userFormUtils.ts'

export default {
name: 'UserFormGroups',
Expand Down Expand Up @@ -73,7 +74,7 @@ export default {
? this.$store.getters.getSortedGroups
: this.$store.getters.getSubAdminGroups

return groups.filter(({ id }) => id !== '__nc_internal_recent' && id !== 'disabled')
return groups.filter(isSelectableGroup)
},

availableSubAdminGroups() {
Expand Down
14 changes: 13 additions & 1 deletion apps/settings/src/components/Users/userFormUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { describe, expect, it } from 'vitest'
import { diffPayload, languageFilterBy, resolveLanguage, userToFormData, validateQuota } from './userFormUtils.ts'
import { diffPayload, isSelectableGroup, languageFilterBy, resolveLanguage, userToFormData, validateQuota } from './userFormUtils.ts'

describe('resolveLanguage', () => {
const serverLanguages = {
Expand Down Expand Up @@ -266,6 +266,18 @@ describe('diffPayload', () => {
})
})

describe('isSelectableGroup', () => {
it('allows regular groups in the groups picker', () => {
expect(isSelectableGroup({ id: 'devs', name: 'Developers' })).toBe(true)
})

it('hides internal and guest-only groups from the groups picker', () => {
expect(isSelectableGroup({ id: '__nc_internal_recent', name: 'Recently active' })).toBe(false)
expect(isSelectableGroup({ id: 'disabled', name: 'Disabled accounts' })).toBe(false)
expect(isSelectableGroup({ id: 'guest_app', name: 'Guests' })).toBe(false)
})
})

describe('validateQuota', () => {
const fallback = { id: 'default', label: 'Default quota' }

Expand Down
15 changes: 15 additions & 0 deletions apps/settings/src/components/Users/userFormUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ interface FormData {
manager: string | { id: string, displayname?: string }
}

const UNSELECTABLE_GROUP_IDS = [
'__nc_internal_recent',
'disabled',
'guest_app',
]

/**
* Whether a group can be offered as a selectable account group option.
*
* @param group Group option
*/
export function isSelectableGroup(group: IGroup): boolean {
return !UNSELECTABLE_GROUP_IDS.includes(group.id)
}

/**
* Resolves the user's language code to a { code, name } object.
*
Expand Down