Merge pull request #60483 from masskrdjn/fix-hiding-unselectable-groups-in-account-manager
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Psalm static code analysis / changes (push) Waiting to run
Psalm static code analysis / static-code-analysis (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis-security (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis-ocp (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis-ncu (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis-strict (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis-summary (push) Blocked by required conditions

feat: implement isSelectableGroup function to filter out unselectable groups
This commit is contained in:
Louis 2026-06-11 15:36:58 +02:00 committed by GitHub
commit e6b8de4d0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 2 deletions

View file

@ -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',
@ -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() {

View file

@ -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 = {
@ -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' }

View file

@ -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.
*