import React from 'react'; import Skeleton from 'react-loading-skeleton'; import { SkeletonComponent, attachSkeleton } from '@grafana/ui/src/unstable'; import { Settings } from './AdminSettings'; interface Props { settings: Settings; } const AdminSettingsTableComponent = ({ 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: SkeletonComponent = ({ rootProps }) => { 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; } export const AdminSettingsTable = attachSkeleton(AdminSettingsTableComponent, AdminSettingsTableSkeleton);