Skip to content

Commit b2e508c

Browse files
authored
Merge pull request #178 from vishnoianil/bug-fix
Log the error, rather than rendering it
2 parents 9435276 + 19e84cf commit b2e508c

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/components/Dashboard/index.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,16 @@ 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[]>([]);
34-
const [error, setError] = React.useState<string | null>(null);
37+
const [isFirstPullDone, setIsFirstPullDone] = React.useState<boolean>(false);
38+
const [isLoading, setIsLoading] = useState<boolean>(true);
39+
//const [error, setError] = React.useState<string | null>(null);
3540
const router = useRouter();
3641

3742
const fetchAndSetPullRequests = React.useCallback(async () => {
@@ -52,8 +57,10 @@ const Index: React.FunctionComponent = () => {
5257

5358
setPullRequests(sortedPRs);
5459
} catch (error) {
55-
setError('Failed to fetch pull requests.');
60+
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,8 +120,15 @@ const Index: React.FunctionComponent = () => {
109120
</PageSection>
110121
<PageSection>
111122
<div style={{ marginBottom: '20px' }} />
112-
{error && <div>{error}</div>}
113-
{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 ? (
114132
<EmptyState>
115133
<EmptyStateHeader
116134
titleText="Welcome to InstructLab"

0 commit comments

Comments
 (0)