11import React from "react" ;
22
33import {
4+ Bullseye ,
45 Button ,
6+ EmptyState ,
7+ EmptyStateBody ,
8+ EmptyStateVariant ,
59 PageSection ,
610 Toolbar ,
711 ToolbarContent ,
812 ToolbarGroup ,
913 ToolbarItem ,
1014} from "@patternfly/react-core" ;
1115import { Table , Thead , Tr , Th , Tbody , Td } from "@patternfly/react-table" ;
16+ import SkeletonTable from "@patternfly/react-component-groups/dist/cjs/SkeletonTable" ;
17+ import ExclamationCircleIcon from "@patternfly/react-icons/dist/dynamic/icons/exclamation-circle-icon" ;
1218import { repoStatus } from "@/getters" ;
1319import { useSession } from "next-auth/react" ;
1420
@@ -21,13 +27,17 @@ export interface TestStatusItem extends Omit<repoStatus, "workflowStatus"> {
2127
2228export interface TestStatusTableProps {
2329 statusItems : TestStatusItem [ ] ;
30+ isLoading : boolean ;
31+ hasError : boolean ;
2432 refresh : ( ) => Promise < void > ;
2533 submit : ( ) => Promise < void > ;
2634 renewBumps : ( ) => Promise < void > ;
2735}
2836
2937export const TestStatusTable : React . FunctionComponent < TestStatusTableProps > = ( {
3038 statusItems,
39+ isLoading,
40+ hasError,
3141 refresh,
3242 submit,
3343 renewBumps,
@@ -102,7 +112,51 @@ export const TestStatusTable: React.FunctionComponent<TestStatusTableProps> = ({
102112 </ Toolbar >
103113 ) : null ;
104114
105- const columns = [ "Name" , "Status" , "Synced with upstream?" ] ;
115+ const columns = [ "Name" , "Status" , "Synced with upstream?" , "Preview" ] ;
116+
117+ if ( isLoading ) {
118+ return (
119+ < PageSection isWidthLimited >
120+ { toolbar }
121+ < SkeletonTable rowsCount = { statusItems . length || 8 } columns = { columns } />
122+ </ PageSection >
123+ ) ;
124+ }
125+
126+ if ( hasError ) {
127+ return (
128+ < PageSection isWidthLimited >
129+ { toolbar }
130+ < Table aria-label = "Testing status error" >
131+ < Thead >
132+ < Tr >
133+ { columns . map ( ( column ) => (
134+ < Th key = { column } > { column } </ Th >
135+ ) ) }
136+ </ Tr >
137+ </ Thead >
138+ < Tbody >
139+ < Tr >
140+ < Td colSpan = { columns . length } >
141+ < Bullseye >
142+ < EmptyState
143+ icon = { ExclamationCircleIcon }
144+ titleText = "Unable to connect"
145+ headingLevel = "h2"
146+ variant = { EmptyStateVariant . sm }
147+ >
148+ < EmptyStateBody >
149+ There was an error retrieving data. Check your connection and reload the page.
150+ </ EmptyStateBody >
151+ </ EmptyState >
152+ </ Bullseye >
153+ </ Td >
154+ </ Tr >
155+ </ Tbody >
156+ </ Table >
157+ </ PageSection >
158+ ) ;
159+ }
106160
107161 return (
108162 < PageSection isWidthLimited >
@@ -116,17 +170,24 @@ export const TestStatusTable: React.FunctionComponent<TestStatusTableProps> = ({
116170 </ Tr >
117171 </ Thead >
118172 < Tbody >
119- { statusItems . map ( ( item , rowIndex ) => (
173+ { statusItems . map ( ( item ) => (
120174 < Tr key = { item . name } >
121175 < Td dataLabel = { columns [ 0 ] } width = { 30 } >
122176 { < a href = { item . upstreamOwnerLink } aria-label = { `upstream repo ${ item . name } ` } > { item . name } </ a > }
123177 </ Td >
124178 < Td dataLabel = { columns [ 1 ] } width = { 30 } >
125179 { < a href = { item . bumpPRLink } aria-label = { `dependency bump PR, status ${ item . status } ` } > { item . status } </ a > }
126180 </ Td >
127- < Td dataLabel = { columns [ 1 ] } width = { 40 } >
181+ < Td dataLabel = { columns [ 2 ] } width = { 30 } >
128182 { item . syncStatus . toString ( ) }
129183 </ Td >
184+ < Td dataLabel = { columns [ 3 ] } width = { 10 } >
185+ { item . previewUrl ? (
186+ < a href = { item . previewUrl } aria-label = { `preview for ${ item . name } ` } > Preview</ a >
187+ ) : (
188+ "-"
189+ ) }
190+ </ Td >
130191 </ Tr >
131192 ) ) }
132193 </ Tbody >
0 commit comments