1
- import Link from "@material-ui/core/Link"
2
- import { makeStyles , useTheme } from "@material-ui/core/styles"
1
+ import { Stats , StatsItem } from "components/Stats/Stats"
3
2
import { FC } from "react"
4
- import { Link as RouterLink } from "react-router-dom"
3
+ import { useTranslation } from "react-i18next"
4
+ import { Link } from "react-router-dom"
5
5
import { WorkspaceBuild } from "../../api/typesGenerated"
6
- import { MONOSPACE_FONT_FAMILY } from "../../theme/constants"
7
- import { combineClasses } from "../../util/combineClasses"
8
- import {
9
- displayWorkspaceBuildDuration ,
10
- getDisplayWorkspaceBuildInitiatedBy ,
11
- getDisplayWorkspaceBuildStatus ,
12
- } from "../../util/workspace"
6
+ import { displayWorkspaceBuildDuration } from "../../util/workspace"
13
7
14
8
export interface WorkspaceBuildStatsProps {
15
9
build : WorkspaceBuild
@@ -18,116 +12,27 @@ export interface WorkspaceBuildStatsProps {
18
12
export const WorkspaceBuildStats : FC < WorkspaceBuildStatsProps > = ( {
19
13
build,
20
14
} ) => {
21
- const styles = useStyles ( )
22
- const theme = useTheme ( )
23
- const status = getDisplayWorkspaceBuildStatus ( theme , build )
24
- const initiatedBy = getDisplayWorkspaceBuildInitiatedBy ( build )
15
+ const { t } = useTranslation ( "buildPage" )
25
16
26
17
return (
27
- < div className = { styles . stats } >
28
- < div className = { styles . statItem } >
29
- < span className = { styles . statsLabel } > Workspace Name</ span >
30
- < Link
31
- component = { RouterLink }
32
- to = { `/@${ build . workspace_owner_name } /${ build . workspace_name } ` }
33
- className = { combineClasses ( [ styles . statsValue , styles . link ] ) }
34
- >
35
- { build . workspace_name }
36
- </ Link >
37
- </ div >
38
- < div className = { styles . statsDivider } />
39
-
40
- < div className = { styles . statItem } >
41
- < span className = { styles . statsLabel } > Duration</ span >
42
- < span className = { styles . statsValue } >
43
- { displayWorkspaceBuildDuration ( build ) }
44
- </ span >
45
- </ div >
46
- < div className = { styles . statsDivider } />
47
- < div className = { styles . statItem } >
48
- < span className = { styles . statsLabel } > Started at</ span >
49
- < span className = { styles . statsValue } >
50
- { new Date ( build . created_at ) . toLocaleString ( ) }
51
- </ span >
52
- </ div >
53
- < div className = { styles . statsDivider } />
54
- < div className = { styles . statItem } >
55
- < span className = { styles . statsLabel } > Status</ span >
56
- < span className = { styles . statsValue } >
57
- < span style = { { color : status . color } } > { status . status } </ span >
58
- </ span >
59
- </ div >
60
- < div className = { styles . statsDivider } />
61
- < div className = { styles . statItem } >
62
- < span className = { styles . statsLabel } > Action</ span >
63
- < span
64
- className = { combineClasses ( [ styles . statsValue , styles . capitalize ] ) }
65
- >
66
- { build . transition }
67
- </ span >
68
- </ div >
69
- < div className = { styles . statsDivider } />
70
- < div className = { styles . statItem } >
71
- < span className = { styles . statsLabel } > Initiated by</ span >
72
- < span className = { styles . statsValue } > { initiatedBy } </ span >
73
- </ div >
74
- </ div >
18
+ < Stats >
19
+ < StatsItem
20
+ label = { t ( "stats.workspace" ) }
21
+ value = {
22
+ < Link to = { `/@${ build . workspace_owner_name } /${ build . workspace_name } ` } >
23
+ { build . workspace_name }
24
+ </ Link >
25
+ }
26
+ />
27
+ < StatsItem
28
+ label = { t ( "stats.duration" ) }
29
+ value = { displayWorkspaceBuildDuration ( build ) }
30
+ />
31
+ < StatsItem
32
+ label = { t ( "stats.startedAt" ) }
33
+ value = { new Date ( build . created_at ) . toLocaleString ( ) }
34
+ />
35
+ < StatsItem label = { t ( "stats.action" ) } value = { build . transition } />
36
+ </ Stats >
75
37
)
76
38
}
77
-
78
- const useStyles = makeStyles ( ( theme ) => ( {
79
- stats : {
80
- paddingLeft : theme . spacing ( 2 ) ,
81
- paddingRight : theme . spacing ( 2 ) ,
82
- backgroundColor : theme . palette . background . paper ,
83
- borderRadius : theme . shape . borderRadius ,
84
- display : "flex" ,
85
- alignItems : "center" ,
86
- color : theme . palette . text . secondary ,
87
- fontFamily : MONOSPACE_FONT_FAMILY ,
88
- border : `1px solid ${ theme . palette . divider } ` ,
89
- [ theme . breakpoints . down ( "sm" ) ] : {
90
- display : "block" ,
91
- } ,
92
- } ,
93
-
94
- statItem : {
95
- minWidth : "13%" ,
96
- padding : theme . spacing ( 2 ) ,
97
- paddingTop : theme . spacing ( 1.75 ) ,
98
- } ,
99
-
100
- statsLabel : {
101
- fontSize : 12 ,
102
- textTransform : "uppercase" ,
103
- display : "block" ,
104
- fontWeight : 600 ,
105
- wordWrap : "break-word" ,
106
- } ,
107
-
108
- statsValue : {
109
- fontSize : 16 ,
110
- marginTop : theme . spacing ( 0.25 ) ,
111
- display : "block" ,
112
- wordWrap : "break-word" ,
113
- } ,
114
-
115
- statsDivider : {
116
- width : 1 ,
117
- height : theme . spacing ( 5 ) ,
118
- backgroundColor : theme . palette . divider ,
119
- marginRight : theme . spacing ( 2 ) ,
120
- [ theme . breakpoints . down ( "sm" ) ] : {
121
- display : "none" ,
122
- } ,
123
- } ,
124
-
125
- capitalize : {
126
- textTransform : "capitalize" ,
127
- } ,
128
-
129
- link : {
130
- color : theme . palette . text . primary ,
131
- fontWeight : 600 ,
132
- } ,
133
- } ) )
0 commit comments