From 4a0c89a8fd50e86fe14f4f14493d3c15d2cb8e19 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Thu, 7 Dec 2023 10:48:06 +0000 Subject: [PATCH] Snapshots: Add loading skeleton (#79134) * add snapshot skeleton * add some unit tests --- .../components/SnapshotListTable.tsx | 50 ++++----- .../components/SnapshotListTableRow.test.tsx | 100 ++++++++++++++++++ .../components/SnapshotListTableRow.tsx | 72 +++++++++++++ public/app/features/playlist/PlaylistCard.tsx | 2 +- 4 files changed, 194 insertions(+), 30 deletions(-) create mode 100644 public/app/features/manage-dashboards/components/SnapshotListTableRow.test.tsx create mode 100644 public/app/features/manage-dashboards/components/SnapshotListTableRow.tsx diff --git a/public/app/features/manage-dashboards/components/SnapshotListTable.tsx b/public/app/features/manage-dashboards/components/SnapshotListTable.tsx index d909eba9e82..37e1d7d03c3 100644 --- a/public/app/features/manage-dashboards/components/SnapshotListTable.tsx +++ b/public/app/features/manage-dashboards/components/SnapshotListTable.tsx @@ -2,10 +2,12 @@ import React, { useState, useCallback } from 'react'; import useAsync from 'react-use/lib/useAsync'; import { config } from '@grafana/runtime'; -import { ConfirmModal, Button, LinkButton } from '@grafana/ui'; +import { ConfirmModal } from '@grafana/ui'; import { Trans } from 'app/core/internationalization'; import { getDashboardSnapshotSrv, Snapshot } from 'app/features/dashboard/services/SnapshotSrv'; +import { SnapshotListTableRow } from './SnapshotListTableRow'; + export function getSnapshots() { return getDashboardSnapshotSrv() .getSnapshots() @@ -18,9 +20,12 @@ export function getSnapshots() { } export const SnapshotListTable = () => { const [snapshots, setSnapshots] = useState([]); + const [isFetching, setIsFetching] = useState(false); const [removeSnapshot, setRemoveSnapshot] = useState(); useAsync(async () => { + setIsFetching(true); const response = await getSnapshots(); + setIsFetching(false); setSnapshots(response); }, [setSnapshots]); @@ -58,34 +63,21 @@ export const SnapshotListTable = () => { - {snapshots.map((snapshot) => { - const url = snapshot.externalUrl || snapshot.url; - return ( - - - {snapshot.name} - - - {url} - - - {snapshot.external && ( - - External - - )} - - - - View - - - -