From dce3e073e832a2bf3c4bc31266ef199c2d2dc0eb Mon Sep 17 00:00:00 2001 From: "Laurie T. Malau" Date: Wed, 27 Jul 2022 11:03:23 +0000 Subject: [PATCH] add spinner --- components/dashboard/src/teams/TeamUsage.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/components/dashboard/src/teams/TeamUsage.tsx b/components/dashboard/src/teams/TeamUsage.tsx index d0ab5e247e5d66..13fb8bf710565f 100644 --- a/components/dashboard/src/teams/TeamUsage.tsx +++ b/components/dashboard/src/teams/TeamUsage.tsx @@ -17,6 +17,7 @@ import Header from "../components/Header"; import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error"; import { FeatureFlagContext } from "../contexts/FeatureFlagContext"; import { ReactComponent as CreditsSvg } from "../images/credits.svg"; +import { ReactComponent as Spinner } from "../icons/Spinner.svg"; function TeamUsage() { const { teams } = useContext(TeamsContext); @@ -32,6 +33,7 @@ function TeamUsage() { const timestampStartOfCurrentMonth = startOfCurrentMonth.getTime(); const [startDateOfBillMonth, setStartDateOfBillMonth] = useState(timestampStartOfCurrentMonth); const [endDateOfBillMonth, setEndDateOfBillMonth] = useState(Date.now()); + const [isLoading, setIsLoading] = useState(true); useEffect(() => { if (!team) { @@ -50,6 +52,8 @@ function TeamUsage() { if (error.code === ErrorCodes.PERMISSION_DENIED) { setErrorMessage("Access to usage details is restricted to team owners."); } + } finally { + setIsLoading(false); } })(); }, [team, startDateOfBillMonth, endDateOfBillMonth]); @@ -146,7 +150,7 @@ function TeamUsage() { - {billedUsage.length === 0 && !errorMessage && ( + {billedUsage.length === 0 && !errorMessage && !isLoading && (

No sessions found.

@@ -163,7 +167,15 @@ function TeamUsage() {

)} - {billedUsage.length > 0 && ( + {isLoading && ( +
+
+ Fetching usage... +
+ +
+ )} + {billedUsage.length > 0 && !isLoading && (