@camunda/ccma-saas-frontend 0.32.0 → 0.33.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.
@@ -342,7 +342,9 @@ export const C4ClusterList = ({ clusters, loading, urls, permissions, onNavigate
342
342
  label: translations.overflowMenu.delete,
343
343
  kind: 'danger--ghost',
344
344
  onClick: (row) => onDeleteCluster(row.id),
345
- visible: (row) => !isActionsLocked?.(row.id) && permissions.canDeleteCluster,
345
+ visible: () =>
346
+ // Delete stays open: it cancels a migration in every phase.
347
+ permissions.canDeleteCluster,
346
348
  },
347
349
  ];
348
350
  const renderDataTable = () => {
@@ -65,8 +65,8 @@ export interface C4ClusterListProps {
65
65
  onFailoverCluster?: (clusterId: string) => void;
66
66
  onDuplicateCluster?: (clusterId: string) => void;
67
67
  /**
68
- * True hides every row action of the cluster, and the Add tag link too
69
- * (migration lock, PDP 3844).
68
+ * True hides every row action of the cluster but Delete, and the Add tag
69
+ * link too (migration lock, PDP 3844).
70
70
  */
71
71
  isActionsLocked?: (clusterId: string) => boolean;
72
72
  trialNotification?: React.ReactNode;
@@ -1,3 +1,4 @@
1
1
  import { type JSX } from 'react';
2
2
  import type { C4ClusterMigrationProps } from './c4-cluster-migration.types.js';
3
- export declare function C4ClusterMigration({ state, roleArn, busy, canConfirm, error, onConfirm, translations: t, }: C4ClusterMigrationProps): JSX.Element;
3
+ /** The view of a migration that is not complete yet, one panel per phase. */
4
+ export declare function C4ClusterMigration({ migration, busy, canEdit, error, onTransferFinished, onReopenTransfer, onChooseBackup, onDelete, translations: t, }: C4ClusterMigrationProps): JSX.Element;
@@ -1,24 +1,55 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  /*
3
3
  * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
4
4
  * under one or more contributor license agreements. Licensed under a commercial license.
5
5
  * You may not use this file except in compliance with the commercial license.
6
6
  */
7
7
  import { useState } from 'react';
8
- import { Button, Checkbox, Stack, TextInput } from '../../ui/index.js';
8
+ import { Button, Checkbox, DsCodeBlock, Stack, TextInput } from '../../ui/index.js';
9
+ import { buildAwsMigrationPolicy, isValidKmsKeyArn, isValidS3BucketName, } from '../../utils/migration-aws-policy.js';
10
+ import { isValidBackupId, isValidPartitionsCount, } from '../../utils/migration-view.js';
9
11
  import { C4InlineNotification } from '../c4-inline-notification/c4-inline-notification.js';
10
- import { isValidBackupId } from './backup-id.js';
11
- export function C4ClusterMigration({ state, roleArn, busy = false, canConfirm = true, error, onConfirm, translations: t, }) {
12
- const [backupId, setBackupId] = useState('');
13
- const [touched, setTouched] = useState(false);
14
- const [transferDone, setTransferDone] = useState(false);
15
- if (state === 'migrating') {
16
- return (_jsxs(Stack, { gap: 3, "data-testid": 'cluster-migration-migrating', children: [_jsx("h3", { children: t.migratingTitle }), _jsx("p", { children: t.migratingText })] }));
17
- }
12
+ /** The view of a migration that is not complete yet, one panel per phase. */
13
+ export function C4ClusterMigration({ migration, busy = false, canEdit = true, error, onTransferFinished, onReopenTransfer, onChooseBackup, onDelete, translations: t, }) {
14
+ const { phase } = migration;
15
+ const disabled = busy || !canEdit;
16
+ return (_jsxs(Stack, { gap: 5, "data-testid": `cluster-migration-${phase}`, children: [_jsx("h3", { children: t.title[phase] }), _jsx("p", { "data-testid": 'cluster-migration-reason', children: t.reasonText(phase, migration.reason, migration.reasonParams) }), (phase === 'AwaitingPrincipal' || phase === 'Transferring') && (_jsxs("p", { children: [t.principalLabel, ' ', _jsx("code", { "data-testid": 'cluster-migration-principal', children: migration.spec.principal })] })), phase === 'Transferring' && (_jsx(TransferPanel, { migration: migration, disabled: disabled, onTransferFinished: onTransferFinished, translations: t })), (phase === 'AwaitingBackup' || phase === 'RestoreFailed') && (_jsx(BackupChoicePanel
17
+ // A new phase starts again from the last choice, with an unchecked box.
18
+ , { migration: migration, disabled: disabled, onChooseBackup: onChooseBackup, onReopenTransfer: phase === 'AwaitingBackup' ? onReopenTransfer : undefined, translations: t }, phase)), (phase === 'AwaitingPrincipal' ||
19
+ phase === 'Verifying' ||
20
+ phase === 'Restoring') && (_jsx("p", { "data-testid": 'cluster-migration-progress', children: t.progressText })), phase === 'VerificationFailed' && onDelete && (_jsx("div", { children: _jsx(Button, { kind: 'danger', disabled: busy, onClick: onDelete, children: t.deleteButton }) })), error && (_jsx(C4InlineNotification, { kind: 'error', title: '', subtitle: error, hideCloseButton: true }))] }));
21
+ }
22
+ function TransferPanel({ migration, disabled, onTransferFinished, translations: t, }) {
23
+ const [bucket, setBucket] = useState(migration.source.bucket ?? '');
24
+ const [kmsKeyArn, setKmsKeyArn] = useState(migration.source.kmsKeyArn ?? '');
25
+ // The operator never reads the source bucket. It only adds the source
26
+ // statements to the policy, thus it is optional.
27
+ const bucketValid = bucket === '' || isValidS3BucketName(bucket);
28
+ // The KMS key is only used in the source statements, and these need a
29
+ // bucket. Thus Console ignores the key while the bucket is empty.
30
+ const sourceKmsKeyArn = bucket === '' ? '' : kmsKeyArn;
31
+ const kmsValid = sourceKmsKeyArn === '' || isValidKmsKeyArn(sourceKmsKeyArn);
32
+ const { access } = migration;
33
+ const policy = access
34
+ ? buildAwsMigrationPolicy({
35
+ access,
36
+ source: { bucket, kmsKeyArn: sourceKmsKeyArn || undefined },
37
+ principal: migration.spec.principal,
38
+ })
39
+ : undefined;
40
+ return (_jsxs(_Fragment, { children: [_jsx(TextInput, { id: 'cluster-migration-source-bucket', labelText: t.sourceBucketLabel, helperText: t.sourceBucketHelper, value: bucket, invalid: !bucketValid, invalidText: t.sourceBucketInvalid, disabled: disabled, onChange: (event) => setBucket(event.target.value.trim()) }), _jsx(TextInput, { id: 'cluster-migration-source-kms-key', labelText: t.sourceKmsKeyLabel, helperText: bucket === '' ? t.sourceKmsKeyNeedsBucket : undefined, value: kmsKeyArn, invalid: !kmsValid, invalidText: t.sourceKmsKeyInvalid, disabled: disabled || bucket === '', onChange: (event) => setKmsKeyArn(event.target.value.trim()) }), _jsxs(Stack, { gap: 3, children: [_jsx("h4", { children: t.policyTitle }), _jsx("p", { children: t.policyText }), !access?.bucket && (_jsx("div", { "data-testid": 'cluster-migration-policy-preparing', children: _jsx(C4InlineNotification, { kind: 'info', title: '', subtitle: t.policyPreparing, hideCloseButton: true }) })), policy && policy.Statement.length > 0 && (_jsx("div", { "data-testid": 'cluster-migration-policy', children: _jsx(DsCodeBlock, { children: JSON.stringify(policy, undefined, 2) }) }))] }), _jsx("div", { children: _jsx(Button, { disabled: disabled || !bucketValid || !kmsValid, onClick: () => onTransferFinished({
41
+ bucket: bucket || undefined,
42
+ kmsKeyArn: sourceKmsKeyArn || undefined,
43
+ }), children: t.transferFinishedButton }) })] }));
44
+ }
45
+ function BackupChoicePanel({ migration, disabled, onChooseBackup, onReopenTransfer, translations: t, }) {
46
+ // A new attempt often uses the same backup, thus the last choice is the
47
+ // start value.
48
+ const last = migration.spec.backup;
49
+ const [backupId, setBackupId] = useState(last?.backupId ?? '');
50
+ const [partitions, setPartitions] = useState(last ? String(last.partitionsCount) : '');
18
51
  const idValid = isValidBackupId(backupId);
19
- const showIdError = touched && !idValid;
20
- return (_jsxs(Stack, { gap: 5, "data-testid": 'cluster-migration-awaiting', children: [_jsx("h3", { children: t.awaitingTitle }), _jsx("p", { children: t.awaitingInstructions }), roleArn && (_jsxs("p", { children: [t.roleArnLabel, ' ', _jsx("code", { "data-testid": 'cluster-migration-role-arn', children: roleArn })] })), _jsx(TextInput, { id: 'cluster-migration-backup-id', labelText: t.backupIdLabel, value: backupId, invalid: showIdError, invalidText: t.backupIdInvalid, disabled: busy, onChange: (event) => {
21
- setTouched(true);
22
- setBackupId(event.target.value.trim());
23
- } }), _jsx(Checkbox, { id: 'cluster-migration-transfer-done', labelText: t.transferDoneLabel, checked: transferDone, disabled: busy, onChange: (event) => setTransferDone(event.target.checked) }), _jsx(C4InlineNotification, { kind: 'warning', title: '', subtitle: t.restoreWarning, hideCloseButton: true }), error && (_jsx(C4InlineNotification, { kind: 'error', title: '', subtitle: error, hideCloseButton: true })), _jsx("div", { children: _jsx(Button, { disabled: busy || !canConfirm || !idValid || !transferDone, onClick: () => onConfirm(backupId), children: t.confirmButton }) })] }));
52
+ const partitionsValid = isValidPartitionsCount(partitions);
53
+ const [backupCopied, setBackupCopied] = useState(false);
54
+ return (_jsxs(_Fragment, { children: [_jsx(TextInput, { id: 'cluster-migration-backup-id', labelText: t.backupIdLabel, value: backupId, invalid: backupId !== '' && !idValid, invalidText: t.backupIdInvalid, disabled: disabled, onChange: (event) => setBackupId(event.target.value.trim()) }), _jsx(TextInput, { id: 'cluster-migration-partitions', labelText: t.partitionsLabel, helperText: t.partitionsHelper, value: partitions, invalid: partitions !== '' && !partitionsValid, invalidText: t.partitionsInvalid, disabled: disabled, onChange: (event) => setPartitions(event.target.value.trim()) }), _jsx(C4InlineNotification, { kind: 'warning', title: '', subtitle: t.restoreWarning, hideCloseButton: true }), _jsx(Checkbox, { id: 'cluster-migration-backup-copied', labelText: t.backupCopiedLabel, checked: backupCopied, disabled: disabled, onChange: (event) => setBackupCopied(event.target.checked) }), _jsxs(Stack, { orientation: 'horizontal', gap: 3, children: [_jsx(Button, { disabled: disabled || !idValid || !partitionsValid || !backupCopied, onClick: () => onChooseBackup({ backupId, partitionsCount: Number(partitions) }), children: t.chooseBackupButton }), onReopenTransfer && (_jsx(Button, { kind: 'secondary', disabled: disabled, onClick: onReopenTransfer, children: t.reopenTransferButton }))] })] }));
24
55
  }
@@ -1,23 +1,58 @@
1
+ import type { MigrationPhase, MigrationReason, MigrationReasonParams, MigrationSourceInput, MigrationView } from '../../utils/migration-view.js';
1
2
  export interface C4ClusterMigrationTranslations {
2
- awaitingTitle: string;
3
- awaitingInstructions: string;
4
- roleArnLabel: string;
3
+ title: Record<MigrationPhase, string>;
4
+ /**
5
+ * The text of a reason with its values. Without a reason, the general text
6
+ * of the phase.
7
+ */
8
+ reasonText: (phase: MigrationPhase, reason: MigrationReason | undefined, params: MigrationReasonParams) => string;
9
+ principalLabel: string;
10
+ sourceBucketLabel: string;
11
+ sourceBucketHelper: string;
12
+ sourceBucketInvalid: string;
13
+ sourceKmsKeyLabel: string;
14
+ /** Shown while the KMS field is disabled, because the bucket is empty. */
15
+ sourceKmsKeyNeedsBucket: string;
16
+ sourceKmsKeyInvalid: string;
17
+ policyTitle: string;
18
+ policyText: string;
19
+ /** Shown while the backup storage of the cluster does not exist yet. */
20
+ policyPreparing: string;
21
+ transferFinishedButton: string;
5
22
  backupIdLabel: string;
6
23
  backupIdInvalid: string;
7
- transferDoneLabel: string;
24
+ partitionsLabel: string;
25
+ partitionsHelper: string;
26
+ partitionsInvalid: string;
8
27
  restoreWarning: string;
9
- confirmButton: string;
10
- migratingTitle: string;
11
- migratingText: string;
28
+ /** The required check before a restore: a restore replaces all data. */
29
+ backupCopiedLabel: string;
30
+ chooseBackupButton: string;
31
+ reopenTransferButton: string;
32
+ progressText: string;
33
+ deleteButton: string;
34
+ }
35
+ export interface C4ClusterMigrationBackupChoice {
36
+ /** A string, because a number loses digits above 2^53. */
37
+ backupId: string;
38
+ partitionsCount: number;
12
39
  }
13
40
  export interface C4ClusterMigrationProps {
14
- state: 'awaitingTransfer' | 'migrating';
15
- roleArn?: string;
41
+ migration: MigrationView;
16
42
  busy?: boolean;
17
43
  /** False for a member without the right to update the cluster. */
18
- canConfirm?: boolean;
44
+ canEdit?: boolean;
19
45
  error?: string;
20
- /** Gets the backup ID as a string, because a number loses digits. */
21
- onConfirm: (backupId: string) => void;
46
+ /** Transferring: the customer finished the copy. */
47
+ onTransferFinished: (source: MigrationSourceInput) => void;
48
+ /** AwaitingBackup: the customer must copy more. */
49
+ onReopenTransfer: () => void;
50
+ /** AwaitingBackup and RestoreFailed: a new attempt with this backup. */
51
+ onChooseBackup: (choice: C4ClusterMigrationBackupChoice) => void;
52
+ /**
53
+ * VerificationFailed: the next step is a new migration cluster. Not set for
54
+ * a member without the right to delete the cluster.
55
+ */
56
+ onDelete?: () => void;
22
57
  translations: C4ClusterMigrationTranslations;
23
58
  }
@@ -1,5 +1,3 @@
1
- import { safeTranslate } from '../../utils/safe-translate.js';
1
+ import { type TranslateFn } from '../../utils/safe-translate.js';
2
2
  import type { C4ClusterMigrationTranslations } from './c4-cluster-migration.types.js';
3
- type T = Parameters<typeof safeTranslate>[0];
4
- export declare const buildMigrationTranslations: (t: T) => C4ClusterMigrationTranslations;
5
- export {};
3
+ export declare const buildMigrationTranslations: (t: TranslateFn | undefined) => C4ClusterMigrationTranslations;
@@ -3,19 +3,94 @@
3
3
  * under one or more contributor license agreements. Licensed under a commercial license.
4
4
  * You may not use this file except in compliance with the commercial license.
5
5
  */
6
+ import { MIGRATION_PHASES, } from '../../utils/migration-view.js';
6
7
  import { safeTranslate } from '../../utils/safe-translate.js';
7
- // TODO(3844-workaround): The English text lives in
8
- // `i18n/en/pages/clusterdetails.json`. The defaults here keep a host without
9
- // the c4 catalog readable.
10
- export const buildMigrationTranslations = (t) => ({
11
- awaitingTitle: safeTranslate(t, 'clusterdetails:migration.awaiting.title', 'Transfer your data'),
12
- awaitingInstructions: safeTranslate(t, 'clusterdetails:migration.awaiting.instructions', 'Copy your Self-Managed backup to the storage that Camunda reads. Let the IAM role below access it. Then enter the backup ID and confirm.'),
13
- roleArnLabel: safeTranslate(t, 'clusterdetails:migration.awaiting.roleArn', 'IAM role:'),
14
- backupIdLabel: safeTranslate(t, 'clusterdetails:migration.awaiting.backupId', 'Backup ID'),
15
- backupIdInvalid: safeTranslate(t, 'clusterdetails:migration.awaiting.backupIdInvalid', 'Enter a whole number from 1 to 9223372036854775807.'),
16
- transferDoneLabel: safeTranslate(t, 'clusterdetails:migration.awaiting.transferDone', 'I copied the backup'),
17
- restoreWarning: safeTranslate(t, 'clusterdetails:migration.awaiting.warning', 'The restore replaces all existing data in this cluster.'),
18
- confirmButton: safeTranslate(t, 'clusterdetails:migration.awaiting.confirm', 'Start migration'),
19
- migratingTitle: safeTranslate(t, 'clusterdetails:migration.migrating.title', 'Migration in progress'),
20
- migratingText: safeTranslate(t, 'clusterdetails:migration.migrating.text', 'Camunda restores your backup. This cluster has no actions until the migration ends.'),
21
- });
8
+ // The English text lives in `i18n/en/pages/clusterdetails.json`. The defaults
9
+ // here keep a host without the c4 catalog readable. The reason texts follow
10
+ // the messages of the operator contract.
11
+ const TITLE = {
12
+ AwaitingPrincipal: 'Preparing the migration',
13
+ Transferring: 'Transfer your backup',
14
+ AwaitingBackup: 'Choose the backup',
15
+ Verifying: 'Checking the backup',
16
+ Restoring: 'Restoring the backup',
17
+ Completed: 'Migration complete',
18
+ VerificationFailed: "The backup can't be used",
19
+ RestoreFailed: 'Restore failed',
20
+ };
21
+ /** The text of a phase that has no reason. */
22
+ const PHASE = {
23
+ AwaitingPrincipal: 'Giving your IAM role access to the backup storage of this cluster.',
24
+ Transferring: 'Your IAM role can copy backups into the backup storage of this cluster. Confirm when the copy is finished.',
25
+ AwaitingBackup: 'Choose the backup to restore.',
26
+ Verifying: 'Checking that the backup is complete and works with this cluster.',
27
+ Restoring: 'Restoring the backup.',
28
+ Completed: 'The migration is complete.',
29
+ VerificationFailed: "The backup didn't pass the checks. Nothing in this cluster changed. Delete this cluster and start a new migration.",
30
+ RestoreFailed: 'The restore failed. Choose a backup to try again. The next restore replaces all data.',
31
+ };
32
+ const REASON = {
33
+ WaitingForPrincipal: 'Enter the IAM role that you created to copy your backups.',
34
+ GrantingAccess: 'Giving your IAM role access to the backup storage of this cluster.',
35
+ TransferOpen: 'Your IAM role can copy backups into the backup storage of this cluster. Confirm when the copy is finished.',
36
+ RemovingAccess: 'Removing the access of your IAM role to the backup storage of this cluster.',
37
+ WaitingForBackupChoice: 'Choose the backup to restore.',
38
+ BackupNotFound: "Backup {{backupId}} isn't in the backup storage of this cluster. Choose another backup or reopen the transfer.",
39
+ PartitionCountMismatch: 'Backup {{backupId}} has {{backupPartitions}} partitions, not {{chosenPartitions}}. Check the partition count and choose again.',
40
+ VerifyingBackup: 'Checking that backup {{backupId}} is complete and works with this cluster.',
41
+ RestoringBackup: 'Restoring backup {{backupId}}.',
42
+ MigrationCompleted: 'The migration is complete.',
43
+ BackupIncomplete: 'Backup {{backupId}} is incomplete. Copy it again completely into a new migration cluster.',
44
+ SnapshotsMissing: 'Some data of backup {{backupId}} is missing. Copy the whole backup, including all Elasticsearch snapshots, into a new migration cluster.',
45
+ BackupUnreadable: 'Backup {{backupId}} was written with an encryption key other than the key of this cluster. Copy it into a new migration cluster without encryption options.',
46
+ ElasticsearchVersionIncompatible: 'The backup was taken with Elasticsearch {{backupVersion}}, which is newer than {{clusterVersion}} of this cluster. Create a new migration cluster with Elasticsearch {{backupVersion}} or later.',
47
+ CamundaVersionIncompatible: 'The backup was taken with Camunda {{backupVersion}}, which is newer than {{clusterVersion}} of this cluster. Create a new migration cluster with Camunda {{backupVersion}} or later.',
48
+ PartitionCountIncompatible: 'The backup has {{backupPartitions}} partitions, but this cluster has {{clusterPartitions}}. Create a new migration cluster with {{backupPartitions}} partitions.',
49
+ InsufficientDiskSize: 'Backup {{backupId}} needs more disk than this cluster has. Create a new migration cluster with a larger plan.',
50
+ RestoreFailedBeforeDataDeletion: 'The restore of backup {{backupId}} failed before it changed data in this cluster. Choose a backup to try again.',
51
+ RestoreFailedAfterDataDeletion: 'The restore of backup {{backupId}} failed after the data of this cluster was replaced. The cluster might be partly restored. Choose a backup to try again. The next restore replaces all data.',
52
+ };
53
+ const PLACEHOLDER = /{{(\w+)}}/g;
54
+ const placeholders = (template) => [...template.matchAll(PLACEHOLDER)].map((match) => match[1]);
55
+ const interpolate = (template, params) => template.replace(PLACEHOLDER, (_, name) => String(params[name] ?? ''));
56
+ export const buildMigrationTranslations = (t) => {
57
+ const text = (key, fallback) => safeTranslate(t, `clusterdetails:migration.${key}`, fallback);
58
+ return {
59
+ title: Object.fromEntries(MIGRATION_PHASES.map((phase) => [
60
+ phase,
61
+ text(`title.${phase}`, TITLE[phase]),
62
+ ])),
63
+ reasonText: (phase, reason, params) => {
64
+ const template = reason ? REASON[reason] : undefined;
65
+ // A reason without its values would show a gap. The text of the phase
66
+ // is better.
67
+ if (!template ||
68
+ placeholders(template).some((name) => params[name] === undefined)) {
69
+ return text(`phase.${phase}`, PHASE[phase]);
70
+ }
71
+ return safeTranslate(t, `clusterdetails:migration.reason.${reason}`, interpolate(template, params), { ...params });
72
+ },
73
+ principalLabel: text('principalLabel', 'IAM role:'),
74
+ sourceBucketLabel: text('sourceBucketLabel', 'Self-Managed backup bucket (optional)'),
75
+ sourceBucketHelper: text('sourceBucketHelper', 'Enter it to add the read access to this bucket to the policy.'),
76
+ sourceBucketInvalid: text('sourceBucketInvalid', 'Enter a valid S3 bucket name, or leave it empty.'),
77
+ sourceKmsKeyLabel: text('sourceKmsKeyLabel', 'KMS key ARN of the bucket (optional)'),
78
+ sourceKmsKeyNeedsBucket: text('sourceKmsKeyNeedsBucket', 'Enter the bucket first.'),
79
+ sourceKmsKeyInvalid: text('sourceKmsKeyInvalid', 'Enter a valid KMS key ARN, or leave it empty.'),
80
+ policyTitle: text('policyTitle', 'IAM policy'),
81
+ policyText: text('policyText', 'Attach this policy to your IAM role. It lets the role read your backup and write it into the backup storage of this cluster.'),
82
+ policyPreparing: text('policyPreparing', 'Camunda is preparing the backup storage of this cluster. The policy gets its statements for it when the storage is ready.'),
83
+ transferFinishedButton: text('transferFinishedButton', 'Transfer finished'),
84
+ backupIdLabel: text('backupIdLabel', 'Backup ID'),
85
+ backupIdInvalid: text('backupIdInvalid', 'Enter a whole number from 1 to 9223372036854775807.'),
86
+ partitionsLabel: text('partitionsLabel', 'Partitions'),
87
+ partitionsHelper: text('partitionsHelper', 'The partition count of the backup. Enter 0 for a backup with Elasticsearch data only.'),
88
+ partitionsInvalid: text('partitionsInvalid', 'Enter a whole number from 0 to 2147483647.'),
89
+ restoreWarning: text('restoreWarning', 'The restore replaces all data in this cluster.'),
90
+ backupCopiedLabel: text('backupCopiedLabel', 'I copied the backup'),
91
+ chooseBackupButton: text('chooseBackupButton', 'Restore backup'),
92
+ reopenTransferButton: text('reopenTransferButton', 'Reopen transfer'),
93
+ progressText: text('progressText', 'This cluster has no actions until the migration ends. To cancel the migration, delete the cluster.'),
94
+ deleteButton: text('deleteButton', 'Delete cluster'),
95
+ };
96
+ };
@@ -779,19 +779,68 @@
779
779
  }
780
780
  },
781
781
  "migration": {
782
- "awaiting": {
783
- "title": "Transfer your data",
784
- "instructions": "Copy your Self-Managed backup to the storage that Camunda reads. Let the IAM role below access it. Then enter the backup ID and confirm.",
785
- "roleArn": "IAM role:",
786
- "backupId": "Backup ID",
787
- "backupIdInvalid": "Enter a whole number from 1 to 9223372036854775807.",
788
- "transferDone": "I copied the backup",
789
- "warning": "The restore replaces all existing data in this cluster.",
790
- "confirm": "Start migration"
791
- },
792
- "migrating": {
793
- "title": "Migration in progress",
794
- "text": "Camunda restores your backup. This cluster has no actions until the migration ends."
795
- }
782
+ "title": {
783
+ "AwaitingPrincipal": "Preparing the migration",
784
+ "Transferring": "Transfer your backup",
785
+ "AwaitingBackup": "Choose the backup",
786
+ "Verifying": "Checking the backup",
787
+ "Restoring": "Restoring the backup",
788
+ "Completed": "Migration complete",
789
+ "VerificationFailed": "The backup can't be used",
790
+ "RestoreFailed": "Restore failed"
791
+ },
792
+ "phase": {
793
+ "AwaitingPrincipal": "Giving your IAM role access to the backup storage of this cluster.",
794
+ "Transferring": "Your IAM role can copy backups into the backup storage of this cluster. Confirm when the copy is finished.",
795
+ "AwaitingBackup": "Choose the backup to restore.",
796
+ "Verifying": "Checking that the backup is complete and works with this cluster.",
797
+ "Restoring": "Restoring the backup.",
798
+ "Completed": "The migration is complete.",
799
+ "VerificationFailed": "The backup didn't pass the checks. Nothing in this cluster changed. Delete this cluster and start a new migration.",
800
+ "RestoreFailed": "The restore failed. Choose a backup to try again. The next restore replaces all data."
801
+ },
802
+ "reason": {
803
+ "WaitingForPrincipal": "Enter the IAM role that you created to copy your backups.",
804
+ "GrantingAccess": "Giving your IAM role access to the backup storage of this cluster.",
805
+ "TransferOpen": "Your IAM role can copy backups into the backup storage of this cluster. Confirm when the copy is finished.",
806
+ "RemovingAccess": "Removing the access of your IAM role to the backup storage of this cluster.",
807
+ "WaitingForBackupChoice": "Choose the backup to restore.",
808
+ "BackupNotFound": "Backup {{backupId}} isn't in the backup storage of this cluster. Choose another backup or reopen the transfer.",
809
+ "PartitionCountMismatch": "Backup {{backupId}} has {{backupPartitions}} partitions, not {{chosenPartitions}}. Check the partition count and choose again.",
810
+ "VerifyingBackup": "Checking that backup {{backupId}} is complete and works with this cluster.",
811
+ "RestoringBackup": "Restoring backup {{backupId}}.",
812
+ "MigrationCompleted": "The migration is complete.",
813
+ "BackupIncomplete": "Backup {{backupId}} is incomplete. Copy it again completely into a new migration cluster.",
814
+ "SnapshotsMissing": "Some data of backup {{backupId}} is missing. Copy the whole backup, including all Elasticsearch snapshots, into a new migration cluster.",
815
+ "BackupUnreadable": "Backup {{backupId}} was written with an encryption key other than the key of this cluster. Copy it into a new migration cluster without encryption options.",
816
+ "ElasticsearchVersionIncompatible": "The backup was taken with Elasticsearch {{backupVersion}}, which is newer than {{clusterVersion}} of this cluster. Create a new migration cluster with Elasticsearch {{backupVersion}} or later.",
817
+ "CamundaVersionIncompatible": "The backup was taken with Camunda {{backupVersion}}, which is newer than {{clusterVersion}} of this cluster. Create a new migration cluster with Camunda {{backupVersion}} or later.",
818
+ "PartitionCountIncompatible": "The backup has {{backupPartitions}} partitions, but this cluster has {{clusterPartitions}}. Create a new migration cluster with {{backupPartitions}} partitions.",
819
+ "InsufficientDiskSize": "Backup {{backupId}} needs more disk than this cluster has. Create a new migration cluster with a larger plan.",
820
+ "RestoreFailedBeforeDataDeletion": "The restore of backup {{backupId}} failed before it changed data in this cluster. Choose a backup to try again.",
821
+ "RestoreFailedAfterDataDeletion": "The restore of backup {{backupId}} failed after the data of this cluster was replaced. The cluster might be partly restored. Choose a backup to try again. The next restore replaces all data."
822
+ },
823
+ "principalLabel": "IAM role:",
824
+ "sourceBucketLabel": "Self-Managed backup bucket (optional)",
825
+ "sourceBucketHelper": "Enter it to add the read access to this bucket to the policy.",
826
+ "sourceBucketInvalid": "Enter a valid S3 bucket name, or leave it empty.",
827
+ "sourceKmsKeyLabel": "KMS key ARN of the bucket (optional)",
828
+ "sourceKmsKeyNeedsBucket": "Enter the bucket first.",
829
+ "sourceKmsKeyInvalid": "Enter a valid KMS key ARN, or leave it empty.",
830
+ "policyTitle": "IAM policy",
831
+ "policyText": "Attach this policy to your IAM role. It lets the role read your backup and write it into the backup storage of this cluster.",
832
+ "policyPreparing": "Camunda is preparing the backup storage of this cluster. The policy gets its statements for it when the storage is ready.",
833
+ "transferFinishedButton": "Transfer finished",
834
+ "backupIdLabel": "Backup ID",
835
+ "backupIdInvalid": "Enter a whole number from 1 to 9223372036854775807.",
836
+ "partitionsLabel": "Partitions",
837
+ "partitionsHelper": "The partition count of the backup. Enter 0 for a backup with Elasticsearch data only.",
838
+ "partitionsInvalid": "Enter a whole number from 0 to 2147483647.",
839
+ "restoreWarning": "The restore replaces all data in this cluster.",
840
+ "backupCopiedLabel": "I copied the backup",
841
+ "chooseBackupButton": "Restore backup",
842
+ "reopenTransferButton": "Reopen transfer",
843
+ "progressText": "This cluster has no actions until the migration ends. To cancel the migration, delete the cluster.",
844
+ "deleteButton": "Delete cluster"
796
845
  }
797
846
  }
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "name": {
35
35
  "validation": {
36
- "maxLength": "Cluster names can't be longer than 35 characters when you migrate."
36
+ "maxLength": "Cluster names can't be longer than 33 characters when you migrate."
37
37
  }
38
38
  }
39
39
  },
@@ -59,7 +59,7 @@ export { C4ClusterList } from './components/c4-cluster-list/c4-cluster-list.js';
59
59
  export type { C4ClusterListProps, ClusterListItem, ClusterListNotification, ClusterListPermissions, ClusterListUrls, } from './components/c4-cluster-list/c4-cluster-list.types.js';
60
60
  export { type ClusterExpiryRemaining, type ClusterExpiryTag, type ClusterExpiryTagCopy, DEFAULT_CLUSTER_EXPIRY_TAG_COPY, getClusterExpiryRemaining, getClusterExpiryTag, } from './components/c4-cluster-list/cluster-expiry-tag.js';
61
61
  export { C4ClusterMigration } from './components/c4-cluster-migration/c4-cluster-migration.js';
62
- export type { C4ClusterMigrationProps, C4ClusterMigrationTranslations, } from './components/c4-cluster-migration/c4-cluster-migration.types.js';
62
+ export type { C4ClusterMigrationBackupChoice, C4ClusterMigrationProps, C4ClusterMigrationTranslations, } from './components/c4-cluster-migration/c4-cluster-migration.types.js';
63
63
  export type { ApplicationsProps, ApplicationTileProps, ClusterStatus, } from './components/c4-cluster-overview/applications.js';
64
64
  export { ClusterStatusElement, normalizeClusterStatus, } from './components/c4-cluster-overview/applications.js';
65
65
  export { C4ClusterOverview, C4IconAndTextElement, getClusterLoadConfig, getDsClusterLoadPresentation, } from './components/c4-cluster-overview/c4-cluster-overview.js';
@@ -215,6 +215,7 @@ export { openC4InviteUserToOrganizationModal, setC4InviteUserToOrganizationModal
215
215
  export { openC4RenameOrganizationModal, setC4RenameOrganizationModalHandle, } from './modals/c4-rename-organization-modal-handle.js';
216
216
  export type { AccountsPermissions, AddC4ConsoleNotificationOptions, C4BreadcrumbCrumb, C4BreadcrumbDropdownItem, C4ClusterNavAppEntry, C4ClusterNavEntry, C4ConsoleAuthzFeatures, C4ConsoleAuthzState, C4ConsoleDataState, C4ConsoleEventsProviderProps, C4ConsoleNotification, C4ConsoleNotificationAction, C4ConsoleNotificationKind, C4ConsoleNotificationsState, C4ConsoleRuntimeConfig, C4ConsoleVisibilities, C4ResolvedTheme, C4ThemePreference, C4UserNotificationsProviderProps, C4UserNotificationsState, C4UserThemeState, CacheState, CamundaWebApp, ConsoleAuth, ConsoleBackendUrls, ConsoleClickwrapConfig, ConsoleClusterDto, ConsolePermissions, ConsolePublicUrls, ConsoleStage, ConsoleTelemetry, ConsoleUser, ExternalClusterDto, ExternalOrganizationDto, NotificationDto, OrganizationPermissions, OrganizationRole, OrgCache, SseEntity, UpgradableGenerationsDto, UseC4ClusterNavEntriesOptions, UseC4WebappBreadcrumbDataOptions, } from './runtime/index.js';
217
217
  export { addC4ConsoleNotification, buildClusterSsoCallbackUrl, buildClusterSwaggerUrl, buildModelerOrgUrl, C4ConsoleDataProvider, C4ConsoleEventsProvider, C4ConsoleNotificationsProvider, C4ConsoleRuntimeProvider, C4UserNotificationsProvider, DEFAULT_NAV_APPS, getClusterStage, getEndpointForApp, getReadableAppName, hasReadPermissionForApp, isAdminApp, isAppHealthyOnCluster, removeC4ConsoleNotificationById, resolveAdminAppName, setC4ConsoleNotificationsHandle, useC4ClusterNavEntries, useC4ConsoleAuthz, useC4ConsoleData, useC4ConsoleEventsState, useC4ConsoleNotifications, useC4ConsoleRuntime, useC4ConsoleStage, useC4FeatureFlag, useC4TwoPhaseUpgradeMockup, useC4UserNotifications, useC4UserTheme, useC4WebappBreadcrumbData, } from './runtime/index.js';
218
+ export type { MigrationAccess, MigrationAccessStatement, MigrationBackupChoice, MigrationDetectedBackup, MigrationPhase, MigrationReason, MigrationReasonParams, MigrationSourceAccess, MigrationSourceInput, MigrationSourceKind, MigrationSpec, MigrationView, } from './utils/migration-view.js';
218
219
  export type { TranslateFn } from './utils/safe-translate.js';
219
220
  export { ENVIRONMENT_KEY_SUFFIX, safeTranslate, scopedTranslate, } from './utils/safe-translate.js';
220
221
  export type { C4WidgetScope } from './widgets/c4-widget-scope.types.js';
@@ -0,0 +1,22 @@
1
+ import type { MigrationAccess, MigrationSourceInput } from './migration-view.js';
2
+ export declare const isValidS3BucketName: (value: string) => boolean;
3
+ export declare const isValidKmsKeyArn: (value: string) => boolean;
4
+ export interface AwsPolicyStatement {
5
+ Effect: 'Allow';
6
+ Action: string[];
7
+ Resource: string;
8
+ }
9
+ export interface AwsPolicyDocument {
10
+ Version: '2012-10-17';
11
+ Statement: AwsPolicyStatement[];
12
+ }
13
+ /**
14
+ * The policy of the customer's principal: the target statements of `access`,
15
+ * and the source statements when the source bucket is valid. The `Key`
16
+ * statement is left out when the source bucket uses no KMS key.
17
+ */
18
+ export declare const buildAwsMigrationPolicy: ({ access, source, principal, }: {
19
+ access: MigrationAccess;
20
+ source: MigrationSourceInput;
21
+ principal: string;
22
+ }) => AwsPolicyDocument;
@@ -0,0 +1,54 @@
1
+ /*
2
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
3
+ * under one or more contributor license agreements. Licensed under a commercial license.
4
+ * You may not use this file except in compliance with the commercial license.
5
+ */
6
+ // The contract publishes the actions. Console adds the resources of the
7
+ // source side that the customer enters, and renders one IAM policy for the
8
+ // customer's principal.
9
+ const S3_BUCKET_NAME_PATTERN = /^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/;
10
+ // AWS forbids two periods, a period next to a hyphen, an IP address form, and
11
+ // the prefixes and suffixes that it keeps for its own use.
12
+ const S3_BUCKET_NAME_FORBIDDEN = /\.\.|\.-|-\.|^\d+\.\d+\.\d+\.\d+$|^(xn--|sthree-|amzn-s3-demo-)|(-s3alias|--ol-s3|\.mrap|--x-s3|--table-s3)$/;
13
+ const KMS_KEY_ARN_PATTERN = /^arn:(aws|aws-cn|aws-us-gov):kms:[a-z0-9-]+:[0-9]{12}:key\/[A-Za-z0-9-]{1,128}$/;
14
+ export const isValidS3BucketName = (value) => S3_BUCKET_NAME_PATTERN.test(value) && !S3_BUCKET_NAME_FORBIDDEN.test(value);
15
+ export const isValidKmsKeyArn = (value) => KMS_KEY_ARN_PATTERN.test(value);
16
+ /** The AWS partition of an ARN, for example `aws` or `aws-cn`. */
17
+ const partitionOf = (arn) => arn.split(':')[1] || 'aws';
18
+ const sourceResource = (kind, bucketArn, kmsKeyArn) => {
19
+ if (kind === 'Bucket')
20
+ return bucketArn;
21
+ if (kind === 'Objects')
22
+ return `${bucketArn}/*`;
23
+ return kmsKeyArn;
24
+ };
25
+ /**
26
+ * The policy of the customer's principal: the target statements of `access`,
27
+ * and the source statements when the source bucket is valid. The `Key`
28
+ * statement is left out when the source bucket uses no KMS key.
29
+ */
30
+ export const buildAwsMigrationPolicy = ({ access, source, principal, }) => {
31
+ const statements = access.statements.map((statement) => ({
32
+ Effect: 'Allow',
33
+ Action: statement.actions,
34
+ Resource: statement.resource,
35
+ }));
36
+ const bucket = source.bucket ?? '';
37
+ if (isValidS3BucketName(bucket)) {
38
+ const bucketArn = `arn:${partitionOf(principal)}:s3:::${bucket}`;
39
+ const kmsKeyArn = source.kmsKeyArn && isValidKmsKeyArn(source.kmsKeyArn)
40
+ ? source.kmsKeyArn
41
+ : undefined;
42
+ for (const entry of access.source) {
43
+ const resource = sourceResource(entry.kind, bucketArn, kmsKeyArn);
44
+ if (resource) {
45
+ statements.push({
46
+ Effect: 'Allow',
47
+ Action: entry.actions,
48
+ Resource: resource,
49
+ });
50
+ }
51
+ }
52
+ }
53
+ return { Version: '2012-10-17', Statement: statements };
54
+ };
@@ -0,0 +1,98 @@
1
+ export declare const MIGRATION_PHASES: readonly ["AwaitingPrincipal", "Transferring", "AwaitingBackup", "Verifying", "Restoring", "Completed", "VerificationFailed", "RestoreFailed"];
2
+ export type MigrationPhase = (typeof MIGRATION_PHASES)[number];
3
+ /** The reasons of the contract's reason catalogue, per phase. */
4
+ export declare const MIGRATION_REASONS_BY_PHASE: {
5
+ readonly AwaitingPrincipal: readonly ["WaitingForPrincipal", "GrantingAccess"];
6
+ readonly Transferring: readonly ["TransferOpen", "RemovingAccess"];
7
+ readonly AwaitingBackup: readonly ["WaitingForBackupChoice", "BackupNotFound", "PartitionCountMismatch"];
8
+ readonly Verifying: readonly ["VerifyingBackup"];
9
+ readonly Restoring: readonly ["RestoringBackup"];
10
+ readonly Completed: readonly ["MigrationCompleted"];
11
+ readonly VerificationFailed: readonly ["BackupIncomplete", "SnapshotsMissing", "BackupUnreadable", "ElasticsearchVersionIncompatible", "CamundaVersionIncompatible", "PartitionCountIncompatible", "InsufficientDiskSize"];
12
+ readonly RestoreFailed: readonly ["RestoreFailedBeforeDataDeletion", "RestoreFailedAfterDataDeletion"];
13
+ };
14
+ export type MigrationReason = (typeof MIGRATION_REASONS_BY_PHASE)[MigrationPhase][number];
15
+ /**
16
+ * The values of a reason. A backup ID is an int64 in Zeebe, thus a string here:
17
+ * a JavaScript number loses digits above 2^53.
18
+ */
19
+ export interface MigrationReasonParams {
20
+ backupId?: string;
21
+ backupPartitions?: number;
22
+ chosenPartitions?: number;
23
+ clusterPartitions?: number;
24
+ backupVersion?: string;
25
+ clusterVersion?: string;
26
+ }
27
+ export interface MigrationAccessStatement {
28
+ resource: string;
29
+ actions: string[];
30
+ }
31
+ export type MigrationSourceKind = 'Bucket' | 'Objects' | 'Key';
32
+ export interface MigrationSourceAccess {
33
+ kind: MigrationSourceKind;
34
+ actions: string[];
35
+ }
36
+ /** What the customer's principal needs. The contract's `status.access`. */
37
+ export interface MigrationAccess {
38
+ /** The backup bucket of the cluster. Not set while the bucket is created. */
39
+ bucket?: string;
40
+ /** The customer's KMS key. Set only for a BYOK cluster. */
41
+ encryptionKey?: string;
42
+ /** The target-side statements. Empty while `bucket` is not set. */
43
+ statements: MigrationAccessStatement[];
44
+ /** The source-side actions. Console fills in the resources. */
45
+ source: MigrationSourceAccess[];
46
+ }
47
+ export interface MigrationDetectedBackup {
48
+ backupId: string;
49
+ partitionsCount: number;
50
+ complete: boolean;
51
+ time: string;
52
+ latestComplete?: boolean;
53
+ }
54
+ export interface MigrationBackupChoice {
55
+ /** An integer from 1 to 2^63-1, as a string. */
56
+ backupId: string;
57
+ partitionsCount: number;
58
+ attempt: number;
59
+ }
60
+ export interface MigrationSpec {
61
+ principal: string;
62
+ transferCompleted: boolean;
63
+ backup?: MigrationBackupChoice;
64
+ }
65
+ /**
66
+ * The source side that the customer enters. The operator never sees it. Console
67
+ * keeps it only to render the source statements of the policy.
68
+ */
69
+ export interface MigrationSourceInput {
70
+ /** The name of the customer's Self-Managed bucket. */
71
+ bucket?: string;
72
+ /** The ARN of the KMS key of that bucket. Not set when it uses none. */
73
+ kmsKeyArn?: string;
74
+ }
75
+ export interface MigrationView {
76
+ phase: MigrationPhase;
77
+ /**
78
+ * Not set only when the source of the view knows no reason. Then the UI
79
+ * shows the general text of the phase.
80
+ */
81
+ reason?: MigrationReason;
82
+ reasonParams: MigrationReasonParams;
83
+ /** Not set while the operator prepares the backup bucket. */
84
+ access?: MigrationAccess;
85
+ detection: {
86
+ backups: MigrationDetectedBackup[];
87
+ };
88
+ spec: MigrationSpec;
89
+ source: MigrationSourceInput;
90
+ /** The cluster name without any state encoding. */
91
+ displayName: string;
92
+ }
93
+ /** The ADR lock rule: a migration cluster is hidden and locked until Completed. */
94
+ export declare const isMigrationLocked: (view: MigrationView | undefined) => boolean;
95
+ /** A backup ID is an integer from 1 to 2^63-1. A string keeps every digit. */
96
+ export declare const isValidBackupId: (value: string) => boolean;
97
+ /** A partition count is a whole number from 0 to 2147483647. `0`: Elasticsearch data only. */
98
+ export declare const isValidPartitionsCount: (value: string) => boolean;