Skip to content

Commit 19e84cf

Browse files
committed
Show a modal with spinner while retriving the data from github.
Currently it shows the empty state and then once the PRs are pulled, it shows the list. This flicker of empty list always happen whenever we switch from any other menu item to Dashboar. Signed-off-by: Anil Vishnoi <[email protected]>
1 parent 8d9d8bb commit 19e84cf

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/components/Dashboard/index.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,15 @@ import { TextContent } from '@patternfly/react-core/dist/esm/components/Text/Tex
2727
import OutlinedQuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/outlined-question-circle-icon';
2828
import { Popover } from '@patternfly/react-core/dist/esm/components/Popover';
2929
import ExternalLinkAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-alt-icon';
30+
import { Modal, ModalVariant } from '@patternfly/react-core/dist/esm/components/Modal/Modal';
31+
import { useState } from 'react';
32+
import { Spinner } from '@patternfly/react-core/dist/esm/components/Spinner';
3033

3134
const Index: React.FunctionComponent = () => {
3235
const { data: session } = useSession();
3336
const [pullRequests, setPullRequests] = React.useState<PullRequest[]>([]);
37+
const [isFirstPullDone, setIsFirstPullDone] = React.useState<boolean>(false);
38+
const [isLoading, setIsLoading] = useState<boolean>(true);
3439
//const [error, setError] = React.useState<string | null>(null);
3540
const router = useRouter();
3641

@@ -54,6 +59,8 @@ const Index: React.FunctionComponent = () => {
5459
} catch (error) {
5560
console.log('Failed to fetch pull requests.' + error);
5661
}
62+
setIsFirstPullDone(true);
63+
setIsLoading(false);
5764
}
5865
}, [session?.accessToken]);
5966

@@ -74,6 +81,10 @@ const Index: React.FunctionComponent = () => {
7481
}
7582
};
7683

84+
const handleOnClose = () => {
85+
setIsLoading(false);
86+
};
87+
7788
if (!session) {
7889
return <div>Loading...</div>;
7990
}
@@ -109,7 +120,15 @@ const Index: React.FunctionComponent = () => {
109120
</PageSection>
110121
<PageSection>
111122
<div style={{ marginBottom: '20px' }} />
112-
{pullRequests.length === 0 ? (
123+
{!isFirstPullDone && (
124+
<Modal variant={ModalVariant.small} title="Retrieving your submissions" isOpen={isLoading} onClose={() => handleOnClose()}>
125+
<div>
126+
<Spinner size="md" />
127+
Retrieving all your skills and knowledge submissions from taxonomy repository.
128+
</div>
129+
</Modal>
130+
)}
131+
{isFirstPullDone && pullRequests.length === 0 ? (
113132
<EmptyState>
114133
<EmptyStateHeader
115134
titleText="Welcome to InstructLab"

0 commit comments

Comments
 (0)