1
1
import Avatar from "@material-ui/core/Avatar"
2
+ import Box from "@material-ui/core/Box"
2
3
import Button from "@material-ui/core/Button"
3
4
import Link from "@material-ui/core/Link"
4
5
import { makeStyles } from "@material-ui/core/styles"
@@ -15,12 +16,16 @@ import { Link as RouterLink } from "react-router-dom"
15
16
import * as TypesGen from "../../api/typesGenerated"
16
17
import { Margins } from "../../components/Margins/Margins"
17
18
import { Stack } from "../../components/Stack/Stack"
19
+ import { TableLoader } from "../../components/TableLoader/TableLoader"
18
20
import { firstLetter } from "../../util/firstLetter"
19
21
20
22
dayjs . extend ( relativeTime )
21
23
22
24
export const Language = {
23
25
createButton : "Create Template" ,
26
+ developerCount : ( ownerCount : number ) : string => {
27
+ return `${ ownerCount } developer${ ownerCount !== 1 && "s" } `
28
+ } ,
24
29
emptyViewCreate : "to standardize development workspaces for your team." ,
25
30
emptyViewNoPerms : "No templates have been created! Contact your Coder administrator." ,
26
31
}
@@ -29,7 +34,6 @@ export interface TemplatesPageViewProps {
29
34
loading ?: boolean
30
35
canCreateTemplate ?: boolean
31
36
templates ?: TypesGen . Template [ ]
32
- error ?: unknown
33
37
}
34
38
35
39
export const TemplatesPageView : React . FC < TemplatesPageViewProps > = ( props ) => {
@@ -49,6 +53,7 @@ export const TemplatesPageView: React.FC<TemplatesPageViewProps> = (props) => {
49
53
</ TableRow >
50
54
</ TableHead >
51
55
< TableBody >
56
+ { props . loading && < TableLoader /> }
52
57
{ ! props . loading && ! props . templates ?. length && (
53
58
< TableRow >
54
59
< TableCell colSpan = { 999 } >
@@ -67,27 +72,25 @@ export const TemplatesPageView: React.FC<TemplatesPageViewProps> = (props) => {
67
72
</ TableCell >
68
73
</ TableRow >
69
74
) }
70
- { props . templates ?. map ( ( template ) => {
71
- return (
72
- < TableRow key = { template . id } className = { styles . templateRow } >
73
- < TableCell >
74
- < div className = { styles . templateName } >
75
- < Avatar variant = "square" className = { styles . templateAvatar } >
76
- { firstLetter ( template . name ) }
77
- </ Avatar >
78
- < Link component = { RouterLink } to = { `/templates/${ template . id } ` } className = { styles . templateLink } >
79
- < b > { template . name } </ b >
80
- < span > { template . description } </ span >
81
- </ Link >
82
- </ div >
83
- </ TableCell >
84
- < TableCell >
85
- { template . workspace_owner_count } developer{ template . workspace_owner_count !== 1 && "s" }
86
- </ TableCell >
87
- < TableCell > { dayjs ( ) . to ( dayjs ( template . updated_at ) ) } </ TableCell >
88
- </ TableRow >
89
- )
90
- } ) }
75
+ { props . templates ?. map ( ( template ) => (
76
+ < TableRow key = { template . id } className = { styles . templateRow } >
77
+ < TableCell >
78
+ < Box alignItems = "center" display = "flex" >
79
+ < Avatar variant = "square" className = { styles . templateAvatar } >
80
+ { firstLetter ( template . name ) }
81
+ </ Avatar >
82
+ < Link component = { RouterLink } to = { `/templates/${ template . id } ` } className = { styles . templateLink } >
83
+ < b > { template . name } </ b >
84
+ < span > { template . description } </ span >
85
+ </ Link >
86
+ </ Box >
87
+ </ TableCell >
88
+
89
+ < TableCell > { Language . developerCount ( template . workspace_owner_count ) } </ TableCell >
90
+
91
+ < TableCell > { dayjs ( ) . to ( dayjs ( template . updated_at ) ) } </ TableCell >
92
+ </ TableRow >
93
+ ) ) }
91
94
</ TableBody >
92
95
</ Table >
93
96
</ Margins >
@@ -133,10 +136,6 @@ const useStyles = makeStyles((theme) => ({
133
136
height : 24 ,
134
137
fontSize : 16 ,
135
138
} ,
136
- templateName : {
137
- display : "flex" ,
138
- alignItems : "center" ,
139
- } ,
140
139
templateLink : {
141
140
display : "flex" ,
142
141
flexDirection : "column" ,
0 commit comments