MCPcopy Index your code
hub / github.com/coder/coder / workspacePermissionsByOrganization

Function workspacePermissionsByOrganization

site/src/api/queries/organizations.ts:373–410  ·  view source on GitHub ↗
(
	organizationIds: string[] | undefined,
	userId: string,
)

Source from the content-addressed store, hash-verified

371};
372
373export const workspacePermissionsByOrganization = (
374 organizationIds: string[] | undefined,
375 userId: string,
376) => {
377 return {
378 enabled: Boolean(organizationIds),
379 queryKey: [
380 "workspaces",
381 [...(organizationIds ?? []).sort()],
382 "permissions",
383 ],
384 queryFn: async () => {
385 const prefixedChecks = (organizationIds ?? []).flatMap((orgId) =>
386 Object.entries(workspacePermissionChecks(orgId, userId)).map(
387 ([key, val]) => [`${orgId}.${key}`, val],
388 ),
389 );
390
391 const response = await API.checkAuthorization({
392 checks: Object.fromEntries(prefixedChecks),
393 });
394
395 return Object.entries(response).reduce(
396 (acc, [key, value]) => {
397 const index = key.indexOf(".");
398 const orgId = key.substring(0, index);
399 const perm = key.substring(index + 1);
400 if (!acc[orgId]) {
401 acc[orgId] = {};
402 }
403 acc[orgId][perm as WorkspacePermissionName] = value;
404 return acc;
405 },
406 {} as Record<string, Partial<WorkspacePermissions>>,
407 ) as Record<string, WorkspacePermissions>;
408 },
409 } satisfies UseQueryOptions<Record<string, WorkspacePermissions>>;
410};
411
412const getOrganizationIdpSyncClaimFieldValuesKey = (
413 organization: string,

Callers 3

WorkspacesPageFunction · 0.90
TemplatesPageFunction · 0.90

Calls 2

checkAuthorizationMethod · 0.80

Tested by

no test coverage detected