From 7ddcd0c9611882858701f4f876fb8e449fe73980 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Fri, 8 Dec 2023 09:25:06 +0000 Subject: [PATCH] Settings: Add skeleton loader (#79234) * add skeleton for settings page * go back to using style so it all overrides properly --- public/app/features/admin/AdminSettings.tsx | 29 ++------ .../app/features/admin/AdminSettingsTable.tsx | 73 +++++++++++++++++++ 2 files changed, 80 insertions(+), 22 deletions(-) create mode 100644 public/app/features/admin/AdminSettingsTable.tsx diff --git a/public/app/features/admin/AdminSettings.tsx b/public/app/features/admin/AdminSettings.tsx index 656709772be..4bd16ba2309 100644 --- a/public/app/features/admin/AdminSettings.tsx +++ b/public/app/features/admin/AdminSettings.tsx @@ -4,39 +4,24 @@ import { useAsync } from 'react-use'; import { getBackendSrv } from '@grafana/runtime'; import { Page } from 'app/core/components/Page/Page'; -type Settings = { [key: string]: { [key: string]: string } }; +import { AdminSettingsTable } from './AdminSettingsTable'; + +export type Settings = { [key: string]: { [key: string]: string } }; function AdminSettings() { const { loading, value: settings } = useAsync(() => getBackendSrv().get('/api/admin/settings'), []); return ( - +
These system settings are defined in grafana.ini or custom.ini (or overridden in ENV variables). To change these you currently need to restart Grafana.
- {settings && ( - - - {Object.entries(settings).map(([sectionName, sectionSettings], i) => ( - - - - - {Object.entries(sectionSettings).map(([settingName, settingValue], j) => ( - - - - - ))} - - ))} - -
{sectionName} -
{settingName}{settingValue}
- )} + {loading && } + + {settings && }
); diff --git a/public/app/features/admin/AdminSettingsTable.tsx b/public/app/features/admin/AdminSettingsTable.tsx new file mode 100644 index 00000000000..9b8ad467486 --- /dev/null +++ b/public/app/features/admin/AdminSettingsTable.tsx @@ -0,0 +1,73 @@ +import React from 'react'; +import Skeleton from 'react-loading-skeleton'; + +import { Settings } from './AdminSettings'; + +interface Props { + settings: Settings; +} + +export const AdminSettingsTable = ({ settings }: Props) => { + return ( + + + {Object.entries(settings).map(([sectionName, sectionSettings], i) => ( + + + + + {Object.entries(sectionSettings).map(([settingName, settingValue], j) => ( + + + + + ))} + + ))} + +
{sectionName} +
{settingName}{settingValue}
+ ); +}; + +// note: don't want to put this in render function else it will get regenerated +const randomValues = new Array(50).fill(null).map(() => Math.random()); + +const AdminSettingsTableSkeleton = () => { + return ( + + + {randomValues.map((randomValue, index) => { + const isSection = index === 0 || randomValue > 0.9; + + return ( + + {isSection && ( + + + + )} + + + + + + ); + })} + +
+ + +
+ + + +
+ ); +}; + +function getRandomInRange(min: number, max: number, randomSeed: number) { + return randomSeed * (max - min) + min; +} + +AdminSettingsTable.Skeleton = AdminSettingsTableSkeleton;