@camunda/ccma-saas-frontend 0.37.0 → 0.37.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,6 +4,7 @@ import { createContext, useCallback, useContext, useEffect, useLayoutEffect, use
|
|
|
4
4
|
import { addC4ConsoleNotification } from '../notifications/c4-console-notifications-handle.js';
|
|
5
5
|
import { ConsoleDataStore, } from './c4-console-data-store.js';
|
|
6
6
|
import { useC4ConsoleRuntime } from './c4-console-runtime-context.js';
|
|
7
|
+
import { isConsoleCliApiOn } from './use-cli-org-api.js';
|
|
7
8
|
/**
|
|
8
9
|
* Shared data context for C4 console widgets
|
|
9
10
|
*
|
|
@@ -47,8 +48,12 @@ export const C4ConsoleDataProvider = ({ children, initialState, }) => {
|
|
|
47
48
|
useLayoutEffect(() => {
|
|
48
49
|
store.setRuntime(runtime);
|
|
49
50
|
}, [runtime, store]);
|
|
51
|
+
// fetchClusters changes identity when the cli flag flips, so a widget that
|
|
52
|
+
// lists it in its effect deps fetches again from the right route.
|
|
53
|
+
const cliApiOn = isConsoleCliApiOn(runtime);
|
|
50
54
|
// Stable action wrappers (avoid recreating function identities on every snapshot)
|
|
51
|
-
|
|
55
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: cliApiOn is a trigger only
|
|
56
|
+
const fetchClusters = useCallback((orgId, options) => store.fetchClusters(orgId, options), [store, cliApiOn]);
|
|
52
57
|
const fetchOrgInfo = useCallback((orgId, options) => store.fetchOrgInfo(orgId, options), [store]);
|
|
53
58
|
const fetchMembers = useCallback((orgId, options) => store.fetchMembers(orgId, options), [store]);
|
|
54
59
|
const fetchAudits = useCallback((orgId, options) => store.fetchAudits(orgId, options), [store]);
|
|
@@ -89,6 +89,16 @@ export declare const ConsoleDataStore: import("mobx-state-tree").IModelType<{
|
|
|
89
89
|
inFlightMyOrgs: boolean;
|
|
90
90
|
inFlightWebappClusters: Set<string>;
|
|
91
91
|
clustersLastRefreshMs: Map<string, number>;
|
|
92
|
+
/**
|
|
93
|
+
* The cli flag value at the last setRuntime. The flag callbacks can read
|
|
94
|
+
* live state, so the old runtime cannot give the old value.
|
|
95
|
+
*/
|
|
96
|
+
cliApiOn: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Grows on each cli flag flip. A fetch that started in an older generation
|
|
99
|
+
* must not write.
|
|
100
|
+
*/
|
|
101
|
+
clustersGeneration: number;
|
|
92
102
|
clusterCapacityLastRefreshMs: Map<string, number>;
|
|
93
103
|
} & {
|
|
94
104
|
getClusters(orgId: string): ConsoleClusterDto[] | undefined;
|
|
@@ -135,6 +135,8 @@ export const ConsoleDataStore = types
|
|
|
135
135
|
inFlightMyOrgs: false,
|
|
136
136
|
inFlightWebappClusters: new Set(),
|
|
137
137
|
clustersLastRefreshMs: new Map(),
|
|
138
|
+
cliApiOn: false,
|
|
139
|
+
clustersGeneration: 0,
|
|
138
140
|
clusterCapacityLastRefreshMs: new Map(),
|
|
139
141
|
}))
|
|
140
142
|
.views((self) => ({
|
|
@@ -196,6 +198,18 @@ export const ConsoleDataStore = types
|
|
|
196
198
|
}))
|
|
197
199
|
.actions((self) => ({
|
|
198
200
|
setRuntime(runtime) {
|
|
201
|
+
// The flags arrive after the first render. A list read from the old
|
|
202
|
+
// route before then is stale: drop it so the next fetch uses /cli/v1.
|
|
203
|
+
const cliApiOn = isConsoleCliApiOn(runtime);
|
|
204
|
+
// The first call only records the flag: the cache holds nothing from an
|
|
205
|
+
// older route yet (it can hold seeded data).
|
|
206
|
+
if (self.runtime && cliApiOn !== self.cliApiOn) {
|
|
207
|
+
self.clusters.clear();
|
|
208
|
+
self.clustersLastRefreshMs.clear();
|
|
209
|
+
self.inFlightClusters.clear();
|
|
210
|
+
self.clustersGeneration += 1;
|
|
211
|
+
}
|
|
212
|
+
self.cliApiOn = cliApiOn;
|
|
199
213
|
self.runtime = runtime;
|
|
200
214
|
},
|
|
201
215
|
upsertCluster(orgId, cluster) {
|
|
@@ -545,12 +559,20 @@ export const ConsoleDataStore = types
|
|
|
545
559
|
error: null,
|
|
546
560
|
lastFetched: cached?.lastFetched ?? null,
|
|
547
561
|
});
|
|
562
|
+
const cliApiOn = isConsoleCliApiOn(self.runtime);
|
|
563
|
+
// The flag flipped while the call ran: a newer fetch owns the cache and
|
|
564
|
+
// the in-flight marker, so this call must not touch them.
|
|
565
|
+
const generation = self.clustersGeneration;
|
|
566
|
+
const isStale = () => self.clustersGeneration !== generation;
|
|
548
567
|
try {
|
|
549
568
|
const apiConfig = toApiConfig(self.runtime);
|
|
550
|
-
const clustersList = yield cliClusterReadsApi(
|
|
569
|
+
const clustersList = yield cliClusterReadsApi(cliApiOn).getClusters({
|
|
551
570
|
params: { orgId },
|
|
552
571
|
config: apiConfig,
|
|
553
572
|
});
|
|
573
|
+
if (isStale()) {
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
554
576
|
self.clusters.set(orgId, {
|
|
555
577
|
data: clustersList,
|
|
556
578
|
isLoading: false,
|
|
@@ -560,6 +582,9 @@ export const ConsoleDataStore = types
|
|
|
560
582
|
self.clustersLastRefreshMs.set(orgId, Date.now());
|
|
561
583
|
}
|
|
562
584
|
catch (error) {
|
|
585
|
+
if (isStale()) {
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
563
588
|
self.clusters.set(orgId, {
|
|
564
589
|
data: cached?.data,
|
|
565
590
|
isLoading: false,
|
|
@@ -569,7 +594,9 @@ export const ConsoleDataStore = types
|
|
|
569
594
|
self.clustersLastRefreshMs.set(orgId, Date.now());
|
|
570
595
|
}
|
|
571
596
|
finally {
|
|
572
|
-
|
|
597
|
+
if (!isStale()) {
|
|
598
|
+
self.inFlightClusters.delete(orgId);
|
|
599
|
+
}
|
|
573
600
|
}
|
|
574
601
|
}),
|
|
575
602
|
fetchUpgradableGenerations: flow(function* (fromGenerationUuid, clusterId, options) {
|