@camunda/ccma-saas-frontend 0.37.0 → 0.37.2
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/i18n/en/modals/alerts.json +2 -1
- package/lib/esm/runtime/c4-console-data-context.js +6 -1
- package/lib/esm/runtime/c4-console-data-store.d.ts +10 -0
- package/lib/esm/runtime/c4-console-data-store.js +29 -2
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-alerts-tab.js +7 -1
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-settings-tab.js +5 -3
- package/package.json +1 -1
|
@@ -91,7 +91,8 @@
|
|
|
91
91
|
"secondary": "Cancel"
|
|
92
92
|
},
|
|
93
93
|
"loadingText": "Deleting...",
|
|
94
|
-
"description": "Are you sure you want to delete the alert",
|
|
94
|
+
"description": "Are you sure you want to delete the alert for \"{{target}}\"?",
|
|
95
|
+
"descriptionNoTarget": "Are you sure you want to delete the alert?",
|
|
95
96
|
"error": {
|
|
96
97
|
"generic": "We're having trouble deleting the alert"
|
|
97
98
|
}
|
|
@@ -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) {
|
|
@@ -47,6 +47,9 @@ export const C4ClusterDetailsAlertsTab = (props) => {
|
|
|
47
47
|
const [alertUrlInvalidText, setAlertUrlInvalidText] = useState('');
|
|
48
48
|
const [alertHmacInvalid, setAlertHmacInvalid] = useState(false);
|
|
49
49
|
const [alertHmacInvalidText, setAlertHmacInvalidText] = useState('');
|
|
50
|
+
// Kept in state, not read from props.alerts on each render: the host reloads
|
|
51
|
+
// the alerts before the dialog closes, and the text must not change then.
|
|
52
|
+
const [deleteAlertTarget, setDeleteAlertTarget] = useState('');
|
|
50
53
|
const alertEmailDestination = props.userEmail?.includes('@')
|
|
51
54
|
? ` (to ${props.userEmail})`
|
|
52
55
|
: '';
|
|
@@ -121,6 +124,7 @@ export const C4ClusterDetailsAlertsTab = (props) => {
|
|
|
121
124
|
}, onDeleteAlert: (alertId) => {
|
|
122
125
|
trackEvent('clusterOverviewAlerts:deleteModal:open', 'Open Delete Alerts Modal', { alertId });
|
|
123
126
|
setSelectedAlertId(alertId);
|
|
127
|
+
setDeleteAlertTarget(props.alerts.find((a) => a.id === alertId)?.userIdOrWebhook ?? '');
|
|
124
128
|
setAlertMutationError('');
|
|
125
129
|
setDeleteAlertOpen(true);
|
|
126
130
|
}, onNoAlertsDocsClick: () => {
|
|
@@ -242,5 +246,7 @@ export const C4ClusterDetailsAlertsTab = (props) => {
|
|
|
242
246
|
setAlertMutationBusy(false);
|
|
243
247
|
}
|
|
244
248
|
})();
|
|
245
|
-
}, children: _jsxs(Stack, { gap: 6, children: [alertMutationError && (_jsx(C4InlineNotification, { kind: 'error', title: safeTranslate(props.t, 'alerts:delete.error.generic', "We're having trouble deleting the alert"), subtitle: alertMutationError, lowContrast: true, hideCloseButton: true })), _jsx("p", {
|
|
249
|
+
}, children: _jsxs(Stack, { gap: 6, children: [alertMutationError && (_jsx(C4InlineNotification, { kind: 'error', title: safeTranslate(props.t, 'alerts:delete.error.generic', "We're having trouble deleting the alert"), subtitle: alertMutationError, lowContrast: true, hideCloseButton: true })), _jsx("p", { style: { overflowWrap: 'anywhere' }, children: deleteAlertTarget
|
|
250
|
+
? safeTranslate(props.t, 'alerts:delete.description', `Are you sure you want to delete the alert for "${deleteAlertTarget}"?`, { target: deleteAlertTarget })
|
|
251
|
+
: safeTranslate(props.t, 'alerts:delete.descriptionNoTarget', 'Are you sure you want to delete the alert?') })] }) })] }));
|
|
246
252
|
};
|
|
@@ -249,10 +249,12 @@ export const C4ClusterDetailsSettingsTab = (props) => {
|
|
|
249
249
|
setIsUpdatingLowLatency(false);
|
|
250
250
|
}
|
|
251
251
|
}, [props, clusterApi, runtime.telemetry]);
|
|
252
|
+
// Unset means on: the cluster runs Swagger until it is switched off.
|
|
253
|
+
const isSwaggerEnabled = props.cluster?.externalMetadata?.swagger ?? true;
|
|
252
254
|
const toggleSwagger = useCallback(async () => {
|
|
253
255
|
if (!props.cluster)
|
|
254
256
|
return;
|
|
255
|
-
const nextState = !
|
|
257
|
+
const nextState = !isSwaggerEnabled;
|
|
256
258
|
setIsUpdatingSwagger(true);
|
|
257
259
|
try {
|
|
258
260
|
await clusterApi.updateCluster({
|
|
@@ -275,7 +277,7 @@ export const C4ClusterDetailsSettingsTab = (props) => {
|
|
|
275
277
|
finally {
|
|
276
278
|
setIsUpdatingSwagger(false);
|
|
277
279
|
}
|
|
278
|
-
}, [props, clusterApi, runtime.telemetry]);
|
|
280
|
+
}, [props, clusterApi, runtime.telemetry, isSwaggerEnabled]);
|
|
279
281
|
const updateSecretsFilterMode = useCallback(async (mode) => {
|
|
280
282
|
if (!props.cluster)
|
|
281
283
|
return;
|
|
@@ -1041,7 +1043,7 @@ export const C4ClusterDetailsSettingsTab = (props) => {
|
|
|
1041
1043
|
},
|
|
1042
1044
|
...(isSwaggerToggleVisible && {
|
|
1043
1045
|
swaggerToggle: {
|
|
1044
|
-
enabled:
|
|
1046
|
+
enabled: isSwaggerEnabled,
|
|
1045
1047
|
description: (_jsxs(_Fragment, { children: [safeTranslate(props.t, 'clusterdetails:settings.swagger.description', 'The Orchestration Cluster REST API is documented using the'), ' ', _jsx(Link, { href: 'https://github.com/camunda/camunda/blob/main/zeebe/gateway-protocol/src/main/proto/rest-api.yaml', target: '_blank', children: safeTranslate(props.t, 'clusterdetails:settings.swagger.spec', 'OpenAPI specification') }), safeTranslate(props.t, 'clusterdetails:settings.swagger.description2', '. When enabled, it is accessible via Swagger UI.'), _jsx("br", {}), _jsx("br", {}), (() => {
|
|
1046
1048
|
const swaggerUrl = buildClusterSwaggerUrl({
|
|
1047
1049
|
cluster: props.cluster,
|