@thunderid/react 1.9.2 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/admin/RoleAssignments/RoleAssignments.cjs +50 -24
- package/dist/cjs/components/admin/RoleAssignments/RoleAssignments.cjs.map +1 -1
- package/dist/components/admin/RoleAssignments/RoleAssignments.d.ts +4 -0
- package/dist/components/admin/RoleAssignments/RoleAssignments.d.ts.map +1 -1
- package/dist/components/admin/RoleAssignments/RoleAssignments.js +51 -25
- package/dist/components/admin/RoleAssignments/RoleAssignments.js.map +1 -1
- package/package.json +2 -2
|
@@ -21,7 +21,7 @@ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
|
21
21
|
* <RoleAssignments roleId={roleId} />
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
const RoleAssignments = ({ administrationMode, editable = false, filterable = true, preferences, roleId,...rest }) => {
|
|
24
|
+
const RoleAssignments = ({ administrationMode, editable = false, filterable = true, ouId, preferences, roleId,...rest }) => {
|
|
25
25
|
const { t } = require_useTranslation.default(preferences?.i18n);
|
|
26
26
|
const [typeFilter, setTypeFilter] = (0, react.useState)(null);
|
|
27
27
|
const rolesEndpoint = require_useManagementEndpoint.default("roles");
|
|
@@ -29,6 +29,7 @@ const RoleAssignments = ({ administrationMode, editable = false, filterable = tr
|
|
|
29
29
|
const groupsEndpoint = require_useManagementEndpoint.default("groups");
|
|
30
30
|
const agentsEndpoint = require_useManagementEndpoint.default("agents");
|
|
31
31
|
const type = typeFilter ?? void 0;
|
|
32
|
+
const filter = (0, __thunderid_browser.toEqualityFilter)("ouId", ouId);
|
|
32
33
|
const assignments = require_useResourceQuery.default([
|
|
33
34
|
__thunderid_browser.RoleQueryKeys.ROLE_ASSIGNMENTS,
|
|
34
35
|
roleId,
|
|
@@ -43,20 +44,41 @@ const RoleAssignments = ({ administrationMode, editable = false, filterable = tr
|
|
|
43
44
|
roleId,
|
|
44
45
|
type
|
|
45
46
|
}), { enabled: Boolean(roleId) });
|
|
46
|
-
const users = require_useResourceQuery.default([__thunderid_browser.UserQueryKeys.USERS, {
|
|
47
|
-
|
|
48
|
-
fetcher,
|
|
47
|
+
const users = require_useResourceQuery.default([__thunderid_browser.UserQueryKeys.USERS, {
|
|
48
|
+
filter,
|
|
49
49
|
limit: 100
|
|
50
|
+
}], async (fetcher) => ({
|
|
51
|
+
filter,
|
|
52
|
+
page: await (0, __thunderid_browser.getUsers)({
|
|
53
|
+
...usersEndpoint,
|
|
54
|
+
fetcher,
|
|
55
|
+
filter,
|
|
56
|
+
limit: 100
|
|
57
|
+
})
|
|
50
58
|
}), { enabled: editable });
|
|
51
|
-
const groups = require_useResourceQuery.default([__thunderid_browser.GroupQueryKeys.GROUPS, {
|
|
52
|
-
|
|
53
|
-
fetcher,
|
|
59
|
+
const groups = require_useResourceQuery.default([__thunderid_browser.GroupQueryKeys.GROUPS, {
|
|
60
|
+
filter,
|
|
54
61
|
limit: 100
|
|
62
|
+
}], async (fetcher) => ({
|
|
63
|
+
filter,
|
|
64
|
+
page: await (0, __thunderid_browser.getGroups)({
|
|
65
|
+
...groupsEndpoint,
|
|
66
|
+
fetcher,
|
|
67
|
+
filter,
|
|
68
|
+
limit: 100
|
|
69
|
+
})
|
|
55
70
|
}), { enabled: editable });
|
|
56
|
-
const agents = require_useResourceQuery.default([__thunderid_browser.AgentQueryKeys.AGENTS, {
|
|
57
|
-
|
|
58
|
-
fetcher,
|
|
71
|
+
const agents = require_useResourceQuery.default([__thunderid_browser.AgentQueryKeys.AGENTS, {
|
|
72
|
+
filter,
|
|
59
73
|
limit: 100
|
|
74
|
+
}], async (fetcher) => ({
|
|
75
|
+
filter,
|
|
76
|
+
page: await (0, __thunderid_browser.getAgents)({
|
|
77
|
+
...agentsEndpoint,
|
|
78
|
+
fetcher,
|
|
79
|
+
filter,
|
|
80
|
+
limit: 100
|
|
81
|
+
})
|
|
60
82
|
}), { enabled: editable });
|
|
61
83
|
const assign = require_useResourceMutation.default(({ assignments: changes, roleId: id }, fetcher) => (0, __thunderid_browser.addRoleAssignments)({
|
|
62
84
|
...rolesEndpoint,
|
|
@@ -71,21 +93,25 @@ const RoleAssignments = ({ administrationMode, editable = false, filterable = tr
|
|
|
71
93
|
fetcher,
|
|
72
94
|
roleId: id
|
|
73
95
|
}), () => [[__thunderid_browser.RoleQueryKeys.ROLE_ASSIGNMENTS]]);
|
|
74
|
-
const candidates = (0, react.useMemo)(() =>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
96
|
+
const candidates = (0, react.useMemo)(() => {
|
|
97
|
+
const current = (data) => data && data.filter === filter ? data.page : void 0;
|
|
98
|
+
return {
|
|
99
|
+
agent: (current(agents.data)?.agents ?? []).map((agent) => ({
|
|
100
|
+
id: agent.id,
|
|
101
|
+
label: (0, __thunderid_browser.getAgentName)(agent)
|
|
102
|
+
})),
|
|
103
|
+
group: (current(groups.data)?.groups ?? []).map((group) => ({
|
|
104
|
+
id: group.id,
|
|
105
|
+
label: group.name
|
|
106
|
+
})),
|
|
107
|
+
user: (current(users.data)?.users ?? []).map((user) => ({
|
|
108
|
+
id: user.id,
|
|
109
|
+
label: (0, __thunderid_browser.resolveManagedIdentityName)(user)
|
|
110
|
+
}))
|
|
111
|
+
};
|
|
112
|
+
}, [
|
|
88
113
|
agents.data,
|
|
114
|
+
filter,
|
|
89
115
|
groups.data,
|
|
90
116
|
users.data
|
|
91
117
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoleAssignments.cjs","names":["RoleAssignments: FC<RoleAssignmentsProps>","useTranslation","rolesEndpoint: ManagementEndpoint","useManagementEndpoint","usersEndpoint: ManagementEndpoint","groupsEndpoint: ManagementEndpoint","agentsEndpoint: ManagementEndpoint","type: RoleAssigneeType | undefined","assignments: ResourceQueryResult<RoleAssignmentListResponse>","useResourceQuery","RoleQueryKeys","users: ResourceQueryResult<ManagedUserListResponse>","UserQueryKeys","groups: ResourceQueryResult<GroupListResponse>","GroupQueryKeys","agents: ResourceQueryResult<AgentListResponse>","AgentQueryKeys","assign: ResourceMutationResult<void, RoleAssignmentsVariables>","useResourceMutation","unassign: ResourceMutationResult<void, RoleAssignmentsVariables>","candidates: Partial<Record<'user' | 'group' | 'agent', IdentityCandidate[]>>","BaseRoleAssignments"],"sources":["../../../../../src/components/admin/RoleAssignments/RoleAssignments.tsx"],"sourcesContent":["// Copyright 2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n AdministrationMode,\n AgentListResponse,\n AgentQueryKeys,\n BasicAgent,\n Group,\n GroupListResponse,\n GroupQueryKeys,\n ManagedUser,\n ManagedUserListResponse,\n RoleAssigneeType,\n RoleAssignment,\n RoleAssignmentInput,\n RoleAssignmentListResponse,\n RoleQueryKeys,\n UserQueryKeys,\n addRoleAssignments,\n getAgentName,\n getAgents,\n getGroups,\n getRoleAssignments,\n getUsers,\n removeRoleAssignments,\n resolveManagedIdentityName,\n toManagementErrorMessage,\n} from '@thunderid/browser';\nimport {FC, ReactElement, useMemo, useState} from 'react';\nimport BaseRoleAssignments, {BaseRoleAssignmentsProps} from './BaseRoleAssignments';\nimport useManagementEndpoint, {ManagementEndpoint} from '../../../hooks/management/useManagementEndpoint';\nimport useResourceMutation, {ResourceMutationResult} from '../../../hooks/management/useResourceMutation';\nimport useResourceQuery, {ResourceQueryResult} from '../../../hooks/management/useResourceQuery';\nimport useTranslation from '../../../hooks/useTranslation';\nimport {IdentityCandidate} from '../shared/IdentityPicker';\n\ninterface RoleAssignmentsVariables {\n assignments: RoleAssignmentInput[];\n roleId: string;\n}\n\nexport type RoleAssignmentsProps = Omit<\n BaseRoleAssignmentsProps,\n | 'assignments'\n | 'candidates'\n | 'error'\n | 'isLoading'\n | 'isMutating'\n | 'onAssign'\n | 'onTypeFilterChange'\n | 'onUnassign'\n | 'typeFilter'\n> & {\n /**\n * How an assignment is removed. `flow` runs the administration flow the server configures for it, which can revoke\n * grants and end sessions first. It needs `baseUrl`.\n * @default 'native'\n */\n administrationMode?: AdministrationMode;\n /**\n * Whether assignments can be added and removed from this view.\n * @default false\n */\n editable?: boolean;\n /**\n * Whether to show the assignee type filter, which narrows the list on the server.\n * @default true\n */\n filterable?: boolean;\n roleId: string;\n};\n\n/**\n * Lists who holds a role, and lets the signed-in user assign it to users, groups and agents or\n * remove it from them.\n *\n * @example\n * ```tsx\n * <RoleAssignments roleId={roleId} />\n * ```\n */\nconst RoleAssignments: FC<RoleAssignmentsProps> = ({\n administrationMode,\n editable = false,\n filterable = true,\n preferences,\n roleId,\n ...rest\n}: RoleAssignmentsProps): ReactElement => {\n const {t} = useTranslation(preferences?.i18n);\n const [typeFilter, setTypeFilter] = useState<RoleAssigneeType | null>(null);\n const rolesEndpoint: ManagementEndpoint = useManagementEndpoint('roles');\n const usersEndpoint: ManagementEndpoint = useManagementEndpoint('users');\n const groupsEndpoint: ManagementEndpoint = useManagementEndpoint('groups');\n const agentsEndpoint: ManagementEndpoint = useManagementEndpoint('agents');\n const type: RoleAssigneeType | undefined = typeFilter ?? undefined;\n const assignments: ResourceQueryResult<RoleAssignmentListResponse> = useResourceQuery(\n [RoleQueryKeys.ROLE_ASSIGNMENTS, roleId, {limit: 100, type}],\n (fetcher) => getRoleAssignments({...rolesEndpoint, fetcher, limit: 100, roleId, type}),\n {enabled: Boolean(roleId)},\n );\n const users: ResourceQueryResult<ManagedUserListResponse> = useResourceQuery(\n [UserQueryKeys.USERS, {limit: 100}],\n (fetcher) => getUsers({...usersEndpoint, fetcher, limit: 100}),\n {enabled: editable},\n );\n const groups: ResourceQueryResult<GroupListResponse> = useResourceQuery(\n [GroupQueryKeys.GROUPS, {limit: 100}],\n (fetcher) => getGroups({...groupsEndpoint, fetcher, limit: 100}),\n {enabled: editable},\n );\n const agents: ResourceQueryResult<AgentListResponse> = useResourceQuery(\n [AgentQueryKeys.AGENTS, {limit: 100}],\n (fetcher) => getAgents({...agentsEndpoint, fetcher, limit: 100}),\n {enabled: editable},\n );\n const assign: ResourceMutationResult<void, RoleAssignmentsVariables> = useResourceMutation(\n ({assignments: changes, roleId: id}: RoleAssignmentsVariables, fetcher) =>\n addRoleAssignments({...rolesEndpoint, assignments: changes, fetcher, roleId: id}),\n () => [[RoleQueryKeys.ROLE_ASSIGNMENTS]],\n );\n const unassign: ResourceMutationResult<void, RoleAssignmentsVariables> = useResourceMutation(\n ({assignments: changes, roleId: id}: RoleAssignmentsVariables, fetcher) =>\n removeRoleAssignments({...rolesEndpoint, administrationMode, assignments: changes, fetcher, roleId: id}),\n () => [[RoleQueryKeys.ROLE_ASSIGNMENTS]],\n );\n\n const candidates: Partial<Record<'user' | 'group' | 'agent', IdentityCandidate[]>> = useMemo(\n () => ({\n agent: (agents.data?.agents ?? []).map((agent: BasicAgent) => ({id: agent.id, label: getAgentName(agent)})),\n group: (groups.data?.groups ?? []).map((group: Group) => ({id: group.id, label: group.name})),\n user: (users.data?.users ?? []).map((user: ManagedUser) => ({\n id: user.id,\n label: resolveManagedIdentityName(user),\n })),\n }),\n [agents.data, groups.data, users.data],\n );\n\n return (\n <BaseRoleAssignments\n assignments={assignments.data?.assignments ?? []}\n isLoading={assignments.isLoading}\n isMutating={assign.isLoading || unassign.isLoading}\n error={\n toManagementErrorMessage(t, assignments.error, 'admin.roles.assignments.error') ??\n toManagementErrorMessage(t, assign.error ?? unassign.error, 'admin.roles.assignments.update_error')\n }\n candidates={editable ? candidates : undefined}\n onAssign={\n editable\n ? (assignment: RoleAssignmentInput): void => void assign.mutate({assignments: [assignment], roleId})\n : undefined\n }\n onUnassign={\n editable\n ? (assignment: RoleAssignment): void =>\n void unassign.mutate({assignments: [{id: assignment.id, type: assignment.type}], roleId})\n : undefined\n }\n typeFilter={typeFilter}\n onTypeFilterChange={filterable ?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ManagementEndpoint","useManagementEndpoint","usersEndpoint: ManagementEndpoint","groupsEndpoint: ManagementEndpoint","agentsEndpoint: ManagementEndpoint","type: RoleAssigneeType | undefined","filter: string | undefined","assignments: ResourceQueryResult<RoleAssignmentListResponse>","useResourceQuery","RoleQueryKeys","users: ResourceQueryResult<FilteredPage<ManagedUserListResponse>>","UserQueryKeys","groups: ResourceQueryResult<FilteredPage<GroupListResponse>>","GroupQueryKeys","agents: ResourceQueryResult<FilteredPage<AgentListResponse>>","AgentQueryKeys","assign: ResourceMutationResult<void, RoleAssignmentsVariables>","useResourceMutation","unassign: ResourceMutationResult<void, RoleAssignmentsVariables>","candidates: Partial<Record<'user' | 'group' | 'agent', IdentityCandidate[]>>","BaseRoleAssignments"],"sources":["../../../../../src/components/admin/RoleAssignments/RoleAssignments.tsx"],"sourcesContent":["// Copyright 2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n AdministrationMode,\n AgentListResponse,\n AgentQueryKeys,\n BasicAgent,\n Group,\n GroupListResponse,\n GroupQueryKeys,\n ManagedUser,\n ManagedUserListResponse,\n RoleAssigneeType,\n RoleAssignment,\n RoleAssignmentInput,\n RoleAssignmentListResponse,\n RoleQueryKeys,\n UserQueryKeys,\n addRoleAssignments,\n getAgentName,\n getAgents,\n getGroups,\n getRoleAssignments,\n getUsers,\n removeRoleAssignments,\n resolveManagedIdentityName,\n toEqualityFilter,\n toManagementErrorMessage,\n} from '@thunderid/browser';\nimport {FC, ReactElement, useMemo, useState} from 'react';\nimport BaseRoleAssignments, {BaseRoleAssignmentsProps} from './BaseRoleAssignments';\nimport useManagementEndpoint, {ManagementEndpoint} from '../../../hooks/management/useManagementEndpoint';\nimport useResourceMutation, {ResourceMutationResult} from '../../../hooks/management/useResourceMutation';\nimport useResourceQuery, {ResourceQueryResult} from '../../../hooks/management/useResourceQuery';\nimport useTranslation from '../../../hooks/useTranslation';\nimport {IdentityCandidate} from '../shared/IdentityPicker';\n\ninterface RoleAssignmentsVariables {\n assignments: RoleAssignmentInput[];\n roleId: string;\n}\n\n/**\n * A candidate page with the filter it was listed with.\n */\ninterface FilteredPage<T> {\n filter: string | undefined;\n page: T;\n}\n\nexport type RoleAssignmentsProps = Omit<\n BaseRoleAssignmentsProps,\n | 'assignments'\n | 'candidates'\n | 'error'\n | 'isLoading'\n | 'isMutating'\n | 'onAssign'\n | 'onTypeFilterChange'\n | 'onUnassign'\n | 'typeFilter'\n> & {\n /**\n * How an assignment is removed. `flow` runs the administration flow the server configures for it, which can revoke\n * grants and end sessions first. It needs `baseUrl`.\n * @default 'native'\n */\n administrationMode?: AdministrationMode;\n /**\n * Whether assignments can be added and removed from this view.\n * @default false\n */\n editable?: boolean;\n /**\n * Whether to show the assignee type filter, which narrows the list on the server.\n * @default true\n */\n filterable?: boolean;\n /**\n * Organization unit the users, groups and agents offered for assignment are listed from.\n */\n ouId?: string;\n roleId: string;\n};\n\n/**\n * Lists who holds a role, and lets the signed-in user assign it to users, groups and agents or\n * remove it from them.\n *\n * @example\n * ```tsx\n * <RoleAssignments roleId={roleId} />\n * ```\n */\nconst RoleAssignments: FC<RoleAssignmentsProps> = ({\n administrationMode,\n editable = false,\n filterable = true,\n ouId,\n preferences,\n roleId,\n ...rest\n}: RoleAssignmentsProps): ReactElement => {\n const {t} = useTranslation(preferences?.i18n);\n const [typeFilter, setTypeFilter] = useState<RoleAssigneeType | null>(null);\n const rolesEndpoint: ManagementEndpoint = useManagementEndpoint('roles');\n const usersEndpoint: ManagementEndpoint = useManagementEndpoint('users');\n const groupsEndpoint: ManagementEndpoint = useManagementEndpoint('groups');\n const agentsEndpoint: ManagementEndpoint = useManagementEndpoint('agents');\n const type: RoleAssigneeType | undefined = typeFilter ?? undefined;\n const filter: string | undefined = toEqualityFilter('ouId', ouId);\n const assignments: ResourceQueryResult<RoleAssignmentListResponse> = useResourceQuery(\n [RoleQueryKeys.ROLE_ASSIGNMENTS, roleId, {limit: 100, type}],\n (fetcher) => getRoleAssignments({...rolesEndpoint, fetcher, limit: 100, roleId, type}),\n {enabled: Boolean(roleId)},\n );\n const users: ResourceQueryResult<FilteredPage<ManagedUserListResponse>> = useResourceQuery(\n [UserQueryKeys.USERS, {filter, limit: 100}],\n async (fetcher) => ({filter, page: await getUsers({...usersEndpoint, fetcher, filter, limit: 100})}),\n {enabled: editable},\n );\n const groups: ResourceQueryResult<FilteredPage<GroupListResponse>> = useResourceQuery(\n [GroupQueryKeys.GROUPS, {filter, limit: 100}],\n async (fetcher) => ({filter, page: await getGroups({...groupsEndpoint, fetcher, filter, limit: 100})}),\n {enabled: editable},\n );\n const agents: ResourceQueryResult<FilteredPage<AgentListResponse>> = useResourceQuery(\n [AgentQueryKeys.AGENTS, {filter, limit: 100}],\n async (fetcher) => ({filter, page: await getAgents({...agentsEndpoint, fetcher, filter, limit: 100})}),\n {enabled: editable},\n );\n const assign: ResourceMutationResult<void, RoleAssignmentsVariables> = useResourceMutation(\n ({assignments: changes, roleId: id}: RoleAssignmentsVariables, fetcher) =>\n addRoleAssignments({...rolesEndpoint, assignments: changes, fetcher, roleId: id}),\n () => [[RoleQueryKeys.ROLE_ASSIGNMENTS]],\n );\n const unassign: ResourceMutationResult<void, RoleAssignmentsVariables> = useResourceMutation(\n ({assignments: changes, roleId: id}: RoleAssignmentsVariables, fetcher) =>\n removeRoleAssignments({...rolesEndpoint, administrationMode, assignments: changes, fetcher, roleId: id}),\n () => [[RoleQueryKeys.ROLE_ASSIGNMENTS]],\n );\n\n const candidates: Partial<Record<'user' | 'group' | 'agent', IdentityCandidate[]>> = useMemo(() => {\n // A page listed for an earlier ouId stays in a query until the next one succeeds, so it is not offered.\n const current = <T,>(data: FilteredPage<T> | undefined): T | undefined =>\n data && data.filter === filter ? data.page : undefined;\n\n return {\n agent: (current(agents.data)?.agents ?? []).map((agent: BasicAgent) => ({\n id: agent.id,\n label: getAgentName(agent),\n })),\n group: (current(groups.data)?.groups ?? []).map((group: Group) => ({id: group.id, label: group.name})),\n user: (current(users.data)?.users ?? []).map((user: ManagedUser) => ({\n id: user.id,\n label: resolveManagedIdentityName(user),\n })),\n };\n }, [agents.data, filter, groups.data, users.data]);\n\n return (\n <BaseRoleAssignments\n assignments={assignments.data?.assignments ?? []}\n isLoading={assignments.isLoading}\n isMutating={assign.isLoading || unassign.isLoading}\n error={\n toManagementErrorMessage(t, assignments.error, 'admin.roles.assignments.error') ??\n toManagementErrorMessage(t, assign.error ?? unassign.error, 'admin.roles.assignments.update_error')\n }\n candidates={editable ? candidates : undefined}\n onAssign={\n editable\n ? (assignment: RoleAssignmentInput): void => void assign.mutate({assignments: [assignment], roleId})\n : undefined\n }\n onUnassign={\n editable\n ? (assignment: RoleAssignment): void =>\n void unassign.mutate({assignments: [{id: assignment.id, type: assignment.type}], roleId})\n : undefined\n }\n typeFilter={typeFilter}\n onTypeFilterChange={filterable ? setTypeFilter : undefined}\n preferences={preferences}\n {...rest}\n />\n );\n};\n\nexport default RoleAssignments;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA+FA,MAAMA,mBAA6C,EACjD,oBACA,WAAW,OACX,aAAa,MACb,MACA,aACA,OACA,GAAG,WACqC;CACxC,MAAM,EAAC,MAAKC,+BAAe,aAAa,KAAK;CAC7C,MAAM,CAAC,YAAY,qCAAmD,KAAK;CAC3E,MAAMC,gBAAoCC,sCAAsB,QAAQ;CACxE,MAAMC,gBAAoCD,sCAAsB,QAAQ;CACxE,MAAME,iBAAqCF,sCAAsB,SAAS;CAC1E,MAAMG,iBAAqCH,sCAAsB,SAAS;CAC1E,MAAMI,OAAqC,cAAc;CACzD,MAAMC,mDAA8C,QAAQ,KAAK;CACjE,MAAMC,cAA+DC,iCACnE;EAACC,kCAAc;EAAkB;EAAQ;GAAC,OAAO;GAAK;GAAK;EAAC,GAC3D,wDAA+B;EAAC,GAAG;EAAe;EAAS,OAAO;EAAK;EAAQ;EAAK,CAAC,EACtF,EAAC,SAAS,QAAQ,OAAO,EAAC,CAC3B;CACD,MAAMC,QAAoEF,iC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AK,WAAkB;IAAC,IAAI,MAAM;IAAI,OAAO,MAAM;IAAK,EAAE;GACtG,OAAO,QAAQ,MAAM,KAAK,EAAE,SAAS,EAAE,EAAE,KAAK,UAAuB;IACnE,IAAI,KAAK;IACT,2DAAkC,KAAK;IACxC,EAAE;GACJ;IACA;EAAC,OAAO;EAAM;EAAQ,OAAO;EAAM,MAAM;EAAK,CAAC;AAElD,QACE,2CAACC;EACC,aAAa,YAAY,MAAM,eAAe,EAAE;EAChD,WAAW,YAAY;EACvB,YAAY,OAAO,aAAa,SAAS;EACzC,yDAC2B,GAAG,YAAY,OAAO,gCAAgC,sDACtD,GAAG,OAAO,SAAS,SAAS,OAAO,uCAAuC;EAErG,YAAY,WAAW,aAAa;EACpC,UACE,YACK,eAA0C,KAAK,OAAO,OAAO;GAAC,aAAa,CAAC,WAAW;GAAE;GAAO,CAAC,GAClG;EAEN,YACE,YACK,eACC,KAAK,SAAS,OAAO;GAAC,aAAa,CAAC;IAAC,IAAI,WAAW;IAAI,MAAM,WAAW;IAAK,CAAC;GAAE;GAAO,CAAC,GAC3F;EAEM;EACZ,oBAAoB,aAAa,gBAAgB;EACpC;EACb,GAAI;GACJ;;AAIN,8BAAe"}
|
|
@@ -18,6 +18,10 @@ export type RoleAssignmentsProps = Omit<BaseRoleAssignmentsProps, 'assignments'
|
|
|
18
18
|
* @default true
|
|
19
19
|
*/
|
|
20
20
|
filterable?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Organization unit the users, groups and agents offered for assignment are listed from.
|
|
23
|
+
*/
|
|
24
|
+
ouId?: string;
|
|
21
25
|
roleId: string;
|
|
22
26
|
};
|
|
23
27
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoleAssignments.d.ts","sourceRoot":"","sources":["../../../../src/components/admin/RoleAssignments/RoleAssignments.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,kBAAkB,
|
|
1
|
+
{"version":3,"file":"RoleAssignments.d.ts","sourceRoot":"","sources":["../../../../src/components/admin/RoleAssignments/RoleAssignments.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,kBAAkB,EAyBnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,EAAE,EAAkC,MAAM,OAAO,CAAC;AAC1D,OAA4B,EAAC,wBAAwB,EAAC,MAAM,uBAAuB,CAAC;AAoBpF,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,wBAAwB,EACtB,aAAa,GACb,YAAY,GACZ,OAAO,GACP,WAAW,GACX,YAAY,GACZ,UAAU,GACV,oBAAoB,GACpB,YAAY,GACZ,YAAY,CACf,GAAG;IACF;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;GAQG;AACH,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CA6F7C,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -3,7 +3,7 @@ import useManagementEndpoint_default from "../../../hooks/management/useManageme
|
|
|
3
3
|
import useResourceQuery_default from "../../../hooks/management/useResourceQuery.js";
|
|
4
4
|
import useResourceMutation_default from "../../../hooks/management/useResourceMutation.js";
|
|
5
5
|
import BaseRoleAssignments_default from "./BaseRoleAssignments.js";
|
|
6
|
-
import { AgentQueryKeys, GroupQueryKeys, RoleQueryKeys, UserQueryKeys, addRoleAssignments, getAgentName, getAgents, getGroups, getRoleAssignments, getUsers, removeRoleAssignments, resolveManagedIdentityName, toManagementErrorMessage } from "@thunderid/browser";
|
|
6
|
+
import { AgentQueryKeys, GroupQueryKeys, RoleQueryKeys, UserQueryKeys, addRoleAssignments, getAgentName, getAgents, getGroups, getRoleAssignments, getUsers, removeRoleAssignments, resolveManagedIdentityName, toEqualityFilter, toManagementErrorMessage } from "@thunderid/browser";
|
|
7
7
|
import { useMemo, useState } from "react";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
9
|
|
|
@@ -17,7 +17,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
17
17
|
* <RoleAssignments roleId={roleId} />
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
const RoleAssignments = ({ administrationMode, editable = false, filterable = true, preferences, roleId,...rest }) => {
|
|
20
|
+
const RoleAssignments = ({ administrationMode, editable = false, filterable = true, ouId, preferences, roleId,...rest }) => {
|
|
21
21
|
const { t } = useTranslation_default(preferences?.i18n);
|
|
22
22
|
const [typeFilter, setTypeFilter] = useState(null);
|
|
23
23
|
const rolesEndpoint = useManagementEndpoint_default("roles");
|
|
@@ -25,6 +25,7 @@ const RoleAssignments = ({ administrationMode, editable = false, filterable = tr
|
|
|
25
25
|
const groupsEndpoint = useManagementEndpoint_default("groups");
|
|
26
26
|
const agentsEndpoint = useManagementEndpoint_default("agents");
|
|
27
27
|
const type = typeFilter ?? void 0;
|
|
28
|
+
const filter = toEqualityFilter("ouId", ouId);
|
|
28
29
|
const assignments = useResourceQuery_default([
|
|
29
30
|
RoleQueryKeys.ROLE_ASSIGNMENTS,
|
|
30
31
|
roleId,
|
|
@@ -39,20 +40,41 @@ const RoleAssignments = ({ administrationMode, editable = false, filterable = tr
|
|
|
39
40
|
roleId,
|
|
40
41
|
type
|
|
41
42
|
}), { enabled: Boolean(roleId) });
|
|
42
|
-
const users = useResourceQuery_default([UserQueryKeys.USERS, {
|
|
43
|
-
|
|
44
|
-
fetcher,
|
|
43
|
+
const users = useResourceQuery_default([UserQueryKeys.USERS, {
|
|
44
|
+
filter,
|
|
45
45
|
limit: 100
|
|
46
|
+
}], async (fetcher) => ({
|
|
47
|
+
filter,
|
|
48
|
+
page: await getUsers({
|
|
49
|
+
...usersEndpoint,
|
|
50
|
+
fetcher,
|
|
51
|
+
filter,
|
|
52
|
+
limit: 100
|
|
53
|
+
})
|
|
46
54
|
}), { enabled: editable });
|
|
47
|
-
const groups = useResourceQuery_default([GroupQueryKeys.GROUPS, {
|
|
48
|
-
|
|
49
|
-
fetcher,
|
|
55
|
+
const groups = useResourceQuery_default([GroupQueryKeys.GROUPS, {
|
|
56
|
+
filter,
|
|
50
57
|
limit: 100
|
|
58
|
+
}], async (fetcher) => ({
|
|
59
|
+
filter,
|
|
60
|
+
page: await getGroups({
|
|
61
|
+
...groupsEndpoint,
|
|
62
|
+
fetcher,
|
|
63
|
+
filter,
|
|
64
|
+
limit: 100
|
|
65
|
+
})
|
|
51
66
|
}), { enabled: editable });
|
|
52
|
-
const agents = useResourceQuery_default([AgentQueryKeys.AGENTS, {
|
|
53
|
-
|
|
54
|
-
fetcher,
|
|
67
|
+
const agents = useResourceQuery_default([AgentQueryKeys.AGENTS, {
|
|
68
|
+
filter,
|
|
55
69
|
limit: 100
|
|
70
|
+
}], async (fetcher) => ({
|
|
71
|
+
filter,
|
|
72
|
+
page: await getAgents({
|
|
73
|
+
...agentsEndpoint,
|
|
74
|
+
fetcher,
|
|
75
|
+
filter,
|
|
76
|
+
limit: 100
|
|
77
|
+
})
|
|
56
78
|
}), { enabled: editable });
|
|
57
79
|
const assign = useResourceMutation_default(({ assignments: changes, roleId: id }, fetcher) => addRoleAssignments({
|
|
58
80
|
...rolesEndpoint,
|
|
@@ -67,21 +89,25 @@ const RoleAssignments = ({ administrationMode, editable = false, filterable = tr
|
|
|
67
89
|
fetcher,
|
|
68
90
|
roleId: id
|
|
69
91
|
}), () => [[RoleQueryKeys.ROLE_ASSIGNMENTS]]);
|
|
70
|
-
const candidates = useMemo(() =>
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
92
|
+
const candidates = useMemo(() => {
|
|
93
|
+
const current = (data) => data && data.filter === filter ? data.page : void 0;
|
|
94
|
+
return {
|
|
95
|
+
agent: (current(agents.data)?.agents ?? []).map((agent) => ({
|
|
96
|
+
id: agent.id,
|
|
97
|
+
label: getAgentName(agent)
|
|
98
|
+
})),
|
|
99
|
+
group: (current(groups.data)?.groups ?? []).map((group) => ({
|
|
100
|
+
id: group.id,
|
|
101
|
+
label: group.name
|
|
102
|
+
})),
|
|
103
|
+
user: (current(users.data)?.users ?? []).map((user) => ({
|
|
104
|
+
id: user.id,
|
|
105
|
+
label: resolveManagedIdentityName(user)
|
|
106
|
+
}))
|
|
107
|
+
};
|
|
108
|
+
}, [
|
|
84
109
|
agents.data,
|
|
110
|
+
filter,
|
|
85
111
|
groups.data,
|
|
86
112
|
users.data
|
|
87
113
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoleAssignments.js","names":["RoleAssignments: FC<RoleAssignmentsProps>","useTranslation","rolesEndpoint: ManagementEndpoint","useManagementEndpoint","usersEndpoint: ManagementEndpoint","groupsEndpoint: ManagementEndpoint","agentsEndpoint: ManagementEndpoint","type: RoleAssigneeType | undefined","assignments: ResourceQueryResult<RoleAssignmentListResponse>","useResourceQuery","users: ResourceQueryResult<ManagedUserListResponse>","groups: ResourceQueryResult<GroupListResponse>","agents: ResourceQueryResult<AgentListResponse>","assign: ResourceMutationResult<void, RoleAssignmentsVariables>","useResourceMutation","unassign: ResourceMutationResult<void, RoleAssignmentsVariables>","candidates: Partial<Record<'user' | 'group' | 'agent', IdentityCandidate[]>>","BaseRoleAssignments"],"sources":["../../../../src/components/admin/RoleAssignments/RoleAssignments.tsx"],"sourcesContent":["// Copyright 2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n AdministrationMode,\n AgentListResponse,\n AgentQueryKeys,\n BasicAgent,\n Group,\n GroupListResponse,\n GroupQueryKeys,\n ManagedUser,\n ManagedUserListResponse,\n RoleAssigneeType,\n RoleAssignment,\n RoleAssignmentInput,\n RoleAssignmentListResponse,\n RoleQueryKeys,\n UserQueryKeys,\n addRoleAssignments,\n getAgentName,\n getAgents,\n getGroups,\n getRoleAssignments,\n getUsers,\n removeRoleAssignments,\n resolveManagedIdentityName,\n toManagementErrorMessage,\n} from '@thunderid/browser';\nimport {FC, ReactElement, useMemo, useState} from 'react';\nimport BaseRoleAssignments, {BaseRoleAssignmentsProps} from './BaseRoleAssignments';\nimport useManagementEndpoint, {ManagementEndpoint} from '../../../hooks/management/useManagementEndpoint';\nimport useResourceMutation, {ResourceMutationResult} from '../../../hooks/management/useResourceMutation';\nimport useResourceQuery, {ResourceQueryResult} from '../../../hooks/management/useResourceQuery';\nimport useTranslation from '../../../hooks/useTranslation';\nimport {IdentityCandidate} from '../shared/IdentityPicker';\n\ninterface RoleAssignmentsVariables {\n assignments: RoleAssignmentInput[];\n roleId: string;\n}\n\nexport type RoleAssignmentsProps = Omit<\n BaseRoleAssignmentsProps,\n | 'assignments'\n | 'candidates'\n | 'error'\n | 'isLoading'\n | 'isMutating'\n | 'onAssign'\n | 'onTypeFilterChange'\n | 'onUnassign'\n | 'typeFilter'\n> & {\n /**\n * How an assignment is removed. `flow` runs the administration flow the server configures for it, which can revoke\n * grants and end sessions first. It needs `baseUrl`.\n * @default 'native'\n */\n administrationMode?: AdministrationMode;\n /**\n * Whether assignments can be added and removed from this view.\n * @default false\n */\n editable?: boolean;\n /**\n * Whether to show the assignee type filter, which narrows the list on the server.\n * @default true\n */\n filterable?: boolean;\n roleId: string;\n};\n\n/**\n * Lists who holds a role, and lets the signed-in user assign it to users, groups and agents or\n * remove it from them.\n *\n * @example\n * ```tsx\n * <RoleAssignments roleId={roleId} />\n * ```\n */\nconst RoleAssignments: FC<RoleAssignmentsProps> = ({\n administrationMode,\n editable = false,\n filterable = true,\n preferences,\n roleId,\n ...rest\n}: RoleAssignmentsProps): ReactElement => {\n const {t} = useTranslation(preferences?.i18n);\n const [typeFilter, setTypeFilter] = useState<RoleAssigneeType | null>(null);\n const rolesEndpoint: ManagementEndpoint = useManagementEndpoint('roles');\n const usersEndpoint: ManagementEndpoint = useManagementEndpoint('users');\n const groupsEndpoint: ManagementEndpoint = useManagementEndpoint('groups');\n const agentsEndpoint: ManagementEndpoint = useManagementEndpoint('agents');\n const type: RoleAssigneeType | undefined = typeFilter ?? undefined;\n const assignments: ResourceQueryResult<RoleAssignmentListResponse> = useResourceQuery(\n [RoleQueryKeys.ROLE_ASSIGNMENTS, roleId, {limit: 100, type}],\n (fetcher) => getRoleAssignments({...rolesEndpoint, fetcher, limit: 100, roleId, type}),\n {enabled: Boolean(roleId)},\n );\n const users: ResourceQueryResult<ManagedUserListResponse> = useResourceQuery(\n [UserQueryKeys.USERS, {limit: 100}],\n (fetcher) => getUsers({...usersEndpoint, fetcher, limit: 100}),\n {enabled: editable},\n );\n const groups: ResourceQueryResult<GroupListResponse> = useResourceQuery(\n [GroupQueryKeys.GROUPS, {limit: 100}],\n (fetcher) => getGroups({...groupsEndpoint, fetcher, limit: 100}),\n {enabled: editable},\n );\n const agents: ResourceQueryResult<AgentListResponse> = useResourceQuery(\n [AgentQueryKeys.AGENTS, {limit: 100}],\n (fetcher) => getAgents({...agentsEndpoint, fetcher, limit: 100}),\n {enabled: editable},\n );\n const assign: ResourceMutationResult<void, RoleAssignmentsVariables> = useResourceMutation(\n ({assignments: changes, roleId: id}: RoleAssignmentsVariables, fetcher) =>\n addRoleAssignments({...rolesEndpoint, assignments: changes, fetcher, roleId: id}),\n () => [[RoleQueryKeys.ROLE_ASSIGNMENTS]],\n );\n const unassign: ResourceMutationResult<void, RoleAssignmentsVariables> = useResourceMutation(\n ({assignments: changes, roleId: id}: RoleAssignmentsVariables, fetcher) =>\n removeRoleAssignments({...rolesEndpoint, administrationMode, assignments: changes, fetcher, roleId: id}),\n () => [[RoleQueryKeys.ROLE_ASSIGNMENTS]],\n );\n\n const candidates: Partial<Record<'user' | 'group' | 'agent', IdentityCandidate[]>> = useMemo(\n () => ({\n agent: (agents.data?.agents ?? []).map((agent: BasicAgent) => ({id: agent.id, label: getAgentName(agent)})),\n group: (groups.data?.groups ?? []).map((group: Group) => ({id: group.id, label: group.name})),\n user: (users.data?.users ?? []).map((user: ManagedUser) => ({\n id: user.id,\n label: resolveManagedIdentityName(user),\n })),\n }),\n [agents.data, groups.data, users.data],\n );\n\n return (\n <BaseRoleAssignments\n assignments={assignments.data?.assignments ?? []}\n isLoading={assignments.isLoading}\n isMutating={assign.isLoading || unassign.isLoading}\n error={\n toManagementErrorMessage(t, assignments.error, 'admin.roles.assignments.error') ??\n toManagementErrorMessage(t, assign.error ?? unassign.error, 'admin.roles.assignments.update_error')\n }\n candidates={editable ? candidates : undefined}\n onAssign={\n editable\n ? (assignment: RoleAssignmentInput): void => void assign.mutate({assignments: [assignment], roleId})\n : undefined\n }\n onUnassign={\n editable\n ? (assignment: RoleAssignment): void =>\n void unassign.mutate({assignments: [{id: assignment.id, type: assignment.type}], roleId})\n : undefined\n }\n typeFilter={typeFilter}\n onTypeFilterChange={filterable ? setTypeFilter : undefined}\n preferences={preferences}\n {...rest}\n />\n );\n};\n\nexport default RoleAssignments;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkFA,MAAMA,mBAA6C,EACjD,oBACA,WAAW,OACX,aAAa,MACb,aACA,OACA,GAAG,WACqC;CACxC,MAAM,EAAC,MAAKC,uBAAe,aAAa,KAAK;CAC7C,MAAM,CAAC,YAAY,iBAAiB,SAAkC,KAAK;CAC3E,MAAMC,gBAAoCC,8BAAsB,QAAQ;CACxE,MAAMC,gBAAoCD,8BAAsB,QAAQ;CACxE,MAAME,iBAAqCF,8BAAsB,SAAS;CAC1E,MAAMG,iBAAqCH,8BAAsB,SAAS;CAC1E,MAAMI,OAAqC,cAAc;CACzD,MAAMC,cAA+DC,yBACnE;EAAC,cAAc;EAAkB;EAAQ;GAAC,OAAO;GAAK;GAAK;EAAC,GAC3D,YAAY,mBAAmB;EAAC,GAAG;EAAe;EAAS,OA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K;GACT,OAAO,2BAA2B,KAAK;GACxC,EAAE;EACJ,GACD;EAAC,OAAO;EAAM,OAAO;EAAM,MAAM;EAAK,CACvC;AAED,QACE,oBAACC;EACC,aAAa,YAAY,MAAM,eAAe,EAAE;EAChD,WAAW,YAAY;EACvB,YAAY,OAAO,aAAa,SAAS;EACzC,OACE,yBAAyB,GAAG,YAAY,OAAO,gCAAgC,IAC/E,yBAAyB,GAAG,OAAO,SAAS,SAAS,OAAO,uCAAuC;EAErG,YAAY,WAAW,aAAa;EACpC,UACE,YACK,eAA0C,KAAK,OAAO,OAAO;GAAC,aAAa,CAAC,WAAW;GAAE;GAAO,CAAC,GAClG;EAEN,YACE,YACK,eACC,KAAK,SAAS,OAAO;GAAC,aAAa,CAAC;IAAC,IAAI,WAAW;IAAI,MAAM,WAAW;IAAK,CAAC;GAAE;GAAO,CAAC,GAC3F;EAEM;EACZ,oBAAoB,aAAa,gBAAgB;EACpC;EACb,GAAI;GACJ;;AAIN,8BAAe"}
|
|
1
|
+
{"version":3,"file":"RoleAssignments.js","names":["RoleAssignments: FC<RoleAssignmentsProps>","useTranslation","rolesEndpoint: ManagementEndpoint","useManagementEndpoint","usersEndpoint: ManagementEndpoint","groupsEndpoint: ManagementEndpoint","agentsEndpoint: ManagementEndpoint","type: RoleAssigneeType | undefined","filter: string | undefined","assignments: ResourceQueryResult<RoleAssignmentListResponse>","useResourceQuery","users: ResourceQueryResult<FilteredPage<ManagedUserListResponse>>","groups: ResourceQueryResult<FilteredPage<GroupListResponse>>","agents: ResourceQueryResult<FilteredPage<AgentListResponse>>","assign: ResourceMutationResult<void, RoleAssignmentsVariables>","useResourceMutation","unassign: ResourceMutationResult<void, RoleAssignmentsVariables>","candidates: Partial<Record<'user' | 'group' | 'agent', IdentityCandidate[]>>","BaseRoleAssignments"],"sources":["../../../../src/components/admin/RoleAssignments/RoleAssignments.tsx"],"sourcesContent":["// Copyright 2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n AdministrationMode,\n AgentListResponse,\n AgentQueryKeys,\n BasicAgent,\n Group,\n GroupListResponse,\n GroupQueryKeys,\n ManagedUser,\n ManagedUserListResponse,\n RoleAssigneeType,\n RoleAssignment,\n RoleAssignmentInput,\n RoleAssignmentListResponse,\n RoleQueryKeys,\n UserQueryKeys,\n addRoleAssignments,\n getAgentName,\n getAgents,\n getGroups,\n getRoleAssignments,\n getUsers,\n removeRoleAssignments,\n resolveManagedIdentityName,\n toEqualityFilter,\n toManagementErrorMessage,\n} from '@thunderid/browser';\nimport {FC, ReactElement, useMemo, useState} from 'react';\nimport BaseRoleAssignments, {BaseRoleAssignmentsProps} from './BaseRoleAssignments';\nimport useManagementEndpoint, {ManagementEndpoint} from '../../../hooks/management/useManagementEndpoint';\nimport useResourceMutation, {ResourceMutationResult} from '../../../hooks/management/useResourceMutation';\nimport useResourceQuery, {ResourceQueryResult} from '../../../hooks/management/useResourceQuery';\nimport useTranslation from '../../../hooks/useTranslation';\nimport {IdentityCandidate} from '../shared/IdentityPicker';\n\ninterface RoleAssignmentsVariables {\n assignments: RoleAssignmentInput[];\n roleId: string;\n}\n\n/**\n * A candidate page with the filter it was listed with.\n */\ninterface FilteredPage<T> {\n filter: string | undefined;\n page: T;\n}\n\nexport type RoleAssignmentsProps = Omit<\n BaseRoleAssignmentsProps,\n | 'assignments'\n | 'candidates'\n | 'error'\n | 'isLoading'\n | 'isMutating'\n | 'onAssign'\n | 'onTypeFilterChange'\n | 'onUnassign'\n | 'typeFilter'\n> & {\n /**\n * How an assignment is removed. `flow` runs the administration flow the server configures for it, which can revoke\n * grants and end sessions first. It needs `baseUrl`.\n * @default 'native'\n */\n administrationMode?: AdministrationMode;\n /**\n * Whether assignments can be added and removed from this view.\n * @default false\n */\n editable?: boolean;\n /**\n * Whether to show the assignee type filter, which narrows the list on the server.\n * @default true\n */\n filterable?: boolean;\n /**\n * Organization unit the users, groups and agents offered for assignment are listed from.\n */\n ouId?: string;\n roleId: string;\n};\n\n/**\n * Lists who holds a role, and lets the signed-in user assign it to users, groups and agents or\n * remove it from them.\n *\n * @example\n * ```tsx\n * <RoleAssignments roleId={roleId} />\n * ```\n */\nconst RoleAssignments: FC<RoleAssignmentsProps> = ({\n administrationMode,\n editable = false,\n filterable = true,\n ouId,\n preferences,\n roleId,\n ...rest\n}: RoleAssignmentsProps): ReactElement => {\n const {t} = useTranslation(preferences?.i18n);\n const [typeFilter, setTypeFilter] = useState<RoleAssigneeType | null>(null);\n const rolesEndpoint: ManagementEndpoint = useManagementEndpoint('roles');\n const usersEndpoint: ManagementEndpoint = useManagementEndpoint('users');\n const groupsEndpoint: ManagementEndpoint = useManagementEndpoint('groups');\n const agentsEndpoint: ManagementEndpoint = useManagementEndpoint('agents');\n const type: RoleAssigneeType | undefined = typeFilter ?? undefined;\n const filter: string | undefined = toEqualityFilter('ouId', ouId);\n const assignments: ResourceQueryResult<RoleAssignmentListResponse> = useResourceQuery(\n [RoleQueryKeys.ROLE_ASSIGNMENTS, roleId, {limit: 100, type}],\n (fetcher) => getRoleAssignments({...rolesEndpoint, fetcher, limit: 100, roleId, type}),\n {enabled: Boolean(roleId)},\n );\n const users: ResourceQueryResult<FilteredPage<ManagedUserListResponse>> = useResourceQuery(\n [UserQueryKeys.USERS, {filter, limit: 100}],\n async (fetcher) => ({filter, page: await getUsers({...usersEndpoint, fetcher, filter, limit: 100})}),\n {enabled: editable},\n );\n const groups: ResourceQueryResult<FilteredPage<GroupListResponse>> = useResourceQuery(\n [GroupQueryKeys.GROUPS, {filter, limit: 100}],\n async (fetcher) => ({filter, page: await getGroups({...groupsEndpoint, fetcher, filter, limit: 100})}),\n {enabled: editable},\n );\n const agents: ResourceQueryResult<FilteredPage<AgentListResponse>> = useResourceQuery(\n [AgentQueryKeys.AGENTS, {filter, limit: 100}],\n async (fetcher) => ({filter, page: await getAgents({...agentsEndpoint, fetcher, filter, limit: 100})}),\n {enabled: editable},\n );\n const assign: ResourceMutationResult<void, RoleAssignmentsVariables> = useResourceMutation(\n ({assignments: changes, roleId: id}: RoleAssignmentsVariables, fetcher) =>\n addRoleAssignments({...rolesEndpoint, assignments: changes, fetcher, roleId: id}),\n () => [[RoleQueryKeys.ROLE_ASSIGNMENTS]],\n );\n const unassign: ResourceMutationResult<void, RoleAssignmentsVariables> = useResourceMutation(\n ({assignments: changes, roleId: id}: RoleAssignmentsVariables, fetcher) =>\n removeRoleAssignments({...rolesEndpoint, administrationMode, assignments: changes, fetcher, roleId: id}),\n () => [[RoleQueryKeys.ROLE_ASSIGNMENTS]],\n );\n\n const candidates: Partial<Record<'user' | 'group' | 'agent', IdentityCandidate[]>> = useMemo(() => {\n // A page listed for an earlier ouId stays in a query until the next one succeeds, so it is not offered.\n const current = <T,>(data: FilteredPage<T> | undefined): T | undefined =>\n data && data.filter === filter ? data.page : undefined;\n\n return {\n agent: (current(agents.data)?.agents ?? []).map((agent: BasicAgent) => ({\n id: agent.id,\n label: getAgentName(agent),\n })),\n group: (current(groups.data)?.groups ?? []).map((group: Group) => ({id: group.id, label: group.name})),\n user: (current(users.data)?.users ?? []).map((user: ManagedUser) => ({\n id: user.id,\n label: resolveManagedIdentityName(user),\n })),\n };\n }, [agents.data, filter, groups.data, users.data]);\n\n return (\n <BaseRoleAssignments\n assignments={assignments.data?.assignments ?? []}\n isLoading={assignments.isLoading}\n isMutating={assign.isLoading || unassign.isLoading}\n error={\n toManagementErrorMessage(t, assignments.error, 'admin.roles.assignments.error') ??\n toManagementErrorMessage(t, assign.error ?? unassign.error, 'admin.roles.assignments.update_error')\n }\n candidates={editable ? candidates : undefined}\n onAssign={\n editable\n ? (assignment: RoleAssignmentInput): void => void assign.mutate({assignments: [assignment], roleId})\n : undefined\n }\n onUnassign={\n editable\n ? (assignment: RoleAssignment): void =>\n void unassign.mutate({assignments: [{id: assignment.id, type: assignment.type}], roleId})\n : undefined\n }\n typeFilter={typeFilter}\n onTypeFilterChange={filterable ? setTypeFilter : undefined}\n preferences={preferences}\n {...rest}\n />\n );\n};\n\nexport default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W;GAAE;GAAO,CAAC,GAClG;EAEN,YACE,YACK,eACC,KAAK,SAAS,OAAO;GAAC,aAAa,CAAC;IAAC,IAAI,WAAW;IAAI,MAAM,WAAW;IAAK,CAAC;GAAE;GAAO,CAAC,GAC3F;EAEM;EACZ,oBAAoB,aAAa,gBAAgB;EACpC;EACb,GAAI;GACJ;;AAIN,8BAAe"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thunderid/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "React SDK for ThunderID",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"thunderid",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@emotion/css": "11.13.5",
|
|
62
62
|
"@floating-ui/react": "0.27.12",
|
|
63
|
-
"@thunderid/browser": "^1.
|
|
63
|
+
"@thunderid/browser": "^1.8.0",
|
|
64
64
|
"dompurify": "3.4.17",
|
|
65
65
|
"tslib": "2.8.1"
|
|
66
66
|
},
|