@camunda/ccma-saas-frontend 0.10.0 → 0.12.0

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.
Files changed (93) hide show
  1. package/lib/esm/components/c4-cluster-list/c4-cluster-list.d.ts +1 -1
  2. package/lib/esm/components/c4-cluster-list/c4-cluster-list.js +40 -9
  3. package/lib/esm/components/c4-cluster-list/c4-cluster-list.types.d.ts +17 -0
  4. package/lib/esm/components/c4-cluster-settings/elements/danger-zone.js +9 -1
  5. package/lib/esm/components/c4-cluster-tag-selector/c4-cluster-tag-selector.js +5 -5
  6. package/lib/esm/components/c4-clusters-empty-state/c4-clusters-empty-state.js +3 -3
  7. package/lib/esm/components/c4-convert-trial-organization-modal/c4-convert-trial-organization-modal.js +1 -11
  8. package/lib/esm/components/c4-create-alert-modal/c4-create-alert-modal.js +1 -14
  9. package/lib/esm/components/c4-create-cluster/c4-create-cluster.d.ts +1 -1
  10. package/lib/esm/components/c4-create-cluster/c4-create-cluster.js +188 -71
  11. package/lib/esm/components/c4-create-cluster/c4-create-cluster.types.d.ts +52 -0
  12. package/lib/esm/components/c4-create-cluster-api-client-modal/c4-create-cluster-api-client-modal.js +1 -11
  13. package/lib/esm/components/c4-create-connector-secret-modal/c4-create-connector-secret-modal.js +6 -13
  14. package/lib/esm/components/c4-create-console-api-client-modal/c4-create-console-api-client-modal.js +1 -11
  15. package/lib/esm/components/c4-create-ip-whitelist-modal/c4-create-ip-whitelist-modal.js +1 -18
  16. package/lib/esm/components/c4-create-trial-organization-modal/c4-create-trial-organization-modal.js +1 -11
  17. package/lib/esm/components/c4-delete-account-modal/c4-delete-account-modal.d.ts +0 -7
  18. package/lib/esm/components/c4-delete-account-modal/c4-delete-account-modal.js +1 -24
  19. package/lib/esm/components/c4-delete-organization-modal/c4-delete-organization-modal.js +1 -18
  20. package/lib/esm/components/c4-divider/c4-divider.js +12 -0
  21. package/lib/esm/components/c4-empty-state/c4-empty-state.d.ts +8 -0
  22. package/lib/esm/components/c4-empty-state/c4-empty-state.js +32 -8
  23. package/lib/esm/components/c4-file-uploader/c4-file-uploader.d.ts +36 -0
  24. package/lib/esm/components/c4-file-uploader/c4-file-uploader.js +43 -0
  25. package/lib/esm/components/c4-invite-user-to-organization-modal/c4-invite-user-to-organization-modal.js +1 -11
  26. package/lib/esm/components/c4-leave-organization-modal/c4-leave-organization-modal.js +1 -11
  27. package/lib/esm/components/c4-rename-organization-modal/c4-rename-organization-modal.js +1 -11
  28. package/lib/esm/components/c4-segmented-control/c4-segmented-control.d.ts +46 -0
  29. package/lib/esm/components/c4-segmented-control/c4-segmented-control.js +117 -0
  30. package/lib/esm/externalUrls.const.d.ts +7 -0
  31. package/lib/esm/externalUrls.const.js +11 -1
  32. package/lib/esm/i18n/c4-console-i18n.js +3 -0
  33. package/lib/esm/i18n/en/modals/apiclients.json +2 -1
  34. package/lib/esm/i18n/en/modals/clusterclients.json +2 -1
  35. package/lib/esm/i18n/en/pages/clusterdetails.json +12 -1
  36. package/lib/esm/i18n/en/pages/clusters.json +1 -0
  37. package/lib/esm/i18n/en/pages/createcluster.json +43 -0
  38. package/lib/esm/i18n/en/pages/orgmanagement.json +3 -0
  39. package/lib/esm/index.d.ts +2 -0
  40. package/lib/esm/index.js +2 -0
  41. package/lib/esm/runtime/c4-console-runtime-context.d.ts +7 -0
  42. package/lib/esm/runtime/c4-console-runtime-context.js +130 -2
  43. package/lib/esm/runtime/c4-console-runtime.types.d.ts +22 -0
  44. package/lib/esm/runtime/cluster-creation-blocked.d.ts +16 -0
  45. package/lib/esm/runtime/cluster-creation-blocked.js +21 -0
  46. package/lib/esm/runtime/cluster-duplication.d.ts +10 -0
  47. package/lib/esm/runtime/cluster-duplication.js +15 -0
  48. package/lib/esm/ui/c4-password-input.js +1 -1
  49. package/lib/esm/ui/index.d.ts +1 -0
  50. package/lib/esm/ui/index.js +16 -2
  51. package/lib/esm/utils/role-labels.d.ts +1 -2
  52. package/lib/esm/utils/role-labels.js +1 -13
  53. package/lib/esm/utils/safe-translate.d.ts +4 -2
  54. package/lib/esm/utils/safe-translate.js +9 -2
  55. package/lib/esm/widgets/cluster-client-details/c4-cluster-client-details-app.js +2 -12
  56. package/lib/esm/widgets/cluster-details/c4-cluster-details-app.js +34 -23
  57. package/lib/esm/widgets/cluster-details/c4-cluster-details-app.types.d.ts +6 -0
  58. package/lib/esm/widgets/cluster-details/c4-cluster-details-page.js +7 -0
  59. package/lib/esm/widgets/cluster-details/c4-cluster-details-page.types.d.ts +3 -0
  60. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-activity-tab.js +1 -19
  61. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-alerts-tab.js +1 -14
  62. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-byom-clients-tab.js +1 -18
  63. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-clients-tab.js +1 -1
  64. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-connector-secrets-tab.d.ts +1 -0
  65. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-connector-secrets-tab.js +77 -28
  66. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-hot-backups-tab.js +1 -6
  67. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-ip-whitelist-tab.js +1 -18
  68. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-overview-tab.js +31 -29
  69. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-secure-connectivity-tab.js +1 -6
  70. package/lib/esm/widgets/cluster-details/tabs/c4-cluster-details-settings-tab.js +1 -16
  71. package/lib/esm/widgets/clusters/c4-clusters-page.js +99 -103
  72. package/lib/esm/widgets/clusters/c4-clusters-page.types.d.ts +9 -0
  73. package/lib/esm/widgets/connector-management/c4-connector-management-page.js +1 -9
  74. package/lib/esm/widgets/connector-management/c4-connector-management.shared.js +1 -9
  75. package/lib/esm/widgets/create-cluster/c4-create-cluster-page.d.ts +88 -1
  76. package/lib/esm/widgets/create-cluster/c4-create-cluster-page.js +285 -45
  77. package/lib/esm/widgets/create-cluster/c4-create-cluster-page.types.d.ts +9 -0
  78. package/lib/esm/widgets/dashboard/c4-dashboard-app.js +10 -24
  79. package/lib/esm/widgets/environment/c4-cluster-connector-secrets-widget.js +1 -1
  80. package/lib/esm/widgets/group-details/c4-group-details-page.js +1 -9
  81. package/lib/esm/widgets/job-worker/c4-job-worker.helpers.d.ts +1 -0
  82. package/lib/esm/widgets/job-worker/c4-job-worker.helpers.js +4 -34
  83. package/lib/esm/widgets/management/c4-management-app.js +1 -20
  84. package/lib/esm/widgets/management/c4-management-page.js +1 -9
  85. package/lib/esm/widgets/management/tabs/c4-management-api-tab.js +1 -13
  86. package/lib/esm/widgets/management/tabs/c4-management-billing-tab.js +1 -9
  87. package/lib/esm/widgets/management/tabs/c4-management-overview-tab.js +1 -13
  88. package/lib/esm/widgets/management/tabs/c4-management-pricing-tab.js +1 -8
  89. package/lib/esm/widgets/management/tabs/c4-management-settings-tab.js +1 -24
  90. package/lib/esm/widgets/management/tabs/c4-management-users-tab.js +1 -13
  91. package/lib/esm/widgets/user-account/c4-delete-account-widget.js +2 -1
  92. package/lib/esm/widgets/user-details/c4-user-details-page.js +1 -9
  93. package/package.json +3 -3
@@ -10,11 +10,14 @@ import { observer } from 'mobx-react-lite';
10
10
  import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
11
11
  import { normalizeClusterStatus } from '../../components/c4-cluster-overview/applications.js';
12
12
  import { getC4ClusterDetailsUrls } from '../../externalUrls.const.js';
13
- import { useC4ConsoleAuthz } from '../../runtime/c4-console-authz.js';
13
+ import { isDeveloperBlockedFromClusterCreate, useC4ConsoleAuthz, } from '../../runtime/c4-console-authz.js';
14
14
  import { useC4ConsoleData } from '../../runtime/c4-console-data-context.js';
15
- import { useC4ConsoleRuntime } from '../../runtime/c4-console-runtime-context.js';
15
+ import { useC4ConsoleRuntime, useC4FeatureFlag, } from '../../runtime/c4-console-runtime-context.js';
16
+ import { CLUSTER_CREATION_BLOCKED_FLAG } from '../../runtime/cluster-creation-blocked.js';
17
+ import { CLUSTER_DUPLICATION_FLAG } from '../../runtime/cluster-duplication.js';
16
18
  import { toApiConfig } from '../../runtime/to-api-config.js';
17
19
  import { Modal, Stack, TextInput } from '../../ui/index.js';
20
+ import { safeTranslate } from '../../utils/safe-translate.js';
18
21
  import { clusterHealthOverride } from '../cluster-health-override.js';
19
22
  import { useClusterApiClients } from '../environment/use-cluster-api-clients.js';
20
23
  import { useClusterVersionFlags } from '../environment/use-cluster-version-flags.js';
@@ -32,26 +35,6 @@ import { C4ClusterDetailsIpWhitelistTab } from './tabs/c4-cluster-details-ip-whi
32
35
  import { C4ClusterDetailsOverviewTab } from './tabs/c4-cluster-details-overview-tab.js';
33
36
  import { C4ClusterDetailsSecureConnectivityTab } from './tabs/c4-cluster-details-secure-connectivity-tab.js';
34
37
  import { C4ClusterDetailsSettingsTab } from './tabs/c4-cluster-details-settings-tab.js';
35
- function safeTranslate(t, key, fallback, options) {
36
- try {
37
- const translated = t?.(key, options);
38
- if (!translated || translated === key) {
39
- return fallback;
40
- }
41
- // i18next can return the key *without* the namespace when the namespace is missing.
42
- // Example: `c4console:clusterDetails.tabs.overview` -> `clusterDetails.tabs.overview`
43
- if (key.includes(':')) {
44
- const withoutNamespace = key.split(':').slice(1).join(':');
45
- if (translated === withoutNamespace) {
46
- return fallback;
47
- }
48
- }
49
- return translated;
50
- }
51
- catch {
52
- return fallback;
53
- }
54
- }
55
38
  function renderInlineStrong(value) {
56
39
  const match = value.match(/^(.*)<strong>(.*)<\/strong>(.*)$/);
57
40
  if (!match)
@@ -305,6 +288,8 @@ function isUnsupportedGenerationStarted(isUnsupportedStarting) {
305
288
  }
306
289
  export const C4ClusterDetailsApp = observer((props) => {
307
290
  const runtime = useC4ConsoleRuntime();
291
+ const clusterDuplicationEnabled = useC4FeatureFlag(CLUSTER_DUPLICATION_FLAG);
292
+ const clusterCreationBlocked = useC4FeatureFlag(CLUSTER_CREATION_BLOCKED_FLAG);
308
293
  const data = useC4ConsoleData();
309
294
  const t = runtime.i18n?.t;
310
295
  const urls = useMemo(() => getC4ClusterDetailsUrls(props.urls), [props.urls]);
@@ -1035,6 +1020,24 @@ export const C4ClusterDetailsApp = observer((props) => {
1035
1020
  const ignoreGracePeriod = Boolean(orgInfo?.organizationToSalesPlan?.limits?.ignoreGracePeriod);
1036
1021
  const clusterPlanTypeReservations = orgInfo?.organizationToSalesPlan
1037
1022
  ?.clusterPlanTypesToReserved;
1023
+ // A duplicate makes a cluster, thus it needs the create permission and not
1024
+ // the edit permission of this cluster. The three guards after it mirror the
1025
+ // ones of the cluster list and of console-backend, so that this menu offers
1026
+ // nothing that the endpoint refuses:
1027
+ // - `developerNoClusterCreate` makes `developerClusterCreateValidator`
1028
+ // answer 403 for a developer of that org.
1029
+ // - A cluster that was failed over is suspended, and the duplicate route
1030
+ // answers 409 for it.
1031
+ const developerBlockedFromClusterCreate = isDeveloperBlockedFromClusterCreate({
1032
+ developerNoClusterCreateLimit: orgInfo?.organizationToSalesPlan?.limits?.developerNoClusterCreate ===
1033
+ true,
1034
+ orgRoles: authz.orgRoles,
1035
+ });
1036
+ const canDuplicate = Boolean(authz.visibilities.clusters?.canCreate) &&
1037
+ clusterDuplicationEnabled &&
1038
+ !clusterCreationBlocked &&
1039
+ !developerBlockedFromClusterCreate &&
1040
+ cluster?.isFailoverSource !== true;
1038
1041
  // -----------------------------
1039
1042
  // Tabs
1040
1043
  // -----------------------------
@@ -1242,7 +1245,7 @@ export const C4ClusterDetailsApp = observer((props) => {
1242
1245
  canRead: Boolean(orgPermissions?.cluster.connectorSecrets.read),
1243
1246
  canUpdate: Boolean(orgPermissions?.cluster.connectorSecrets.update),
1244
1247
  canDelete: Boolean(orgPermissions?.cluster.connectorSecrets.delete),
1245
- }, docsUrl: urls.docs.connectorSecrets, t: t, onNavigate: props.onNavigate }));
1248
+ }, docsUrl: urls.docs.connectorSecrets, clusterSecretsDocsUrl: urls.docs.clusterSecrets, t: t, onNavigate: props.onNavigate }));
1246
1249
  const hotBackupsComponent = (_jsx(C4ClusterDetailsHotBackupsTab, { cluster: cluster, orgId: props.orgId, clusterId: props.clusterId, apiConfig: apiConfig, canMutateCluster: canMutateCluster, isHotBackupEnabled: Boolean(orgInfo?.organizationToSalesPlan?.limits?.hotBackup), manualBackupRetainedCount: orgInfo?.organizationToSalesPlan?.limits?.hotBackupManualRetainedCount, scheduledBackupRetainedCount: orgInfo?.organizationToSalesPlan?.limits
1247
1250
  ?.hotBackupScheduledRetainedCount, docsUrls: {
1248
1251
  hotBackups: urls.docs.hotBackups,
@@ -1540,8 +1543,16 @@ export const C4ClusterDetailsApp = observer((props) => {
1540
1543
  return (_jsxs(_Fragment, { children: [_jsx(C4ClusterDetailsPage, { loading: isClusterLoading || authz.isLoading, padding: props.padding, clusterName: cluster?.name, phaseTag: headerPhaseTag, healthStatus: headerHealthStatus, versionLabel: headerVersionLabel, isDevelopmentPlan: cluster?.planType?.development, urls: { clusters: urls.clusters }, onNavigateToClusters: () => props.onNavigate?.({ kind: 'clusters', orgId: props.orgId }), menu: {
1541
1544
  canRename,
1542
1545
  canDelete,
1546
+ canDuplicate,
1543
1547
  onRename: canRename ? () => setRenameOpen(true) : undefined,
1544
1548
  onDelete: canDelete ? () => setDeleteOpen(true) : undefined,
1549
+ onDuplicate: canDuplicate
1550
+ ? () => props.onNavigate?.({
1551
+ kind: 'duplicateCluster',
1552
+ orgId: props.orgId,
1553
+ clusterId: props.clusterId,
1554
+ })
1555
+ : undefined,
1545
1556
  }, banner: banner, secondaryReplicationNotReady: secondaryReplicationNotReady, onGoToEncryptionTab: () => handleTabChange('encryption'), tabs: {
1546
1557
  list: tabs,
1547
1558
  desiredTabId: activeTabId,
@@ -8,6 +8,10 @@ export type C4ClusterDetailsNavigateEvent = {
8
8
  } | {
9
9
  kind: 'clusters';
10
10
  orgId: string;
11
+ } | {
12
+ kind: 'duplicateCluster';
13
+ orgId: string;
14
+ clusterId: string;
11
15
  } | {
12
16
  kind: 'dashboard';
13
17
  orgId: string;
@@ -78,6 +82,7 @@ export interface C4ClusterDetailsDocsUrls {
78
82
  ipWhitelist: string;
79
83
  clients: string;
80
84
  connectorSecrets: string;
85
+ clusterSecrets: string;
81
86
  mcpSetup: string;
82
87
  upgrade: C4ClusterDetailsUpgradeDocsUrls;
83
88
  byom: string;
@@ -110,6 +115,7 @@ export interface C4ClusterDetailsUrls {
110
115
  ipWhitelist?: string;
111
116
  clients?: string;
112
117
  connectorSecrets?: string;
118
+ clusterSecrets?: string;
113
119
  mcpSetup?: string;
114
120
  upgrade?: Partial<C4ClusterDetailsUpgradeDocsUrls>;
115
121
  byom?: string;
@@ -55,6 +55,13 @@ function buildMenuItems(opts) {
55
55
  label: safeTranslate(t, 'c4console:clusterDetails.menu.rename', 'Rename'),
56
56
  });
57
57
  }
58
+ if (menu.canDuplicate && menu.onDuplicate) {
59
+ items.push({
60
+ key: 'clusterDuplicateOperation',
61
+ onClick: menu.onDuplicate,
62
+ label: safeTranslate(t, 'c4console:clusterDetails.menu.duplicate', 'Duplicate'),
63
+ });
64
+ }
58
65
  if (menu.canDelete && menu.onDelete) {
59
66
  items.push({
60
67
  key: 'clusterDeleteOperation',
@@ -44,8 +44,11 @@ export interface C4ClusterDetailsPageProps {
44
44
  menu?: {
45
45
  canRename: boolean;
46
46
  canDelete: boolean;
47
+ /** Gated by the `console.clusterDuplication` flag and by the create permission. */
48
+ canDuplicate?: boolean;
47
49
  onRename?: () => void;
48
50
  onDelete?: () => void;
51
+ onDuplicate?: () => void;
49
52
  };
50
53
  banner?: C4ClusterDetailsPageBanner;
51
54
  /**
@@ -1,24 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { C4ClusterDetailsActivity } from '../../../components/c4-cluster-details-activity/c4-cluster-details-activity.js';
3
- function safeTranslate(t, key, fallback) {
4
- try {
5
- const translated = t?.(key);
6
- if (!translated || translated === key) {
7
- return fallback;
8
- }
9
- // i18next can return the key *without* the namespace when the namespace is missing.
10
- if (key.includes(':')) {
11
- const withoutNamespace = key.split(':').slice(1).join(':');
12
- if (translated === withoutNamespace) {
13
- return fallback;
14
- }
15
- }
16
- return translated;
17
- }
18
- catch {
19
- return fallback;
20
- }
21
- }
3
+ import { safeTranslate } from '../../../utils/safe-translate.js';
22
4
  export const C4ClusterDetailsActivityTab = (props) => {
23
5
  return (_jsx(C4ClusterDetailsActivity, { activityGroups: props.activityGroups, isLoading: props.isLoading, hasError: props.hasError, text: {
24
6
  today: safeTranslate(props.t, 'clusterdetails:activity.today', 'Today'),
@@ -12,20 +12,7 @@ import { C4InlineNotification } from '../../../components/c4-inline-notification
12
12
  import { useC4ConsoleRuntime } from '../../../runtime/c4-console-runtime-context.js';
13
13
  import { Checkbox, Form, Link, Modal, PasswordInput, Stack, TextInput, } from '../../../ui/index.js';
14
14
  import { useRadioFamily } from '../../../ui/families.js';
15
- // Helper to translate with fallback
16
- function safeTranslate(translateFn, key, fallback, options) {
17
- try {
18
- const result = translateFn(key, options);
19
- // If i18next returns the key unchanged, use fallback
20
- if (result === key) {
21
- return fallback;
22
- }
23
- return result;
24
- }
25
- catch {
26
- return fallback;
27
- }
28
- }
15
+ import { safeTranslate } from '../../../utils/safe-translate.js';
29
16
  export function resolveUpdatedAlertHmacSecret(params) {
30
17
  const { reportType, wantsHmac, hadHmacOnOpen, hmacSecret } = params;
31
18
  if (reportType !== 'Webhook') {
@@ -7,25 +7,8 @@ import { C4ClusterByomClients } from '../../../components/c4-cluster-byom-client
7
7
  import { C4InlineNotification } from '../../../components/c4-inline-notification/c4-inline-notification.js';
8
8
  import { useC4ConsoleRuntime } from '../../../runtime/c4-console-runtime-context.js';
9
9
  import { Button, CodeSnippet, Modal, Stack, TextInput } from '../../../ui/index.js';
10
+ import { safeTranslate } from '../../../utils/safe-translate.js';
10
11
  import { SECTION_HEADING_STYLE } from '../../../utils/section-heading-style.js';
11
- // Helper function to ensure translations work
12
- function safeTranslate(t, key, fallback) {
13
- if (!t)
14
- return fallback;
15
- const result = t(key);
16
- if (!result || result === key) {
17
- return fallback;
18
- }
19
- // i18next can return the key *without* the namespace when the namespace is missing.
20
- // Example: `clusterdetails:byomClients.noClientsMessage.title` -> `byomClients.noClientsMessage.title`
21
- if (key.includes(':')) {
22
- const withoutNamespace = key.split(':').slice(1).join(':');
23
- if (result === withoutNamespace) {
24
- return fallback;
25
- }
26
- }
27
- return result;
28
- }
29
12
  function asByomStatusLike(value) {
30
13
  if (!value || typeof value !== 'object')
31
14
  return undefined;
@@ -92,7 +92,7 @@ export const C4ClusterDetailsClientsTab = (props) => {
92
92
  const [clientCreatedScopes, setClientCreatedScopes] = useState([]);
93
93
  const validateClientName = useCallback((value) => {
94
94
  if (!value) {
95
- return 'Client Name is required';
95
+ return safeTranslate(t, 'clusterclients:update.fields.name.required', 'Client name is required');
96
96
  }
97
97
  const isAllowed = /^[A-Za-z0-9_-]+$/.test(value);
98
98
  if (!isAllowed) {
@@ -14,6 +14,7 @@ interface C4ClusterDetailsConnectorSecretsTabProps {
14
14
  canDelete: boolean;
15
15
  };
16
16
  docsUrl?: string;
17
+ clusterSecretsDocsUrl?: string;
17
18
  t?: SecretsTranslateFn;
18
19
  onNavigate?: (event: {
19
20
  kind: string;
@@ -1,15 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { ConsoleConnectorSecretsService } from '@camunda/ccma-api';
3
3
  import { SECRETS_MAX_LENGTH, SseEntity } from '@camunda/ccma-shared-types';
4
- import { FileUploader, InlineLoading } from '@carbon/react';
4
+ import { InlineLoading } from '@carbon/react';
5
5
  import { observer } from 'mobx-react-lite';
6
6
  import { useCallback, useEffect, useRef, useState } from 'react';
7
7
  import { C4ClusterDetailsConnectorSecrets } from '../../../components/c4-cluster-details-connector-secrets/c4-cluster-details-connector-secrets.js';
8
+ import { C4FileUploader } from '../../../components/c4-file-uploader/c4-file-uploader.js';
8
9
  import { C4InlineNotification } from '../../../components/c4-inline-notification/c4-inline-notification.js';
9
10
  import { useC4ConsoleData } from '../../../runtime/c4-console-data-context.js';
10
- import { useC4ConsoleRuntime } from '../../../runtime/c4-console-runtime-context.js';
11
+ import { useC4ConsoleRuntime, useC4DesignSystem, } from '../../../runtime/c4-console-runtime-context.js';
11
12
  import { CodeSnippet, Form, Link, Modal, PasswordInput, Stack, TextArea, TextInput, } from '../../../ui/index.js';
12
13
  import { useSelectFamily } from '../../../ui/families.js';
14
+ import { clientErrorMessage } from '../../../utils/http-error-message.js';
13
15
  import { safeTranslate, scopedTranslate } from '../../../utils/safe-translate.js';
14
16
  function renderInlineStrong(value) {
15
17
  const match = value.match(/^(.*)<strong>(.*)<\/strong>(.*)$/);
@@ -27,10 +29,26 @@ function renderInlineLink0(value, linkRenderer) {
27
29
  }
28
30
  const C4ClusterDetailsConnectorSecretsTabImpl = (props) => {
29
31
  const { Select, SelectItem } = useSelectFamily();
30
- const { orgId, clusterId, apiConfig, canMutateCluster, connectorSecretsPermissions, docsUrl, t, onNavigate, useClusterSecretsLabel, permissionsLoading = false, scope = 'cluster', onPanelState, } = props;
31
- const pickSecretsText = (connectorKey, connectorFallback, clusterKey, clusterFallback) => useClusterSecretsLabel
32
- ? safeTranslate(t, clusterKey, clusterFallback)
33
- : safeTranslate(t, connectorKey, connectorFallback);
32
+ const { orgId, clusterId, apiConfig, canMutateCluster, connectorSecretsPermissions, docsUrl, clusterSecretsDocsUrl, t, onNavigate, useClusterSecretsLabel, permissionsLoading = false, scope = 'cluster', onPanelState, } = props;
33
+ const designSystem = useC4DesignSystem();
34
+ const useDsClusterSecretsContent = designSystem === 'ds' && useClusterSecretsLabel;
35
+ const pickValue = (condition, defaultValue, alternateValue) => (condition ? alternateValue : defaultValue);
36
+ const resolvedDocsUrl = pickValue(useDsClusterSecretsContent, docsUrl, clusterSecretsDocsUrl);
37
+ const clusterEmptyState = pickValue(designSystem === 'ds', {
38
+ titleKey: 'clusterdetails:clusterSecrets.noSecrets.title',
39
+ titleFallback: 'No secrets',
40
+ descriptionKey: 'clusterdetails:clusterSecrets.noSecrets.description',
41
+ descriptionFallback: 'Create a cluster secret to reference encrypted credentials in your cluster.',
42
+ }, {
43
+ titleKey: 'clusterdetails:clusterSecrets.noSecretsDs.title',
44
+ titleFallback: 'Store sensitive values as cluster secrets',
45
+ descriptionKey: 'clusterdetails:clusterSecrets.noSecretsDs.description',
46
+ descriptionFallback: 'Cluster secrets store API keys, passwords, and other sensitive values. Reference them from credentials and supported fields.',
47
+ });
48
+ const pickSecretsText = (connectorKey, connectorFallback, clusterKey, clusterFallback) => {
49
+ const [key, fallback] = pickValue(useClusterSecretsLabel, [connectorKey, connectorFallback], [clusterKey, clusterFallback]);
50
+ return safeTranslate(t, key, fallback);
51
+ };
34
52
  const data = useC4ConsoleData();
35
53
  const runtime = useC4ConsoleRuntime();
36
54
  // Console's own cluster-details page never mounts this tab without read
@@ -157,23 +175,21 @@ const C4ClusterDetailsConnectorSecretsTabImpl = (props) => {
157
175
  useEffect(() => {
158
176
  onPanelState?.({ isEmpty, title });
159
177
  }, [isEmpty, title, onPanelState]);
160
- // Neither empty-state description names a surface — the connector-secrets one
161
- // reads "…in your connectors", and the cluster-secrets one explains the
162
- // secrets vault without ever saying "cluster". Scope-neutral copy takes no
163
- // scoped key: only strings that actually describe the surface get one.
178
+ // Neither empty-state description varies by surface scope, so only strings
179
+ // that actually describe the surface get a scoped key.
164
180
  const emptyDescription = renderInlineStrong(useClusterSecretsLabel
165
- ? safeTranslate(t, 'clusterdetails:clusterSecrets.noSecrets.description', 'Create a cluster secret to reference encrypted credentials in your cluster.')
181
+ ? safeTranslate(t, clusterEmptyState.descriptionKey, clusterEmptyState.descriptionFallback)
166
182
  : safeTranslate(t, 'clusterdetails:connectorSecrets.noSecrets.description', 'Create a connector secret to use in your connectors.'));
167
183
  // The cluster-secrets info text is the one string here that names the surface
168
184
  // ("…credentials in your cluster"), so it is the one that takes a scoped key.
169
185
  // The connector-secrets variant is scope-neutral and stays unscoped.
170
186
  const infoText = renderInlineLink0(useClusterSecretsLabel
171
187
  ? scopedTranslate(t, scope, 'clusterdetails:clusterSecrets.infoText', 'Learn more about cluster secrets in our <0>documentation</0>.', 'Learn more about cluster secrets in our <0>documentation</0>.')
172
- : safeTranslate(t, 'clusterdetails:connectorSecrets.infoText', 'Learn more about connector secrets in our <0>documentation</0>.'), (label) => (_jsx(Link, { size: 'sm', href: docsUrl ?? '', onClick: (e) => {
188
+ : safeTranslate(t, 'clusterdetails:connectorSecrets.infoText', 'Learn more about connector secrets in our <0>documentation</0>.'), (label) => (_jsx(Link, { size: 'sm', href: resolvedDocsUrl ?? '', onClick: (e) => {
173
189
  e.preventDefault();
174
190
  onNavigate?.({
175
191
  kind: 'openUrl',
176
- url: docsUrl ?? '',
192
+ url: resolvedDocsUrl ?? '',
177
193
  });
178
194
  }, children: label })));
179
195
  return (_jsxs(_Fragment, { children: [_jsx(C4ClusterDetailsConnectorSecrets, { secrets: secrets, isLoading: isListLoading, hasError: connectorSecretsError, hasImportFromClusterFeature: true, hasExportFeature: true, text: {
@@ -191,17 +207,17 @@ const C4ClusterDetailsConnectorSecretsTabImpl = (props) => {
191
207
  errorTitle: safeTranslate(t, 'clusterdetails:connectorSecrets.fetchError.title', 'Could not load secrets'),
192
208
  errorDescription: safeTranslate(t, 'clusterdetails:connectorSecrets.fetchError.description', 'Please try again.'),
193
209
  errorButton: safeTranslate(t, 'clusterdetails:connectorSecrets.fetchError.button', 'Retry'),
194
- emptyTitle: pickSecretsText('clusterdetails:connectorSecrets.noSecrets.title', 'No secrets', 'clusterdetails:clusterSecrets.noSecrets.title', 'No secrets'),
210
+ emptyTitle: pickSecretsText('clusterdetails:connectorSecrets.noSecrets.title', 'No secrets', clusterEmptyState.titleKey, clusterEmptyState.titleFallback),
195
211
  emptyDescription,
196
212
  emptyCreateButton: safeTranslate(t, 'clusterdetails:connectorSecrets.noSecrets.button', 'Create secret'),
197
- emptyLearnMoreLabel: safeTranslate(t, 'clusterdetails:connectorSecrets.noSecrets.link', 'Learn more'),
213
+ emptyLearnMoreLabel: pickValue(useDsClusterSecretsContent, safeTranslate(t, 'clusterdetails:connectorSecrets.noSecrets.link', 'Learn more'), safeTranslate(t, 'clusterdetails:clusterSecrets.noSecretsDs.link', 'Learn more about cluster secrets')),
198
214
  emptyIconAltText: pickSecretsText('clusterdetails:connectorSecrets.emptyIconAltText', 'Connector secrets icon', 'clusterdetails:clusterSecrets.emptyIconAltText', 'Cluster secrets icon'),
199
215
  infoText,
200
216
  // Label for the badge shown on CAMUNDA_PROVIDED_ secrets
201
217
  protectedBadge: safeTranslate(t, 'clusterdetails:connectorSecrets.protectedBadge', 'Hidden'),
202
218
  forbiddenTitle: pickSecretsText('clusterdetails:connectorSecrets.forbidden.title', "You don't have access to connector secrets", 'clusterdetails:clusterSecrets.forbidden.title', "You don't have access to cluster secrets"),
203
219
  forbiddenDescription: pickSecretsText('clusterdetails:connectorSecrets.forbidden.description', "You don't have permission to view connector secrets for this cluster. Contact an organization owner or admin for access.", 'clusterdetails:clusterSecrets.forbidden.description', "You don't have permission to view cluster secrets for this cluster. Contact an organization owner or admin for access."),
204
- }, urls: { docs: docsUrl ?? '' }, permissions: {
220
+ }, urls: { docs: resolvedDocsUrl ?? '' }, permissions: {
205
221
  canCreate: connectorSecretsPermissions?.canCreate ?? canMutateCluster,
206
222
  canRead: connectorSecretsPermissions?.canRead ?? canMutateCluster,
207
223
  canUpdate: connectorSecretsPermissions?.canUpdate ?? canMutateCluster,
@@ -274,7 +290,7 @@ const C4ClusterDetailsConnectorSecretsTabImpl = (props) => {
274
290
  }, onRefresh: () => reloadConnectorSecrets(), onOpenDocs: () => {
275
291
  onNavigate?.({
276
292
  kind: 'openUrl',
277
- url: docsUrl ?? '',
293
+ url: resolvedDocsUrl ?? '',
278
294
  });
279
295
  } }), _jsx(Modal, { open: secretCreateOpen, modalHeading: safeTranslate(t, 'connectorsecrets:create.heading', 'Create connector secret'), primaryButtonText: safeTranslate(t, 'connectorsecrets:create.buttons.primary', 'Create'), secondaryButtonText: safeTranslate(t, 'connectorsecrets:create.buttons.secondary', 'Cancel'), primaryButtonDisabled: secretMutationBusy, onRequestClose: () => {
280
296
  trackEvent('listConnectors:create:cancel', 'Close Create Connector Secret Modal');
@@ -317,12 +333,19 @@ const C4ClusterDetailsConnectorSecretsTabImpl = (props) => {
317
333
  setSecretMutationBusy(false);
318
334
  }
319
335
  })();
320
- }, children: _jsxs(Stack, { gap: 6, children: [secretMutationError && (_jsx(C4InlineNotification, { kind: 'error', title: 'Error', subtitle: secretMutationError, hideCloseButton: true, lowContrast: true })), _jsxs(Form, { children: [_jsx(TextInput, { id: 'secret-create-key', labelText: safeTranslate(t, 'connectorsecrets:create.fields.key', 'Key'), helperText: safeTranslate(t, 'connectorsecrets:create.fields.keyHelperText', 'Unique identifier for the secret'), maxLength: 50, value: secretKey, invalid: secretKeyInvalid, invalidText: 'Key is required', onChange: (event) => {
336
+ }, children: _jsxs(Stack, { gap: 6, children: [secretMutationError && (_jsx(C4InlineNotification, { kind: 'error', title: 'Error', subtitle: secretMutationError, hideCloseButton: true, lowContrast: true })), _jsxs(Form, { children: [_jsx(TextInput, { id: 'secret-create-key', labelText: safeTranslate(t, 'connectorsecrets:create.fields.key', 'Key'), helperText: safeTranslate(t, 'connectorsecrets:create.fields.keyHelperText', 'Unique identifier for the secret'), maxLength: 50, value: secretKey, invalid: secretKeyInvalid, invalidText: 'Key is required',
337
+ // The key of a connector secret is not a personal detail. The
338
+ // browser offered the keys of other forms, and one of them was a
339
+ // password field.
340
+ autoComplete: 'off', onChange: (event) => {
321
341
  setSecretKey(event.target.value);
322
342
  if (secretKeyInvalid && event.target.value.length > 0) {
323
343
  setSecretKeyInvalid(false);
324
344
  }
325
- } }), _jsx(PasswordInput, { id: 'secret-create-value', labelText: safeTranslate(t, 'connectorsecrets:create.fields.value', 'Value'), maxLength: SECRETS_MAX_LENGTH, value: secretValue, invalid: secretValueInvalid, invalidText: 'Value is required', onChange: (event) => {
345
+ } }), _jsx(PasswordInput, { id: 'secret-create-value', labelText: safeTranslate(t, 'connectorsecrets:create.fields.value', 'Value'), maxLength: SECRETS_MAX_LENGTH, value: secretValue, invalid: secretValueInvalid, invalidText: 'Value is required',
346
+ // Keeps the password manager of the browser away from a value
347
+ // that belongs to the cluster and not to the reader.
348
+ autoComplete: 'new-password', onChange: (event) => {
326
349
  setSecretValue(event.target.value);
327
350
  if (secretValueInvalid && event.target.value.length > 0) {
328
351
  setSecretValueInvalid(false);
@@ -364,7 +387,7 @@ const C4ClusterDetailsConnectorSecretsTabImpl = (props) => {
364
387
  setSecretMutationBusy(false);
365
388
  }
366
389
  })();
367
- }, children: _jsxs(Stack, { gap: 6, children: [secretMutationError && (_jsx(C4InlineNotification, { kind: 'error', title: 'Error', subtitle: secretMutationError, hideCloseButton: true, lowContrast: true })), _jsx(Form, { children: _jsx(PasswordInput, { id: 'secret-update-value', labelText: safeTranslate(t, 'connectorsecrets:update.fields.value', 'Value'), maxLength: SECRETS_MAX_LENGTH, value: secretValue, onChange: (event) => setSecretValue(event.target.value) }) })] }) }), _jsx(Modal, { open: secretDeleteOpen, danger: true, modalHeading: `${safeTranslate(t, 'connectorsecrets:delete.heading', 'Delete connector secret')}: ${secretKey}`, primaryButtonText: safeTranslate(t, 'connectorsecrets:delete.buttons.primary', 'Delete'), secondaryButtonText: safeTranslate(t, 'connectorsecrets:delete.buttons.secondary', 'Cancel'), primaryButtonDisabled: secretMutationBusy, onRequestClose: () => {
390
+ }, children: _jsxs(Stack, { gap: 6, children: [secretMutationError && (_jsx(C4InlineNotification, { kind: 'error', title: 'Error', subtitle: secretMutationError, hideCloseButton: true, lowContrast: true })), _jsx(Form, { children: _jsx(PasswordInput, { id: 'secret-update-value', labelText: safeTranslate(t, 'connectorsecrets:update.fields.value', 'Value'), maxLength: SECRETS_MAX_LENGTH, value: secretValue, autoComplete: 'new-password', onChange: (event) => setSecretValue(event.target.value) }) })] }) }), _jsx(Modal, { open: secretDeleteOpen, danger: true, modalHeading: `${safeTranslate(t, 'connectorsecrets:delete.heading', 'Delete connector secret')}: ${secretKey}`, primaryButtonText: safeTranslate(t, 'connectorsecrets:delete.buttons.primary', 'Delete'), secondaryButtonText: safeTranslate(t, 'connectorsecrets:delete.buttons.secondary', 'Cancel'), primaryButtonDisabled: secretMutationBusy, onRequestClose: () => {
368
391
  trackEvent('listConnectors:delete:cancel', 'Close Delete Connector Secret Modal', {
369
392
  key: secretKey,
370
393
  });
@@ -449,8 +472,19 @@ const C4ClusterDetailsConnectorSecretsTabImpl = (props) => {
449
472
  }
450
473
  // Import all secrets
451
474
  let successCount = 0;
452
- let errorCount = 0;
475
+ const failures = [];
453
476
  for (const secret of secrets) {
477
+ // The backend answers a duplicate with a plain 4xx, and the
478
+ // reader then saw a count of failures with no reason. A name
479
+ // that is already on the cluster is the usual cause, thus this
480
+ // reason comes from the list that the page already holds.
481
+ if (Object.hasOwn(connectorSecretsMap, secret.key)) {
482
+ failures.push({
483
+ key: secret.key,
484
+ reason: safeTranslate(t, 'connectorsecrets:bulkImport.errors.duplicate', 'a secret with this key already exists'),
485
+ });
486
+ continue;
487
+ }
454
488
  try {
455
489
  await ConsoleConnectorSecretsService.create({
456
490
  config: apiConfig,
@@ -473,14 +507,21 @@ const C4ClusterDetailsConnectorSecretsTabImpl = (props) => {
473
507
  clusterId,
474
508
  key: secret.key,
475
509
  });
476
- errorCount++;
510
+ failures.push({
511
+ key: secret.key,
512
+ reason: clientErrorMessage(error) ??
513
+ safeTranslate(t, 'connectorsecrets:bulkImport.errors.unknown', 'the server rejected it'),
514
+ });
477
515
  }
478
516
  }
479
- if (errorCount === 0) {
517
+ if (failures.length === 0) {
480
518
  setBulkImportOpen(false);
481
519
  }
482
520
  else {
483
- setBulkImportError(`Imported ${successCount} secrets, ${errorCount} failed`);
521
+ const reasons = failures
522
+ .map((failure) => `${failure.key} — ${failure.reason}`)
523
+ .join('; ');
524
+ setBulkImportError(`Imported ${successCount} of ${secrets.length} secrets. Not imported: ${reasons}.`);
484
525
  }
485
526
  await reloadConnectorSecrets();
486
527
  }
@@ -497,18 +538,26 @@ const C4ClusterDetailsConnectorSecretsTabImpl = (props) => {
497
538
  setBulkImportBusy(false);
498
539
  }
499
540
  })();
500
- }, size: 'md', children: _jsxs(Stack, { gap: 6, children: [bulkImportError && (_jsx(C4InlineNotification, { kind: 'error', title: 'Error', subtitle: bulkImportError, hideCloseButton: true, lowContrast: true })), _jsx(FileUploader, { labelTitle: safeTranslate(t, 'connectorsecrets:bulkImport.fields.fileUploadLabel', 'Upload file'), labelDescription: safeTranslate(t, 'connectorsecrets:bulkImport.fields.fileUploadDescription', 'Select a .env or .txt file'), buttonLabel: safeTranslate(t, 'connectorsecrets:bulkImport.fields.fileUploadButton', 'Select file'), buttonKind: 'tertiary', size: 'md', filenameStatus: 'edit', accept: ['.env', '.txt'], multiple: false, iconDescription: 'Remove file', onChange: async (event) => {
501
- const files = event.target.files;
502
- if (files && files.length > 0) {
541
+ }, size: 'md', children: _jsxs(Stack, { gap: 6, children: [bulkImportError && (_jsx(C4InlineNotification, { kind: 'error', title: 'Error', subtitle: bulkImportError, hideCloseButton: true, lowContrast: true })), _jsx(C4FileUploader, { labelTitle: safeTranslate(t, 'connectorsecrets:bulkImport.fields.fileUploadLabel', 'Upload file'), labelDescription: safeTranslate(t, 'connectorsecrets:bulkImport.fields.fileUploadDescription', 'Select a .env or .txt file'), buttonLabel: safeTranslate(t, 'connectorsecrets:bulkImport.fields.fileUploadButton', 'Select file'), accept: ['.env', '.txt'], onFilesChange: (files) => {
542
+ // An empty list means that the reader removed the file. The
543
+ // content of that file is still in the box below, thus the
544
+ // dialog would import a file that the reader took away.
545
+ if (files.length === 0) {
546
+ setBulkImportContent('');
547
+ setBulkImportError('');
548
+ return;
549
+ }
550
+ void (async () => {
503
551
  try {
504
552
  const text = await files[0].text();
505
553
  setBulkImportContent(text);
506
554
  setBulkImportContentInvalid(false);
555
+ setBulkImportError('');
507
556
  }
508
557
  catch {
509
558
  setBulkImportError('Failed to read file');
510
559
  }
511
- }
560
+ })();
512
561
  } }), _jsx(Form, { children: _jsx(TextArea, { id: 'bulk-import-content', labelText: safeTranslate(t, 'connectorsecrets:bulkImport.fields.envContent', 'Content'), helperText: safeTranslate(t, 'connectorsecrets:bulkImport.fields.envContentHelperText', 'KEY=VALUE format, one per line'), placeholder: 'MY_SECRET=secret_value\\nANOTHER_SECRET=another_value', value: bulkImportContent, invalid: bulkImportContentInvalid, invalidText: 'Content is required', rows: 12, onChange: (event) => {
513
562
  setBulkImportContent(event.target.value);
514
563
  if (bulkImportContentInvalid && event.target.value.trim()) {
@@ -11,6 +11,7 @@ import { useC4ConsoleNotifications } from '../../../runtime/c4-console-notificat
11
11
  import { useC4ConsoleRuntime } from '../../../runtime/c4-console-runtime-context.js';
12
12
  import { Checkbox, Modal, Stack, TextInput } from '../../../ui/index.js';
13
13
  import { useSelectFamily } from '../../../ui/families.js';
14
+ import { safeTranslate } from '../../../utils/safe-translate.js';
14
15
  const WEEKDAYS = [
15
16
  'Monday',
16
17
  'Tuesday',
@@ -169,12 +170,6 @@ function toDateOrDash(value) {
169
170
  function isManualBackup(backup) {
170
171
  return backup.name.includes('on-demand');
171
172
  }
172
- function safeTranslate(t, key, fallback) {
173
- if (!t)
174
- return fallback;
175
- const result = t(key);
176
- return result === key ? fallback : result;
177
- }
178
173
  const C4ClusterDetailsHotBackupsTabImpl = (props) => {
179
174
  const { Select, SelectItem } = useSelectFamily();
180
175
  const { cluster, orgId, clusterId, apiConfig, canMutateCluster, isHotBackupEnabled, manualBackupRetainedCount, scheduledBackupRetainedCount, docsUrls, t, onNavigate, onReloadCluster, } = props;
@@ -7,24 +7,7 @@ import { C4CreateIpWhitelistModal } from '../../../components/c4-create-ip-white
7
7
  import { C4InlineNotification } from '../../../components/c4-inline-notification/c4-inline-notification.js';
8
8
  import { useC4ConsoleRuntime } from '../../../runtime/c4-console-runtime-context.js';
9
9
  import { Form, Modal, Stack, TextInput } from '../../../ui/index.js';
10
- // Helper function to ensure translations work
11
- function safeTranslate(t, key, fallback) {
12
- if (!t)
13
- return fallback;
14
- const result = t(key);
15
- if (!result || result === key) {
16
- return fallback;
17
- }
18
- // i18next can return the key *without* the namespace when the namespace is missing.
19
- // Example: `ipwhitelist:data.title` -> `data.title`
20
- if (key.includes(':')) {
21
- const withoutNamespace = key.split(':').slice(1).join(':');
22
- if (result === withoutNamespace) {
23
- return fallback;
24
- }
25
- }
26
- return result;
27
- }
10
+ import { safeTranslate } from '../../../utils/safe-translate.js';
28
11
  function renderInlineStrong(value) {
29
12
  const parts = value.split(/<strong>|<\/strong>/);
30
13
  if (parts.length === 1)