From 17bd302ef25f40b3a644d37cf3675ae274582950 Mon Sep 17 00:00:00 2001 From: Josh Hunt Date: Fri, 26 Jul 2024 09:52:59 +0100 Subject: [PATCH] E2C: Add stat rollup to MigrationSummary (#90970) Co-authored-by: Michael Mandrus --- .../features/migrate-to-cloud/api/endpoints.gen.ts | 14 +++++++++++++- .../migrate-to-cloud/onprem/MigrationSummary.tsx | 14 ++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/public/app/features/migrate-to-cloud/api/endpoints.gen.ts b/public/app/features/migrate-to-cloud/api/endpoints.gen.ts index cd533d124aa..890138028b4 100644 --- a/public/app/features/migrate-to-cloud/api/endpoints.gen.ts +++ b/public/app/features/migrate-to-cloud/api/endpoints.gen.ts @@ -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; diff --git a/public/app/features/migrate-to-cloud/onprem/MigrationSummary.tsx b/public/app/features/migrate-to-cloud/onprem/MigrationSummary.tsx index 19405d42be1..22742acd860 100644 --- a/public/app/features/migrate-to-cloud/onprem/MigrationSummary.tsx +++ b/public/app/features/migrate-to-cloud/onprem/MigrationSummary.tsx @@ -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 ( {snapshot?.created ? ( - snapshot?.created + formatDate(snapshot.created, DATE_FORMAT) ) : ( Not yet created