@@ -5,19 +5,19 @@ import {
5
5
Icon ,
6
6
IconButton ,
7
7
makeStyles ,
8
- Snackbar ,
9
- SnackbarContent ,
10
8
Theme ,
11
9
Tooltip ,
12
10
} from "@material-ui/core" ;
13
11
import Card from "@material-ui/core/Card" ;
14
12
import CardContent from "@material-ui/core/CardContent" ;
15
13
import Grid from "@material-ui/core/Grid" ;
16
14
import Typography from "@material-ui/core/Typography" ;
17
- import CloseIcon from "@material-ui/icons/Close" ;
18
15
import GetAppOutlinedIcon from "@material-ui/icons/GetAppOutlined" ;
19
16
import React , { ReactElement , useState } from "react" ;
17
+ import { Subject } from "rxjs" ;
20
18
import api from "../../api" ;
19
+ import Snackbar from "../../common/components/data-display/feedback/Snackbar" ;
20
+ import LabeledRow from "../../common/components/data-display/LabeledRow" ;
21
21
import { formatDateTimeForFilename } from "../../common/utils/dateUtil" ;
22
22
import { isServiceReady } from "../../common/utils/serviceUtil" ;
23
23
import { SERVICES_WITH_ADDITIONAL_INFO } from "../../constants" ;
@@ -41,10 +41,6 @@ const useStyles = makeStyles((theme: Theme) =>
41
41
paddingBottom : 0 ,
42
42
} ,
43
43
} ,
44
- cardCell : {
45
- padding : theme . spacing ( 4 ) ,
46
- textAlign : "center" ,
47
- } ,
48
44
statusDot : {
49
45
height : 10 ,
50
46
width : 10 ,
@@ -58,14 +54,6 @@ const useStyles = makeStyles((theme: Theme) =>
58
54
inactive : {
59
55
backgroundColor : theme . palette . error . light ,
60
56
} ,
61
- snackbar : {
62
- bottom : theme . spacing ( 3 ) * 2 ,
63
- right : theme . spacing ( 3 ) * 2 ,
64
- } ,
65
- snackbarMessage : {
66
- backgroundColor : theme . palette . error . main ,
67
- color : theme . palette . error . contrastText ,
68
- } ,
69
57
} )
70
58
) ;
71
59
@@ -88,7 +76,7 @@ const downloadLogs = (serviceName: string, handleError: () => void): void => {
88
76
const OverviewItem = ( props : OverviewItemProps ) : ReactElement => {
89
77
const { status, opendexdLocked, opendexdNotReady } = props ;
90
78
const [ detailsOpen , setDetailsOpen ] = useState ( false ) ;
91
- const [ errorMsgOpen , setErrorMsgOpen ] = useState ( false ) ;
79
+ const errorMsgOpenSubject = new Subject < boolean > ( ) ;
92
80
const classes = useStyles ( ) ;
93
81
94
82
const statusDotClass = `${ classes . statusDot } ${
@@ -122,6 +110,7 @@ const OverviewItem = (props: OverviewItemProps): ReactElement => {
122
110
>
123
111
< Grid container item >
124
112
{ isDetailsIconVisible ( status ) && (
113
+ /* IconButton */
125
114
< Tooltip title = "details" >
126
115
< IconButton size = "small" onClick = { ( ) => setDetailsOpen ( true ) } >
127
116
< Icon fontSize = "small" > open_in_full</ Icon >
@@ -143,12 +132,15 @@ const OverviewItem = (props: OverviewItemProps): ReactElement => {
143
132
</ Grid >
144
133
< Grid container item justify = "flex-end" >
145
134
{ isDownloadLogsEnabled ( status ) && (
135
+ /* TextButton */
146
136
< Tooltip title = "Download logs" >
147
137
< Button
148
138
size = "small"
149
139
startIcon = { < GetAppOutlinedIcon fontSize = "small" /> }
150
140
onClick = { ( ) =>
151
- downloadLogs ( status . service , ( ) => setErrorMsgOpen ( true ) )
141
+ downloadLogs ( status . service , ( ) =>
142
+ errorMsgOpenSubject ?. next ( true )
143
+ )
152
144
}
153
145
>
154
146
Logs
@@ -159,15 +151,11 @@ const OverviewItem = (props: OverviewItemProps): ReactElement => {
159
151
</ Grid >
160
152
< Divider />
161
153
< CardContent className = { classes . cardContent } >
162
- < Grid container item >
163
- < Grid item xs = { 4 } className = { classes . cardCell } >
164
- Status
165
- </ Grid >
166
- < Divider orientation = "vertical" flexItem />
167
- < Grid item xs = { 7 } className = { classes . cardCell } >
168
- { props . status . status }
169
- </ Grid >
170
- </ Grid >
154
+ < LabeledRow
155
+ label = "Status"
156
+ value = { props . status . status }
157
+ paddingSpacing = { 4 }
158
+ />
171
159
</ CardContent >
172
160
</ Card >
173
161
@@ -179,22 +167,10 @@ const OverviewItem = (props: OverviewItemProps): ReactElement => {
179
167
) }
180
168
181
169
< Snackbar
182
- className = { classes . snackbar }
183
- open = { errorMsgOpen }
184
- autoHideDuration = { 10000 }
185
- onClose = { ( ) => setErrorMsgOpen ( false ) }
186
- anchorOrigin = { { vertical : "bottom" , horizontal : "right" } }
187
- >
188
- < SnackbarContent
189
- className = { classes . snackbarMessage }
190
- message = { `Could not download the logs for ${ status . service } ` }
191
- action = {
192
- < IconButton onClick = { ( ) => setErrorMsgOpen ( false ) } >
193
- < CloseIcon />
194
- </ IconButton >
195
- }
196
- />
197
- </ Snackbar >
170
+ message = { `Could not download the logs for ${ status . service } ` }
171
+ openSubject = { errorMsgOpenSubject }
172
+ type = "error"
173
+ > </ Snackbar >
198
174
</ Grid >
199
175
) ;
200
176
} ;
0 commit comments