E2C: Add stat rollup to MigrationSummary (#90970)

Co-authored-by: Michael Mandrus <michael.mandrus@grafana.com>
This commit is contained in:
Josh Hunt
2024-07-26 09:52:59 +01:00
committed by GitHub
co-authored by Michael Mandrus
parent a19a9903bf
commit 17bd302ef2
2 changed files with 23 additions and 5 deletions
@@ -143,7 +143,7 @@ export type ErrorResponseBody = {
/** a human readable version of the error */
message: string;
/** Status An optional status to denote the cause of the error.
For example, a 412 Precondition Failed error may include additional information of why that error happened. */
status?: string;
};
@@ -159,11 +159,21 @@ export type MigrateDataResponseItemDto = {
status: 'OK' | 'ERROR' | 'PENDING' | 'UNKNOWN';
type: 'DASHBOARD' | 'DATASOURCE' | 'FOLDER';
};
export type SnapshotResourceStats = {
statuses?: {
[key: string]: number;
};
total?: number;
types?: {
[key: string]: number;
};
};
export type GetSnapshotResponseDto = {
created?: string;
finished?: string;
results?: MigrateDataResponseItemDto[];
sessionUid?: string;
stats?: SnapshotResourceStats;
status?:
| 'INITIALIZING'
| 'CREATING'
@@ -172,6 +182,7 @@ export type GetSnapshotResponseDto = {
| 'PENDING_PROCESSING'
| 'PROCESSING'
| 'FINISHED'
| 'CANCELED'
| 'ERROR'
| 'UNKNOWN';
uid?: string;
@@ -188,6 +199,7 @@ export type SnapshotDto = {
| 'PENDING_PROCESSING'
| 'PROCESSING'
| 'FINISHED'
| 'CANCELED'
| 'ERROR'
| 'UNKNOWN';
uid?: string;
@@ -1,5 +1,6 @@
import { Box, Button, Space, Stack, Text } from '@grafana/ui';
import { Trans, t } from 'app/core/internationalization';
import { formatDate } from 'app/core/internationalization/dates';
import { GetSessionApiResponse, GetSnapshotResponseDto } from '../api';
@@ -24,6 +25,11 @@ interface MigrationSummaryProps {
showRebuildSnapshot: boolean;
}
const DATE_FORMAT: Intl.DateTimeFormatOptions = {
dateStyle: 'medium',
timeStyle: 'short',
};
export function MigrationSummary(props: MigrationSummaryProps) {
const {
session,
@@ -43,9 +49,9 @@ export function MigrationSummary(props: MigrationSummaryProps) {
showRebuildSnapshot,
} = props;
const totalCount = 0;
const errorCount = 0;
const successCount = 0;
const totalCount = snapshot?.stats?.total ?? 0;
const errorCount = snapshot?.stats?.statuses?.['ERROR'] ?? 0;
const successCount = snapshot?.stats?.statuses?.['OK'] ?? 0;
return (
<Box
@@ -60,7 +66,7 @@ export function MigrationSummary(props: MigrationSummaryProps) {
<Stack gap={4} wrap="wrap">
<MigrationInfo title={t('migrate-to-cloud.summary.snapshot-date', 'Snapshot timestamp')}>
{snapshot?.created ? (
snapshot?.created
formatDate(snapshot.created, DATE_FORMAT)
) : (
<Text color="secondary">
<Trans i18nKey="migrate-to-cloud.summary.snapshot-not-created">Not yet created</Trans>