E2C: Post success toast when migration finishes (#91640)

pull/91476/head
Josh Hunt 10 months ago committed by GitHub
parent 2a67367777
commit 83d8fde5be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      public/app/features/migrate-to-cloud/onprem/Page.tsx
  2. 60
      public/app/features/migrate-to-cloud/onprem/useNotifyOnSuccess.tsx
  3. 7
      public/locales/en-US/grafana.json
  4. 7
      public/locales/pseudo-LOCALE/grafana.json

@ -24,6 +24,7 @@ import { MigrationSummary } from './MigrationSummary';
import { ResourcesTable } from './ResourcesTable';
import { BuildSnapshotCTA, CreatingSnapshotCTA } from './SnapshotCTAs';
import { SupportedTypesDisclosure } from './SupportedTypesDisclosure';
import { useNotifySuccessful } from './useNotifyOnSuccess';
/**
* Here's how migrations work:
@ -119,6 +120,8 @@ export const Page = () => {
const [performCancelSnapshot, cancelSnapshotResult] = useCancelSnapshotMutation();
const [performDisconnect, disconnectResult] = useDeleteSessionMutation();
useNotifySuccessful(snapshot.data);
const sessionUid = session.data?.uid;
const snapshotUid = snapshot.data?.uid;
const isInitialLoading = session.isLoading;

@ -0,0 +1,60 @@
import { t } from 'i18next';
import { useRef, useEffect } from 'react';
import { useAppNotification } from 'app/core/copy/appNotification';
import { GetSnapshotResponseDto, SnapshotDto } from '../api';
export function useNotifySuccessful(snapshot: GetSnapshotResponseDto | undefined) {
const previousStatusRef = useRef<SnapshotDto['status']>(undefined);
const notifyApp = useAppNotification();
useEffect(() => {
const status = snapshot?.status;
const didJustFinish =
previousStatusRef.current !== 'FINISHED' && previousStatusRef.current !== undefined && status === 'FINISHED';
previousStatusRef.current = status; // must be AFTER the check above
if (!didJustFinish) {
return;
}
if (snapshot) {
const title = t('migrate-to-cloud.onprem.success-title', 'Migration completed!');
const message = getTranslatedMessage(snapshot);
notifyApp.success(title, message);
}
}, [notifyApp, snapshot]);
}
function getTranslatedMessage(snapshot: GetSnapshotResponseDto) {
const types: string[] = [];
for (const [type, count] of Object.entries(snapshot.stats?.types ?? {})) {
if (count <= 0) {
continue;
}
// We don't have per-resource status counts, so there's no way to accurately pluralize these
// so we just don't :)
if (type === 'DASHBOARD') {
types.push(t('migrate-to-cloud.migrated-counts.dashboards', 'dashboards'));
} else if (type === 'DATASOURCE') {
types.push(t('migrate-to-cloud.migrated-counts.datasources', 'data sources'));
} else if (type === 'FOLDER') {
types.push(t('migrate-to-cloud.migrated-counts.folders', 'folders'));
}
}
const successCount = snapshot?.stats?.statuses?.['OK'] ?? 0;
const message = t(
'migrate-to-cloud.onprem.success-message',
'Successfully migrated {{successCount}} {{types, list}} to your Grafana Cloud instance.',
{ successCount, types }
);
return message;
}

@ -1090,6 +1090,11 @@
"link-title": "View the full migration guide",
"title": "Let us help you migrate to this stack"
},
"migrated-counts": {
"dashboards": "dashboards",
"datasources": "data sources",
"folders": "folders"
},
"migration-token": {
"delete-button": "Delete 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.",
@ -1121,6 +1126,8 @@
"migration-finished-with-warnings-body": "The migration has completed with some warnings. Check individual resources for more details",
"snapshot-error-status-body": "There was an error creating the snapshot or starting the migration process. See the Grafana server logs for more details",
"snapshot-error-status-title": "Error migrating resources",
"success-message": "Successfully migrated {{successCount}} {{types, list}} to your Grafana Cloud instance.",
"success-title": "Migration completed!",
"upload-snapshot-error-title": "Error uploading snapshot"
},
"pdc": {

@ -1090,6 +1090,11 @@
"link-title": "Vįęŵ ŧĥę ƒūľľ mįģřäŧįőʼn ģūįđę",
"title": "Ŀęŧ ūş ĥęľp yőū mįģřäŧę ŧő ŧĥįş şŧäčĸ"
},
"migrated-counts": {
"dashboards": "đäşĥþőäřđş",
"datasources": "đäŧä şőūřčęş",
"folders": "ƒőľđęřş"
},
"migration-token": {
"delete-button": "Đęľęŧę ŧőĸęʼn",
"delete-modal-body": "Ĩƒ yőū'vę äľřęäđy ūşęđ ŧĥįş ŧőĸęʼn ŵįŧĥ ä şęľƒ-mäʼnäģęđ įʼnşŧäľľäŧįőʼn, ŧĥäŧ įʼnşŧäľľäŧįőʼn ŵįľľ ʼnő ľőʼnģęř þę äþľę ŧő ūpľőäđ čőʼnŧęʼnŧ.",
@ -1121,6 +1126,8 @@
"migration-finished-with-warnings-body": "Ŧĥę mįģřäŧįőʼn ĥäş čőmpľęŧęđ ŵįŧĥ şőmę ŵäřʼnįʼnģş. Cĥęčĸ įʼnđįvįđūäľ řęşőūřčęş ƒőř mőřę đęŧäįľş",
"snapshot-error-status-body": "Ŧĥęřę ŵäş äʼn ęřřőř čřęäŧįʼnģ ŧĥę şʼnäpşĥőŧ őř şŧäřŧįʼnģ ŧĥę mįģřäŧįőʼn přőčęşş. Ŝęę ŧĥę Ğřäƒäʼnä şęřvęř ľőģş ƒőř mőřę đęŧäįľş",
"snapshot-error-status-title": "Ēřřőř mįģřäŧįʼnģ řęşőūřčęş",
"success-message": "Ŝūččęşşƒūľľy mįģřäŧęđ {{successCount}} {{types, list}} ŧő yőūř Ğřäƒäʼnä Cľőūđ įʼnşŧäʼnčę.",
"success-title": "Mįģřäŧįőʼn čőmpľęŧęđ!",
"upload-snapshot-error-title": "Ēřřőř ūpľőäđįʼnģ şʼnäpşĥőŧ"
},
"pdc": {

Loading…
Cancel
Save