@camunda/ccma-saas-frontend 0.35.7 → 0.35.8
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.
|
@@ -23,6 +23,7 @@ import { useCliClusterApi } from '../../runtime/use-cli-cluster-api.js';
|
|
|
23
23
|
import { useCliClusterReadsApi } from '../../runtime/use-cli-cluster-reads-api.js';
|
|
24
24
|
import { useCliExtrasApi } from '../../runtime/use-cli-extras-api.js';
|
|
25
25
|
import { useCliResourcesApi } from '../../runtime/use-cli-resources-api.js';
|
|
26
|
+
import { useConsoleCliApi } from '../../runtime/use-console-cli-api.js';
|
|
26
27
|
import { Modal, Stack, TextInput } from '../../ui/index.js';
|
|
27
28
|
import { isMigrationLocked, } from '../../utils/migration-view.js';
|
|
28
29
|
import { buildBackupChoiceUpdate, buildReopenTransferUpdate, buildTransferFinishedUpdate, getMigrationView, isMigrationPlan, MIGRATION_NAME_MAX_LENGTH, } from '../../utils/migration-workaround.js';
|
|
@@ -391,7 +392,14 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
391
392
|
setActiveTabId(props.desiredTabId);
|
|
392
393
|
}
|
|
393
394
|
}, [props.desiredTabId]);
|
|
395
|
+
// A newer reload replaces an older one that is still pending (for example
|
|
396
|
+
// when the CLI flag turns on). Only the newest call writes its result.
|
|
397
|
+
const clusterRequestRef = useRef(0);
|
|
398
|
+
const creationParametersRequestRef = useRef(0);
|
|
399
|
+
const alertsRequestRef = useRef(0);
|
|
400
|
+
const byomRequestRef = useRef(0);
|
|
394
401
|
const reloadCluster = useCallback(async () => {
|
|
402
|
+
const request = ++clusterRequestRef.current;
|
|
395
403
|
setIsClusterLoading(true);
|
|
396
404
|
setClusterError('');
|
|
397
405
|
try {
|
|
@@ -399,11 +407,17 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
399
407
|
config: apiConfig,
|
|
400
408
|
params: { orgId: props.orgId, clusterId: props.clusterId },
|
|
401
409
|
});
|
|
410
|
+
if (request !== clusterRequestRef.current) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
402
413
|
skipNextSseMergeRef.current = true;
|
|
403
414
|
setCluster(loaded);
|
|
404
415
|
data.upsertCluster(props.orgId, loaded);
|
|
405
416
|
}
|
|
406
417
|
catch (error) {
|
|
418
|
+
if (request !== clusterRequestRef.current) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
407
421
|
// A cluster that no longer exists (e.g. a stale/typo'd URL) is not an
|
|
408
422
|
// error state worth rendering inline — send the user back to the
|
|
409
423
|
// dashboard instead of showing an empty tab shell with the backend's
|
|
@@ -420,7 +434,9 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
420
434
|
setClusterError(error instanceof Error ? error.message : 'Failed to load');
|
|
421
435
|
}
|
|
422
436
|
finally {
|
|
423
|
-
|
|
437
|
+
if (request === clusterRequestRef.current) {
|
|
438
|
+
setIsClusterLoading(false);
|
|
439
|
+
}
|
|
424
440
|
}
|
|
425
441
|
}, [
|
|
426
442
|
apiConfig,
|
|
@@ -431,19 +447,26 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
431
447
|
props.orgId,
|
|
432
448
|
]);
|
|
433
449
|
const reloadCreationParameters = useCallback(async () => {
|
|
450
|
+
const request = ++creationParametersRequestRef.current;
|
|
434
451
|
setIsCreationParametersLoading(true);
|
|
435
452
|
try {
|
|
436
453
|
const loaded = await clusterReads.getCreationParameters({
|
|
437
454
|
config: apiConfig,
|
|
438
455
|
params: { orgId: props.orgId },
|
|
439
456
|
});
|
|
440
|
-
|
|
457
|
+
if (request === creationParametersRequestRef.current) {
|
|
458
|
+
setCreationParameters(loaded);
|
|
459
|
+
}
|
|
441
460
|
}
|
|
442
461
|
catch {
|
|
443
|
-
|
|
462
|
+
if (request === creationParametersRequestRef.current) {
|
|
463
|
+
setCreationParameters(undefined);
|
|
464
|
+
}
|
|
444
465
|
}
|
|
445
466
|
finally {
|
|
446
|
-
|
|
467
|
+
if (request === creationParametersRequestRef.current) {
|
|
468
|
+
setIsCreationParametersLoading(false);
|
|
469
|
+
}
|
|
447
470
|
}
|
|
448
471
|
}, [apiConfig, clusterReads, props.orgId]);
|
|
449
472
|
const canSeeClusterLoad = Boolean(authz.visibilities.clusters?.canSeeClusterLoad);
|
|
@@ -785,11 +808,13 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
785
808
|
}, []);
|
|
786
809
|
const reloadAlerts = useCallback(async () => {
|
|
787
810
|
if (!canViewAlertsTab) {
|
|
811
|
+
alertsRequestRef.current++;
|
|
788
812
|
setAlerts([]);
|
|
789
813
|
alertsLoadedRef.current = true;
|
|
790
814
|
setAlertsLoading(false);
|
|
791
815
|
return;
|
|
792
816
|
}
|
|
817
|
+
const request = ++alertsRequestRef.current;
|
|
793
818
|
setAlertsLoading(true);
|
|
794
819
|
try {
|
|
795
820
|
const [loaded] = await Promise.all([
|
|
@@ -800,6 +825,9 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
800
825
|
data.fetchMembers(props.orgId),
|
|
801
826
|
]);
|
|
802
827
|
const members = data.getMembers(props.orgId) ?? [];
|
|
828
|
+
if (request !== alertsRequestRef.current) {
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
803
831
|
setAlerts(loaded.map((a) => {
|
|
804
832
|
const alert = a;
|
|
805
833
|
const resolvedTarget = a.report === 'Webhook'
|
|
@@ -825,8 +853,10 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
825
853
|
}));
|
|
826
854
|
}
|
|
827
855
|
finally {
|
|
828
|
-
|
|
829
|
-
|
|
856
|
+
if (request === alertsRequestRef.current) {
|
|
857
|
+
alertsLoadedRef.current = true;
|
|
858
|
+
setAlertsLoading(false);
|
|
859
|
+
}
|
|
830
860
|
}
|
|
831
861
|
}, [
|
|
832
862
|
apiConfig,
|
|
@@ -1020,6 +1050,7 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
1020
1050
|
]);
|
|
1021
1051
|
const reloadByom = useCallback(async () => {
|
|
1022
1052
|
if (!canViewMonitoringTab) {
|
|
1053
|
+
byomRequestRef.current++;
|
|
1023
1054
|
setByomClients([]);
|
|
1024
1055
|
setByomStatus({});
|
|
1025
1056
|
setByomError(false);
|
|
@@ -1027,6 +1058,7 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
1027
1058
|
setByomLoading(false);
|
|
1028
1059
|
return;
|
|
1029
1060
|
}
|
|
1061
|
+
const request = ++byomRequestRef.current;
|
|
1030
1062
|
setByomLoading(true);
|
|
1031
1063
|
setByomError(false);
|
|
1032
1064
|
try {
|
|
@@ -1034,6 +1066,9 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
1034
1066
|
config: apiConfig,
|
|
1035
1067
|
params: { orgId: props.orgId, clusterId: props.clusterId },
|
|
1036
1068
|
});
|
|
1069
|
+
if (request !== byomRequestRef.current) {
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1037
1072
|
setByomStatus(response.status ?? {});
|
|
1038
1073
|
setByomClients((response.clients ?? []).map((client) => ({
|
|
1039
1074
|
id: client.uuid,
|
|
@@ -1044,13 +1079,18 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
1044
1079
|
})));
|
|
1045
1080
|
}
|
|
1046
1081
|
catch {
|
|
1082
|
+
if (request !== byomRequestRef.current) {
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1047
1085
|
setByomError(true);
|
|
1048
1086
|
setByomClients([]);
|
|
1049
1087
|
setByomStatus({});
|
|
1050
1088
|
}
|
|
1051
1089
|
finally {
|
|
1052
|
-
|
|
1053
|
-
|
|
1090
|
+
if (request === byomRequestRef.current) {
|
|
1091
|
+
byomLoadedRef.current = true;
|
|
1092
|
+
setByomLoading(false);
|
|
1093
|
+
}
|
|
1054
1094
|
}
|
|
1055
1095
|
}, [
|
|
1056
1096
|
apiConfig,
|
|
@@ -1088,7 +1128,10 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
1088
1128
|
// -----------------------------
|
|
1089
1129
|
// Initial load: load all tab data once per org/cluster
|
|
1090
1130
|
// -----------------------------
|
|
1091
|
-
|
|
1131
|
+
// On a hard load the flag answer comes after authz. The key holds the flag
|
|
1132
|
+
// so the load runs again with the right services when it changes.
|
|
1133
|
+
const cliApiOn = useConsoleCliApi();
|
|
1134
|
+
const initialLoadKey = `${props.orgId}:${props.clusterId}:${cliApiOn}`;
|
|
1092
1135
|
const lastInitialLoadKeyRef = useRef(undefined);
|
|
1093
1136
|
useEffect(() => {
|
|
1094
1137
|
// Wait for authz to resolve so tab visibility is stable.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* under one or more contributor license agreements. Licensed under a commercial license.
|
|
4
4
|
* You may not use this file except in compliance with the commercial license.
|
|
5
5
|
*/
|
|
6
|
-
import { useCallback, useState } from 'react';
|
|
6
|
+
import { useCallback, useRef, useState } from 'react';
|
|
7
7
|
import { useCliResourcesApi } from '../../runtime/use-cli-resources-api.js';
|
|
8
8
|
/**
|
|
9
9
|
* The cluster's API clients, with the load/error/reload state the clients panel
|
|
@@ -23,12 +23,19 @@ export function useClusterApiClients(params) {
|
|
|
23
23
|
const [clients, setClients] = useState([]);
|
|
24
24
|
const [loading, setLoading] = useState(false);
|
|
25
25
|
const [error, setError] = useState(false);
|
|
26
|
+
// A newer reload replaces an older one that is still pending. Only the
|
|
27
|
+
// newest call writes its result.
|
|
28
|
+
const requestRef = useRef(0);
|
|
26
29
|
const reload = useCallback(async () => {
|
|
27
30
|
if (!enabled) {
|
|
31
|
+
// Drop a request that is still pending.
|
|
32
|
+
requestRef.current++;
|
|
28
33
|
setClients([]);
|
|
29
34
|
setError(false);
|
|
35
|
+
setLoading(false);
|
|
30
36
|
return;
|
|
31
37
|
}
|
|
38
|
+
const request = ++requestRef.current;
|
|
32
39
|
setLoading(true);
|
|
33
40
|
setError(false);
|
|
34
41
|
try {
|
|
@@ -36,13 +43,19 @@ export function useClusterApiClients(params) {
|
|
|
36
43
|
config: apiConfig,
|
|
37
44
|
params: { orgId, clusterId },
|
|
38
45
|
});
|
|
39
|
-
|
|
46
|
+
if (request === requestRef.current) {
|
|
47
|
+
setClients(loaded);
|
|
48
|
+
}
|
|
40
49
|
}
|
|
41
50
|
catch {
|
|
42
|
-
|
|
51
|
+
if (request === requestRef.current) {
|
|
52
|
+
setError(true);
|
|
53
|
+
}
|
|
43
54
|
}
|
|
44
55
|
finally {
|
|
45
|
-
|
|
56
|
+
if (request === requestRef.current) {
|
|
57
|
+
setLoading(false);
|
|
58
|
+
}
|
|
46
59
|
}
|
|
47
60
|
}, [apiConfig, clusterId, enabled, orgId, resourcesApi]);
|
|
48
61
|
return { clients, loading, error, reload };
|