fixed loader in gcalendar when not signed in
Signed-off-by: Alex Rybchenko <arybchenko@box.com>
This commit is contained in:
@@ -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>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user