fixed loader in gcalendar when not signed in

Signed-off-by: Alex Rybchenko <arybchenko@box.com>
This commit is contained in:
Alex Rybchenko
2022-09-28 15:53:33 +02:00
parent 4d0d53fcaa
commit 4c2ed7ecf1
2 changed files with 22 additions and 7 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-gcalendar': patch
---
Fixed loader showing when user not signed in
@@ -50,10 +50,13 @@ export const CalendarCard = () => {
useAsync(async () => signIn(true), [signIn]);
const { isLoading: isCalendarLoading, data: calendars = [] } =
useCalendarsQuery({
enabled: isSignedIn,
});
const {
isLoading: isCalendarLoading,
isFetching: isCalendarFetching,
data: calendars = [],
} = useCalendarsQuery({
enabled: isSignedIn,
});
const primaryCalendarId = calendars.find(c => c.primary === true)?.id;
const defaultSelectedCalendars = primaryCalendarId ? [primaryCalendarId] : [];
const [storedCalendars, setStoredCalendars] = useStoredCalendars(
@@ -69,6 +72,11 @@ export const CalendarCard = () => {
timeZone: date.zoneName,
});
const showLoader =
(isCalendarLoading && isCalendarFetching) ||
isEventLoading ||
!isInitialized;
return (
<InfoCard
noPadding
@@ -100,7 +108,9 @@ export const CalendarCard = () => {
calendars={calendars}
selectedCalendars={storedCalendars}
setSelectedCalendars={setStoredCalendars}
disabled={isCalendarLoading || !isSignedIn}
disabled={
(isCalendarFetching && isCalendarLoading) || !isSignedIn
}
/>
</>
) : (
@@ -114,8 +124,8 @@ export const CalendarCard = () => {
}}
>
<Box>
{(isCalendarLoading || isEventLoading || !isInitialized) && (
<Box pt={2} pb={2}>
{showLoader && (
<Box py={2}>
<Progress variant="query" />
</Box>
)}