diff --git a/webui/src/types.ts b/webui/src/types.ts index e7a80a6..2704251 100644 --- a/webui/src/types.ts +++ b/webui/src/types.ts @@ -365,11 +365,12 @@ export type OrganizationFunctionActionContext = PlatformRouteContext & { export type OrganizationFunctionActionContribution = { id: string; - label?: string; + label: string; + icon: ReactNode; order?: number; anyOf?: string[]; allOf?: string[]; - render: (context: OrganizationFunctionActionContext) => ReactNode; + onClick: (context: OrganizationFunctionActionContext) => void; }; export type OrganizationFunctionActionsUiCapability = { diff --git a/webui/tests/module-capabilities.test.ts b/webui/tests/module-capabilities.test.ts index dc09fc3..21c70d2 100644 --- a/webui/tests/module-capabilities.test.ts +++ b/webui/tests/module-capabilities.test.ts @@ -1,4 +1,8 @@ -import type { PlatformWebModule } from "../src/types"; +import type { + OrganizationFunctionActionContext, + OrganizationFunctionActionContribution, + PlatformWebModule +} from "../src/types"; import { hasUiCapability, moduleInstalled, @@ -67,3 +71,28 @@ assert(routes.join(",") === "/campaigns,/files,/mail", "routes should aggregate assert(scopeGrants("tenant:*", "calendar:event:read"), "tenant wildcard should grant tenant-level module scopes"); assert(!scopeGrants("tenant:*", "system:settings:read"), "tenant wildcard should not grant system scopes"); + +let selectedFunctionId = ""; +const functionAction: OrganizationFunctionActionContribution = { + id: "test.view-assignments", + label: "View assignments", + icon: "assignments-icon", + order: 40, + anyOf: ["idm:organization_assignment:read"], + onClick: (context) => { + selectedFunctionId = context.function.id; + } +}; +functionAction.onClick({ + settings: { apiBaseUrl: "", apiKey: "", accessToken: "" }, + auth: {} as OrganizationFunctionActionContext["auth"], + function: { + id: "function-1", + tenant_id: "tenant-1", + organization_unit_id: "unit-1", + slug: "test-function", + name: "Test function" + } +}); +assert(selectedFunctionId === "function-1", "organization function actions receive their row context"); +assert(!("render" in functionAction), "organization function actions expose metadata instead of arbitrary rendered controls");