@camunda/ccma-saas-frontend 0.19.10 → 0.20.1

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.
@@ -4,8 +4,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
4
4
  * under one or more contributor license agreements. Licensed under a commercial license.
5
5
  * You may not use this file except in compliance with the commercial license.
6
6
  */
7
- import { ControlFeatureFlagsService, ExternalAccountsService, } from '@camunda/ccma-api';
8
- import { createContext, useContext, useEffect, useMemo, useRef, useState, } from 'react';
7
+ import { ControlFeatureFlagsService, ExternalAccountsService, setAccountsNgBackend, } from '@camunda/ccma-api';
8
+ import { createContext, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, } from 'react';
9
9
  import { toApiConfig } from './to-api-config.js';
10
10
  const RuntimeContext = createContext(undefined);
11
11
  // Carbon dark theme names (set by c3 on <html data-carbon-theme>).
@@ -242,6 +242,14 @@ function useFetchedClickwrap(config) {
242
242
  }, [hostOwnsClickwrap, stage, userId, accountsApiBaseUrl]);
243
243
  return clickwrap;
244
244
  }
245
+ /**
246
+ * The mounted providers, the newest last. The accounts-ng switch reads the
247
+ * newest one, and a provider leaves the list when it unmounts. With no
248
+ * provider, the switch reads false.
249
+ */
250
+ const switchOwners = [];
251
+ const readSwitch = () => switchOwners.at(-1)?.current.featureFlags?.isEnabled('accounts.ngBackend') ??
252
+ false;
245
253
  export const C4ConsoleRuntimeProvider = ({ config, children, }) => {
246
254
  useSyncThemeToDesignSystem();
247
255
  const fetchedFlags = useFetchedFeatureFlags(config);
@@ -262,6 +270,22 @@ export const C4ConsoleRuntimeProvider = ({ config, children, }) => {
262
270
  },
263
271
  };
264
272
  }, [config, fetchedFlags, fetchedClickwrap]);
273
+ // Sends the accounts requests of a host to accounts-ng while the flag
274
+ // `accounts.ngBackend` is on (spec `docs/specs/accounts-ng.md`, section 9).
275
+ // Thus a host such as hub needs no change. A host that gives `featureFlags`
276
+ // answers the flag itself, so this reads the same value as its own switch,
277
+ // and it replaces the switch that the host set. The switch reads a ref, thus
278
+ // it follows each new answer. A layout effect sets it before the passive
279
+ // effects of the children send their first request.
280
+ const valueRef = useRef(value);
281
+ valueRef.current = value;
282
+ useLayoutEffect(() => {
283
+ switchOwners.push(valueRef);
284
+ setAccountsNgBackend(readSwitch);
285
+ return () => {
286
+ switchOwners.splice(switchOwners.indexOf(valueRef), 1);
287
+ };
288
+ }, []);
265
289
  return (_jsx(RuntimeContext.Provider, { value: value, children: children }));
266
290
  };
267
291
  export const useC4ConsoleRuntime = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camunda/ccma-saas-frontend",
3
- "version": "0.19.10",
3
+ "version": "0.20.1",
4
4
  "description": "Camunda Composite Components",
5
5
  "bugs": {
6
6
  "url": "https://github.com/camunda/camunda-cloud-management-apps/issues"
@@ -85,8 +85,8 @@
85
85
  "react-markdown": "^8.0.7 || ^10.0.0"
86
86
  },
87
87
  "dependencies": {
88
- "@camunda/ccma-api": "5.11.2",
89
- "@camunda/ccma-shared-types": "9.0.0",
88
+ "@camunda/ccma-api": "5.11.3",
89
+ "@camunda/ccma-shared-types": "9.1.0",
90
90
  "@pactsafe/pactsafe-react-sdk": "2.15.0",
91
91
  "cron-parser": "5.10.1",
92
92
  "mobx": "6.16.1",