import React from 'react'; import {Alert, Flex} from '@gravity-ui/uikit'; import {ResponseError} from '../../../../../components/Errors/ResponseError'; import {Skeleton} from '../../../../../components/Skeleton/Skeleton'; import {EStorageStatsProblem} from '../../../../../types/api/storage'; import {cn} from '../../../../../utils/cn'; import {useIsViewerUser} from '../../../../../utils/hooks/useIsUserAllowedToMakeChanges'; import {TenantStorageGroups} from './TenantStorageGroups'; import { TenantStorageGroupedMediaSectionsView, TenantStorageMediaSectionView, } from './TenantStorageSummarySections'; import {TenantStorageTopUsageTable} from './TenantStorageTopUsageTable'; import i18n from './i18n'; import type {TenantStorageProps} from './types'; import {useTenantStorageNewData} from './useTenantStorageNewData'; import {buildTenantStorageMediaSections} from './utils'; import './TenantStorageNew.scss'; const b = cn('ydb-tenant-storage-new'); interface TenantStorageSummarySkeletonProps { showPhysicalDiskUsage?: boolean; } function TenantStorageSummarySkeleton({showPhysicalDiskUsage}: TenantStorageSummarySkeletonProps) { const skeletonCards = React.useMemo(() => { return Array.from({length: showPhysicalDiskUsage ? 2 : 1}, (_, index) => index); }, [showPhysicalDiskUsage]); return ( {skeletonCards.map((cardIndex) => ( {[0, 1, 2].map((metricIndex) => ( ))} ))} ); } export function TenantStorageNew({ allocatedResources, database, databaseFullPath, metrics, blobStorageStats, storageGroupsTotal, tabletStorageStats, }: TenantStorageProps) { const {currentData, data, error, isFetching} = useTenantStorageNewData({ database, databaseFullPath, metrics, }); const loading = isFetching && currentData === undefined; const isViewerUser = useIsViewerUser(); const mediaSections = React.useMemo(() => { return buildTenantStorageMediaSections({ blobStorageStats, metrics, tabletStorageStats, }); }, [blobStorageStats, metrics, tabletStorageStats]); const showDataIncompleteAlert = React.useMemo(() => { return (currentData?.problems ?? []).includes(EStorageStatsProblem.DataIncomplete); }, [currentData?.problems]); if (error && !currentData) { return ; } const topRowsError = data.topRowsError ?? error; const grouped = mediaSections.length > 1; if (loading) { return ( ); } return ( {showDataIncompleteAlert ? ( ) : null} {grouped ? ( ) : ( mediaSections.map((section, index) => ( )) )} ); }