1
1
import Button from "@material-ui/core/Button"
2
2
import Link from "@material-ui/core/Link"
3
- import { makeStyles , Theme } from "@material-ui/core/styles"
3
+ import { fade , makeStyles , Theme } from "@material-ui/core/styles"
4
4
import Table from "@material-ui/core/Table"
5
5
import TableBody from "@material-ui/core/TableBody"
6
6
import TableCell from "@material-ui/core/TableCell"
7
7
import TableHead from "@material-ui/core/TableHead"
8
8
import TableRow from "@material-ui/core/TableRow"
9
9
import AddCircleOutline from "@material-ui/icons/AddCircleOutline"
10
+ import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight"
10
11
import useTheme from "@material-ui/styles/useTheme"
11
12
import dayjs from "dayjs"
12
13
import relativeTime from "dayjs/plugin/relativeTime"
13
14
import { FC } from "react"
14
- import { Link as RouterLink } from "react-router-dom"
15
+ import { Link as RouterLink , useNavigate } from "react-router-dom"
15
16
import * as TypesGen from "../../api/typesGenerated"
16
17
import { AvatarData } from "../../components/AvatarData/AvatarData"
17
18
import { EmptyState } from "../../components/EmptyState/EmptyState"
@@ -33,19 +34,21 @@ export interface WorkspacesPageViewProps {
33
34
}
34
35
35
36
export const WorkspacesPageView : FC < WorkspacesPageViewProps > = ( { loading, workspaces } ) => {
36
- useStyles ( )
37
+ const styles = useStyles ( )
38
+ const navigate = useNavigate ( )
37
39
const theme : Theme = useTheme ( )
38
40
39
41
return (
40
42
< Stack spacing = { 4 } >
41
43
< Table >
42
44
< TableHead >
43
45
< TableRow >
44
- < TableCell > Name</ TableCell >
45
- < TableCell > Template</ TableCell >
46
- < TableCell > Version</ TableCell >
47
- < TableCell > Last Built</ TableCell >
48
- < TableCell > Status</ TableCell >
46
+ < TableCell width = "20%" > Name</ TableCell >
47
+ < TableCell width = "20%" > Template</ TableCell >
48
+ < TableCell width = "20%" > Version</ TableCell >
49
+ < TableCell width = "20%" > Last Built</ TableCell >
50
+ < TableCell width = "20%" > Status</ TableCell >
51
+ < TableCell > </ TableCell >
49
52
</ TableRow >
50
53
</ TableHead >
51
54
< TableBody >
@@ -68,14 +71,25 @@ export const WorkspacesPageView: FC<WorkspacesPageViewProps> = ({ loading, works
68
71
{ workspaces &&
69
72
workspaces . map ( ( workspace ) => {
70
73
const status = getDisplayStatus ( theme , workspace . latest_build )
74
+ const navigateToWorkspacePage = ( ) => {
75
+ navigate ( `/workspaces/${ workspace . id } ` )
76
+ }
71
77
return (
72
- < TableRow key = { workspace . id } >
78
+ < TableRow
79
+ key = { workspace . id }
80
+ hover
81
+ data-testid = { `workspace-${ workspace . id } ` }
82
+ tabIndex = { 0 }
83
+ onClick = { navigateToWorkspacePage }
84
+ onKeyDown = { ( event ) => {
85
+ if ( event . key === "Enter" ) {
86
+ navigateToWorkspacePage ( )
87
+ }
88
+ } }
89
+ className = { styles . clickableTableRow }
90
+ >
73
91
< TableCell >
74
- < AvatarData
75
- title = { workspace . name }
76
- subtitle = { workspace . owner_name }
77
- link = { `/workspaces/${ workspace . id } ` }
78
- />
92
+ < AvatarData title = { workspace . name } subtitle = { workspace . owner_name } />
79
93
</ TableCell >
80
94
< TableCell > { workspace . template_name } </ TableCell >
81
95
< TableCell >
@@ -93,6 +107,11 @@ export const WorkspacesPageView: FC<WorkspacesPageViewProps> = ({ loading, works
93
107
< TableCell >
94
108
< span style = { { color : status . color } } > { status . status } </ span >
95
109
</ TableCell >
110
+ < TableCell >
111
+ < div className = { styles . arrowCell } >
112
+ < KeyboardArrowRight className = { styles . arrowRight } />
113
+ </ div >
114
+ </ TableCell >
96
115
</ TableRow >
97
116
)
98
117
} ) }
@@ -117,4 +136,27 @@ const useStyles = makeStyles((theme) => ({
117
136
lineHeight : `${ theme . spacing ( 3 ) } px` ,
118
137
} ,
119
138
} ,
139
+ clickableTableRow : {
140
+ cursor : "pointer" ,
141
+
142
+ "&:hover td" : {
143
+ backgroundColor : fade ( theme . palette . primary . light , 0.1 ) ,
144
+ } ,
145
+
146
+ "&:focus" : {
147
+ outline : `1px solid ${ theme . palette . secondary . dark } ` ,
148
+ } ,
149
+
150
+ "& .MuiTableCell-root:last-child" : {
151
+ paddingRight : theme . spacing ( 2 ) ,
152
+ } ,
153
+ } ,
154
+ arrowRight : {
155
+ color : fade ( theme . palette . primary . contrastText , 0.7 ) ,
156
+ width : 20 ,
157
+ height : 20 ,
158
+ } ,
159
+ arrowCell : {
160
+ display : "flex" ,
161
+ } ,
120
162
} ) )
0 commit comments