@camunda/ccma-saas-frontend 0.0.44 → 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-app-teaser-cards/c4-app-teaser-cards.d.ts +1 -1
- package/lib/esm/components/c4-cluster-client-credentials/c4-cluster-client-credentials.d.ts +3 -3
- package/lib/esm/components/c4-cluster-client-credentials-identity/c4-cluster-client-credentials-identity.d.ts +3 -3
- 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-overview/c4-cluster-overview.d.ts +1 -1
- 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/components/c4-cluster-settings/elements/tasklist-mode-toggle.d.ts +1 -1
- package/lib/esm/components/c4-console-dashboard/elements/empty-state.d.ts +1 -1
- package/lib/esm/components/c4-create-cluster/c4-create-cluster.js +1 -1
- package/lib/esm/components/c4-create-cluster/c4-create-cluster.spec.js +3 -3
- package/lib/esm/components/c4-create-console-api-client-modal/c4-create-console-api-client-modal.js +8 -0
- package/lib/esm/components/c4-divider/c4-divider.d.ts +1 -1
- package/lib/esm/components/c4-job-dashboard-details-page/c4-job-dashboard-details-page.d.ts +1 -1
- package/lib/esm/components/c4-job-dashboard-details-page/elements/c4-job-dashboard-error-table.d.ts +1 -1
- package/lib/esm/components/c4-job-dashboard-details-page/elements/c4-job-dashboard-piechart.d.ts +1 -1
- package/lib/esm/components/c4-job-dashboard-details-page/elements/c4-job-dashboard-worker-table.d.ts +1 -1
- package/lib/esm/components/c4-job-dashboard-shared/c4-job-dashboard-time-range-dropdown.d.ts +1 -1
- package/lib/esm/components/c4-job-dashboard-shared/c4-timestamp-information.d.ts +1 -1
- package/lib/esm/components/c4-multi-step-modal-ugly/c4-multi-step-modal-ugly.d.ts +1 -1
- package/lib/esm/components/c4-number-input/c4-number-input.d.ts +1 -1
- package/lib/esm/components/c4-page-template/c4-page-template.d.ts +1 -1
- package/lib/esm/components/c4-search/c4-search-results.d.ts +1 -1
- package/lib/esm/components/c4-telemetry-page/metrics-empty-state-image.d.ts +1 -1
- package/lib/esm/i18n/c4-console-i18n.js +4 -0
- package/lib/esm/i18n/en/modals/clusters.json +6 -0
- package/lib/esm/i18n/en/pages/clusterdetails.json +4 -0
- package/lib/esm/i18n/en/pages/clusters.json +5 -1
- package/lib/esm/i18n/en/pages/createcluster.json +1 -1
- package/lib/esm/icons/c4-icons.d.ts +11 -11
- package/lib/esm/runtime/c4-console-authz.d.ts +1 -0
- package/lib/esm/runtime/c4-console-authz.js +1 -0
- package/lib/esm/runtime/c4-console-data-context.d.ts +1 -1
- package/lib/esm/runtime/c4-console-data-context.js +2 -2
- package/lib/esm/runtime/c4-console-data-context.types.d.ts +3 -3
- package/lib/esm/runtime/c4-console-data-store.d.ts +3 -3
- package/lib/esm/runtime/c4-console-data-store.js +34 -15
- package/lib/esm/runtime/c4-console-data-store.spec.js +55 -1
- package/lib/esm/runtime/c4-console-notifications-context.d.ts +1 -1
- package/lib/esm/runtime/c4-console-runtime-context.d.ts +1 -1
- package/lib/esm/widgets/cluster-details/c4-cluster-details-app.js +34 -2
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-clients-tab.spec.js +1 -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-ip-whitelist-tab.js +37 -2
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-overview-tab.js +91 -50
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-overview-tab.spec.js +226 -3
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-secure-connectivity-tab.js +17 -4
- package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-settings-tab.js +56 -1
- package/lib/esm/widgets/clusters/c4-clusters-page.d.ts +1 -1
- package/lib/esm/widgets/clusters/c4-clusters-page.js +207 -17
- 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/connector-management/c4-connector-management-executable-details-page.d.ts +1 -1
- package/lib/esm/widgets/connector-management/c4-connector-management-executables-table-page.d.ts +1 -1
- package/lib/esm/widgets/connector-management/c4-connector-management-page.d.ts +1 -1
- package/lib/esm/widgets/create-cluster/c4-create-cluster-page.js +1 -1
- package/lib/esm/widgets/job-worker/c4-job-worker.helpers.js +14 -2
- package/package.json +22 -22
|
@@ -11,7 +11,9 @@ import { isClusterReconciliationPaused } from '../../is-cluster-reconciliation-p
|
|
|
11
11
|
function safeTranslate(translateFn, key, fallback, options) {
|
|
12
12
|
try {
|
|
13
13
|
const result = translateFn(key, options);
|
|
14
|
-
const keyWithoutNamespace = key.includes(':')
|
|
14
|
+
const keyWithoutNamespace = key.includes(':')
|
|
15
|
+
? key.split(':').slice(1).join(':')
|
|
16
|
+
: key;
|
|
15
17
|
if (result === key || result === keyWithoutNamespace) {
|
|
16
18
|
return fallback;
|
|
17
19
|
}
|
|
@@ -438,6 +440,49 @@ export const C4ClusterDetailsSettingsTab = (props) => {
|
|
|
438
440
|
const shouldShowMultiTenancy = useMemo(() => {
|
|
439
441
|
return checkClusterVersion('8.8.0-alpha7') && isMultiTenancyFeatureEnabled;
|
|
440
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
|
+
]);
|
|
441
486
|
if (!props.cluster)
|
|
442
487
|
return _jsx(_Fragment, {});
|
|
443
488
|
const isSubjectToIdentityAuthorization = checkClusterVersion('8.8.0-alpha5');
|
|
@@ -686,6 +731,16 @@ export const C4ClusterDetailsSettingsTab = (props) => {
|
|
|
686
731
|
false),
|
|
687
732
|
},
|
|
688
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
|
+
},
|
|
689
744
|
}), dangerZone: {
|
|
690
745
|
title: safeTranslate(props.t, 'clusterdetails:settings.dangerZone.title', 'Danger zone'),
|
|
691
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
|
|
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;
|
|
@@ -271,21 +290,27 @@ export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate,
|
|
|
271
290
|
const isLoading = clustersCache?.isLoading ?? false;
|
|
272
291
|
const error = clustersCache?.error;
|
|
273
292
|
const upgradableGenerationsCache = data.upgradableGenerations;
|
|
293
|
+
const generationToClusterId = useMemo(() => {
|
|
294
|
+
const map = new Map();
|
|
295
|
+
for (const rawCluster of rawClusters) {
|
|
296
|
+
const genUuid = getClusterGenerationUuid(rawCluster);
|
|
297
|
+
const clusterUuid = getString(rawCluster, 'uuid') ??
|
|
298
|
+
getString(rawCluster, 'id') ??
|
|
299
|
+
getString(rawCluster, 'clusterId');
|
|
300
|
+
if (genUuid && clusterUuid && !map.has(genUuid)) {
|
|
301
|
+
map.set(genUuid, clusterUuid);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return map;
|
|
305
|
+
}, [rawClusters]);
|
|
274
306
|
useEffect(() => {
|
|
275
307
|
if (rawClusters.length === 0) {
|
|
276
308
|
return;
|
|
277
309
|
}
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
const generationUuid = getClusterGenerationUuid(rawCluster);
|
|
281
|
-
if (generationUuid) {
|
|
282
|
-
uniqueGenerationUuids.add(generationUuid);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
for (const generationUuid of uniqueGenerationUuids) {
|
|
286
|
-
void data.fetchUpgradableGenerations(generationUuid);
|
|
310
|
+
for (const [generationUuid, clusterId] of generationToClusterId) {
|
|
311
|
+
void data.fetchUpgradableGenerations(generationUuid, clusterId);
|
|
287
312
|
}
|
|
288
|
-
}, [data.fetchUpgradableGenerations, rawClusters]);
|
|
313
|
+
}, [data.fetchUpgradableGenerations, generationToClusterId, rawClusters]);
|
|
289
314
|
// Map cluster load from context
|
|
290
315
|
const clusterLoadData = useMemo(() => {
|
|
291
316
|
return clusterCapacityMap;
|
|
@@ -320,12 +345,21 @@ export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate,
|
|
|
320
345
|
const item = mapClusterToListItem(rawCluster, index);
|
|
321
346
|
if (!item)
|
|
322
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
|
+
}
|
|
323
354
|
if (isClusterReconciliationPaused(rawCluster)) {
|
|
324
355
|
return { ...item, status: 'maintenance' };
|
|
325
356
|
}
|
|
326
357
|
const generationUuid = getClusterGenerationUuid(rawCluster);
|
|
358
|
+
const representativeClusterId = generationUuid
|
|
359
|
+
? generationToClusterId.get(generationUuid)
|
|
360
|
+
: undefined;
|
|
327
361
|
const upgradableCount = generationUuid
|
|
328
|
-
? (data.getUpgradableGenerations(generationUuid)?.length ?? 0)
|
|
362
|
+
? (data.getUpgradableGenerations(generationUuid, representativeClusterId)?.options.length ?? 0)
|
|
329
363
|
: 0;
|
|
330
364
|
const zeebeStatus = getPathString(rawCluster, [
|
|
331
365
|
'status',
|
|
@@ -355,6 +389,7 @@ export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate,
|
|
|
355
389
|
authz,
|
|
356
390
|
clusterLoadData,
|
|
357
391
|
data,
|
|
392
|
+
generationToClusterId,
|
|
358
393
|
isOrgAdmin,
|
|
359
394
|
rawClusters,
|
|
360
395
|
runtime.i18n,
|
|
@@ -484,6 +519,15 @@ export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate,
|
|
|
484
519
|
hideCloseButton: true,
|
|
485
520
|
}
|
|
486
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]);
|
|
487
531
|
const derivedPermissions = useMemo(() => {
|
|
488
532
|
const clustersVisibility = authz.visibilities.clusters;
|
|
489
533
|
const base = {
|
|
@@ -493,10 +537,15 @@ export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate,
|
|
|
493
537
|
canUpdateTag: clustersVisibility?.canUpdateTag ?? false,
|
|
494
538
|
canSeeClusterLoad: clustersVisibility?.canSeeClusterLoad ?? false,
|
|
495
539
|
canWakeCluster: clustersVisibility?.canWake ?? false,
|
|
540
|
+
canFailoverCluster: (clustersVisibility?.canFailover ?? false) && orgFailoverLimitEnabled,
|
|
496
541
|
createClusterButtonDisabled: !(clustersVisibility?.canCreate ?? false),
|
|
497
542
|
};
|
|
498
543
|
return mergePermissions(base, permissionsOverride);
|
|
499
|
-
}, [
|
|
544
|
+
}, [
|
|
545
|
+
authz.visibilities.clusters,
|
|
546
|
+
orgFailoverLimitEnabled,
|
|
547
|
+
permissionsOverride,
|
|
548
|
+
]);
|
|
500
549
|
const resolvedTranslations = useMemo(() => {
|
|
501
550
|
if (translations) {
|
|
502
551
|
return translations;
|
|
@@ -619,6 +668,53 @@ export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate,
|
|
|
619
668
|
runtime.telemetry?.track?.('c4Clusters.wake.requested', { clusterId });
|
|
620
669
|
}
|
|
621
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]);
|
|
622
718
|
const isClusterPausedFallback = (clusterId) => {
|
|
623
719
|
const status = clusterStatusById.get(clusterId);
|
|
624
720
|
return status === 'suspended';
|
|
@@ -626,6 +722,32 @@ export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate,
|
|
|
626
722
|
const isRunningOnUnsupportedGenerationFallback = (clusterId) => {
|
|
627
723
|
return unsupportedGenerationById.get(clusterId) ?? false;
|
|
628
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]);
|
|
629
751
|
const isPageLoading = isLoading || authz.isLoading;
|
|
630
752
|
useEffect(() => {
|
|
631
753
|
if (!error) {
|
|
@@ -636,7 +758,7 @@ export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate,
|
|
|
636
758
|
orgId,
|
|
637
759
|
});
|
|
638
760
|
}, [error, orgId, runtime.telemetry]);
|
|
639
|
-
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 ??
|
|
640
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: () => {
|
|
641
763
|
if (deleteBusy)
|
|
642
764
|
return;
|
|
@@ -743,5 +865,73 @@ export const C4ClustersPage = observer(({ orgId, gettingStartedHref, onNavigate,
|
|
|
743
865
|
finally {
|
|
744
866
|
setWakeBusy(false);
|
|
745
867
|
}
|
|
746
|
-
}, 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] }));
|
|
747
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
|
}
|
package/lib/esm/widgets/connector-management/c4-connector-management-executable-details-page.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { C4ConnectorManagementExecutableDetailsPageProps } from './c4-connector-management-executable-details-page.types';
|
|
2
|
-
export declare const C4ConnectorManagementExecutableDetailsPage: (({ orgId, clusterId, connectorId, connectorInstanceId, onNavigate, }: C4ConnectorManagementExecutableDetailsPageProps) => import("react
|
|
2
|
+
export declare const C4ConnectorManagementExecutableDetailsPage: (({ orgId, clusterId, connectorId, connectorInstanceId, onNavigate, }: C4ConnectorManagementExecutableDetailsPageProps) => import("react").JSX.Element) & {
|
|
3
3
|
displayName: string;
|
|
4
4
|
};
|
package/lib/esm/widgets/connector-management/c4-connector-management-executables-table-page.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { C4ConnectorManagementExecutablesTablePageProps } from './c4-connector-management-executables-table-page.types';
|
|
2
|
-
export declare const C4ConnectorManagementExecutablesTablePage: (({ orgId, clusterId, connectorId, onNavigate, }: C4ConnectorManagementExecutablesTablePageProps) => import("react
|
|
2
|
+
export declare const C4ConnectorManagementExecutablesTablePage: (({ orgId, clusterId, connectorId, onNavigate, }: C4ConnectorManagementExecutablesTablePageProps) => import("react").JSX.Element) & {
|
|
3
3
|
displayName: string;
|
|
4
4
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { C4ConnectorManagementPageProps } from './c4-connector-management-page.types';
|
|
2
|
-
export declare const C4ConnectorManagementPage: (({ orgId, clusterId, onNavigate }: C4ConnectorManagementPageProps) => import("react
|
|
2
|
+
export declare const C4ConnectorManagementPage: (({ orgId, clusterId, onNavigate }: C4ConnectorManagementPageProps) => import("react").JSX.Element) & {
|
|
3
3
|
displayName: string;
|
|
4
4
|
};
|
|
@@ -204,7 +204,7 @@ function buildCreateClusterTranslations(t) {
|
|
|
204
204
|
generationTitle: translate('createcluster:form.generation.title', 'Channel'),
|
|
205
205
|
olderGenerationsLabel: translate('createcluster:form.generation.olderGenerationsLabel', 'View older generations'),
|
|
206
206
|
olderGenerationsHelperText: translate('createcluster:form.generation.olderGenerationsHelperText', 'These are older generations that are used in your organization.'),
|
|
207
|
-
orgUnlockedGenerationsHelperText: translate('createcluster:form.generation.orgUnlockedGenerationsHelperText', 'These are
|
|
207
|
+
orgUnlockedGenerationsHelperText: translate('createcluster:form.generation.orgUnlockedGenerationsHelperText', 'These are generations that have been unlocked for your organization.'),
|
|
208
208
|
autoUpdateTitle: translate('createcluster:form.autoUpdate.title', 'Automatic cluster patch updates'),
|
|
209
209
|
autoUpdateDescription: translate('createcluster:form.autoUpdate.description', 'When enabled, the cluster will be updated to the latest patch release. For entirely new cluster versions, updates will need to be performed manually. Please note that during the update, there may be a brief period of unavailability for the cluster.'),
|
|
210
210
|
autoUpdateDescriptionIfDisabled: translate('createcluster:form.autoUpdate.descriptionIfDisabled', 'Only available for generations in the stable channel.'),
|
|
@@ -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;
|