@@ -27,11 +27,16 @@ import { TextContent } from '@patternfly/react-core/dist/esm/components/Text/Tex
27
27
import OutlinedQuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/outlined-question-circle-icon' ;
28
28
import { Popover } from '@patternfly/react-core/dist/esm/components/Popover' ;
29
29
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' ;
30
33
31
34
const Index : React . FunctionComponent = ( ) => {
32
35
const { data : session } = useSession ( ) ;
33
36
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);
35
40
const router = useRouter ( ) ;
36
41
37
42
const fetchAndSetPullRequests = React . useCallback ( async ( ) => {
@@ -52,8 +57,10 @@ const Index: React.FunctionComponent = () => {
52
57
53
58
setPullRequests ( sortedPRs ) ;
54
59
} catch ( error ) {
55
- setError ( 'Failed to fetch pull requests.' ) ;
60
+ console . log ( 'Failed to fetch pull requests.' + error ) ;
56
61
}
62
+ setIsFirstPullDone ( true ) ;
63
+ setIsLoading ( false ) ;
57
64
}
58
65
} , [ session ?. accessToken ] ) ;
59
66
@@ -74,6 +81,10 @@ const Index: React.FunctionComponent = () => {
74
81
}
75
82
} ;
76
83
84
+ const handleOnClose = ( ) => {
85
+ setIsLoading ( false ) ;
86
+ } ;
87
+
77
88
if ( ! session ) {
78
89
return < div > Loading...</ div > ;
79
90
}
@@ -109,8 +120,15 @@ const Index: React.FunctionComponent = () => {
109
120
</ PageSection >
110
121
< PageSection >
111
122
< 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 ? (
114
132
< EmptyState >
115
133
< EmptyStateHeader
116
134
titleText = "Welcome to InstructLab"
0 commit comments