diff --git a/public/app/features/migrate-to-cloud/cloud/MigrationTokenPane/MigrationTokenModal.tsx b/public/app/features/migrate-to-cloud/cloud/MigrationTokenPane/MigrationTokenModal.tsx
index 70a61593e01..d0b17c6a29d 100644
--- a/public/app/features/migrate-to-cloud/cloud/MigrationTokenPane/MigrationTokenModal.tsx
+++ b/public/app/features/migrate-to-cloud/cloud/MigrationTokenPane/MigrationTokenModal.tsx
@@ -3,43 +3,54 @@ import React, { useId } from 'react';
import { Modal, Button, Input, Stack, ClipboardButton, Field } from '@grafana/ui';
import { Trans, t } from 'app/core/internationalization';
+import { TokenErrorAlert } from '../TokenErrorAlert';
+
interface Props {
hideModal: () => void;
- migrationToken: string;
+ migrationToken?: string;
}
export const MigrationTokenModal = ({ hideModal, migrationToken }: Props) => {
- const inputId = useId();
-
return (
-
-
-
- migrationToken}>
- Copy to clipboard
-
-
-
+ {migrationToken ? : }
+
- migrationToken} onClipboardCopy={hideModal}>
- Copy to clipboard and close
-
+
+ {migrationToken && (
+ migrationToken} onClipboardCopy={hideModal}>
+ Copy to clipboard and close
+
+ )}
);
};
+
+function TokenSuccessContent({ migrationToken }: { migrationToken: string }) {
+ const inputId = useId();
+ return (
+
+
+
+ migrationToken}>
+ Copy to clipboard
+
+
+
+ );
+}
diff --git a/public/app/features/migrate-to-cloud/cloud/MigrationTokenPane/MigrationTokenPane.tsx b/public/app/features/migrate-to-cloud/cloud/MigrationTokenPane/MigrationTokenPane.tsx
index 3c640abfcbd..e580b40ec50 100644
--- a/public/app/features/migrate-to-cloud/cloud/MigrationTokenPane/MigrationTokenPane.tsx
+++ b/public/app/features/migrate-to-cloud/cloud/MigrationTokenPane/MigrationTokenPane.tsx
@@ -3,21 +3,20 @@ import React from 'react';
import { Box, Button, ModalsController, Text } from '@grafana/ui';
import { t, Trans } from 'app/core/internationalization';
-import {
- useCreateMigrationTokenMutationMock,
- useDeleteMigrationTokenMutationMock,
- useHasMigrationTokenQueryMock,
-} from '../../mockAPI';
+import { useCreateCloudMigrationTokenMutation } from '../../api';
import { InfoItem } from '../../shared/InfoItem';
+import { TokenErrorAlert } from '../TokenErrorAlert';
-import { DeleteMigrationTokenModal } from './DeleteMigrationTokenModal';
import { MigrationTokenModal } from './MigrationTokenModal';
import { TokenStatus } from './TokenStatus';
export const MigrationTokenPane = () => {
- const { data: hasToken, isFetching } = useHasMigrationTokenQueryMock();
- const [createToken, createTokenResponse] = useCreateMigrationTokenMutationMock();
- const [deleteToken, deleteTokenResponse] = useDeleteMigrationTokenMutationMock();
+ const isFetchingStatus = false; // TODO: No API for this yet
+
+ const [createToken, createTokenResponse] = useCreateCloudMigrationTokenMutation();
+ const hasToken = Boolean(createTokenResponse.data?.token);
+
+ const isLoading = isFetchingStatus || createTokenResponse.isLoading; /* || deleteTokenResponse.isLoading */
return (
@@ -29,46 +28,33 @@ export const MigrationTokenPane = () => {
cloud stack.
-
-
- Current status:{' '}
-
-
-
- {hasToken ? (
-
+
+ {createTokenResponse?.isError ? (
+
) : (
-
+
+
+ Current status:
+
+
)}
+
+
)}
diff --git a/public/app/features/migrate-to-cloud/cloud/TokenErrorAlert.tsx b/public/app/features/migrate-to-cloud/cloud/TokenErrorAlert.tsx
new file mode 100644
index 00000000000..998ee7fbd25
--- /dev/null
+++ b/public/app/features/migrate-to-cloud/cloud/TokenErrorAlert.tsx
@@ -0,0 +1,14 @@
+import React from 'react';
+
+import { Alert } from '@grafana/ui';
+import { Trans, t } from 'app/core/internationalization';
+
+export function TokenErrorAlert() {
+ return (
+
+
+ Unable to generate a migration token. Please try again later.
+
+
+ );
+}
diff --git a/public/locales/en-US/grafana.json b/public/locales/en-US/grafana.json
index 77decc82bce..5cf2fdc5e90 100644
--- a/public/locales/en-US/grafana.json
+++ b/public/locales/en-US/grafana.json
@@ -753,12 +753,13 @@
},
"migration-token": {
"body": "Your self-managed Grafana instance will require a special authentication token to securely connect to this cloud stack.",
- "delete-button": "Delete this migration token",
"delete-modal-body": "If you've already used this token with a self-managed installation, that installation will no longer be able to upload content.",
"delete-modal-cancel": "Cancel",
"delete-modal-confirm": "Delete",
"delete-modal-deleting": "Deleting...",
"delete-modal-title": "Delete migration token",
+ "error-body": "Unable to generate a migration token. Please try again later.",
+ "error-title": "Something went wrong",
"generate-button": "Generate a migration token",
"generate-button-loading": "Generating a migration token...",
"modal-close": "Close",
@@ -767,7 +768,7 @@
"modal-field-description": "Copy the token now as you will not be able to see it again. Losing a token requires creating a new one.",
"modal-field-label": "Token",
"modal-title": "Migration token created",
- "status": "Current status: <2>2>",
+ "status": "Current status: <1>1>",
"title": "Migration token"
},
"pdc": {
diff --git a/public/locales/pseudo-LOCALE/grafana.json b/public/locales/pseudo-LOCALE/grafana.json
index 116f23a7e3f..b6c7e819674 100644
--- a/public/locales/pseudo-LOCALE/grafana.json
+++ b/public/locales/pseudo-LOCALE/grafana.json
@@ -753,12 +753,13 @@
},
"migration-token": {
"body": "Ÿőūř şęľƒ-mäʼnäģęđ Ğřäƒäʼnä įʼnşŧäʼnčę ŵįľľ řęqūįřę ä şpęčįäľ äūŧĥęʼnŧįčäŧįőʼn ŧőĸęʼn ŧő şęčūřęľy čőʼnʼnęčŧ ŧő ŧĥįş čľőūđ şŧäčĸ.",
- "delete-button": "Đęľęŧę ŧĥįş mįģřäŧįőʼn ŧőĸęʼn",
"delete-modal-body": "Ĩƒ yőū'vę äľřęäđy ūşęđ ŧĥįş ŧőĸęʼn ŵįŧĥ ä şęľƒ-mäʼnäģęđ įʼnşŧäľľäŧįőʼn, ŧĥäŧ įʼnşŧäľľäŧįőʼn ŵįľľ ʼnő ľőʼnģęř þę äþľę ŧő ūpľőäđ čőʼnŧęʼnŧ.",
"delete-modal-cancel": "Cäʼnčęľ",
"delete-modal-confirm": "Đęľęŧę",
"delete-modal-deleting": "Đęľęŧįʼnģ...",
"delete-modal-title": "Đęľęŧę mįģřäŧįőʼn ŧőĸęʼn",
+ "error-body": "Ůʼnäþľę ŧő ģęʼnęřäŧę ä mįģřäŧįőʼn ŧőĸęʼn. Pľęäşę ŧřy äģäįʼn ľäŧęř.",
+ "error-title": "Ŝőmęŧĥįʼnģ ŵęʼnŧ ŵřőʼnģ",
"generate-button": "Ğęʼnęřäŧę ä mįģřäŧįőʼn ŧőĸęʼn",
"generate-button-loading": "Ğęʼnęřäŧįʼnģ ä mįģřäŧįőʼn ŧőĸęʼn...",
"modal-close": "Cľőşę",
@@ -767,7 +768,7 @@
"modal-field-description": "Cőpy ŧĥę ŧőĸęʼn ʼnőŵ äş yőū ŵįľľ ʼnőŧ þę äþľę ŧő şęę įŧ äģäįʼn. Ŀőşįʼnģ ä ŧőĸęʼn řęqūįřęş čřęäŧįʼnģ ä ʼnęŵ őʼnę.",
"modal-field-label": "Ŧőĸęʼn",
"modal-title": "Mįģřäŧįőʼn ŧőĸęʼn čřęäŧęđ",
- "status": "Cūřřęʼnŧ şŧäŧūş: <2>2>",
+ "status": "Cūřřęʼnŧ şŧäŧūş: <1>1>",
"title": "Mįģřäŧįőʼn ŧőĸęʼn"
},
"pdc": {