Skip to content

Commit 3ee7764

Browse files
Laurie T. Malauroboquat
Laurie T. Malau
authored andcommitted
add spinner
1 parent f46c742 commit 3ee7764

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

components/dashboard/src/teams/TeamUsage.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import Header from "../components/Header";
1717
import { ErrorCodes } from "@gitpod/gitpod-protocol/lib/messaging/error";
1818
import { FeatureFlagContext } from "../contexts/FeatureFlagContext";
1919
import { ReactComponent as CreditsSvg } from "../images/credits.svg";
20+
import { ReactComponent as Spinner } from "../icons/Spinner.svg";
2021

2122
function TeamUsage() {
2223
const { teams } = useContext(TeamsContext);
@@ -32,6 +33,7 @@ function TeamUsage() {
3233
const timestampStartOfCurrentMonth = startOfCurrentMonth.getTime();
3334
const [startDateOfBillMonth, setStartDateOfBillMonth] = useState(timestampStartOfCurrentMonth);
3435
const [endDateOfBillMonth, setEndDateOfBillMonth] = useState(Date.now());
36+
const [isLoading, setIsLoading] = useState<boolean>(true);
3537

3638
useEffect(() => {
3739
if (!team) {
@@ -50,6 +52,8 @@ function TeamUsage() {
5052
if (error.code === ErrorCodes.PERMISSION_DENIED) {
5153
setErrorMessage("Access to usage details is restricted to team owners.");
5254
}
55+
} finally {
56+
setIsLoading(false);
5357
}
5458
})();
5559
}, [team, startDateOfBillMonth, endDateOfBillMonth]);
@@ -146,7 +150,7 @@ function TeamUsage() {
146150
</div>
147151
</div>
148152
</div>
149-
{billedUsage.length === 0 && !errorMessage && (
153+
{billedUsage.length === 0 && !errorMessage && !isLoading && (
150154
<div className="flex flex-col w-full mb-8">
151155
<h3 className="text-center text-gray-500 mt-8">No sessions found.</h3>
152156
<p className="text-center text-gray-500 mt-1">
@@ -163,7 +167,15 @@ function TeamUsage() {
163167
</p>
164168
</div>
165169
)}
166-
{billedUsage.length > 0 && (
170+
{isLoading && (
171+
<div className="flex flex-col place-items-center align-center w-full">
172+
<div className="uppercase text-sm text-gray-400 dark:text-gray-500 mb-5">
173+
Fetching usage...
174+
</div>
175+
<Spinner className="m-2 h-5 w-5 animate-spin" />
176+
</div>
177+
)}
178+
{billedUsage.length > 0 && !isLoading && (
167179
<div className="flex flex-col w-full mb-8">
168180
<ItemsList className="mt-2 text-gray-500">
169181
<Item header={false} className="grid grid-cols-5 bg-gray-100 mb-5">

0 commit comments

Comments
 (0)