@camunda/ccma-saas-frontend 0.38.2 → 0.39.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/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/runtime/c4-console-data-context.js +6 -3
- package/lib/esm/runtime/c4-console-data-store.js +9 -0
- package/lib/esm/runtime/c4-console-runtime-context.d.ts +10 -0
- package/lib/esm/runtime/c4-console-runtime-context.js +61 -4
- package/lib/esm/runtime/c4-console-runtime.types.d.ts +5 -0
- package/lib/esm/runtime/index.d.ts +1 -1
- package/lib/esm/runtime/index.js +1 -1
- package/lib/esm/runtime/to-api-config.js +16 -0
- package/lib/esm/widgets/cluster-details/c4-cluster-details-app.js +6 -2
- package/lib/esm/widgets/create-cluster/c4-create-cluster-page.js +17 -6
- package/lib/esm/widgets/dashboard/c4-dashboard-app.js +9 -4
- package/package.json +1 -1
package/lib/esm/index.d.ts
CHANGED
|
@@ -214,7 +214,7 @@ export { openC4CreateConsoleApiClientModal, setC4CreateConsoleApiClientModalHand
|
|
|
214
214
|
export { openC4InviteUserToOrganizationModal, setC4InviteUserToOrganizationModalHandle, } from './modals/c4-invite-user-to-organization-modal-handle.js';
|
|
215
215
|
export { openC4RenameOrganizationModal, setC4RenameOrganizationModalHandle, } from './modals/c4-rename-organization-modal-handle.js';
|
|
216
216
|
export type { AccountsPermissions, AddC4ConsoleNotificationOptions, C4BreadcrumbCrumb, C4BreadcrumbDropdownItem, C4ClusterNavAppEntry, C4ClusterNavEntry, C4ConsoleAuthzFeatures, C4ConsoleAuthzState, C4ConsoleDataState, C4ConsoleEventsProviderProps, C4ConsoleNotification, C4ConsoleNotificationAction, C4ConsoleNotificationKind, C4ConsoleNotificationsState, C4ConsoleRuntimeConfig, C4ConsoleVisibilities, C4ResolvedTheme, C4ThemePreference, C4UserNotificationsProviderProps, C4UserNotificationsState, C4UserThemeState, CacheState, CamundaWebApp, ConsoleAuth, ConsoleBackendUrls, ConsoleClickwrapConfig, ConsoleClusterDto, ConsolePermissions, ConsolePublicUrls, ConsoleStage, ConsoleTelemetry, ConsoleUser, ExternalClusterDto, ExternalOrganizationDto, NotificationDto, OrganizationPermissions, OrganizationRole, OrgCache, SseEntity, UpgradableGenerationsDto, UseC4ClusterNavEntriesOptions, UseC4WebappBreadcrumbDataOptions, } from './runtime/index.js';
|
|
217
|
-
export { addC4ConsoleNotification, buildClusterSsoCallbackUrl, buildClusterSwaggerUrl, buildModelerOrgUrl, C4ConsoleDataProvider, C4ConsoleEventsProvider, C4ConsoleNotificationsProvider, C4ConsoleRuntimeProvider, C4UserNotificationsProvider, CONSOLE_CLI_API_FLAG, DEFAULT_NAV_APPS, getClusterStage, getEndpointForApp, getReadableAppName, hasReadPermissionForApp, isAdminApp, isAppHealthyOnCluster, removeC4ConsoleNotificationById, resolveAdminAppName, setC4ConsoleNotificationsHandle, useC4ClusterNavEntries, useC4ConsoleAuthz, useC4ConsoleData, useC4ConsoleEventsState, useC4ConsoleNotifications, useC4ConsoleRuntime, useC4ConsoleStage, useC4FeatureFlag, useC4TwoPhaseRestoreMockup, useC4TwoPhaseUpgradeMockup, useC4UserNotifications, useC4UserTheme, useC4WebappBreadcrumbData, useConsoleCliApi, } from './runtime/index.js';
|
|
217
|
+
export { addC4ConsoleNotification, buildClusterSsoCallbackUrl, buildClusterSwaggerUrl, buildModelerOrgUrl, C4ConsoleDataProvider, C4ConsoleEventsProvider, C4ConsoleNotificationsProvider, C4ConsoleRuntimeProvider, C4UserNotificationsProvider, CONSOLE_CLI_API_FLAG, DEFAULT_NAV_APPS, getClusterStage, getEndpointForApp, getReadableAppName, hasReadPermissionForApp, isAdminApp, isAppHealthyOnCluster, removeC4ConsoleNotificationById, resolveAdminAppName, setC4ConsoleNotificationsHandle, useC4ClusterNavEntries, useC4ConsoleAuthz, useC4ConsoleData, useC4ConsoleEventsState, useC4ConsoleNotifications, useC4ConsoleRuntime, useC4ConsoleStage, useC4FeatureFlag, useC4FeatureFlagsSettled, useC4TwoPhaseRestoreMockup, useC4TwoPhaseUpgradeMockup, useC4UserNotifications, useC4UserTheme, useC4WebappBreadcrumbData, useConsoleCliApi, } from './runtime/index.js';
|
|
218
218
|
export type { MigrationAccess, MigrationAccessStatement, MigrationBackupChoice, MigrationDetectedBackup, MigrationPhase, MigrationReason, MigrationReasonParams, MigrationSourceAccess, MigrationSourceInput, MigrationSourceKind, MigrationSpec, MigrationView, } from './utils/migration-view.js';
|
|
219
219
|
export type { TranslateFn } from './utils/safe-translate.js';
|
|
220
220
|
export { ENVIRONMENT_KEY_SUFFIX, safeTranslate, scopedTranslate, } from './utils/safe-translate.js';
|
package/lib/esm/index.js
CHANGED
|
@@ -123,7 +123,7 @@ export { openC4RenameOrganizationModal, setC4RenameOrganizationModalHandle, } fr
|
|
|
123
123
|
// re-listed per module, so the package root and the
|
|
124
124
|
// `@camunda/ccma-saas-frontend/runtime` subpath expose one identical surface.
|
|
125
125
|
// Add runtime exports in `src/runtime/index.ts` and mirror them here.
|
|
126
|
-
export { addC4ConsoleNotification, buildClusterSsoCallbackUrl, buildClusterSwaggerUrl, buildModelerOrgUrl, C4ConsoleDataProvider, C4ConsoleEventsProvider, C4ConsoleNotificationsProvider, C4ConsoleRuntimeProvider, C4UserNotificationsProvider, CONSOLE_CLI_API_FLAG, DEFAULT_NAV_APPS, getClusterStage, getEndpointForApp, getReadableAppName, hasReadPermissionForApp, isAdminApp, isAppHealthyOnCluster, removeC4ConsoleNotificationById, resolveAdminAppName, setC4ConsoleNotificationsHandle, useC4ClusterNavEntries, useC4ConsoleAuthz, useC4ConsoleData, useC4ConsoleEventsState, useC4ConsoleNotifications, useC4ConsoleRuntime, useC4ConsoleStage, useC4FeatureFlag, useC4TwoPhaseRestoreMockup, useC4TwoPhaseUpgradeMockup, useC4UserNotifications, useC4UserTheme, useC4WebappBreadcrumbData, useConsoleCliApi, } from './runtime/index.js';
|
|
126
|
+
export { addC4ConsoleNotification, buildClusterSsoCallbackUrl, buildClusterSwaggerUrl, buildModelerOrgUrl, C4ConsoleDataProvider, C4ConsoleEventsProvider, C4ConsoleNotificationsProvider, C4ConsoleRuntimeProvider, C4UserNotificationsProvider, CONSOLE_CLI_API_FLAG, DEFAULT_NAV_APPS, getClusterStage, getEndpointForApp, getReadableAppName, hasReadPermissionForApp, isAdminApp, isAppHealthyOnCluster, removeC4ConsoleNotificationById, resolveAdminAppName, setC4ConsoleNotificationsHandle, useC4ClusterNavEntries, useC4ConsoleAuthz, useC4ConsoleData, useC4ConsoleEventsState, useC4ConsoleNotifications, useC4ConsoleRuntime, useC4ConsoleStage, useC4FeatureFlag, useC4FeatureFlagsSettled, useC4TwoPhaseRestoreMockup, useC4TwoPhaseUpgradeMockup, useC4UserNotifications, useC4UserTheme, useC4WebappBreadcrumbData, useConsoleCliApi, } from './runtime/index.js';
|
|
127
127
|
export { ENVIRONMENT_KEY_SUFFIX, safeTranslate, scopedTranslate, } from './utils/safe-translate.js';
|
|
128
128
|
export { C4ClusterClientDetailsApp } from './widgets/cluster-client-details/c4-cluster-client-details-app.js';
|
|
129
129
|
export { C4ClusterDetailsApp } from './widgets/cluster-details/c4-cluster-details-app.js';
|
|
@@ -48,8 +48,10 @@ export const C4ConsoleDataProvider = ({ children, initialState, }) => {
|
|
|
48
48
|
useLayoutEffect(() => {
|
|
49
49
|
store.setRuntime(runtime);
|
|
50
50
|
}, [runtime, store]);
|
|
51
|
-
// fetchClusters
|
|
52
|
-
// lists
|
|
51
|
+
// fetchClusters and fetchClients change identity when the cli flag flips, so
|
|
52
|
+
// a widget that lists one in its effect deps fetches again from the right
|
|
53
|
+
// route. The biome-ignore lines below run long on purpose: both
|
|
54
|
+
// wrappers use the same form.
|
|
53
55
|
const cliApiOn = isConsoleCliApiOn(runtime);
|
|
54
56
|
// Stable action wrappers (avoid recreating function identities on every snapshot)
|
|
55
57
|
// biome-ignore lint/correctness/useExhaustiveDependencies: cliApiOn is a trigger only
|
|
@@ -57,7 +59,8 @@ export const C4ConsoleDataProvider = ({ children, initialState, }) => {
|
|
|
57
59
|
const fetchOrgInfo = useCallback((orgId, options) => store.fetchOrgInfo(orgId, options), [store]);
|
|
58
60
|
const fetchMembers = useCallback((orgId, options) => store.fetchMembers(orgId, options), [store]);
|
|
59
61
|
const fetchAudits = useCallback((orgId, options) => store.fetchAudits(orgId, options), [store]);
|
|
60
|
-
|
|
62
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: cliApiOn is a trigger only
|
|
63
|
+
const fetchClients = useCallback((orgId, options) => store.fetchClients(orgId, options), [store, cliApiOn]);
|
|
61
64
|
const fetchOrgOwner = useCallback((orgId, options) => store.fetchOrgOwner(orgId, options), [store]);
|
|
62
65
|
const fetchEarlyAccessFeatures = useCallback((orgId, options) => store.fetchEarlyAccessFeatures(orgId, options), [store]);
|
|
63
66
|
const fetchClusterCapacity = useCallback((orgId, clusterIds, options) => store.fetchClusterCapacity(orgId, clusterIds, options), [store]);
|
|
@@ -213,6 +213,7 @@ export const ConsoleDataStore = types
|
|
|
213
213
|
// older route yet (it can hold seeded data).
|
|
214
214
|
if (self.runtime && cliApiOn !== self.cliApiOn) {
|
|
215
215
|
self.clusters.clear();
|
|
216
|
+
self.clients.clear();
|
|
216
217
|
self.clustersLastRefreshMs.clear();
|
|
217
218
|
self.inFlightClusters.clear();
|
|
218
219
|
self.clustersGeneration += 1;
|
|
@@ -808,12 +809,17 @@ export const ConsoleDataStore = types
|
|
|
808
809
|
error: null,
|
|
809
810
|
lastFetched: cached?.lastFetched ?? null,
|
|
810
811
|
});
|
|
812
|
+
// A flip of the cli flag while the call runs makes this answer stale.
|
|
813
|
+
const generation = self.clustersGeneration;
|
|
811
814
|
try {
|
|
812
815
|
const apiConfig = toApiConfig(self.runtime);
|
|
813
816
|
const clientsList = yield cliOrgApi(isConsoleCliApiOn(self.runtime)).listApiClients({
|
|
814
817
|
params: { orgId },
|
|
815
818
|
config: apiConfig,
|
|
816
819
|
});
|
|
820
|
+
if (self.clustersGeneration !== generation) {
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
817
823
|
self.clients.set(orgId, {
|
|
818
824
|
data: clientsList,
|
|
819
825
|
isLoading: false,
|
|
@@ -822,6 +828,9 @@ export const ConsoleDataStore = types
|
|
|
822
828
|
});
|
|
823
829
|
}
|
|
824
830
|
catch (error) {
|
|
831
|
+
if (self.clustersGeneration !== generation) {
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
825
834
|
self.clients.set(orgId, {
|
|
826
835
|
data: cached?.data,
|
|
827
836
|
isLoading: false,
|
|
@@ -34,3 +34,13 @@ export declare const useC4ConsoleStage: () => ConsoleStage | undefined;
|
|
|
34
34
|
* twice.
|
|
35
35
|
*/
|
|
36
36
|
export declare const useC4FeatureFlag: (flagKey: string) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Whether the flags of the organization `orgId` have arrived. A load that
|
|
39
|
+
* reads `useConsoleCliApi` waits for it: else it runs once with the flag off
|
|
40
|
+
* and once again with the flag on. With `config.featureFlags`, the answer is
|
|
41
|
+
* `featureFlags.isSettledFor`, and a host that gives none is settled. Without
|
|
42
|
+
* it, the answer comes from the flag request of the provider: false until that
|
|
43
|
+
* request has ended for the current org and user. Outside a provider it is
|
|
44
|
+
* true.
|
|
45
|
+
*/
|
|
46
|
+
export declare const useC4FeatureFlagsSettled: (orgId: string | undefined) => boolean;
|
|
@@ -8,6 +8,13 @@ import { ControlFeatureFlagsService, ExternalAccountsService, } from '@camunda/c
|
|
|
8
8
|
import { createContext, useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
9
9
|
import { toApiConfig } from './to-api-config.js';
|
|
10
10
|
const RuntimeContext = createContext(undefined);
|
|
11
|
+
/**
|
|
12
|
+
* The settled state of the flag fetch of the provider. It has its own context,
|
|
13
|
+
* not a field of the runtime value: a change of the runtime value makes every
|
|
14
|
+
* load that keys on it (`toApiConfig`) run again, and a failed flag call must
|
|
15
|
+
* not cost that.
|
|
16
|
+
*/
|
|
17
|
+
const FlagsSettledContext = createContext(undefined);
|
|
11
18
|
// Carbon dark theme names (set by c3 on <html data-carbon-theme>).
|
|
12
19
|
const CARBON_DARK_THEMES = new Set(['g90', 'g100']);
|
|
13
20
|
/**
|
|
@@ -80,6 +87,11 @@ function readFlag(flags, flagKey) {
|
|
|
80
87
|
*/
|
|
81
88
|
function useFetchedFeatureFlags(config) {
|
|
82
89
|
const [flags, setFlags] = useState(undefined);
|
|
90
|
+
// The key of the request that has ended, with an answer or without one.
|
|
91
|
+
// `settled` is derived from it while rendering. A flag set in an effect
|
|
92
|
+
// would stay true for one commit after an org switch, because the effects of
|
|
93
|
+
// the children run before this one.
|
|
94
|
+
const [settledKey, setSettledKey] = useState(undefined);
|
|
83
95
|
// The host usually gives `config` as an object literal, thus its identity
|
|
84
96
|
// changes on every render. The effect below must depend on primitives alone,
|
|
85
97
|
// or it fetches in a loop.
|
|
@@ -92,6 +104,13 @@ function useFetchedFeatureFlags(config) {
|
|
|
92
104
|
// which is the point at which an access token starts to exist.
|
|
93
105
|
const userId = config.user?.sub;
|
|
94
106
|
const accountsApiBaseUrl = config.backendUrls.accountsApiBaseUrl;
|
|
107
|
+
const requestKey = JSON.stringify([
|
|
108
|
+
stage,
|
|
109
|
+
orgId,
|
|
110
|
+
email,
|
|
111
|
+
userId,
|
|
112
|
+
accountsApiBaseUrl,
|
|
113
|
+
]);
|
|
95
114
|
useEffect(() => {
|
|
96
115
|
if (hostOwnsFlags) {
|
|
97
116
|
return;
|
|
@@ -102,6 +121,9 @@ function useFetchedFeatureFlags(config) {
|
|
|
102
121
|
// new organization must not get. A request that never settles would keep
|
|
103
122
|
// the old values for the life of the page.
|
|
104
123
|
setFlags(undefined);
|
|
124
|
+
// The answer that was stored is for an older request. Without this, a
|
|
125
|
+
// switch A to B to A counts A as settled while the flags are cleared.
|
|
126
|
+
setSettledKey(undefined);
|
|
105
127
|
let cancelled = false;
|
|
106
128
|
const load = async () => {
|
|
107
129
|
try {
|
|
@@ -115,6 +137,10 @@ function useFetchedFeatureFlags(config) {
|
|
|
115
137
|
'Give `config.user` when the session starts, or the feature flags stay off. ' +
|
|
116
138
|
'See docs/runtime.md section 4a.');
|
|
117
139
|
}
|
|
140
|
+
// No request goes out, thus no answer is coming: do not block.
|
|
141
|
+
if (!cancelled) {
|
|
142
|
+
setSettledKey(requestKey);
|
|
143
|
+
}
|
|
118
144
|
return;
|
|
119
145
|
}
|
|
120
146
|
const request = {
|
|
@@ -142,6 +168,7 @@ function useFetchedFeatureFlags(config) {
|
|
|
142
168
|
}
|
|
143
169
|
if (!cancelled) {
|
|
144
170
|
setFlags(fetched);
|
|
171
|
+
setSettledKey(requestKey);
|
|
145
172
|
}
|
|
146
173
|
}
|
|
147
174
|
catch (error) {
|
|
@@ -149,6 +176,7 @@ function useFetchedFeatureFlags(config) {
|
|
|
149
176
|
// Every flag stays off. A flag holds the behavior that a host must
|
|
150
177
|
// not get by default, thus off is the safe answer.
|
|
151
178
|
setFlags(undefined);
|
|
179
|
+
setSettledKey(requestKey);
|
|
152
180
|
configRef.current.telemetry?.captureException?.(error, {
|
|
153
181
|
source: 'C4ConsoleRuntimeProvider.featureFlags',
|
|
154
182
|
});
|
|
@@ -159,8 +187,8 @@ function useFetchedFeatureFlags(config) {
|
|
|
159
187
|
return () => {
|
|
160
188
|
cancelled = true;
|
|
161
189
|
};
|
|
162
|
-
}, [hostOwnsFlags,
|
|
163
|
-
return flags;
|
|
190
|
+
}, [hostOwnsFlags, requestKey, orgId]);
|
|
191
|
+
return { flags, settled: settledKey === requestKey };
|
|
164
192
|
}
|
|
165
193
|
/**
|
|
166
194
|
* Reads the clickwrap config from accounts-ng. The request runs on mount
|
|
@@ -244,8 +272,9 @@ function useFetchedClickwrap(config) {
|
|
|
244
272
|
}
|
|
245
273
|
export const C4ConsoleRuntimeProvider = ({ config, children, }) => {
|
|
246
274
|
useSyncThemeToDesignSystem();
|
|
247
|
-
const fetchedFlags = useFetchedFeatureFlags(config);
|
|
275
|
+
const { flags: fetchedFlags, settled: flagsSettled } = useFetchedFeatureFlags(config);
|
|
248
276
|
const fetchedClickwrap = useFetchedClickwrap(config);
|
|
277
|
+
const hostOwnsFlags = Boolean(config.featureFlags);
|
|
249
278
|
const value = useMemo(() => {
|
|
250
279
|
// The host-fed clickwrap wins. A host that feeds none gets the fetched
|
|
251
280
|
// config, thus the opt-in works without a change in the host.
|
|
@@ -262,7 +291,14 @@ export const C4ConsoleRuntimeProvider = ({ config, children, }) => {
|
|
|
262
291
|
},
|
|
263
292
|
};
|
|
264
293
|
}, [config, fetchedFlags, fetchedClickwrap]);
|
|
265
|
-
|
|
294
|
+
// The provider asks for one org, `config.orgId`. A widget that works on
|
|
295
|
+
// another org never gets that answer, thus it does not wait.
|
|
296
|
+
const settledState = useMemo(() => ({
|
|
297
|
+
// A host with its own flags makes the provider fetch nothing.
|
|
298
|
+
settled: hostOwnsFlags || flagsSettled,
|
|
299
|
+
orgId: config.orgId,
|
|
300
|
+
}), [hostOwnsFlags, flagsSettled, config.orgId]);
|
|
301
|
+
return (_jsx(RuntimeContext.Provider, { value: value, children: _jsx(FlagsSettledContext.Provider, { value: settledState, children: children }) }));
|
|
266
302
|
};
|
|
267
303
|
export const useC4ConsoleRuntime = () => {
|
|
268
304
|
const runtime = useContext(RuntimeContext);
|
|
@@ -303,3 +339,24 @@ export const useC4ConsoleStage = () => {
|
|
|
303
339
|
export const useC4FeatureFlag = (flagKey) => {
|
|
304
340
|
return useContext(RuntimeContext)?.featureFlags?.isEnabled?.(flagKey) ?? false;
|
|
305
341
|
};
|
|
342
|
+
/**
|
|
343
|
+
* Whether the flags of the organization `orgId` have arrived. A load that
|
|
344
|
+
* reads `useConsoleCliApi` waits for it: else it runs once with the flag off
|
|
345
|
+
* and once again with the flag on. With `config.featureFlags`, the answer is
|
|
346
|
+
* `featureFlags.isSettledFor`, and a host that gives none is settled. Without
|
|
347
|
+
* it, the answer comes from the flag request of the provider: false until that
|
|
348
|
+
* request has ended for the current org and user. Outside a provider it is
|
|
349
|
+
* true.
|
|
350
|
+
*/
|
|
351
|
+
export const useC4FeatureFlagsSettled = (orgId) => {
|
|
352
|
+
const isSettledFor = useContext(RuntimeContext)?.featureFlags?.isSettledFor;
|
|
353
|
+
const own = useContext(FlagsSettledContext);
|
|
354
|
+
if (!orgId)
|
|
355
|
+
return true;
|
|
356
|
+
if (isSettledFor)
|
|
357
|
+
return isSettledFor(orgId);
|
|
358
|
+
// No provider: settled.
|
|
359
|
+
if (!own)
|
|
360
|
+
return true;
|
|
361
|
+
return own.settled || (own.orgId !== undefined && own.orgId !== orgId);
|
|
362
|
+
};
|
|
@@ -75,5 +75,10 @@ export interface C4ConsoleRuntimeConfig {
|
|
|
75
75
|
*/
|
|
76
76
|
featureFlags?: {
|
|
77
77
|
isEnabled: (flagKey: string) => boolean;
|
|
78
|
+
/**
|
|
79
|
+
* True once the flags of the organization `orgId` have arrived (or the
|
|
80
|
+
* request failed). Omit it when the flags are known at the first render.
|
|
81
|
+
*/
|
|
82
|
+
isSettledFor?: (orgId: string) => boolean;
|
|
78
83
|
};
|
|
79
84
|
}
|
|
@@ -32,7 +32,7 @@ export { C4ConsoleEventsProvider, useC4ConsoleEventsState, } from './c4-console-
|
|
|
32
32
|
export { C4ConsoleNotificationsProvider, useC4ConsoleNotifications, } from './c4-console-notifications-context.js';
|
|
33
33
|
export type { AddC4ConsoleNotificationOptions, C4ConsoleNotification, C4ConsoleNotificationAction, C4ConsoleNotificationKind, C4ConsoleNotificationsState, } from './c4-console-notifications-context.types.js';
|
|
34
34
|
export type { C4ConsoleRuntimeConfig, ConsoleAuth, ConsoleBackendUrls, ConsoleClickwrapConfig, ConsolePublicUrls, ConsoleStage, ConsoleTelemetry, ConsoleUser, } from './c4-console-runtime.types.js';
|
|
35
|
-
export { C4ConsoleRuntimeProvider, useC4ConsoleRuntime, useC4ConsoleStage, useC4FeatureFlag, } from './c4-console-runtime-context.js';
|
|
35
|
+
export { C4ConsoleRuntimeProvider, useC4ConsoleRuntime, useC4ConsoleStage, useC4FeatureFlag, useC4FeatureFlagsSettled, } from './c4-console-runtime-context.js';
|
|
36
36
|
export { C4UserNotificationsProvider, useC4UserNotifications, } from './c4-user-notifications-context.js';
|
|
37
37
|
export type { C4UserNotificationsProviderProps, C4UserNotificationsState, } from './c4-user-notifications-context.types.js';
|
|
38
38
|
export type { C4ResolvedTheme, C4ThemePreference, C4UserThemeState, } from './c4-user-theme.js';
|
package/lib/esm/runtime/index.js
CHANGED
|
@@ -13,7 +13,7 @@ export { useC4ConsoleAuthz } from './c4-console-authz.js';
|
|
|
13
13
|
export { C4ConsoleDataProvider, useC4ConsoleData, } from './c4-console-data-context.js';
|
|
14
14
|
export { C4ConsoleEventsProvider, useC4ConsoleEventsState, } from './c4-console-events-context.js';
|
|
15
15
|
export { C4ConsoleNotificationsProvider, useC4ConsoleNotifications, } from './c4-console-notifications-context.js';
|
|
16
|
-
export { C4ConsoleRuntimeProvider, useC4ConsoleRuntime, useC4ConsoleStage, useC4FeatureFlag, } from './c4-console-runtime-context.js';
|
|
16
|
+
export { C4ConsoleRuntimeProvider, useC4ConsoleRuntime, useC4ConsoleStage, useC4FeatureFlag, useC4FeatureFlagsSettled, } from './c4-console-runtime-context.js';
|
|
17
17
|
export { C4UserNotificationsProvider, useC4UserNotifications, } from './c4-user-notifications-context.js';
|
|
18
18
|
export { useC4UserTheme } from './c4-user-theme.js';
|
|
19
19
|
export { buildModelerOrgUrl, DEFAULT_NAV_APPS, getClusterStage, getEndpointForApp, getReadableAppName, hasReadPermissionForApp, isAdminApp, isAppHealthyOnCluster, resolveAdminAppName, } from './nav/camunda-apps.js';
|
|
@@ -7,7 +7,23 @@ import { correlationHeaders, } from '@camunda/ccma-api';
|
|
|
7
7
|
function normalizeBaseUrl(url) {
|
|
8
8
|
return url.endsWith('/') ? url.slice(0, -1) : url;
|
|
9
9
|
}
|
|
10
|
+
// The last config for each token getter. A widget that keys a load on the
|
|
11
|
+
// config (`useMemo(() => toApiConfig(runtime), [runtime])`) must not load
|
|
12
|
+
// again when the runtime changes in a field that the config does not read,
|
|
13
|
+
// for example the flags that arrive after the first render.
|
|
14
|
+
const lastConfig = new WeakMap();
|
|
10
15
|
export function toApiConfig(runtime) {
|
|
16
|
+
const config = buildApiConfig(runtime);
|
|
17
|
+
const key = JSON.stringify([config.stage, config.envOverride]);
|
|
18
|
+
const getToken = runtime.auth.getAccessToken;
|
|
19
|
+
const last = lastConfig.get(getToken);
|
|
20
|
+
if (last?.key === key) {
|
|
21
|
+
return last.config;
|
|
22
|
+
}
|
|
23
|
+
lastConfig.set(getToken, { key, config });
|
|
24
|
+
return config;
|
|
25
|
+
}
|
|
26
|
+
function buildApiConfig(runtime) {
|
|
11
27
|
const envOverride = {};
|
|
12
28
|
const consoleApiBaseUrl = runtime.backendUrls.consoleApiBaseUrl;
|
|
13
29
|
if (consoleApiBaseUrl && consoleApiBaseUrl.length > 0) {
|
|
@@ -14,7 +14,7 @@ import { normalizeClusterStatus } from '../../components/c4-cluster-overview/app
|
|
|
14
14
|
import { getC4ClusterDetailsUrls } from '../../externalUrls.const.js';
|
|
15
15
|
import { isDeveloperBlockedFromClusterCreate, useC4ConsoleAuthz, } from '../../runtime/c4-console-authz.js';
|
|
16
16
|
import { useC4ConsoleData } from '../../runtime/c4-console-data-context.js';
|
|
17
|
-
import { useC4ConsoleRuntime, useC4FeatureFlag, } from '../../runtime/c4-console-runtime-context.js';
|
|
17
|
+
import { useC4ConsoleRuntime, useC4FeatureFlag, useC4FeatureFlagsSettled, } from '../../runtime/c4-console-runtime-context.js';
|
|
18
18
|
import { CLUSTER_CREATION_BLOCKED_FLAG } from '../../runtime/cluster-creation-blocked.js';
|
|
19
19
|
import { SELF_MANAGED_MIGRATION_FLAG } from '../../runtime/self-managed-migration.js';
|
|
20
20
|
import { toApiConfig } from '../../runtime/to-api-config.js';
|
|
@@ -1140,11 +1140,14 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
1140
1140
|
// On a hard load the flag answer comes after authz. The key holds the flag
|
|
1141
1141
|
// so the load runs again with the right services when it changes.
|
|
1142
1142
|
const cliApiOn = useConsoleCliApi();
|
|
1143
|
+
// The flags arrive per org. A load before that goes to the old routes and
|
|
1144
|
+
// the load after it to `/cli/v1`: each read would run twice.
|
|
1145
|
+
const flagsSettled = useC4FeatureFlagsSettled(props.orgId);
|
|
1143
1146
|
const initialLoadKey = `${props.orgId}:${props.clusterId}:${cliApiOn}`;
|
|
1144
1147
|
const lastInitialLoadKeyRef = useRef(undefined);
|
|
1145
1148
|
useEffect(() => {
|
|
1146
1149
|
// Wait for authz to resolve so tab visibility is stable.
|
|
1147
|
-
if (authz.isLoading) {
|
|
1150
|
+
if (authz.isLoading || !flagsSettled) {
|
|
1148
1151
|
return;
|
|
1149
1152
|
}
|
|
1150
1153
|
if (lastInitialLoadKeyRef.current === initialLoadKey) {
|
|
@@ -1173,6 +1176,7 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
1173
1176
|
canViewApiClientsTab,
|
|
1174
1177
|
canViewMonitoringTab,
|
|
1175
1178
|
data,
|
|
1179
|
+
flagsSettled,
|
|
1176
1180
|
initialLoadKey,
|
|
1177
1181
|
props.orgId,
|
|
1178
1182
|
reloadActivity,
|
|
@@ -14,7 +14,7 @@ import { getC4CreateClusterExternalLinks, getC4TalkToAnExpertUrl, } from '../../
|
|
|
14
14
|
import { addC4ConsoleNotification } from '../../notifications/c4-console-notifications-handle.js';
|
|
15
15
|
import { useC4ConsoleAuthz } from '../../runtime/c4-console-authz.js';
|
|
16
16
|
import { useC4ConsoleData } from '../../runtime/c4-console-data-context.js';
|
|
17
|
-
import { useC4ConsoleRuntime, useC4FeatureFlag, } from '../../runtime/c4-console-runtime-context.js';
|
|
17
|
+
import { useC4ConsoleRuntime, useC4FeatureFlag, useC4FeatureFlagsSettled, } from '../../runtime/c4-console-runtime-context.js';
|
|
18
18
|
import { SELF_MANAGED_MIGRATION_FLAG } from '../../runtime/self-managed-migration.js';
|
|
19
19
|
import { toApiConfig } from '../../runtime/to-api-config.js';
|
|
20
20
|
import { useCliActionsApi } from '../../runtime/use-cli-actions-api.js';
|
|
@@ -435,14 +435,17 @@ export const C4CreateClusterPage = observer(({ orgId, afterCreateModalUrl, talkT
|
|
|
435
435
|
const [replaceSource, setReplaceSource] = useState(false);
|
|
436
436
|
const [apiError, setApiError] = useState(undefined);
|
|
437
437
|
const selectedEncryptionRef = useRef(undefined);
|
|
438
|
+
// The flags arrive per org. A read before that goes to the old route and
|
|
439
|
+
// the read after it to `/cli/v1`: each read would run twice.
|
|
440
|
+
const flagsSettled = useC4FeatureFlagsSettled(orgId);
|
|
438
441
|
useEffect(() => {
|
|
439
|
-
if (!orgId) {
|
|
442
|
+
if (!orgId || !flagsSettled) {
|
|
440
443
|
return;
|
|
441
444
|
}
|
|
442
445
|
data.fetchClusters(orgId);
|
|
443
|
-
}, [orgId, data.fetchClusters]);
|
|
446
|
+
}, [orgId, flagsSettled, data.fetchClusters]);
|
|
444
447
|
useEffect(() => {
|
|
445
|
-
if (!orgId) {
|
|
448
|
+
if (!orgId || !flagsSettled) {
|
|
446
449
|
return;
|
|
447
450
|
}
|
|
448
451
|
let cancelled = false;
|
|
@@ -498,7 +501,14 @@ export const C4CreateClusterPage = observer(({ orgId, afterCreateModalUrl, talkT
|
|
|
498
501
|
return () => {
|
|
499
502
|
cancelled = true;
|
|
500
503
|
};
|
|
501
|
-
}, [
|
|
504
|
+
}, [
|
|
505
|
+
orgId,
|
|
506
|
+
apiConfig,
|
|
507
|
+
clusterReads,
|
|
508
|
+
flagsSettled,
|
|
509
|
+
runtime.telemetry,
|
|
510
|
+
sourceClusterId,
|
|
511
|
+
]);
|
|
502
512
|
const clustersCache = data.clusters[orgId];
|
|
503
513
|
const rawClusters = (clustersCache?.data ?? []);
|
|
504
514
|
const clustersLoading = clustersCache?.isLoading ?? false;
|
|
@@ -507,7 +517,8 @@ export const C4CreateClusterPage = observer(({ orgId, afterCreateModalUrl, talkT
|
|
|
507
517
|
// not open before the source cluster is there. Either the cluster arrives,
|
|
508
518
|
// or the read fails and `apiError` replaces the form.
|
|
509
519
|
const sourceClusterPending = Boolean(sourceClusterId) && !sourceCluster;
|
|
510
|
-
const loading =
|
|
520
|
+
const loading = !flagsSettled ||
|
|
521
|
+
clustersLoading ||
|
|
511
522
|
creationParametersLoading ||
|
|
512
523
|
organizationsLoading ||
|
|
513
524
|
sourceClusterLoading ||
|
|
@@ -14,7 +14,7 @@ import { C4OldDashboard } from '../../components/c4-old-dashboard/c4-old-dashboa
|
|
|
14
14
|
import { getC4DashboardUrls } from '../../externalUrls.const.js';
|
|
15
15
|
import { hasAvailableClusterReservation, isDeveloperBlockedFromClusterCreate, useC4ConsoleAuthz, } from '../../runtime/c4-console-authz.js';
|
|
16
16
|
import { useC4ConsoleData } from '../../runtime/c4-console-data-context.js';
|
|
17
|
-
import { useC4ConsoleRuntime, useC4FeatureFlag, } from '../../runtime/c4-console-runtime-context.js';
|
|
17
|
+
import { useC4ConsoleRuntime, useC4FeatureFlag, useC4FeatureFlagsSettled, } from '../../runtime/c4-console-runtime-context.js';
|
|
18
18
|
import { CLUSTER_CREATION_BLOCKED_FLAG } from '../../runtime/cluster-creation-blocked.js';
|
|
19
19
|
import { toApiConfig } from '../../runtime/to-api-config.js';
|
|
20
20
|
import { useCliExtrasApi } from '../../runtime/use-cli-extras-api.js';
|
|
@@ -125,9 +125,12 @@ export const C4DashboardApp = observer((props) => {
|
|
|
125
125
|
const shouldLoadMembers = canReadMembers === true;
|
|
126
126
|
const shouldLoadActivity = canReadActivity === true;
|
|
127
127
|
const shouldLoadApiClients = canReadApiClients === true;
|
|
128
|
+
// The flags arrive per org: a read before that goes to the old route and
|
|
129
|
+
// the read after it to `/cli/v1`.
|
|
130
|
+
const flagsSettled = useC4FeatureFlagsSettled(orgId);
|
|
128
131
|
// Fetch data on mount/orgId change (idempotent, cached in context)
|
|
129
132
|
useEffect(() => {
|
|
130
|
-
if (!orgId)
|
|
133
|
+
if (!orgId || !flagsSettled)
|
|
131
134
|
return;
|
|
132
135
|
// Fetch clusters first; capacity depends on cluster IDs.
|
|
133
136
|
// IMPORTANT: Do not gate capacity fetching behind members/audits.
|
|
@@ -145,7 +148,7 @@ export const C4DashboardApp = observer((props) => {
|
|
|
145
148
|
.catch(() => {
|
|
146
149
|
// Errors are surfaced via the shared cache; keep other requests running.
|
|
147
150
|
});
|
|
148
|
-
}, [orgId, fetchClusterCapacity, fetchClusters, getClusters]);
|
|
151
|
+
}, [orgId, flagsSettled, fetchClusterCapacity, fetchClusters, getClusters]);
|
|
149
152
|
// Load members only when permitted.
|
|
150
153
|
useEffect(() => {
|
|
151
154
|
if (!orgId)
|
|
@@ -172,10 +175,12 @@ export const C4DashboardApp = observer((props) => {
|
|
|
172
175
|
return;
|
|
173
176
|
if (!shouldLoadApiClients)
|
|
174
177
|
return;
|
|
178
|
+
if (!flagsSettled)
|
|
179
|
+
return;
|
|
175
180
|
fetchClients(orgId).catch(() => {
|
|
176
181
|
// Errors are surfaced via the shared cache.
|
|
177
182
|
});
|
|
178
|
-
}, [fetchClients, orgId, shouldLoadApiClients]);
|
|
183
|
+
}, [fetchClients, flagsSettled, orgId, shouldLoadApiClients]);
|
|
179
184
|
useEffect(() => {
|
|
180
185
|
if (!orgId) {
|
|
181
186
|
return;
|