@@ -15,7 +15,7 @@ import { Link as RouterLink } from "react-router-dom"
15
15
import * as TypesGen from "../../api/typesGenerated"
16
16
import { AvatarData } from "../../components/AvatarData/AvatarData"
17
17
import { EmptyState } from "../../components/EmptyState/EmptyState"
18
- import { Margins } from "../../components/Margins/Margins "
18
+ import { ErrorSummary } from "../../components/ErrorSummary/ErrorSummary "
19
19
import { Stack } from "../../components/Stack/Stack"
20
20
import { TableLoader } from "../../components/TableLoader/TableLoader"
21
21
import { getDisplayStatus } from "../../util/workspace"
@@ -34,93 +34,78 @@ export interface WorkspacesPageViewProps {
34
34
error ?: unknown
35
35
}
36
36
37
- export const WorkspacesPageView : FC < WorkspacesPageViewProps > = ( props ) => {
38
- const styles = useStyles ( )
37
+ export const WorkspacesPageView : FC < WorkspacesPageViewProps > = ( { loading , workspaces , error } ) => {
38
+ useStyles ( )
39
39
const theme : Theme = useTheme ( )
40
+
40
41
return (
41
42
< Stack spacing = { 4 } >
42
- < Margins >
43
- < div className = { styles . actions } >
44
- < Link underline = "none" component = { RouterLink } to = "/workspaces/new" >
45
- < Button startIcon = { < AddCircleOutline /> } > { Language . createButton } </ Button >
46
- </ Link >
47
- </ div >
48
- < Table >
49
- < TableHead >
43
+ { error && < ErrorSummary error = { error } /> }
44
+ < Table >
45
+ < TableHead >
46
+ < TableRow >
47
+ < TableCell > Name</ TableCell >
48
+ < TableCell > Template</ TableCell >
49
+ < TableCell > Version</ TableCell >
50
+ < TableCell > Last Built</ TableCell >
51
+ < TableCell > Status</ TableCell >
52
+ </ TableRow >
53
+ </ TableHead >
54
+ < TableBody >
55
+ { loading && < TableLoader /> }
56
+ { workspaces && workspaces . length === 0 && (
50
57
< TableRow >
51
- < TableCell > Name</ TableCell >
52
- < TableCell > Template</ TableCell >
53
- < TableCell > Version</ TableCell >
54
- < TableCell > Last Built</ TableCell >
55
- < TableCell > Status</ TableCell >
58
+ < TableCell colSpan = { 999 } >
59
+ < EmptyState
60
+ message = { Language . emptyMessage }
61
+ description = { Language . emptyDescription }
62
+ cta = {
63
+ < Link underline = "none" component = { RouterLink } to = "/workspaces/new" >
64
+ < Button startIcon = { < AddCircleOutline /> } > { Language . createButton } </ Button >
65
+ </ Link >
66
+ }
67
+ />
68
+ </ TableCell >
56
69
</ TableRow >
57
- </ TableHead >
58
- < TableBody >
59
- { props . loading && < TableLoader /> }
60
- { props . workspaces && props . workspaces . length === 0 && (
61
- < TableRow >
62
- < TableCell colSpan = { 999 } >
63
- < EmptyState
64
- message = { Language . emptyMessage }
65
- description = { Language . emptyDescription }
66
- cta = {
67
- < Link underline = "none" component = { RouterLink } to = "/workspaces/new" >
68
- < Button startIcon = { < AddCircleOutline /> } > { Language . createButton } </ Button >
69
- </ Link >
70
- }
71
- />
72
- </ TableCell >
73
- </ TableRow >
74
- ) }
75
- { props . workspaces &&
76
- props . workspaces . map ( ( workspace ) => {
77
- const status = getDisplayStatus ( theme , workspace . latest_build )
78
- return (
79
- < TableRow key = { workspace . id } >
80
- < TableCell >
81
- < AvatarData
82
- title = { workspace . name }
83
- subtitle = { workspace . owner_name }
84
- link = { `/workspaces/${ workspace . id } ` }
85
- />
86
- </ TableCell >
87
- < TableCell > { workspace . template_name } </ TableCell >
88
- < TableCell >
89
- { workspace . outdated ? (
90
- < span style = { { color : theme . palette . error . main } } > outdated</ span >
91
- ) : (
92
- < span style = { { color : theme . palette . text . secondary } } > up to date</ span >
93
- ) }
94
- </ TableCell >
95
- < TableCell >
96
- < span data-chromatic = "ignore" style = { { color : theme . palette . text . secondary } } >
97
- { dayjs ( ) . to ( dayjs ( workspace . latest_build . created_at ) ) }
98
- </ span >
99
- </ TableCell >
100
- < TableCell >
101
- < span style = { { color : status . color } } > { status . status } </ span >
102
- </ TableCell >
103
- </ TableRow >
104
- )
105
- } ) }
106
- </ TableBody >
107
- </ Table >
108
- </ Margins >
70
+ ) }
71
+ { workspaces &&
72
+ workspaces . map ( ( workspace ) => {
73
+ const status = getDisplayStatus ( theme , workspace . latest_build )
74
+ return (
75
+ < TableRow key = { workspace . id } >
76
+ < TableCell >
77
+ < AvatarData
78
+ title = { workspace . name }
79
+ subtitle = { workspace . owner_name }
80
+ link = { `/workspaces/${ workspace . id } ` }
81
+ />
82
+ </ TableCell >
83
+ < TableCell > { workspace . template_name } </ TableCell >
84
+ < TableCell >
85
+ { workspace . outdated ? (
86
+ < span style = { { color : theme . palette . error . main } } > outdated</ span >
87
+ ) : (
88
+ < span style = { { color : theme . palette . text . secondary } } > up to date</ span >
89
+ ) }
90
+ </ TableCell >
91
+ < TableCell >
92
+ < span data-chromatic = "ignore" style = { { color : theme . palette . text . secondary } } >
93
+ { dayjs ( ) . to ( dayjs ( workspace . latest_build . created_at ) ) }
94
+ </ span >
95
+ </ TableCell >
96
+ < TableCell >
97
+ < span style = { { color : status . color } } > { status . status } </ span >
98
+ </ TableCell >
99
+ </ TableRow >
100
+ )
101
+ } ) }
102
+ </ TableBody >
103
+ </ Table >
109
104
</ Stack >
110
105
)
111
106
}
112
107
113
108
const useStyles = makeStyles ( ( theme ) => ( {
114
- actions : {
115
- marginTop : theme . spacing ( 3 ) ,
116
- marginBottom : theme . spacing ( 3 ) ,
117
- display : "flex" ,
118
- height : theme . spacing ( 6 ) ,
119
-
120
- "& > *" : {
121
- marginLeft : "auto" ,
122
- } ,
123
- } ,
124
109
welcome : {
125
110
paddingTop : theme . spacing ( 12 ) ,
126
111
paddingBottom : theme . spacing ( 12 ) ,
0 commit comments