diff --git a/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx b/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx index 79b85b9fa4e..b51d3f2e842 100644 --- a/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx +++ b/apps/studio/components/interfaces/Home/ProjectUsageSection.tsx @@ -1,11 +1,13 @@ import { useParams } from 'common' import { observer } from 'mobx-react-lite' -import { IconAlertCircle, IconLoader } from 'ui' +import { IconAlertCircle } from 'ui' import { NewProjectPanel } from 'components/interfaces/Home' +import { ProjectUsageLoadingState } from 'components/layouts/ProjectLayout/LoadingState' import InformationBox from 'components/ui/InformationBox' -import ProjectUsage from './ProjectUsage' import { useProjectLogRequestsCountQuery } from 'data/analytics/project-log-requests-count-query' +import { useProjectLogStatsQuery } from 'data/analytics/project-log-stats-query' +import ProjectUsage from './ProjectUsage' const ProjectUsageSection = observer(() => { const { ref: projectRef } = useParams() @@ -15,6 +17,13 @@ const ProjectUsageSection = observer(() => { isLoading, } = useProjectLogRequestsCountQuery({ projectRef }) + // wait for the stats to load before showing the usage section + // to eliminate multiple spinners + const { isLoading: isLogsStatsLoading } = useProjectLogStatsQuery({ + projectRef, + interval: 'hourly', + }) + if (usageError) { return ( { return ( <> - {isLoading ? ( -
- -

Retrieving project usage statistics

-
+ {isLoading || isLogsStatsLoading ? ( + ) : hasProjectData ? ( ) : ( diff --git a/apps/studio/components/layouts/ProjectLayout/LoadingState.tsx b/apps/studio/components/layouts/ProjectLayout/LoadingState.tsx index 83c759bebaa..4c35bd39c07 100644 --- a/apps/studio/components/layouts/ProjectLayout/LoadingState.tsx +++ b/apps/studio/components/layouts/ProjectLayout/LoadingState.tsx @@ -21,14 +21,8 @@ const LoadingState = () => { )} -
- -
- - - - -
+
+
@@ -40,3 +34,17 @@ const LoadingState = () => { } export default LoadingState + +export const ProjectUsageLoadingState = () => { + return ( +
+ +
+ + + + +
+
+ ) +}