@camunda/ccma-saas-frontend 0.0.45 → 0.0.46
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/components/c4-cluster-list/c4-cluster-list.d.ts +1 -1
- package/lib/esm/components/c4-cluster-list/c4-cluster-list.js +13 -1
- package/lib/esm/components/c4-cluster-list/c4-cluster-list.types.d.ts +4 -0
- package/lib/esm/components/c4-cluster-settings/c4-cluster-settings.d.ts +1 -1
- package/lib/esm/components/c4-cluster-settings/c4-cluster-settings.js +5 -2
- package/lib/esm/components/c4-cluster-settings/c4-cluster-settings.types.d.ts +4 -0
- package/lib/esm/components/c4-cluster-settings/elements/optimize-filtering-settings.d.ts +17 -0
- package/lib/esm/components/c4-cluster-settings/elements/optimize-filtering-settings.js +75 -0
- package/lib/esm/i18n/c4-console-i18n.js +4 -0
- package/lib/esm/i18n/en/pages/clusters.json +5 -1
- package/lib/esm/runtime/c4-console-authz.d.ts +1 -0
- package/lib/esm/runtime/c4-console-authz.js +1 -0
- package/lib/esm/widgets/cluster-details/c4-cluster-details-app.js +11 -1
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-hot-backups-tab.d.ts +7 -0
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-hot-backups-tab.js +5 -2
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-hot-backups-tab.spec.js +49 -1
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-settings-tab.js +53 -0
- package/lib/esm/widgets/clusters/c4-clusters-page.d.ts +1 -1
- package/lib/esm/widgets/clusters/c4-clusters-page.js +186 -6
- package/lib/esm/widgets/clusters/c4-clusters-page.spec.js +87 -0
- package/lib/esm/widgets/clusters/c4-clusters-page.types.d.ts +2 -0
- package/lib/esm/widgets/job-worker/c4-job-worker.helpers.js +14 -2
- package/package.json +12 -12
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type JSX } from 'react';
|
|
2
2
|
import type { C4ClusterListProps } from './c4-cluster-list.types';
|
|
3
|
-
export declare const C4ClusterList: ({ clusters, loading, urls, permissions, onNavigate, onDeleteCluster, onAssignTag, onWakeCluster, trialNotification, encryptionNotification, clusterCapMessage, emptyStateContent, translations, isClusterPaused, isRunningOnUnsupportedGeneration, }: C4ClusterListProps) => JSX.Element;
|
|
3
|
+
export declare const C4ClusterList: ({ clusters, loading, urls, permissions, onNavigate, onDeleteCluster, onAssignTag, onWakeCluster, onFailoverCluster, trialNotification, encryptionNotification, clusterCapMessage, emptyStateContent, translations, isClusterPaused, isMultiRegionCluster, isRunningOnUnsupportedGeneration, }: C4ClusterListProps) => JSX.Element;
|
|
@@ -25,7 +25,7 @@ function isPlainLeftClick(event) {
|
|
|
25
25
|
!event.ctrlKey &&
|
|
26
26
|
!event.shiftKey);
|
|
27
27
|
}
|
|
28
|
-
export const C4ClusterList = ({ clusters, loading, urls, permissions, onNavigate, onDeleteCluster, onAssignTag, onWakeCluster, trialNotification, encryptionNotification, clusterCapMessage, emptyStateContent, translations, isClusterPaused, isRunningOnUnsupportedGeneration, }) => {
|
|
28
|
+
export const C4ClusterList = ({ clusters, loading, urls, permissions, onNavigate, onDeleteCluster, onAssignTag, onWakeCluster, onFailoverCluster, trialNotification, encryptionNotification, clusterCapMessage, emptyStateContent, translations, isClusterPaused, isMultiRegionCluster, isRunningOnUnsupportedGeneration, }) => {
|
|
29
29
|
const tableContainerRef = useRef(null);
|
|
30
30
|
const stableClustersRef = useRef(clusters.map((cluster) => ({ ...cluster })));
|
|
31
31
|
const selectedPageRef = useRef(1);
|
|
@@ -307,6 +307,18 @@ export const C4ClusterList = ({ clusters, loading, urls, permissions, onNavigate
|
|
|
307
307
|
onClick: (row) => onWakeCluster(row.id),
|
|
308
308
|
visible: (row) => isClusterPaused(row.id) && permissions.canWakeCluster,
|
|
309
309
|
},
|
|
310
|
+
...(onFailoverCluster && isMultiRegionCluster
|
|
311
|
+
? [
|
|
312
|
+
{
|
|
313
|
+
id: 'failover-cluster',
|
|
314
|
+
label: translations.overflowMenu.failover ?? 'Failover',
|
|
315
|
+
kind: 'ghost',
|
|
316
|
+
onClick: (row) => onFailoverCluster(row.id),
|
|
317
|
+
visible: (row) => (permissions.canFailoverCluster ?? false) &&
|
|
318
|
+
isMultiRegionCluster(row.id),
|
|
319
|
+
},
|
|
320
|
+
]
|
|
321
|
+
: []),
|
|
310
322
|
{
|
|
311
323
|
id: 'delete-cluster',
|
|
312
324
|
label: translations.overflowMenu.delete,
|
|
@@ -21,6 +21,7 @@ export interface ClusterListPermissions {
|
|
|
21
21
|
canUpdateTag: boolean;
|
|
22
22
|
canSeeClusterLoad: boolean;
|
|
23
23
|
canWakeCluster: boolean;
|
|
24
|
+
canFailoverCluster?: boolean;
|
|
24
25
|
createClusterButtonDisabled: boolean;
|
|
25
26
|
}
|
|
26
27
|
export interface ClusterListNotification {
|
|
@@ -40,6 +41,7 @@ export interface C4ClusterListProps {
|
|
|
40
41
|
onDeleteCluster: (clusterId: string) => void;
|
|
41
42
|
onAssignTag: (clusterId: string) => void;
|
|
42
43
|
onWakeCluster: (clusterId: string) => void;
|
|
44
|
+
onFailoverCluster?: (clusterId: string) => void;
|
|
43
45
|
trialNotification?: React.ReactNode;
|
|
44
46
|
encryptionNotification?: ClusterListNotification;
|
|
45
47
|
clusterCapMessage?: string;
|
|
@@ -63,6 +65,7 @@ export interface C4ClusterListProps {
|
|
|
63
65
|
overflowMenu: {
|
|
64
66
|
delete: string;
|
|
65
67
|
resume: string;
|
|
68
|
+
failover?: string;
|
|
66
69
|
};
|
|
67
70
|
tags: {
|
|
68
71
|
addLabel: string;
|
|
@@ -72,5 +75,6 @@ export interface C4ClusterListProps {
|
|
|
72
75
|
};
|
|
73
76
|
};
|
|
74
77
|
isClusterPaused: (clusterId: string) => boolean;
|
|
78
|
+
isMultiRegionCluster?: (clusterId: string) => boolean;
|
|
75
79
|
isRunningOnUnsupportedGeneration: (clusterId: string) => boolean;
|
|
76
80
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { JSX } from 'react';
|
|
2
2
|
import type { C4ClusterSettingsProps } from './c4-cluster-settings.types';
|
|
3
|
-
export declare const C4ClusterSettings: ({ settings, tasklistSettings, dangerZone, }: C4ClusterSettingsProps) => JSX.Element;
|
|
3
|
+
export declare const C4ClusterSettings: ({ settings, tasklistSettings, optimizeFilteringSettings, dangerZone, }: C4ClusterSettingsProps) => JSX.Element;
|
|
@@ -7,11 +7,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
7
7
|
import { Stack } from '@carbon/react';
|
|
8
8
|
import { ClusterSettings } from './elements/cluster-settings.js';
|
|
9
9
|
import { DangerZone } from './elements/danger-zone.js';
|
|
10
|
+
import { OptimizeFilteringSettings } from './elements/optimize-filtering-settings.js';
|
|
11
|
+
import { SettingsTile } from './elements/settings-tile.js';
|
|
10
12
|
import { TasklistSettings } from './elements/tasklist-mode-settings.js';
|
|
11
|
-
export const C4ClusterSettings = ({ settings, tasklistSettings, dangerZone, }) => {
|
|
13
|
+
export const C4ClusterSettings = ({ settings, tasklistSettings, optimizeFilteringSettings, dangerZone, }) => {
|
|
12
14
|
const settingsComponent = _jsx(ClusterSettings, { ...settings });
|
|
13
15
|
const tasklistComponent = tasklistSettings?.enabled && (_jsx(TasklistSettings, { ...tasklistSettings }));
|
|
16
|
+
const optimizeFilteringComponent = optimizeFilteringSettings ? (_jsx(SettingsTile, { title: optimizeFilteringSettings.title, children: _jsx(OptimizeFilteringSettings, { filtering: optimizeFilteringSettings.filtering, permissions: optimizeFilteringSettings.permissions, onToggle: optimizeFilteringSettings.onToggle, onSave: optimizeFilteringSettings.onSave }) })) : undefined;
|
|
14
17
|
const dangerZoneComponent = dangerZone ? (_jsx(DangerZone, { ...dangerZone })) : undefined;
|
|
15
|
-
const component = (_jsxs(Stack, { gap: 6, children: [settingsComponent, tasklistComponent, dangerZoneComponent] }));
|
|
18
|
+
const component = (_jsxs(Stack, { gap: 6, children: [settingsComponent, tasklistComponent, optimizeFilteringComponent, dangerZoneComponent] }));
|
|
16
19
|
return component;
|
|
17
20
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ClusterSettingsProps } from './elements/cluster-settings';
|
|
2
2
|
import type { DangerZoneProps } from './elements/danger-zone';
|
|
3
|
+
import type { OptimizeFilteringSettingsProps } from './elements/optimize-filtering-settings';
|
|
3
4
|
import type { SwaggerToggleProps } from './elements/swagger-toggle';
|
|
4
5
|
import type { TasklistModeToggleProps } from './elements/tasklist-mode-toggle';
|
|
5
6
|
export interface C4ClusterSettingsProps {
|
|
@@ -8,5 +9,8 @@ export interface C4ClusterSettingsProps {
|
|
|
8
9
|
title: string;
|
|
9
10
|
};
|
|
10
11
|
swaggerToggle?: SwaggerToggleProps;
|
|
12
|
+
optimizeFilteringSettings?: OptimizeFilteringSettingsProps & {
|
|
13
|
+
title: string;
|
|
14
|
+
};
|
|
11
15
|
dangerZone?: DangerZoneProps;
|
|
12
16
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type JSX } from 'react';
|
|
2
|
+
export interface OptimizeFilteringConfig {
|
|
3
|
+
includeProcessIds?: string[] | null;
|
|
4
|
+
excludeProcessIds?: string[] | null;
|
|
5
|
+
includeVariableNames?: string[] | null;
|
|
6
|
+
excludeVariableNames?: string[] | null;
|
|
7
|
+
}
|
|
8
|
+
export interface OptimizeFilteringSettingsProps {
|
|
9
|
+
/** undefined = filtering deactivated / not configured */
|
|
10
|
+
filtering: OptimizeFilteringConfig | undefined;
|
|
11
|
+
permissions: {
|
|
12
|
+
mayChange: boolean;
|
|
13
|
+
};
|
|
14
|
+
onToggle: (enabled: boolean) => Promise<void>;
|
|
15
|
+
onSave: (config: OptimizeFilteringConfig) => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare const OptimizeFilteringSettings: ({ filtering, permissions, onToggle, onSave, }: OptimizeFilteringSettingsProps) => JSX.Element;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
|
|
4
|
+
* under one or more contributor license agreements. Licensed under a commercial license.
|
|
5
|
+
* You may not use this file except in compliance with the commercial license.
|
|
6
|
+
*/
|
|
7
|
+
import { Button, Stack, TextArea } from '@carbon/react';
|
|
8
|
+
import { useEffect, useState } from 'react';
|
|
9
|
+
import { C4Divider } from '../../c4-divider/c4-divider.js';
|
|
10
|
+
import { C4Toggle } from '../../c4-toggle/c4-toggle.js';
|
|
11
|
+
function patternsToText(patterns) {
|
|
12
|
+
return patterns?.join('\n') ?? '';
|
|
13
|
+
}
|
|
14
|
+
function textToPatterns(text) {
|
|
15
|
+
const trimmed = text
|
|
16
|
+
.split('\n')
|
|
17
|
+
.map((s) => s.trim())
|
|
18
|
+
.filter(Boolean);
|
|
19
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
20
|
+
}
|
|
21
|
+
export const OptimizeFilteringSettings = ({ filtering, permissions, onToggle, onSave, }) => {
|
|
22
|
+
const isActive = filtering !== undefined;
|
|
23
|
+
const [includeProcessIds, setIncludeProcessIds] = useState(patternsToText(filtering?.includeProcessIds));
|
|
24
|
+
const [excludeProcessIds, setExcludeProcessIds] = useState(patternsToText(filtering?.excludeProcessIds));
|
|
25
|
+
const [includeVariableNames, setIncludeVariableNames] = useState(patternsToText(filtering?.includeVariableNames));
|
|
26
|
+
const [excludeVariableNames, setExcludeVariableNames] = useState(patternsToText(filtering?.excludeVariableNames));
|
|
27
|
+
const [isSaving, setIsSaving] = useState(false);
|
|
28
|
+
const [isToggling, setIsToggling] = useState(false);
|
|
29
|
+
// Sync text fields from server state. Blocked while a toggle is in flight so
|
|
30
|
+
// intermediate renders (e.g. isClusterLoading flipping) don't clear edits.
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (isToggling)
|
|
33
|
+
return;
|
|
34
|
+
setIncludeProcessIds(patternsToText(filtering?.includeProcessIds));
|
|
35
|
+
setExcludeProcessIds(patternsToText(filtering?.excludeProcessIds));
|
|
36
|
+
setIncludeVariableNames(patternsToText(filtering?.includeVariableNames));
|
|
37
|
+
setExcludeVariableNames(patternsToText(filtering?.excludeVariableNames));
|
|
38
|
+
}, [filtering, isToggling]);
|
|
39
|
+
const handleToggle = async () => {
|
|
40
|
+
setIsToggling(true);
|
|
41
|
+
try {
|
|
42
|
+
await onToggle(!isActive);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// error notification is shown by the parent handler
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
setIsToggling(false);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const handleSave = async () => {
|
|
52
|
+
setIsSaving(true);
|
|
53
|
+
try {
|
|
54
|
+
await onSave({
|
|
55
|
+
includeProcessIds: textToPatterns(includeProcessIds),
|
|
56
|
+
excludeProcessIds: textToPatterns(excludeProcessIds),
|
|
57
|
+
includeVariableNames: textToPatterns(includeVariableNames),
|
|
58
|
+
excludeVariableNames: textToPatterns(excludeVariableNames),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
setIsSaving(false);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const isPending = isToggling || isSaving;
|
|
66
|
+
return (_jsxs(Stack, { gap: 6, children: [_jsx(C4Toggle, { id: 'optimize-filtering-toggle', supported: true, enabled: isActive, title: 'Enable data filters', notices: [
|
|
67
|
+
{
|
|
68
|
+
notice: 'When enabled, the Optimize exporter will only process data matching the configured include/exclude patterns. Patterns support wildcards (e.g. business_*).',
|
|
69
|
+
},
|
|
70
|
+
], onClick: handleToggle, permissions: { mayToggle: permissions.mayChange && !isPending } }), isActive && (_jsxs(_Fragment, { children: [_jsx(C4Divider, {}), _jsx("p", { style: {
|
|
71
|
+
color: 'var(--cds-text-secondary)',
|
|
72
|
+
fontSize: 'var(--cds-body-compact-01-font-size)',
|
|
73
|
+
maxWidth: '650px',
|
|
74
|
+
}, children: "Enter one pattern per line. Wildcards (*) are supported." }), _jsxs(Stack, { gap: 5, style: { maxWidth: '650px' }, children: [_jsx(TextArea, { id: 'optimize-include-process-ids', labelText: 'Include process definitions', helperText: 'Only process definitions with a matching bpmnProcessId will be exported. All records for those processes follow the same rule.', value: includeProcessIds, onChange: (e) => setIncludeProcessIds(e.target.value), disabled: !permissions.mayChange || isPending, rows: 3 }), _jsx(TextArea, { id: 'optimize-exclude-process-ids', labelText: 'Exclude process definitions', helperText: 'Process definitions with a matching bpmnProcessId will not be exported. Exclusion takes precedence over inclusion.', value: excludeProcessIds, onChange: (e) => setExcludeProcessIds(e.target.value), disabled: !permissions.mayChange || isPending, rows: 3 }), _jsx(TextArea, { id: 'optimize-include-variable-names', labelText: 'Include variable names', helperText: 'Only variables with matching names will be exported', value: includeVariableNames, onChange: (e) => setIncludeVariableNames(e.target.value), disabled: !permissions.mayChange || isPending, rows: 3 }), _jsx(TextArea, { id: 'optimize-exclude-variable-names', labelText: 'Exclude variable names', helperText: 'Variables with matching names will not be exported', value: excludeVariableNames, onChange: (e) => setExcludeVariableNames(e.target.value), disabled: !permissions.mayChange || isPending, rows: 3 }), permissions.mayChange && (_jsx("div", { children: _jsx(Button, { size: 'md', kind: 'primary', onClick: handleSave, disabled: isPending, children: isSaving ? 'Saving…' : 'Save filters' }) }))] })] }))] }));
|
|
75
|
+
};
|
|
@@ -51,6 +51,7 @@ const resources = {
|
|
|
51
51
|
overflowMenu: {
|
|
52
52
|
delete: 'Delete',
|
|
53
53
|
resume: 'Resume',
|
|
54
|
+
failover: 'Failover',
|
|
54
55
|
},
|
|
55
56
|
},
|
|
56
57
|
tags: {
|
|
@@ -65,6 +66,9 @@ const resources = {
|
|
|
65
66
|
text: 'Complete the remaining steps to finalize the cluster creation.',
|
|
66
67
|
},
|
|
67
68
|
},
|
|
69
|
+
details: {
|
|
70
|
+
jobDashboard: 'Job dashboard',
|
|
71
|
+
},
|
|
68
72
|
},
|
|
69
73
|
clusterDetails: {
|
|
70
74
|
tag: {
|
|
@@ -32,9 +32,13 @@
|
|
|
32
32
|
"overflowMenu": {
|
|
33
33
|
"rename": "Rename",
|
|
34
34
|
"delete": "Delete",
|
|
35
|
-
"resume": "Resume"
|
|
35
|
+
"resume": "Resume",
|
|
36
|
+
"failover": "Failover"
|
|
36
37
|
}
|
|
37
38
|
},
|
|
39
|
+
"details": {
|
|
40
|
+
"jobDashboard": "Job dashboard"
|
|
41
|
+
},
|
|
38
42
|
"createModal": {
|
|
39
43
|
"title": "Create new cluster",
|
|
40
44
|
"createButton": "Create",
|
|
@@ -134,6 +134,7 @@ export function deriveConsoleAuthzFromAccessToken(params) {
|
|
|
134
134
|
// Backport behavior exposed cluster load to org members with cluster
|
|
135
135
|
// read access, while still allowing token-scoped internal access.
|
|
136
136
|
canSeeClusterLoad: canSeeClusterLoadFromOrgPermissions ?? clusters.canReadAllClusterInfo,
|
|
137
|
+
canFailover: canCreateFromOrgPermissions ?? clusters.createOnBehalf,
|
|
137
138
|
},
|
|
138
139
|
};
|
|
139
140
|
return {
|
|
@@ -277,6 +277,7 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
277
277
|
config: apiConfig,
|
|
278
278
|
params: { orgId: props.orgId, clusterId: props.clusterId },
|
|
279
279
|
});
|
|
280
|
+
skipNextSseMergeRef.current = true;
|
|
280
281
|
setCluster(loaded);
|
|
281
282
|
data.upsertCluster(props.orgId, loaded);
|
|
282
283
|
}
|
|
@@ -305,6 +306,11 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
305
306
|
}
|
|
306
307
|
}, [apiConfig, props.orgId]);
|
|
307
308
|
const canSeeClusterLoad = Boolean(authz.visibilities.clusters?.canSeeClusterLoad);
|
|
309
|
+
// After a manual reload, skip the immediately-following SSE merge. A stale
|
|
310
|
+
// SSE event that arrives during the PATCH+reload cycle can overwrite the
|
|
311
|
+
// fresh getCluster() result via mergeNestedSnapshot (e.g. an SSE payload
|
|
312
|
+
// that still carries the old externalMetadata before the PATCH was applied).
|
|
313
|
+
const skipNextSseMergeRef = useRef(false);
|
|
308
314
|
const clusterLoadLoadedRef = useRef(false);
|
|
309
315
|
const reloadClusterLoad = useCallback(async () => {
|
|
310
316
|
if (!canSeeClusterLoad) {
|
|
@@ -807,6 +813,10 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
807
813
|
if (!found || typeof found !== 'object') {
|
|
808
814
|
return;
|
|
809
815
|
}
|
|
816
|
+
if (skipNextSseMergeRef.current) {
|
|
817
|
+
skipNextSseMergeRef.current = false;
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
810
820
|
setCluster((previous) => {
|
|
811
821
|
if (!previous) {
|
|
812
822
|
return found;
|
|
@@ -1075,7 +1085,7 @@ export const C4ClusterDetailsApp = observer((props) => {
|
|
|
1075
1085
|
hotBackups: urls.docs.hotBackups,
|
|
1076
1086
|
support: urls.docs.support,
|
|
1077
1087
|
contact: urls.docs.contact,
|
|
1078
|
-
}, t: t, onNavigate: props.onNavigate }));
|
|
1088
|
+
}, t: t, onNavigate: props.onNavigate, onReloadCluster: reloadCluster }));
|
|
1079
1089
|
const auditLogComponent = useMemo(() => {
|
|
1080
1090
|
const state = cluster?.externalMetadata?.auditLog;
|
|
1081
1091
|
const enabled = state?.enabled ?? true;
|
|
@@ -17,6 +17,13 @@ interface C4ClusterDetailsHotBackupsTabProps {
|
|
|
17
17
|
};
|
|
18
18
|
t?: TranslateFn;
|
|
19
19
|
onNavigate?: (event: C4ClusterDetailsNavigateEvent) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Re-fetches the cluster. The restore-in-progress notification and the
|
|
22
|
+
* edit lockdown key off `cluster.restoreInProgress`, which only changes
|
|
23
|
+
* when the cluster itself is reloaded — so the tab must trigger this after
|
|
24
|
+
* confirming a restore for the UI to update without a page refresh.
|
|
25
|
+
*/
|
|
26
|
+
onReloadCluster?: () => void | Promise<void>;
|
|
20
27
|
}
|
|
21
28
|
export declare const C4ClusterDetailsHotBackupsTab: (props: C4ClusterDetailsHotBackupsTabProps) => JSX.Element;
|
|
22
29
|
export {};
|
|
@@ -95,7 +95,7 @@ function safeTranslate(t, key, fallback) {
|
|
|
95
95
|
return result === key ? fallback : result;
|
|
96
96
|
}
|
|
97
97
|
export const C4ClusterDetailsHotBackupsTab = (props) => {
|
|
98
|
-
const { cluster, orgId, clusterId, apiConfig, canMutateCluster, isHotBackupEnabled, docsUrls, t, onNavigate, } = props;
|
|
98
|
+
const { cluster, orgId, clusterId, apiConfig, canMutateCluster, isHotBackupEnabled, docsUrls, t, onNavigate, onReloadCluster, } = props;
|
|
99
99
|
const data = useC4ConsoleData();
|
|
100
100
|
const runtime = useC4ConsoleRuntime();
|
|
101
101
|
const { add: addNotification } = useC4ConsoleNotifications();
|
|
@@ -534,7 +534,10 @@ export const C4ClusterDetailsHotBackupsTab = (props) => {
|
|
|
534
534
|
params: { orgId, clusterId, backupId },
|
|
535
535
|
});
|
|
536
536
|
setRestoreBackupOpen(false);
|
|
537
|
-
|
|
537
|
+
// Reload the backup list AND the cluster: the latter flips
|
|
538
|
+
// `restoreInProgress`, which drives the restore notification
|
|
539
|
+
// and the edit lockdown instantly, without a page refresh.
|
|
540
|
+
await Promise.all([reloadHotBackups(), onReloadCluster?.()]);
|
|
538
541
|
}
|
|
539
542
|
catch (error) {
|
|
540
543
|
setBackupMutationError(error instanceof Error ? error.message : 'Failed');
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ConsoleBackupScheduleService, ConsoleHotBackupsService, } from '@camunda/ccma-api';
|
|
3
|
+
import { BackupStatus } from '@camunda/ccma-shared-types';
|
|
3
4
|
import { cleanup, render, screen, waitFor } from '@testing-library/react';
|
|
4
5
|
import userEvent from '@testing-library/user-event';
|
|
5
6
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
@@ -23,6 +24,7 @@ vi.mock('@camunda/ccma-api', async () => {
|
|
|
23
24
|
getHotBackups: vi.fn(),
|
|
24
25
|
createHotBackup: vi.fn(),
|
|
25
26
|
deleteHotBackup: vi.fn(),
|
|
27
|
+
restoreHotBackup: vi.fn(),
|
|
26
28
|
},
|
|
27
29
|
ConsoleBackupScheduleService: {
|
|
28
30
|
getBackupSchedule: vi.fn(),
|
|
@@ -41,10 +43,17 @@ vi.mock('../../../components/c4-cluster-details-hot-backups/c4-cluster-details-h
|
|
|
41
43
|
return {
|
|
42
44
|
C4ClusterDetailsHotBackups: (props) => {
|
|
43
45
|
lastHotBackupsProps = props;
|
|
44
|
-
return (_jsxs("div", { children: [_jsx("div", { children: "Hot backups" }), _jsx("button", { type: 'button', onClick: props.onGiveFeedback, children: props.text.giveFeedback })] }));
|
|
46
|
+
return (_jsxs("div", { children: [_jsx("div", { children: "Hot backups" }), _jsx("button", { type: 'button', onClick: props.onGiveFeedback, children: props.text.giveFeedback }), props.backups.map((backup) => (_jsx("button", { type: 'button', onClick: () => props.onRestoreBackup?.(backup.uuid), children: `restore-${backup.uuid}` }, backup.uuid)))] }));
|
|
45
47
|
},
|
|
46
48
|
};
|
|
47
49
|
});
|
|
50
|
+
// Stub the restore modal so the test can drive its confirm callback directly,
|
|
51
|
+
// without rendering the real Carbon modal.
|
|
52
|
+
vi.mock('../../../components/c4-cluster-details-hot-backups-restore/c4-cluster-details-hot-backups-restore', () => {
|
|
53
|
+
return {
|
|
54
|
+
C4ClusterDetailsHotBackupsRestore: (props) => props.open ? (_jsx("button", { type: 'button', onClick: () => props.onConfirm(props.backup.id), children: "confirm-restore" })) : null,
|
|
55
|
+
};
|
|
56
|
+
});
|
|
48
57
|
function buildCluster() {
|
|
49
58
|
return {
|
|
50
59
|
uuid: 'cluster-1',
|
|
@@ -128,4 +137,43 @@ describe('C4ClusterDetailsHotBackupsTab', () => {
|
|
|
128
137
|
expect(ConsoleBackupScheduleService.getBackupSchedule).toHaveBeenCalledTimes(1);
|
|
129
138
|
});
|
|
130
139
|
});
|
|
140
|
+
it('reloads the cluster after confirming a restore so the lockdown applies instantly', async () => {
|
|
141
|
+
const user = userEvent.setup();
|
|
142
|
+
const onReloadCluster = vi.fn().mockResolvedValue(undefined);
|
|
143
|
+
vi.mocked(ConsoleHotBackupsService.getHotBackups).mockResolvedValue([
|
|
144
|
+
{
|
|
145
|
+
uuid: 'backup-1',
|
|
146
|
+
name: 'Backup 1',
|
|
147
|
+
status: BackupStatus.COMPLETE,
|
|
148
|
+
generationUuid: 'gen-1',
|
|
149
|
+
generationName: 'Gen',
|
|
150
|
+
created: '2025-01-01T00:00:00Z',
|
|
151
|
+
completed: '2025-01-01T01:00:00Z',
|
|
152
|
+
},
|
|
153
|
+
]);
|
|
154
|
+
vi.mocked(ConsoleBackupScheduleService.getBackupSchedule).mockResolvedValue([]);
|
|
155
|
+
vi.mocked(ConsoleHotBackupsService.restoreHotBackup).mockResolvedValue(undefined);
|
|
156
|
+
render(_jsx(C4ConsoleRuntimeProvider, { config: {
|
|
157
|
+
stage: 'dev',
|
|
158
|
+
auth: { getAccessToken: async () => 'token' },
|
|
159
|
+
backendUrls: {},
|
|
160
|
+
}, children: _jsx(C4ConsoleNotificationsProvider, { children: _jsx(C4ClusterDetailsHotBackupsTab, { cluster: buildCluster(), orgId: 'org-1', clusterId: 'cluster-1', apiConfig: apiConfig, canMutateCluster: true, isHotBackupEnabled: true, docsUrls: {
|
|
161
|
+
hotBackups: 'https://docs.example/hot-backups',
|
|
162
|
+
support: 'https://docs.example/support',
|
|
163
|
+
contact: 'https://docs.example/contact',
|
|
164
|
+
}, onReloadCluster: onReloadCluster }) }) }));
|
|
165
|
+
// Open the restore modal for the backup, then confirm.
|
|
166
|
+
await user.click(await screen.findByText('restore-backup-1'));
|
|
167
|
+
await user.click(await screen.findByText('confirm-restore'));
|
|
168
|
+
await waitFor(() => {
|
|
169
|
+
expect(ConsoleHotBackupsService.restoreHotBackup).toHaveBeenCalledWith(expect.objectContaining({
|
|
170
|
+
params: {
|
|
171
|
+
orgId: 'org-1',
|
|
172
|
+
clusterId: 'cluster-1',
|
|
173
|
+
backupId: 'backup-1',
|
|
174
|
+
},
|
|
175
|
+
}));
|
|
176
|
+
expect(onReloadCluster).toHaveBeenCalledTimes(1);
|
|
177
|
+
});
|
|
178
|
+
});
|
|
131
179
|
});
|
|
@@ -440,6 +440,49 @@ export const C4ClusterDetailsSettingsTab = (props) => {
|
|
|
440
440
|
const shouldShowMultiTenancy = useMemo(() => {
|
|
441
441
|
return checkClusterVersion('8.8.0-alpha7') && isMultiTenancyFeatureEnabled;
|
|
442
442
|
}, [checkClusterVersion, isMultiTenancyFeatureEnabled]);
|
|
443
|
+
const isOptimizeFilteringFeatureEnabled = runtime.featureFlags?.isEnabled?.('console.optimizeFiltering') ?? false;
|
|
444
|
+
const shouldShowOptimizeFiltering = useMemo(() => {
|
|
445
|
+
return (checkClusterVersion('8.10.0-alpha1') && isOptimizeFilteringFeatureEnabled);
|
|
446
|
+
}, [checkClusterVersion, isOptimizeFilteringFeatureEnabled]);
|
|
447
|
+
const handleOptimizeFilteringToggle = useCallback(async (enabled) => {
|
|
448
|
+
try {
|
|
449
|
+
await ConsoleClusterService.updateCluster({
|
|
450
|
+
config: props.apiConfig,
|
|
451
|
+
params: { orgId: props.orgId, clusterId: props.clusterId },
|
|
452
|
+
body: { optimizeFiltering: enabled ? {} : null },
|
|
453
|
+
});
|
|
454
|
+
await props.onReloadCluster();
|
|
455
|
+
}
|
|
456
|
+
catch (error) {
|
|
457
|
+
setOperationError(settingUpdateFailedFallback);
|
|
458
|
+
throw error;
|
|
459
|
+
}
|
|
460
|
+
}, [
|
|
461
|
+
props.apiConfig,
|
|
462
|
+
props.orgId,
|
|
463
|
+
props.clusterId,
|
|
464
|
+
props.onReloadCluster,
|
|
465
|
+
settingUpdateFailedFallback,
|
|
466
|
+
]);
|
|
467
|
+
const handleOptimizeFilteringSave = useCallback(async (config) => {
|
|
468
|
+
try {
|
|
469
|
+
await ConsoleClusterService.updateCluster({
|
|
470
|
+
config: props.apiConfig,
|
|
471
|
+
params: { orgId: props.orgId, clusterId: props.clusterId },
|
|
472
|
+
body: { optimizeFiltering: config },
|
|
473
|
+
});
|
|
474
|
+
await props.onReloadCluster();
|
|
475
|
+
}
|
|
476
|
+
catch (error) {
|
|
477
|
+
setOperationError(settingUpdateFailedFallback);
|
|
478
|
+
}
|
|
479
|
+
}, [
|
|
480
|
+
props.apiConfig,
|
|
481
|
+
props.orgId,
|
|
482
|
+
props.clusterId,
|
|
483
|
+
props.onReloadCluster,
|
|
484
|
+
settingUpdateFailedFallback,
|
|
485
|
+
]);
|
|
443
486
|
if (!props.cluster)
|
|
444
487
|
return _jsx(_Fragment, {});
|
|
445
488
|
const isSubjectToIdentityAuthorization = checkClusterVersion('8.8.0-alpha5');
|
|
@@ -688,6 +731,16 @@ export const C4ClusterDetailsSettingsTab = (props) => {
|
|
|
688
731
|
false),
|
|
689
732
|
},
|
|
690
733
|
},
|
|
734
|
+
}), ...(shouldShowOptimizeFiltering && {
|
|
735
|
+
optimizeFilteringSettings: {
|
|
736
|
+
title: 'Data filters',
|
|
737
|
+
filtering: props.cluster.externalMetadata?.optimizeFiltering ?? undefined,
|
|
738
|
+
permissions: {
|
|
739
|
+
mayChange: effectiveCanEdit,
|
|
740
|
+
},
|
|
741
|
+
onToggle: handleOptimizeFilteringToggle,
|
|
742
|
+
onSave: handleOptimizeFilteringSave,
|
|
743
|
+
},
|
|
691
744
|
}), dangerZone: {
|
|
692
745
|
title: safeTranslate(props.t, 'clusterdetails:settings.dangerZone.title', 'Danger zone'),
|
|
693
746
|
deleteCluster: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { C4ClustersPageProps } from './c4-clusters-page.types';
|
|
2
|
-
export declare const C4ClustersPage: (({ orgId, gettingStartedHref, onNavigate, translations, permissionsOverride, clusterCapMessage, isClusterPaused: isClusterPausedOverride, isRunningOnUnsupportedGeneration: isRunningOnUnsupportedGenerationOverride, onRequestAssignTag, onRequestDeleteCluster, onRequestWakeCluster, }: C4ClustersPageProps) => import("react").JSX.Element) & {
|
|
2
|
+
export declare const C4ClustersPage: (({ orgId, gettingStartedHref, onNavigate, translations, permissionsOverride, clusterCapMessage, isClusterPaused: isClusterPausedOverride, isRunningOnUnsupportedGeneration: isRunningOnUnsupportedGenerationOverride, onRequestAssignTag, onRequestDeleteCluster, onRequestWakeCluster, onRequestFailoverCluster, }: C4ClustersPageProps) => import("react").JSX.Element) & {
|
|
3
3
|
displayName: string;
|
|
4
4
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { ClusterEncryptionKey, OrganizationRole, SalesPlanType, } from '@camunda/ccma-shared-types';
|
|
2
|
+
import { BackupStatus, ClusterEncryptionKey, OrganizationRole, SalesPlanType, } from '@camunda/ccma-shared-types';
|
|
3
3
|
import { InlineNotification, Modal, Select, SelectItem, Stack, TextInput, } from '@carbon/react';
|
|
4
4
|
import { observer } from 'mobx-react-lite';
|
|
5
5
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
@@ -126,7 +126,17 @@ function buildDefaultTranslations(t) {
|
|
|
126
126
|
const translate = (key, fallback) => {
|
|
127
127
|
try {
|
|
128
128
|
const translated = t?.(key);
|
|
129
|
-
|
|
129
|
+
// Guard against i18n implementations that strip the namespace prefix on
|
|
130
|
+
// a missing key (e.g. t('ns:a.b') → 'a.b') — same fix applied in safeT.
|
|
131
|
+
const keyWithoutNamespace = key.includes(':')
|
|
132
|
+
? key.split(':').slice(1).join(':')
|
|
133
|
+
: key;
|
|
134
|
+
if (!translated ||
|
|
135
|
+
translated === key ||
|
|
136
|
+
translated === keyWithoutNamespace) {
|
|
137
|
+
return fallback;
|
|
138
|
+
}
|
|
139
|
+
return translated;
|
|
130
140
|
}
|
|
131
141
|
catch {
|
|
132
142
|
return fallback;
|
|
@@ -151,6 +161,7 @@ function buildDefaultTranslations(t) {
|
|
|
151
161
|
overflowMenu: {
|
|
152
162
|
delete: translate('c4console:clusters.list.overflowMenu.delete', 'Delete'),
|
|
153
163
|
resume: translate('c4console:clusters.list.overflowMenu.resume', 'Resume'),
|
|
164
|
+
failover: translate('c4console:clusters.list.overflowMenu.failover', 'Failover'),
|
|
154
165
|
},
|
|
155
166
|
tags: {
|
|
156
167
|
addLabel: translate('c4console:clusters.tags.addLabel', 'Add tag'),
|
|
@@ -203,7 +214,7 @@ function mergePermissions(base, override) {
|
|
|
203
214
|
}
|
|
204
215
|
return { ...base, ...override };
|
|
205
216
|
}
|
|
206
|
-
export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate, translations, permissionsOverride, clusterCapMessage, isClusterPaused: isClusterPausedOverride, isRunningOnUnsupportedGeneration: isRunningOnUnsupportedGenerationOverride, onRequestAssignTag, onRequestDeleteCluster, onRequestWakeCluster, }) => {
|
|
217
|
+
export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate, translations, permissionsOverride, clusterCapMessage, isClusterPaused: isClusterPausedOverride, isRunningOnUnsupportedGeneration: isRunningOnUnsupportedGenerationOverride, onRequestAssignTag, onRequestDeleteCluster, onRequestWakeCluster, onRequestFailoverCluster, }) => {
|
|
207
218
|
const resolvedGettingStartedHref = useMemo(() => getC4ClustersGettingStartedHref(gettingStartedHref), [gettingStartedHref]);
|
|
208
219
|
const runtime = useC4ConsoleRuntime();
|
|
209
220
|
const data = useC4ConsoleData();
|
|
@@ -235,6 +246,14 @@ export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate,
|
|
|
235
246
|
const [wakeTarget, setWakeTarget] = useState(undefined);
|
|
236
247
|
const [wakeBusy, setWakeBusy] = useState(false);
|
|
237
248
|
const [wakeError, setWakeError] = useState(undefined);
|
|
249
|
+
const [failoverModalOpen, setFailoverModalOpen] = useState(false);
|
|
250
|
+
const [failoverTarget, setFailoverTarget] = useState(undefined);
|
|
251
|
+
const [failoverBusy, setFailoverBusy] = useState(false);
|
|
252
|
+
const [failoverError, setFailoverError] = useState(undefined);
|
|
253
|
+
const [failoverBackups, setFailoverBackups] = useState([]);
|
|
254
|
+
const [failoverBackupsLoading, setFailoverBackupsLoading] = useState(false);
|
|
255
|
+
const [failoverBackupsError, setFailoverBackupsError] = useState(false);
|
|
256
|
+
const [selectedBackupId, setSelectedBackupId] = useState('');
|
|
238
257
|
useEffect(() => {
|
|
239
258
|
if (!orgId) {
|
|
240
259
|
return;
|
|
@@ -326,6 +345,12 @@ export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate,
|
|
|
326
345
|
const item = mapClusterToListItem(rawCluster, index);
|
|
327
346
|
if (!item)
|
|
328
347
|
return undefined;
|
|
348
|
+
// A restoring cluster pauses reconciliation (and may report a
|
|
349
|
+
// suspended/paused status); surface the more specific "Restoring"
|
|
350
|
+
// state so the list matches the restore-in-progress notification.
|
|
351
|
+
if (getBoolean(rawCluster, 'restoreInProgress')) {
|
|
352
|
+
return { ...item, status: 'restoring' };
|
|
353
|
+
}
|
|
329
354
|
if (isClusterReconciliationPaused(rawCluster)) {
|
|
330
355
|
return { ...item, status: 'maintenance' };
|
|
331
356
|
}
|
|
@@ -494,6 +519,15 @@ export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate,
|
|
|
494
519
|
hideCloseButton: true,
|
|
495
520
|
}
|
|
496
521
|
: undefined;
|
|
522
|
+
const orgFailoverLimitEnabled = useMemo(() => {
|
|
523
|
+
if (!orgInfo || typeof orgInfo !== 'object')
|
|
524
|
+
return false;
|
|
525
|
+
const limits = getPathUnknown(orgInfo, [
|
|
526
|
+
'organizationToSalesPlan',
|
|
527
|
+
'limits',
|
|
528
|
+
]);
|
|
529
|
+
return getBoolean(limits ?? {}, 'failover') === true;
|
|
530
|
+
}, [orgInfo]);
|
|
497
531
|
const derivedPermissions = useMemo(() => {
|
|
498
532
|
const clustersVisibility = authz.visibilities.clusters;
|
|
499
533
|
const base = {
|
|
@@ -503,10 +537,15 @@ export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate,
|
|
|
503
537
|
canUpdateTag: clustersVisibility?.canUpdateTag ?? false,
|
|
504
538
|
canSeeClusterLoad: clustersVisibility?.canSeeClusterLoad ?? false,
|
|
505
539
|
canWakeCluster: clustersVisibility?.canWake ?? false,
|
|
540
|
+
canFailoverCluster: (clustersVisibility?.canFailover ?? false) && orgFailoverLimitEnabled,
|
|
506
541
|
createClusterButtonDisabled: !(clustersVisibility?.canCreate ?? false),
|
|
507
542
|
};
|
|
508
543
|
return mergePermissions(base, permissionsOverride);
|
|
509
|
-
}, [
|
|
544
|
+
}, [
|
|
545
|
+
authz.visibilities.clusters,
|
|
546
|
+
orgFailoverLimitEnabled,
|
|
547
|
+
permissionsOverride,
|
|
548
|
+
]);
|
|
510
549
|
const resolvedTranslations = useMemo(() => {
|
|
511
550
|
if (translations) {
|
|
512
551
|
return translations;
|
|
@@ -629,6 +668,53 @@ export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate,
|
|
|
629
668
|
runtime.telemetry?.track?.('c4Clusters.wake.requested', { clusterId });
|
|
630
669
|
}
|
|
631
670
|
};
|
|
671
|
+
const handleFailoverCluster = (clusterId) => {
|
|
672
|
+
onRequestFailoverCluster?.(clusterId);
|
|
673
|
+
if (!onRequestFailoverCluster) {
|
|
674
|
+
const cluster = clusterById.get(clusterId);
|
|
675
|
+
setFailoverTarget({
|
|
676
|
+
clusterId,
|
|
677
|
+
clusterName: cluster?.name ?? clusterId,
|
|
678
|
+
});
|
|
679
|
+
setFailoverError(undefined);
|
|
680
|
+
setSelectedBackupId('');
|
|
681
|
+
setFailoverBackups([]);
|
|
682
|
+
setFailoverModalOpen(true);
|
|
683
|
+
runtime.telemetry?.track?.('c4Clusters.failover.requested', {
|
|
684
|
+
clusterId,
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
useEffect(() => {
|
|
689
|
+
if (!failoverTarget || !failoverModalOpen)
|
|
690
|
+
return;
|
|
691
|
+
let cancelled = false;
|
|
692
|
+
setFailoverBackupsLoading(true);
|
|
693
|
+
setFailoverBackupsError(false);
|
|
694
|
+
import('@camunda/ccma-api')
|
|
695
|
+
.then(({ ConsoleHotBackupsService }) => ConsoleHotBackupsService.getHotBackups({
|
|
696
|
+
config: apiConfig,
|
|
697
|
+
params: { orgId, clusterId: failoverTarget.clusterId },
|
|
698
|
+
}))
|
|
699
|
+
.then((backups) => {
|
|
700
|
+
if (cancelled)
|
|
701
|
+
return;
|
|
702
|
+
setFailoverBackups(backups.filter((b) => b.status === BackupStatus.COMPLETE));
|
|
703
|
+
})
|
|
704
|
+
.catch(() => {
|
|
705
|
+
if (cancelled)
|
|
706
|
+
return;
|
|
707
|
+
setFailoverBackupsError(true);
|
|
708
|
+
})
|
|
709
|
+
.finally(() => {
|
|
710
|
+
if (cancelled)
|
|
711
|
+
return;
|
|
712
|
+
setFailoverBackupsLoading(false);
|
|
713
|
+
});
|
|
714
|
+
return () => {
|
|
715
|
+
cancelled = true;
|
|
716
|
+
};
|
|
717
|
+
}, [failoverTarget, failoverModalOpen, orgId, apiConfig]);
|
|
632
718
|
const isClusterPausedFallback = (clusterId) => {
|
|
633
719
|
const status = clusterStatusById.get(clusterId);
|
|
634
720
|
return status === 'suspended';
|
|
@@ -636,6 +722,32 @@ export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate,
|
|
|
636
722
|
const isRunningOnUnsupportedGenerationFallback = (clusterId) => {
|
|
637
723
|
return unsupportedGenerationById.get(clusterId) ?? false;
|
|
638
724
|
};
|
|
725
|
+
const multiRegionClusterIds = useMemo(() => {
|
|
726
|
+
const set = new Set();
|
|
727
|
+
for (const rawCluster of rawClusters) {
|
|
728
|
+
// Failover requires a secondary region to fail over to. A selected
|
|
729
|
+
// backup config (`backupRegionId`) is not enough — that config can be
|
|
730
|
+
// single-region. `backupRegionCodes` holds one entry for single-region
|
|
731
|
+
// backups and two (primary → secondary) for dual-region ones, so only
|
|
732
|
+
// clusters with more than one code can actually be failed over.
|
|
733
|
+
const backupRegionCodes = rawCluster.backupRegionCodes;
|
|
734
|
+
if (!Array.isArray(backupRegionCodes) ||
|
|
735
|
+
backupRegionCodes.length <= 1) {
|
|
736
|
+
continue;
|
|
737
|
+
}
|
|
738
|
+
// Must use the same priority as mapClusterToListItem so the ID stored
|
|
739
|
+
// here matches the row.id the action's visible() receives.
|
|
740
|
+
const clusterId = getString(rawCluster, 'id') ??
|
|
741
|
+
getString(rawCluster, 'clusterId') ??
|
|
742
|
+
getString(rawCluster, 'uuid') ??
|
|
743
|
+
getString(rawCluster, 'clusterUuid');
|
|
744
|
+
if (clusterId) {
|
|
745
|
+
set.add(clusterId);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
return set;
|
|
749
|
+
}, [rawClusters]);
|
|
750
|
+
const isMultiRegionClusterFallback = useCallback((clusterId) => multiRegionClusterIds.has(clusterId), [multiRegionClusterIds]);
|
|
639
751
|
const isPageLoading = isLoading || authz.isLoading;
|
|
640
752
|
useEffect(() => {
|
|
641
753
|
if (!error) {
|
|
@@ -646,7 +758,7 @@ export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate,
|
|
|
646
758
|
orgId,
|
|
647
759
|
});
|
|
648
760
|
}, [error, orgId, runtime.telemetry]);
|
|
649
|
-
return (_jsxs(_Fragment, { children: [_jsx(C4ClusterList, { orgId: orgId, clusters: clusters, loading: isPageLoading, urls: urls, permissions: derivedPermissions, onNavigate: handleNavigate, onDeleteCluster: handleDeleteCluster, onAssignTag: handleAssignTag, onWakeCluster: handleWakeCluster, trialNotification: derivedTrialNotification, encryptionNotification: encryptionNotification, clusterCapMessage: clusterCapMessage, emptyStateContent: derivedEmptyStateContent, translations: resolvedTranslations, isClusterPaused: isClusterPausedOverride ?? isClusterPausedFallback, isRunningOnUnsupportedGeneration: isRunningOnUnsupportedGenerationOverride ??
|
|
761
|
+
return (_jsxs(_Fragment, { children: [_jsx(C4ClusterList, { orgId: orgId, clusters: clusters, loading: isPageLoading, urls: urls, permissions: derivedPermissions, onNavigate: handleNavigate, onDeleteCluster: handleDeleteCluster, onAssignTag: handleAssignTag, onWakeCluster: handleWakeCluster, onFailoverCluster: handleFailoverCluster, trialNotification: derivedTrialNotification, encryptionNotification: encryptionNotification, clusterCapMessage: clusterCapMessage, emptyStateContent: derivedEmptyStateContent, translations: resolvedTranslations, isClusterPaused: isClusterPausedOverride ?? isClusterPausedFallback, isMultiRegionCluster: isMultiRegionClusterFallback, isRunningOnUnsupportedGeneration: isRunningOnUnsupportedGenerationOverride ??
|
|
650
762
|
isRunningOnUnsupportedGenerationFallback }), deleteTarget ? (_jsx(Modal, { open: deleteModalOpen, danger: true, modalHeading: safeTranslate('clustermodals:delete.heading', 'Delete cluster'), primaryButtonText: safeTranslate('clustermodals:delete.buttons.primary', 'Delete'), secondaryButtonText: safeTranslate('clustermodals:delete.buttons.secondary', 'Cancel'), primaryButtonDisabled: deleteBusy || deleteConfirmation.trim() !== 'DELETE', onRequestClose: () => {
|
|
651
763
|
if (deleteBusy)
|
|
652
764
|
return;
|
|
@@ -753,5 +865,73 @@ export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate,
|
|
|
753
865
|
finally {
|
|
754
866
|
setWakeBusy(false);
|
|
755
867
|
}
|
|
756
|
-
}, children: _jsxs(Stack, { gap: 4, children: [wakeError ? (_jsx(InlineNotification, { kind: 'error', lowContrast: true, title: safeTranslate('clustermodals:resume.errorMessage', 'Error resuming cluster'), subtitle: wakeError, hideCloseButton: true })) : null, _jsx("p", { children: safeTranslate('clustermodals:resume.description', `Resume ${wakeTarget.clusterName}?`) })] }) })) : null
|
|
868
|
+
}, children: _jsxs(Stack, { gap: 4, children: [wakeError ? (_jsx(InlineNotification, { kind: 'error', lowContrast: true, title: safeTranslate('clustermodals:resume.errorMessage', 'Error resuming cluster'), subtitle: wakeError, hideCloseButton: true })) : null, _jsx("p", { children: safeTranslate('clustermodals:resume.description', `Resume ${wakeTarget.clusterName}?`) })] }) })) : null, failoverTarget ? (_jsx(Modal, { open: failoverModalOpen, modalHeading: safeTranslate('clustermodals:failover.heading', 'Failover cluster'), primaryButtonText: safeTranslate('clustermodals:failover.buttons.primary', 'Start failover'), secondaryButtonText: safeTranslate('clustermodals:failover.buttons.secondary', 'Cancel'), primaryButtonDisabled: failoverBusy ||
|
|
869
|
+
failoverBackupsLoading ||
|
|
870
|
+
failoverBackupsError ||
|
|
871
|
+
selectedBackupId === '', onRequestClose: () => {
|
|
872
|
+
if (failoverBusy)
|
|
873
|
+
return;
|
|
874
|
+
setFailoverModalOpen(false);
|
|
875
|
+
}, onRequestSubmit: async () => {
|
|
876
|
+
if (failoverBusy || selectedBackupId === '')
|
|
877
|
+
return;
|
|
878
|
+
setFailoverError(undefined);
|
|
879
|
+
setFailoverBusy(true);
|
|
880
|
+
try {
|
|
881
|
+
const { ConsoleClusterService } = await import('@camunda/ccma-api');
|
|
882
|
+
const result = await ConsoleClusterService.failoverCluster({
|
|
883
|
+
config: apiConfig,
|
|
884
|
+
params: {
|
|
885
|
+
orgId,
|
|
886
|
+
clusterId: failoverTarget.clusterId,
|
|
887
|
+
backupId: selectedBackupId,
|
|
888
|
+
},
|
|
889
|
+
});
|
|
890
|
+
// Refresh regardless — the new cluster exists even on partial failure.
|
|
891
|
+
data.invalidateClusters(orgId);
|
|
892
|
+
await data.fetchClusters(orgId, { force: true });
|
|
893
|
+
const stepLabels = {
|
|
894
|
+
backupClone: 'Backup clone',
|
|
895
|
+
restore: 'Restore',
|
|
896
|
+
secureConnectivity: 'Secure connectivity',
|
|
897
|
+
};
|
|
898
|
+
const failedSteps = Object.entries(result.results).filter((entry) => typeof entry[1] === 'object' && 'error' in entry[1]);
|
|
899
|
+
if (failedSteps.length > 0) {
|
|
900
|
+
const detail = failedSteps
|
|
901
|
+
.map(([step, v]) => `${stepLabels[step] ?? step}: ${v.error}`)
|
|
902
|
+
.join(' · ');
|
|
903
|
+
setFailoverError(`Cluster created, but ${failedSteps.length} step${failedSteps.length > 1 ? 's' : ''} failed — ${detail}`);
|
|
904
|
+
runtime.telemetry?.track?.('c4Clusters.failover.partialSuccess', {
|
|
905
|
+
clusterId: failoverTarget.clusterId,
|
|
906
|
+
newClusterId: result.newClusterId,
|
|
907
|
+
failedSteps: failedSteps.map(([s]) => s),
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
else {
|
|
911
|
+
setFailoverModalOpen(false);
|
|
912
|
+
runtime.telemetry?.track?.('c4Clusters.failover.completed', {
|
|
913
|
+
clusterId: failoverTarget.clusterId,
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
catch (error) {
|
|
918
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
919
|
+
setFailoverError(message);
|
|
920
|
+
runtime.telemetry?.captureException?.(error, {
|
|
921
|
+
widget: 'C4ClustersPage',
|
|
922
|
+
action: 'failover',
|
|
923
|
+
orgId,
|
|
924
|
+
clusterId: failoverTarget.clusterId,
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
finally {
|
|
928
|
+
setFailoverBusy(false);
|
|
929
|
+
}
|
|
930
|
+
}, children: _jsxs(Stack, { gap: 4, children: [failoverBackupsError ? (_jsx(InlineNotification, { kind: 'error', lowContrast: true, title: safeTranslate('clustermodals:failover.backup.error.title', 'Could not load backups'), subtitle: safeTranslate('clustermodals:failover.backup.error.subtitle', 'Failed to fetch backups for this cluster. Check your connection and try again.'), hideCloseButton: true })) : null, failoverError ? (_jsx(InlineNotification, { kind: 'error', lowContrast: true, title: safeTranslate('clustermodals:failover.error.generic', 'Failover failed'), subtitle: failoverError, hideCloseButton: true })) : null, _jsx("p", { children: safeTranslate('clustermodals:failover.description', `This will create a new cluster in the secondary region using a backup from ${failoverTarget.clusterName}. The original cluster will remain unchanged.`, { clusterName: failoverTarget.clusterName }) }), _jsxs(Select, { id: 'c4-failover-backup-select', labelText: safeTranslate('clustermodals:failover.backup.label', 'Select backup to restore from'), value: selectedBackupId, disabled: failoverBusy || failoverBackupsLoading, onChange: (e) => setSelectedBackupId(e.target.value), children: [_jsx(SelectItem, { value: '', text: failoverBackupsLoading
|
|
931
|
+
? safeTranslate('clustermodals:failover.backup.loading', 'Loading backups…')
|
|
932
|
+
: failoverBackupsError
|
|
933
|
+
? safeTranslate('clustermodals:failover.backup.error.select', 'Backup list unavailable')
|
|
934
|
+
: failoverBackups.length === 0
|
|
935
|
+
? safeTranslate('clustermodals:failover.backup.none', 'No completed backups available')
|
|
936
|
+
: safeTranslate('clustermodals:failover.backup.placeholder', 'Select a backup') }), failoverBackups.map((backup) => (_jsx(SelectItem, { value: backup.uuid, text: `${backup.name} — ${backup.created}` }, backup.uuid)))] })] }) })) : null] }));
|
|
757
937
|
});
|
|
@@ -150,6 +150,63 @@ describe('C4ClustersPage', () => {
|
|
|
150
150
|
clusterId: 'c1',
|
|
151
151
|
});
|
|
152
152
|
});
|
|
153
|
+
it('only treats clusters with a dual-region backup config as failover-eligible', async () => {
|
|
154
|
+
vi.mocked(ConsoleClusterService.getClusters).mockResolvedValue([
|
|
155
|
+
{
|
|
156
|
+
uuid: 'no-backup',
|
|
157
|
+
name: 'No backup region',
|
|
158
|
+
generation: 'G1',
|
|
159
|
+
type: 'prod',
|
|
160
|
+
region: 'eu',
|
|
161
|
+
status: { ready: 'healthy' },
|
|
162
|
+
labels: { camunda: [], custom: [] },
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
uuid: 'single-region',
|
|
166
|
+
name: 'Single region backup',
|
|
167
|
+
generation: 'G1',
|
|
168
|
+
type: 'prod',
|
|
169
|
+
region: 'eu',
|
|
170
|
+
status: { ready: 'healthy' },
|
|
171
|
+
labels: { camunda: [], custom: [] },
|
|
172
|
+
// A backup config is selected, but it only covers the primary region —
|
|
173
|
+
// there is nothing to fail over to.
|
|
174
|
+
backupRegionId: 'backup-cfg-single',
|
|
175
|
+
backupRegionCodes: ['eu-west-1'],
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
uuid: 'dual-region',
|
|
179
|
+
name: 'Dual region backup',
|
|
180
|
+
generation: 'G1',
|
|
181
|
+
type: 'prod',
|
|
182
|
+
region: 'eu',
|
|
183
|
+
status: { ready: 'healthy' },
|
|
184
|
+
labels: { camunda: [], custom: [] },
|
|
185
|
+
backupRegionId: 'backup-cfg-dual',
|
|
186
|
+
backupRegionCodes: ['eu-west-1', 'eu-west-2'],
|
|
187
|
+
},
|
|
188
|
+
]);
|
|
189
|
+
vi.mocked(HdpService.getClusterCapacity).mockResolvedValue([]);
|
|
190
|
+
vi.mocked(OrgsService.getOrgInfo).mockResolvedValue({
|
|
191
|
+
uuid: 'org-1',
|
|
192
|
+
});
|
|
193
|
+
render(_jsx(C4ConsoleRuntimeProvider, { config: {
|
|
194
|
+
stage: 'dev',
|
|
195
|
+
auth: {
|
|
196
|
+
getAccessToken: async () => 'token',
|
|
197
|
+
},
|
|
198
|
+
backendUrls: {},
|
|
199
|
+
}, children: _jsx(C4ConsoleDataProvider, { children: _jsx(C4ClustersPage, { orgId: 'org-1', onNavigate: vi.fn() }) }) }));
|
|
200
|
+
await waitFor(() => {
|
|
201
|
+
expect(lastClusterListProps?.clusters).toHaveLength(3);
|
|
202
|
+
});
|
|
203
|
+
const isMultiRegionCluster = lastClusterListProps?.isMultiRegionCluster;
|
|
204
|
+
// Only the dual-region backup config exposes a secondary region, so it is
|
|
205
|
+
// the only cluster the failover action should be offered for.
|
|
206
|
+
expect(isMultiRegionCluster?.('no-backup')).toBe(false);
|
|
207
|
+
expect(isMultiRegionCluster?.('single-region')).toBe(false);
|
|
208
|
+
expect(isMultiRegionCluster?.('dual-region')).toBe(true);
|
|
209
|
+
});
|
|
153
210
|
it('marks spec or legacy-label paused clusters as maintenance and suppresses update suffix', async () => {
|
|
154
211
|
authzMock.features = {
|
|
155
212
|
console: {
|
|
@@ -229,6 +286,36 @@ describe('C4ClustersPage', () => {
|
|
|
229
286
|
expect(labelPausedCluster?.generation).not.toContain('update available');
|
|
230
287
|
});
|
|
231
288
|
});
|
|
289
|
+
it('marks restoring clusters with the restoring status, taking precedence over paused', async () => {
|
|
290
|
+
vi.mocked(ConsoleClusterService.getClusters).mockResolvedValue([
|
|
291
|
+
{
|
|
292
|
+
uuid: 'cluster-restoring',
|
|
293
|
+
name: 'Cluster restoring',
|
|
294
|
+
generation: '8.8',
|
|
295
|
+
type: 'prod',
|
|
296
|
+
region: 'eu',
|
|
297
|
+
status: { ready: 'healthy' },
|
|
298
|
+
labels: { camunda: [], custom: [] },
|
|
299
|
+
// Restore pauses reconciliation, so this would otherwise resolve to
|
|
300
|
+
// 'maintenance'; restoreInProgress must win.
|
|
301
|
+
restoreInProgress: true,
|
|
302
|
+
spec: { reconciliation: { paused: true } },
|
|
303
|
+
},
|
|
304
|
+
]);
|
|
305
|
+
vi.mocked(HdpService.getClusterCapacity).mockResolvedValue([]);
|
|
306
|
+
vi.mocked(OrgsService.getOrgInfo).mockResolvedValue({
|
|
307
|
+
uuid: 'org-1',
|
|
308
|
+
});
|
|
309
|
+
render(_jsx(C4ConsoleRuntimeProvider, { config: {
|
|
310
|
+
stage: 'dev',
|
|
311
|
+
auth: { getAccessToken: async () => 'token' },
|
|
312
|
+
backendUrls: {},
|
|
313
|
+
}, children: _jsx(C4ConsoleDataProvider, { children: _jsx(C4ClustersPage, { orgId: 'org-1' }) }) }));
|
|
314
|
+
await waitFor(() => {
|
|
315
|
+
const restoringCluster = lastClusterListProps?.clusters.find((cluster) => cluster.id === 'cluster-restoring');
|
|
316
|
+
expect(restoringCluster?.status).toBe('restoring');
|
|
317
|
+
});
|
|
318
|
+
});
|
|
232
319
|
it('merges permissionsOverride into derived permissions', async () => {
|
|
233
320
|
vi.mocked(ConsoleClusterService.getClusters).mockResolvedValue([]);
|
|
234
321
|
vi.mocked(HdpService.getClusterCapacity).mockResolvedValue([]);
|
|
@@ -26,6 +26,7 @@ export interface C4ClustersPageTranslations {
|
|
|
26
26
|
overflowMenu: {
|
|
27
27
|
delete: string;
|
|
28
28
|
resume: string;
|
|
29
|
+
failover?: string;
|
|
29
30
|
};
|
|
30
31
|
tags: {
|
|
31
32
|
addLabel: string;
|
|
@@ -46,4 +47,5 @@ export interface C4ClustersPageProps {
|
|
|
46
47
|
onRequestDeleteCluster?: (clusterId: string) => void;
|
|
47
48
|
onRequestAssignTag?: (clusterId: string) => void;
|
|
48
49
|
onRequestWakeCluster?: (clusterId: string) => void;
|
|
50
|
+
onRequestFailoverCluster?: (clusterId: string) => void;
|
|
49
51
|
}
|
|
@@ -10,7 +10,11 @@ export function makeTr(t) {
|
|
|
10
10
|
try {
|
|
11
11
|
const full = `jobDashboard:${key}`;
|
|
12
12
|
const result = t(full);
|
|
13
|
-
|
|
13
|
+
// Guard against the namespace-stripped form (e.g. t('jobDashboard:a.b') → 'a.b')
|
|
14
|
+
if (!result || result === full || result === key) {
|
|
15
|
+
return fallback;
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
14
18
|
}
|
|
15
19
|
catch {
|
|
16
20
|
return fallback;
|
|
@@ -22,7 +26,15 @@ export function safeT(t, key, fallback) {
|
|
|
22
26
|
return fallback;
|
|
23
27
|
try {
|
|
24
28
|
const result = t(key);
|
|
25
|
-
|
|
29
|
+
// Some i18n implementations return the key with the namespace prefix stripped
|
|
30
|
+
// (e.g. t('ns:a.b') → 'a.b') when a key is missing. Treat that as a miss too.
|
|
31
|
+
const keyWithoutNamespace = key.includes(':')
|
|
32
|
+
? key.split(':').slice(1).join(':')
|
|
33
|
+
: key;
|
|
34
|
+
if (!result || result === key || result === keyWithoutNamespace) {
|
|
35
|
+
return fallback;
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
26
38
|
}
|
|
27
39
|
catch {
|
|
28
40
|
return fallback;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camunda/ccma-saas-frontend",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46",
|
|
4
4
|
"description": "Camunda Composite Components",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/camunda/camunda-cloud-management-apps/issues"
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@camunda/c4-connectors": "1.5.0",
|
|
27
27
|
"@camunda/c4-identity": "0.0.41",
|
|
28
|
-
"@carbon/charts": "1.27.
|
|
29
|
-
"@carbon/charts-react": "1.27.
|
|
28
|
+
"@carbon/charts": "1.27.12",
|
|
29
|
+
"@carbon/charts-react": "1.27.12",
|
|
30
30
|
"@carbon/layout": "11.53.0",
|
|
31
31
|
"@carbon/motion": "^11.46.0",
|
|
32
32
|
"@carbon/react": "1.109.0",
|
|
@@ -35,25 +35,25 @@
|
|
|
35
35
|
"@carbon/type": "11.61.0",
|
|
36
36
|
"@chromatic-com/storybook": "5.2.1",
|
|
37
37
|
"@mdx-js/react": "3.1.1",
|
|
38
|
-
"@storybook/addon-docs": "10.4.
|
|
39
|
-
"@storybook/addon-links": "10.4.
|
|
40
|
-
"@storybook/react": "10.4.
|
|
41
|
-
"@storybook/react-vite": "10.4.
|
|
38
|
+
"@storybook/addon-docs": "10.4.6",
|
|
39
|
+
"@storybook/addon-links": "10.4.6",
|
|
40
|
+
"@storybook/react": "10.4.6",
|
|
41
|
+
"@storybook/react-vite": "10.4.6",
|
|
42
42
|
"@testing-library/jest-dom": "6.9.1",
|
|
43
43
|
"@testing-library/react": "16.3.2",
|
|
44
44
|
"@testing-library/user-event": "14.6.1",
|
|
45
45
|
"eslint-import-resolver-typescript": "4.4.5",
|
|
46
46
|
"eslint-plugin-react": "7.37.5",
|
|
47
47
|
"eslint-plugin-react-hooks": "7.1.1",
|
|
48
|
-
"eslint-plugin-storybook": "10.4.
|
|
48
|
+
"eslint-plugin-storybook": "10.4.6",
|
|
49
49
|
"jsdom": "29.1.1",
|
|
50
50
|
"react": "19.2.7",
|
|
51
51
|
"react-dom": "19.2.7",
|
|
52
52
|
"react-is": "19.2.7",
|
|
53
53
|
"rimraf": "6.1.3",
|
|
54
|
-
"storybook": "10.4.
|
|
54
|
+
"storybook": "10.4.6",
|
|
55
55
|
"styled-components": "6.4.2",
|
|
56
|
-
"@camunda/camunda-composite-components": "0.25.
|
|
56
|
+
"@camunda/camunda-composite-components": "0.25.1"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@camunda/c4-connectors": "1.x",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"mobx-react-lite": "4.1.1",
|
|
76
76
|
"mobx-state-tree": "7.2.0",
|
|
77
77
|
"semver": "7.8.4",
|
|
78
|
-
"@camunda/ccma-api": "0.0.
|
|
79
|
-
"@camunda/ccma-shared-types": "0.1.
|
|
78
|
+
"@camunda/ccma-api": "0.0.10",
|
|
79
|
+
"@camunda/ccma-shared-types": "0.1.3"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
82
82
|
"clean": "rimraf lib/",
|