@equinor/fusion-framework-react-app 14.1.2 → 14.2.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/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # @equinor/fusion-framework-react-app
2
2
 
3
- React bindings for building modular Fusion Framework applications. Provides rendering helpers, configuration callbacks, and React hooks for accessing framework modules (HTTP, auth, context, navigation, bookmarks, settings, and more).
3
+ React bindings for building modular Fusion Framework applications. Provides rendering helpers, configuration callbacks, and React hooks for accessing framework modules (HTTP, auth, context, navigation, bookmarks, roles, settings, and more).
4
4
 
5
5
  ## Features
6
6
 
7
7
  - **One-line app bootstrap** via `renderApp` — creates a render function that mounts your component with React 18's `createRoot`
8
8
  - **Module hooks** — `useAppModule` / `useAppModules` for type-safe access to any registered module
9
- - **Sub-path entry-points** for optional capabilities: MSAL auth, HTTP, context, navigation, bookmarks, feature flags, settings, analytics, AG Grid theming, help center, and apploader
9
+ - **Sub-path entry-points** for optional capabilities: MSAL auth, HTTP, context, navigation, bookmarks, roles, feature flags, settings, analytics, AG Grid theming, help center, and apploader
10
10
  - **Environment variables** hook — `useAppEnvironmentVariables` for accessing app config at runtime
11
11
  - **Lazy loading** — components are wrapped in `React.lazy` + `Suspense` automatically
12
12
 
@@ -338,6 +338,56 @@ const Toggle = () => {
338
338
  };
339
339
  ```
340
340
 
341
+ ### Roles
342
+
343
+ > **Note:** Requires `@equinor/fusion-framework-module-roles` in the application or parent
344
+ > framework scope.
345
+
346
+ ```tsx
347
+ import { enableRoles } from '@equinor/fusion-framework-module-roles';
348
+
349
+ export const configure: AppModuleInitiator = (configurator) => {
350
+ enableRoles(configurator);
351
+ };
352
+ ```
353
+
354
+ ```tsx
355
+ import { useAccessRole } from '@equinor/fusion-framework-react-app/roles';
356
+
357
+ const ReportsAccess = ({ claimableRoleId }: { claimableRoleId: string }) => {
358
+ const role = useAccessRole('Reports.Read');
359
+
360
+ if (role.isChecking) return <Spinner />;
361
+ if (role.checkError) return <ErrorMessage error={role.checkError} />;
362
+ if (role.hasAccessRole) return <Reports />;
363
+
364
+ /** Consumes the event-handler rejection; activationError below owns the visible failure. */
365
+ const handleActivate = (): void => {
366
+ void role
367
+ .activateClaimableRoleAssignment({
368
+ assignmentId: claimableRoleId,
369
+ reason: 'Open reports',
370
+ hours: 2,
371
+ })
372
+ .catch(() => undefined);
373
+ };
374
+
375
+ return role.hasClaimableRoleAssignmentForAccessRole ? (
376
+ <>
377
+ {role.activationError ? <p role="alert">{String(role.activationError)}</p> : null}
378
+ <button disabled={role.isActivating} onClick={handleActivate}>
379
+ Claim access
380
+ </button>
381
+ </>
382
+ ) : null;
383
+ };
384
+ ```
385
+
386
+ `useAccessRole` checks the exact access-role name when mounted and checks again after a successful claim.
387
+ Check and claim operations expose separate loading and error states.
388
+ `activateClaimableRoleAssignment` rejects on failure as well as setting `activationError`; React event handlers must consume
389
+ that rejection and render the mutation error so users can retry.
390
+
341
391
  ### Bookmarks
342
392
 
343
393
  ```tsx
@@ -404,6 +454,7 @@ see that package's README for usage.
404
454
  | `/context` | `useCurrentContext`, `useContextProvider`, `useFrameworkCurrentContext` |
405
455
  | `/navigation` | `useRouter`, `useNavigationModule` |
406
456
  | `/feature-flag` | `enableFeatureFlag`, `useFeature` |
457
+ | `/roles` | `useAccessRole` |
407
458
  | `/bookmark` | `enableBookmark`, `useCurrentBookmark`, `useBookmark` |
408
459
  | `/settings` | `useAppSetting`, `useAppSettings` |
409
460
  | `/analytics` | `useTrackFeature` |
@@ -1 +1 @@
1
- {"version":3,"file":"create-component.js","sourceRoot":"","sources":["../../src/create-component.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAGpE,OAAO,EAAe,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAO9E,OAAO,EAAE,cAAc,IAAI,iBAAiB,EAAE,M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1B,CACE,SAA4B,EAC5B,SAAoD,EACrB,EAAE,CACnC,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CACd,IAAI,CAAC,KAAK,IAAI,EAAE;IACd,MAAM,IAAI,GAAG,gBAAgB,CAAuB,SAAS,CAAC,CAAC;IAC/D,wEAAwE;IACxE,8DAA8D;IAC9D,MAAM,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC;QAC1B,MAAM;QACN,GAAG;KACJ,CAAC,CAAkC,CAAC;IAErC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,kBAAkB,EAAE;QAC9C,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE;QACrC,MAAM,EAAE,SAAS;KAClB,CAAC,CAAC;IACH,OAAO;QACL,OAAO,EAAE,GAAG,EAAE,CAAC,CACb,KAAC,iBAAiB,IAAC,KAAK,EAAE,MAAM,YAC9B,KAAC,iBAAiB,IAAC,KAAK,EAAE,OAAO,YAI/B,KAAC,SAAS,KAAG,GACK,GACF,CACrB;KACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAaP,eAAe,eAAe,CAAC"}
@@ -26,7 +26,15 @@ import { ModuleProvider as AppModuleProvider } from '@equinor/fusion-framework-r
26
26
  */
27
27
  export const makeComponent = (Component, args, configure) => lazy(async () => {
28
28
  const init = configureModules(configure);
29
- const modules = await init(args);
29
+ let modules;
30
+ // Hosts cannot catch lazy initialization failures synchronously after mounting the React root.
31
+ try {
32
+ modules = await init(args);
33
+ }
34
+ catch (error) {
35
+ args.onError?.(error);
36
+ throw error;
37
+ }
30
38
  const { fusion } = args;
31
39
  modules.event.dispatchEvent('onReactAppLoaded', {
32
40
  detail: { modules, fusion, env: args.env },
@@ -1 +1 @@
1
- {"version":3,"file":"make-component.js","sourceRoot":"","sources":["../../src/make-component.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAA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,MAAM,aAAa,GAAG,CAK3B,SAA0B,EAC1B,IAAqC,EACrC,SAAoD,EACJ,EAAE,CAClD,IAAI,CAAC,KAAK,IAAI,EAAE;IACd,MAAM,IAAI,GAAG,gBAAgB,CAAuB,SAAS,CAAC,CAAC;IAC/D,IAAI,OAAqC,CAAC;IAC1C,+FAA+F;IAC/F,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;QACtB,MAAM,KAAK,CAAC;IACd,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAExB,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,kBAAkB,EAAE;QAC9C,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE;QAC1C,MAAM,EAAE,SAAS;KAClB,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,GAAG,EAAE,CAAC,CACb,KAAC,iBAAiB,IAAC,KAAK,EAAE,MAAM,YAC9B,KAAC,iBAAiB,IAAC,KAAK,EAAE,OAAO,YAAG,SAAS,GAAqB,GAChD,CACrB;KACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAaL,eAAe,aAAa,CAAC"}
@@ -9,10 +9,11 @@ import { createRoot } from 'react-dom/client';
9
9
  *
10
10
  * @param el - The DOM element to render into.
11
11
  * @param Component - The React function component to render.
12
+ * @param onError - Optional host callback for uncaught React render and lazy-initialization errors.
12
13
  * @returns A {@link RenderTeardown} callback that unmounts the component.
13
14
  */
14
- const render = (el, Component) => {
15
- const root = createRoot(el);
15
+ const render = (el, Component, onError) => {
16
+ const root = createRoot(el, { onUncaughtError: onError });
16
17
  root.render(_jsx(StrictMode, { children: _jsx(Suspense, { fallback: _jsx("p", { children: "loading app" }), children: _jsx(Component, {}) }) }));
17
18
  return () => {
18
19
  root.unmount();
@@ -33,7 +34,7 @@ const render = (el, Component) => {
33
34
  export const renderComponent = (renderer) => {
34
35
  return (el, args) => {
35
36
  const Component = renderer(args.fusion, args.env);
36
- return render(el, Component);
37
+ return render(el, Component, args.onError);
37
38
  };
38
39
  };
39
40
  export default renderComponent;
@@ -1 +1 @@
1
- {"version":3,"file":"render-component.js","sourceRoot":"","sources":["../../src/render-component.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAa,MAAM,kBAAkB,CAAC;AASzD;;;;;;;;;GASG;AACH,MAAM,MAAM,GAAG,CAAC,EAAW,EAAE,SAA4B,EAAkB,EAAE;IAC3E,MAAM,IAAI,GAAS,UAAU,CAAC,EAAE,CAAC,CAAC;IAClC,IAAI,CAAC,MAAM,CACT,KAAC,UAAU,cACT,KAAC,QAAQ,IAAC,QAAQ,EAAE,sCAAkB,YACpC,KAAC,SAAS,KAAG,GACJ,GACA,CACd,CAAC;IACF,OAAO,GAAG,EAAE;QACV,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAA2B,EAAE,EAAE;IAC7D,OAAO,CAAC,EAAe,EAAE,IAAyB,EAAkB,EAAE;QACpE,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAClD,OAAO,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;IAC/B,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"render-component.js","sourceRoot":"","sources":["../../src/render-component.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAa,MAAM,kBAAkB,CAAC;AASzD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,GAAG,CACb,EAAW,EACX,SAA4B,EAC5B,OAAkC,EAClB,EAAE;IAClB,MAAM,IAAI,GAAS,UAAU,CAAC,EAAE,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC,CAAC;IAChE,IAAI,CAAC,MAAM,CACT,KAAC,UAAU,cACT,KAAC,QAAQ,IAAC,QAAQ,EAAE,sCAAkB,YACpC,KAAC,SAAS,KAAG,GACJ,GACA,CACd,CAAC;IACF,OAAO,GAAG,EAAE;QACV,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAA2B,EAAE,EAAE;IAC7D,OAAO,CAAC,EAAe,EAAE,IAAyB,EAAkB,EAAE;QACpE,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAClD,OAAO,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Roles V2 React hooks for Fusion Framework applications.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export { useAccessRole, } from './useAccessRole';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/roles/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,EACL,aAAa,GAGd,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,154 @@
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { useAppModule } from '../useAppModule';
3
+ /**
4
+ * Checks one Roles V2 access role and activates a claimable role assignment when available.
5
+ *
6
+ * The hook checks both active access-role assignments and claimable access-role mappings when
7
+ * mounted. A successful activation triggers a new check so rendered access state follows it.
8
+ *
9
+ * @param accessRoleName - Exact, case-sensitive Roles V2 access-role name to check.
10
+ * @returns Access-role state and an activation action backed by the app-scoped Roles provider.
11
+ * @throws The function returned as `activateClaimableRoleAssignment` rethrows cancellation and
12
+ * Roles V2 failures.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * const role = useAccessRole('Reports.Read');
17
+ *
18
+ * if (role.isChecking) return <Spinner />;
19
+ * if (role.checkError) return <ErrorMessage error={role.checkError} />;
20
+ * if (role.hasAccessRole) return <Reports />;
21
+ *
22
+ * // Consume the event-handler rejection; activationError below owns the visible failure.
23
+ * const handleActivate = (): void => {
24
+ * void role.activateClaimableRoleAssignment({
25
+ * assignmentId: claimableRoleId,
26
+ * reason: 'Open reports',
27
+ * hours: 2,
28
+ * }).catch(() => undefined);
29
+ * };
30
+ *
31
+ * return role.hasClaimableRoleAssignmentForAccessRole ? (
32
+ * <>
33
+ * {role.activationError ? <p role="alert">{String(role.activationError)}</p> : null}
34
+ * <button disabled={role.isActivating} onClick={handleActivate}>
35
+ * Claim access
36
+ * </button>
37
+ * </>
38
+ * ) : null;
39
+ * ```
40
+ */
41
+ export const useAccessRole = (accessRoleName) => {
42
+ const roles = useAppModule('roles');
43
+ const mountedRef = useRef(false);
44
+ const checkRequestRef = useRef(0);
45
+ const activationScopeRef = useRef(0);
46
+ const activationRequestRef = useRef(0);
47
+ const pendingActivationCountRef = useRef(0);
48
+ const [hasAccessRole, setHasAccessRole] = useState();
49
+ const [hasClaimableRoleAssignmentForAccessRole, setHasClaimableRoleAssignmentForAccessRole] = useState();
50
+ const [isChecking, setIsChecking] = useState(true);
51
+ const [checkError, setCheckError] = useState();
52
+ const [isActivating, setIsActivating] = useState(false);
53
+ const [activationError, setActivationError] = useState();
54
+ useEffect(() => {
55
+ mountedRef.current = true;
56
+ return () => {
57
+ mountedRef.current = false;
58
+ checkRequestRef.current += 1;
59
+ };
60
+ }, []);
61
+ const checkAccessRole = useCallback(async () => {
62
+ const requestId = ++checkRequestRef.current;
63
+ // Keep previous values visible while callers explicitly refresh an already resolved role.
64
+ if (mountedRef.current) {
65
+ setIsChecking(true);
66
+ setCheckError(undefined);
67
+ }
68
+ try {
69
+ const [isActive, isClaimable] = await Promise.all([
70
+ roles.hasAccessRole([accessRoleName], { required: true }),
71
+ roles.hasClaimableRoleAssignmentForAccessRole(accessRoleName),
72
+ ]);
73
+ // Only the latest check may update state after role names or providers change.
74
+ if (mountedRef.current && checkRequestRef.current === requestId) {
75
+ setHasAccessRole(isActive);
76
+ setHasClaimableRoleAssignmentForAccessRole(isClaimable);
77
+ }
78
+ }
79
+ catch (error) {
80
+ // Surface failures as hook state while preserving rejection for explicit refresh callers.
81
+ if (mountedRef.current && checkRequestRef.current === requestId) {
82
+ setCheckError(error);
83
+ }
84
+ throw error;
85
+ }
86
+ finally {
87
+ // A stale request must not mark a newer role check as complete.
88
+ if (mountedRef.current && checkRequestRef.current === requestId) {
89
+ setIsChecking(false);
90
+ }
91
+ }
92
+ }, [accessRoleName, roles]);
93
+ useEffect(() => {
94
+ // A new role or provider owns independent mutation state; old completions become stale.
95
+ activationScopeRef.current += 1;
96
+ activationRequestRef.current += 1;
97
+ pendingActivationCountRef.current = 0;
98
+ setIsActivating(false);
99
+ setActivationError(undefined);
100
+ // A changed role name must not render access resolved for the previous role while checking.
101
+ setHasAccessRole(undefined);
102
+ setHasClaimableRoleAssignmentForAccessRole(undefined);
103
+ // Automatic checks expose failures through checkError because effects cannot return promises.
104
+ void checkAccessRole().catch(() => undefined);
105
+ }, [checkAccessRole]);
106
+ const activateClaimableRoleAssignment = useCallback(async (input) => {
107
+ const scopeId = activationScopeRef.current;
108
+ const requestId = ++activationRequestRef.current;
109
+ pendingActivationCountRef.current += 1;
110
+ // Activation state is independent from checks so UIs can render each operation explicitly.
111
+ if (mountedRef.current) {
112
+ setIsActivating(true);
113
+ setActivationError(undefined);
114
+ }
115
+ try {
116
+ const result = await roles.activateClaimableRoleAssignment(input);
117
+ // Successful activation invalidates provider caches; refresh the rendered access state.
118
+ if (mountedRef.current && activationScopeRef.current === scopeId) {
119
+ void checkAccessRole().catch(() => undefined);
120
+ }
121
+ return result;
122
+ }
123
+ catch (error) {
124
+ // Callers receive the original failure while React consumers can also render activationError.
125
+ if (mountedRef.current &&
126
+ activationScopeRef.current === scopeId &&
127
+ activationRequestRef.current === requestId) {
128
+ setActivationError(error);
129
+ }
130
+ throw error;
131
+ }
132
+ finally {
133
+ // Only same-scope completions contribute to the current role's pending mutation state.
134
+ if (activationScopeRef.current === scopeId) {
135
+ pendingActivationCountRef.current = Math.max(0, pendingActivationCountRef.current - 1);
136
+ // Preserve the busy state while another activation in this role scope is still pending.
137
+ if (mountedRef.current) {
138
+ setIsActivating(pendingActivationCountRef.current > 0);
139
+ }
140
+ }
141
+ }
142
+ }, [checkAccessRole, roles]);
143
+ return {
144
+ hasAccessRole,
145
+ hasClaimableRoleAssignmentForAccessRole,
146
+ isChecking,
147
+ checkError,
148
+ checkAccessRole,
149
+ activateClaimableRoleAssignment,
150
+ isActivating,
151
+ activationError,
152
+ };
153
+ };
154
+ //# sourceMappingURL=useAccessRole.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAccessRole.js","sourceRoot":"","sources":["../../../src/roles/useAccessRole.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQjE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AA+B/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,cAAsB,EAAuB,EAAE;IAC3E,MAAM,KAAK,GAAG,YAAY,CAAc,OAAO,CAAC,CAAC;IACjD,MAAM,UAA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F,wFAAwF;gBACxF,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;oBACvB,eAAe,CAAC,yBAAyB,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;gBACzD,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,EACD,CAAC,eAAe,EAAE,KAAK,CAAC,CACzB,CAAC;IAEF,OAAO;QACL,aAAa;QACb,uCAAuC;QACvC,UAAU;QACV,UAAU;QACV,eAAe;QACf,+BAA+B;QAC/B,YAAY;QACZ,eAAe;KAChB,CAAC;AACJ,CAAC,CAAC"}
@@ -1,3 +1,3 @@
1
1
  // Generated by genversion.
2
- export const version = '14.1.2';
2
+ export const version = '14.2.0';
3
3
  //# sourceMappingURL=version.js.map