mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
E2C: Show rebuild snapshot button (#90941)
* E2C: Show rebuild snapshot button * i18n * Update public/app/features/migrate-to-cloud/onprem/Page.tsx Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com> --------- Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
This commit is contained in:
parent
14396048d7
commit
7e6e76f4ff
@ -4751,9 +4751,6 @@ exports[`better eslint`] = {
|
|||||||
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"],
|
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"],
|
||||||
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"]
|
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"]
|
||||||
],
|
],
|
||||||
"public/app/features/migrate-to-cloud/onprem/Page.tsx:5381": [
|
|
||||||
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"]
|
|
||||||
],
|
|
||||||
"public/app/features/notifications/StoredNotifications.tsx:5381": [
|
"public/app/features/notifications/StoredNotifications.tsx:5381": [
|
||||||
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"]
|
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"]
|
||||||
],
|
],
|
||||||
|
@ -49,8 +49,9 @@ export const cloudMigrationAPI = generatedAPI.enhanceEndpoints({
|
|||||||
getShapshotList: {
|
getShapshotList: {
|
||||||
providesTags: ['cloud-migration-snapshot'],
|
providesTags: ['cloud-migration-snapshot'],
|
||||||
},
|
},
|
||||||
createSnapshot: {
|
createSnapshot(endpoint) {
|
||||||
invalidatesTags: ['cloud-migration-snapshot'],
|
suppressErrorsOnQuery(endpoint);
|
||||||
|
endpoint.invalidatesTags = ['cloud-migration-snapshot'];
|
||||||
},
|
},
|
||||||
uploadSnapshot: {
|
uploadSnapshot: {
|
||||||
invalidatesTags: ['cloud-migration-snapshot'],
|
invalidatesTags: ['cloud-migration-snapshot'],
|
||||||
|
@ -20,6 +20,8 @@ interface MigrationSummaryProps {
|
|||||||
showUploadSnapshot: boolean;
|
showUploadSnapshot: boolean;
|
||||||
uploadSnapshotIsLoading: boolean;
|
uploadSnapshotIsLoading: boolean;
|
||||||
onUploadSnapshot: () => void;
|
onUploadSnapshot: () => void;
|
||||||
|
|
||||||
|
showRebuildSnapshot: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function MigrationSummary(props: MigrationSummaryProps) {
|
export function MigrationSummary(props: MigrationSummaryProps) {
|
||||||
@ -29,6 +31,7 @@ export function MigrationSummary(props: MigrationSummaryProps) {
|
|||||||
isBusy,
|
isBusy,
|
||||||
disconnectIsLoading,
|
disconnectIsLoading,
|
||||||
onDisconnect,
|
onDisconnect,
|
||||||
|
|
||||||
showBuildSnapshot,
|
showBuildSnapshot,
|
||||||
buildSnapshotIsLoading,
|
buildSnapshotIsLoading,
|
||||||
onBuildSnapshot,
|
onBuildSnapshot,
|
||||||
@ -36,6 +39,8 @@ export function MigrationSummary(props: MigrationSummaryProps) {
|
|||||||
showUploadSnapshot,
|
showUploadSnapshot,
|
||||||
uploadSnapshotIsLoading,
|
uploadSnapshotIsLoading,
|
||||||
onUploadSnapshot,
|
onUploadSnapshot,
|
||||||
|
|
||||||
|
showRebuildSnapshot,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const totalCount = 0;
|
const totalCount = 0;
|
||||||
@ -96,6 +101,17 @@ export function MigrationSummary(props: MigrationSummaryProps) {
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{showRebuildSnapshot && (
|
||||||
|
<Button
|
||||||
|
disabled={isBusy}
|
||||||
|
onClick={onBuildSnapshot}
|
||||||
|
icon={buildSnapshotIsLoading ? 'spinner' : undefined}
|
||||||
|
variant="secondary"
|
||||||
|
>
|
||||||
|
<Trans i18nKey="migrate-to-cloud.summary.rebuild-snapshot">Rebuild snapshot</Trans>
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
{showUploadSnapshot && (
|
{showUploadSnapshot && (
|
||||||
<Button
|
<Button
|
||||||
disabled={isBusy || uploadSnapshotIsLoading}
|
disabled={isBusy || uploadSnapshotIsLoading}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { skipToken } from '@reduxjs/toolkit/query/react';
|
import { skipToken } from '@reduxjs/toolkit/query/react';
|
||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
|
|
||||||
import { Alert, Box, Stack } from '@grafana/ui';
|
import { isFetchError } from '@grafana/runtime';
|
||||||
|
import { Alert, Box, Stack, Text } from '@grafana/ui';
|
||||||
import { Trans, t } from 'app/core/internationalization';
|
import { Trans, t } from 'app/core/internationalization';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -56,6 +57,8 @@ const SHOULD_POLL_STATUSES: Array<SnapshotDto['status']> = [
|
|||||||
'PROCESSING',
|
'PROCESSING',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const SNAPSHOT_REBUILD_STATUSES: Array<SnapshotDto['status']> = ['FINISHED', 'ERROR', 'UNKNOWN'];
|
||||||
|
|
||||||
const SNAPSHOT_BUILDING_STATUSES: Array<SnapshotDto['status']> = ['INITIALIZING', 'CREATING'];
|
const SNAPSHOT_BUILDING_STATUSES: Array<SnapshotDto['status']> = ['INITIALIZING', 'CREATING'];
|
||||||
|
|
||||||
const SNAPSHOT_UPLOADING_STATUSES: Array<SnapshotDto['status']> = ['UPLOADING', 'PENDING_PROCESSING', 'PROCESSING'];
|
const SNAPSHOT_UPLOADING_STATUSES: Array<SnapshotDto['status']> = ['UPLOADING', 'PENDING_PROCESSING', 'PROCESSING'];
|
||||||
@ -66,7 +69,7 @@ function useGetLatestSnapshot(sessionUid?: string) {
|
|||||||
const [shouldPoll, setShouldPoll] = useState(false);
|
const [shouldPoll, setShouldPoll] = useState(false);
|
||||||
|
|
||||||
const listResult = useGetShapshotListQuery(sessionUid ? { uid: sessionUid } : skipToken);
|
const listResult = useGetShapshotListQuery(sessionUid ? { uid: sessionUid } : skipToken);
|
||||||
const lastItem = listResult.data?.snapshots?.at(-1); // TODO: account for pagination and ensure we're truely getting the last one
|
const lastItem = listResult.data?.snapshots?.at(0);
|
||||||
|
|
||||||
const getSnapshotQueryArgs = sessionUid && lastItem?.uid ? { uid: sessionUid, snapshotUid: lastItem.uid } : skipToken;
|
const getSnapshotQueryArgs = sessionUid && lastItem?.uid ? { uid: sessionUid, snapshotUid: lastItem.uid } : skipToken;
|
||||||
|
|
||||||
@ -120,6 +123,7 @@ export const Page = () => {
|
|||||||
const showBuildSnapshot = !snapshot.isLoading && !snapshot.data;
|
const showBuildSnapshot = !snapshot.isLoading && !snapshot.data;
|
||||||
const showBuildingSnapshot = SNAPSHOT_BUILDING_STATUSES.includes(status);
|
const showBuildingSnapshot = SNAPSHOT_BUILDING_STATUSES.includes(status);
|
||||||
const showUploadSnapshot = status === 'PENDING_UPLOAD' || SNAPSHOT_UPLOADING_STATUSES.includes(status);
|
const showUploadSnapshot = status === 'PENDING_UPLOAD' || SNAPSHOT_UPLOADING_STATUSES.includes(status);
|
||||||
|
const showRebuildSnapshot = SNAPSHOT_REBUILD_STATUSES.includes(status);
|
||||||
|
|
||||||
const handleDisconnect = useCallback(async () => {
|
const handleDisconnect = useCallback(async () => {
|
||||||
if (sessionUid) {
|
if (sessionUid) {
|
||||||
@ -147,7 +151,11 @@ export const Page = () => {
|
|||||||
|
|
||||||
if (isInitialLoading) {
|
if (isInitialLoading) {
|
||||||
// TODO: better loading state
|
// TODO: better loading state
|
||||||
return <div>Loading...</div>;
|
return (
|
||||||
|
<div>
|
||||||
|
<Trans i18nKey="migrate-to-cloud.summary.page-loading">Loading...</Trans>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
} else if (!session.data) {
|
} else if (!session.data) {
|
||||||
return <EmptyState />;
|
return <EmptyState />;
|
||||||
}
|
}
|
||||||
@ -156,17 +164,23 @@ export const Page = () => {
|
|||||||
<>
|
<>
|
||||||
<Stack direction="column" gap={4}>
|
<Stack direction="column" gap={4}>
|
||||||
{/* TODO: show errors from all mutation's in a... modal? */}
|
{/* TODO: show errors from all mutation's in a... modal? */}
|
||||||
|
|
||||||
{createSnapshotResult.isError && (
|
{createSnapshotResult.isError && (
|
||||||
<Alert
|
<Alert
|
||||||
severity="error"
|
severity="error"
|
||||||
title={t(
|
title={t('migrate-to-cloud.summary.run-migration-error-title', 'Error creating snapshot')}
|
||||||
'migrate-to-cloud.summary.run-migration-error-title',
|
|
||||||
'There was an error migrating your resources'
|
|
||||||
)}
|
|
||||||
>
|
>
|
||||||
<Trans i18nKey="migrate-to-cloud.summary.run-migration-error-description">
|
<Text element="p">
|
||||||
See the Grafana server logs for more details
|
<Trans i18nKey="migrate-to-cloud.summary.run-migration-error-description">
|
||||||
</Trans>
|
See the Grafana server logs for more details
|
||||||
|
</Trans>
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
{maybeGetTraceID(createSnapshotResult.error) && (
|
||||||
|
// Deliberately don't want to translate 'Trace ID'
|
||||||
|
// eslint-disable-next-line @grafana/no-untranslated-strings
|
||||||
|
<Text element="p">Trace ID: {maybeGetTraceID(createSnapshotResult.error)}</Text>
|
||||||
|
)}
|
||||||
</Alert>
|
</Alert>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@ -194,6 +208,7 @@ export const Page = () => {
|
|||||||
showUploadSnapshot={showUploadSnapshot}
|
showUploadSnapshot={showUploadSnapshot}
|
||||||
uploadSnapshotIsLoading={uploadSnapshotResult.isLoading || SNAPSHOT_UPLOADING_STATUSES.includes(status)}
|
uploadSnapshotIsLoading={uploadSnapshotResult.isLoading || SNAPSHOT_UPLOADING_STATUSES.includes(status)}
|
||||||
onUploadSnapshot={handleUploadSnapshot}
|
onUploadSnapshot={handleUploadSnapshot}
|
||||||
|
showRebuildSnapshot={showRebuildSnapshot}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@ -232,3 +247,13 @@ export const Page = () => {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function maybeGetTraceID(err: unknown) {
|
||||||
|
const data = isFetchError<unknown>(err) ? err.data : undefined;
|
||||||
|
|
||||||
|
if (typeof data === 'object' && data && 'traceID' in data && typeof data.traceID === 'string') {
|
||||||
|
return data.traceID;
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
@ -1099,8 +1099,10 @@
|
|||||||
"disconnect-error-description": "See the Grafana server logs for more details",
|
"disconnect-error-description": "See the Grafana server logs for more details",
|
||||||
"disconnect-error-title": "There was an error disconnecting",
|
"disconnect-error-title": "There was an error disconnecting",
|
||||||
"errored-resource-count": "Errors",
|
"errored-resource-count": "Errors",
|
||||||
|
"page-loading": "Loading...",
|
||||||
|
"rebuild-snapshot": "Rebuild snapshot",
|
||||||
"run-migration-error-description": "See the Grafana server logs for more details",
|
"run-migration-error-description": "See the Grafana server logs for more details",
|
||||||
"run-migration-error-title": "There was an error migrating your resources",
|
"run-migration-error-title": "Error creating snapshot",
|
||||||
"snapshot-date": "Snapshot timestamp",
|
"snapshot-date": "Snapshot timestamp",
|
||||||
"snapshot-not-created": "Not yet created",
|
"snapshot-not-created": "Not yet created",
|
||||||
"start-migration": "Build snapshot",
|
"start-migration": "Build snapshot",
|
||||||
|
@ -1099,8 +1099,10 @@
|
|||||||
"disconnect-error-description": "Ŝęę ŧĥę Ğřäƒäʼnä şęřvęř ľőģş ƒőř mőřę đęŧäįľş",
|
"disconnect-error-description": "Ŝęę ŧĥę Ğřäƒäʼnä şęřvęř ľőģş ƒőř mőřę đęŧäįľş",
|
||||||
"disconnect-error-title": "Ŧĥęřę ŵäş äʼn ęřřőř đįşčőʼnʼnęčŧįʼnģ",
|
"disconnect-error-title": "Ŧĥęřę ŵäş äʼn ęřřőř đįşčőʼnʼnęčŧįʼnģ",
|
||||||
"errored-resource-count": "Ēřřőřş",
|
"errored-resource-count": "Ēřřőřş",
|
||||||
|
"page-loading": "Ŀőäđįʼnģ...",
|
||||||
|
"rebuild-snapshot": "Ŗęþūįľđ şʼnäpşĥőŧ",
|
||||||
"run-migration-error-description": "Ŝęę ŧĥę Ğřäƒäʼnä şęřvęř ľőģş ƒőř mőřę đęŧäįľş",
|
"run-migration-error-description": "Ŝęę ŧĥę Ğřäƒäʼnä şęřvęř ľőģş ƒőř mőřę đęŧäįľş",
|
||||||
"run-migration-error-title": "Ŧĥęřę ŵäş äʼn ęřřőř mįģřäŧįʼnģ yőūř řęşőūřčęş",
|
"run-migration-error-title": "Ēřřőř čřęäŧįʼnģ şʼnäpşĥőŧ",
|
||||||
"snapshot-date": "Ŝʼnäpşĥőŧ ŧįmęşŧämp",
|
"snapshot-date": "Ŝʼnäpşĥőŧ ŧįmęşŧämp",
|
||||||
"snapshot-not-created": "Ńőŧ yęŧ čřęäŧęđ",
|
"snapshot-not-created": "Ńőŧ yęŧ čřęäŧęđ",
|
||||||
"start-migration": "ßūįľđ şʼnäpşĥőŧ",
|
"start-migration": "ßūįľđ şʼnäpşĥőŧ",
|
||||||
|
Loading…
Reference in New Issue
Block a user