15
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
17
17
import React , { Fragment } from "react" ;
18
- import { Theme } from "@mui/material/styles" ;
19
- import { Tooltip } from "@mui/material" ;
20
- import createStyles from "@mui/styles/createStyles" ;
21
- import withStyles from "@mui/styles/withStyles" ;
22
18
import { IFileItem } from "../../ObjectBrowser/types" ;
23
19
import ProgressBarWrapper from "../ProgressBarWrapper/ProgressBarWrapper" ;
24
20
import {
21
+ Box ,
25
22
CancelledIcon ,
26
23
DisabledIcon ,
27
24
DownloadStatIcon ,
28
25
EnabledIcon ,
29
26
UploadStatIcon ,
27
+ Tooltip ,
30
28
} from "mds" ;
31
29
import clsx from "clsx" ;
32
30
import { callForObjectID } from "../../ObjectBrowser/transferManager" ;
31
+ import styled from "styled-components" ;
32
+ import get from "lodash/get" ;
33
33
34
34
interface IObjectHandled {
35
- classes : any ;
36
35
objectToDisplay : IFileItem ;
37
36
deleteFromList : ( instanceID : string ) => void ;
38
37
}
39
38
40
- const styles = ( theme : Theme ) =>
41
- createStyles ( {
42
- container : {
43
- borderBottom : "#E2E2E2 1px solid" ,
44
- padding : "15px 5px" ,
45
- margin : "0 30px" ,
46
- position : "relative" ,
47
- "& .showOnHover" : {
48
- opacity : 1 ,
49
- transitionDuration : "0.2s" ,
50
- } ,
51
- "&.inProgress" : {
52
- "& .hideOnProgress" : {
53
- //visibility: "hidden",
54
- } ,
55
- } ,
56
- "&:hover" : {
57
- "& .showOnHover" : {
58
- opacity : 1 ,
59
- } ,
60
- } ,
39
+ const ObjectHandledCloseButton = styled . button ( ( { theme } ) => ( {
40
+ backgroundColor : "transparent" ,
41
+ border : 0 ,
42
+ right : 0 ,
43
+ top : 5 ,
44
+ marginTop : 15 ,
45
+ position : "absolute" ,
46
+ cursor : "pointer" ,
47
+ "& .closeIcon" : {
48
+ backgroundColor : get ( theme , "buttons.regular.hover.background" , "#E6EAEB" ) ,
49
+ display : "block" ,
50
+ width : 18 ,
51
+ height : 18 ,
52
+ borderRadius : "100%" ,
53
+ "&:hover" : {
54
+ backgroundColor : get ( theme , "mutedText" , "#E9EDEE" ) ,
61
55
} ,
62
- headItem : {
63
- fontSize : 14 ,
64
- fontWeight : "bold" ,
65
- width : "100%" ,
66
- whiteSpace : "nowrap" ,
67
- textOverflow : "ellipsis" ,
68
- overflow : "hidden" ,
69
- } ,
70
- downloadHeader : {
71
- display : "flex" ,
72
- alignItems : "center" ,
73
- width : "100%" ,
74
- } ,
75
- progressContainer : {
76
- marginTop : 5 ,
77
- } ,
78
- objectDetails : {
79
- display : "flex" ,
80
- alignItems : "center" ,
81
- } ,
82
- iconContainer : {
83
- paddingTop : 5 ,
84
- marginRight : 5 ,
85
- "& svg" : {
86
- width : 16 ,
87
- height : 16 ,
88
- } ,
89
- } ,
90
- completedSuccess : {
91
- color : "#4CCB92" ,
92
- } ,
93
- inProgress : {
94
- color : "#2781B0" ,
95
- } ,
96
- completedError : {
97
- color : "#C83B51" ,
98
- } ,
99
- cancelledAction : {
100
- color : "#FFBD62" ,
101
- } ,
102
- closeIcon : {
103
- backgroundColor : "#E9EDEE" ,
104
- display : "block" ,
105
- width : 18 ,
106
- height : 18 ,
107
- borderRadius : "100%" ,
108
- "&:hover" : {
109
- backgroundColor : "#cecbcb" ,
110
- } ,
111
- "&::before" : {
112
- width : 1 ,
113
- height : 9 ,
114
- top : "50%" ,
115
- content : "' '" ,
116
- position : "absolute" ,
117
- transform : "translate(-50%, -50%) rotate(45deg)" ,
118
- borderLeft : "#000 2px solid" ,
119
- } ,
120
- "&::after" : {
121
- width : 1 ,
122
- height : 9 ,
123
- top : "50%" ,
124
- content : "' '" ,
125
- position : "absolute" ,
126
- transform : "translate(-50%, -50%) rotate(-45deg)" ,
127
- borderLeft : "#000 2px solid" ,
128
- } ,
129
- } ,
130
- closeButton : {
131
- backgroundColor : "transparent" ,
132
- border : 0 ,
133
- right : 0 ,
134
- top : 5 ,
135
- marginTop : 15 ,
56
+ "&::before" : {
57
+ width : 1 ,
58
+ height : 9 ,
59
+ top : "50%" ,
60
+ content : "' '" ,
136
61
position : "absolute" ,
62
+ transform : "translate(-50%, -50%) rotate(45deg)" ,
63
+ borderLeft : `${ get ( theme , "fontColor" , "#000" ) } 2px solid` ,
137
64
} ,
138
- fileName : {
139
- width : 295 ,
140
- } ,
141
- bucketName : {
142
- fontSize : 12 ,
143
- color : "#696969" ,
144
- fontWeight : "normal" ,
65
+ "&::after" : {
66
+ width : 1 ,
67
+ height : 9 ,
68
+ top : "50%" ,
69
+ content : "' '" ,
70
+ position : "absolute" ,
71
+ transform : "translate(-50%, -50%) rotate(-45deg)" ,
72
+ borderLeft : `${ get ( theme , "fontColor" , "#000" ) } 2px solid` ,
145
73
} ,
146
- errorMessage : {
147
- fontSize : 12 ,
148
- color : "#C83B51" ,
149
- fontWeight : "normal" ,
150
- marginTop : 6 ,
151
- overflowWrap : "break-word" ,
74
+ } ,
75
+ } ) ) ;
76
+
77
+ const ObjectInformation = styled . div ( ( { theme } ) => ( {
78
+ display : "flex" ,
79
+ alignItems : "center" ,
80
+ width : "100%" ,
81
+ "span.headItem" : {
82
+ fontSize : 14 ,
83
+ fontWeight : "bold" ,
84
+ width : 270 ,
85
+ whiteSpace : "nowrap" ,
86
+ textOverflow : "ellipsis" ,
87
+ overflow : "hidden" ,
88
+ } ,
89
+ "& .iconContainer" : {
90
+ paddingTop : 5 ,
91
+ marginRight : 5 ,
92
+ "& svg" : {
93
+ width : 16 ,
94
+ height : 16 ,
152
95
} ,
153
- } ) ;
96
+ } ,
97
+ "& .completedSuccess" : {
98
+ color : get ( theme , "signalColors.good" , "#4CCB92" ) ,
99
+ } ,
100
+ "& .inProgress" : {
101
+ color : get ( theme , "signalColors.main" , "#2781B0" ) ,
102
+ } ,
103
+ "& .completedError" : {
104
+ color : get ( theme , "signalColors.danger" , "#C83B51" ) ,
105
+ } ,
106
+ "& .cancelledAction" : {
107
+ color : get ( theme , "signalColors.warning" , "#FFBD62" ) ,
108
+ } ,
109
+ } ) ) ;
154
110
155
- const ObjectHandled = ( {
156
- classes,
157
- objectToDisplay,
158
- deleteFromList,
159
- } : IObjectHandled ) => {
111
+ const ObjectHandled = ( { objectToDisplay, deleteFromList } : IObjectHandled ) => {
160
112
const prefix = `${ objectToDisplay . prefix } ` ;
161
113
return (
162
114
< Fragment >
163
- < div
164
- className = { `${ classes . container } ${
165
- objectToDisplay . percentage !== 100 ? "inProgress" : ""
166
- } `}
115
+ < Box
116
+ sx = { {
117
+ borderBottom : "#E2E2E2 1px solid" ,
118
+ padding : "15px 5px" ,
119
+ margin : "0 30px" ,
120
+ position : "relative" ,
121
+ "& .showOnHover" : {
122
+ opacity : 1 ,
123
+ transitionDuration : "0.2s" ,
124
+ } ,
125
+ "&:hover" : {
126
+ "& .showOnHover" : {
127
+ opacity : 1 ,
128
+ } ,
129
+ } ,
130
+ } }
131
+ className = { objectToDisplay . percentage !== 100 ? "inProgress" : "" }
167
132
>
168
- < div className = { classes . clearListIcon } >
169
- < button
133
+ < Box
134
+ sx = { {
135
+ "& .closeButton" : {
136
+ backgroundColor : "transparent" ,
137
+ border : 0 ,
138
+ right : 0 ,
139
+ top : 5 ,
140
+ marginTop : 15 ,
141
+ position : "absolute" ,
142
+ } ,
143
+ } }
144
+ >
145
+ < ObjectHandledCloseButton
170
146
onClick = { ( ) => {
171
147
if ( ! objectToDisplay . done ) {
172
148
const call = callForObjectID ( objectToDisplay . ID ) ;
@@ -177,27 +153,39 @@ const ObjectHandled = ({
177
153
deleteFromList ( objectToDisplay . instanceID ) ;
178
154
}
179
155
} }
180
- className = { `${ classes . closeButton } hideOnProgress` }
156
+ className = { `closeButton hideOnProgress` }
157
+ >
158
+ < span className = { "closeIcon" } />
159
+ </ ObjectHandledCloseButton >
160
+ </ Box >
161
+ < Box
162
+ sx = { {
163
+ display : "flex" ,
164
+ alignItems : "center" ,
165
+ } }
166
+ >
167
+ < Box
168
+ sx = { {
169
+ width : 295 ,
170
+ "& .bucketName" : {
171
+ fontSize : 12 ,
172
+ } ,
173
+ } }
181
174
>
182
- < span className = { classes . closeIcon } />
183
- </ button >
184
- </ div >
185
- < div className = { classes . objectDetails } >
186
- < div className = { classes . fileName } >
187
- < Tooltip title = { prefix } placement = "top-start" >
188
- < div className = { classes . downloadHeader } >
175
+ < Tooltip tooltip = { prefix } placement = "top" >
176
+ < ObjectInformation >
189
177
< span
190
- className = { clsx ( classes . iconContainer , {
191
- [ classes . inProgress ] :
178
+ className = { clsx ( " iconContainer" , {
179
+ inProgress :
192
180
! objectToDisplay . done &&
193
181
! objectToDisplay . failed &&
194
182
! objectToDisplay . cancelled ,
195
- [ classes . completedSuccess ] :
183
+ completedSuccess :
196
184
objectToDisplay . done &&
197
185
! objectToDisplay . failed &&
198
186
! objectToDisplay . cancelled ,
199
- [ classes . completedError ] : objectToDisplay . failed ,
200
- [ classes . cancelledAction ] : objectToDisplay . cancelled ,
187
+ completedError : objectToDisplay . failed ,
188
+ cancelledAction : objectToDisplay . cancelled ,
201
189
} ) }
202
190
>
203
191
{ objectToDisplay . cancelled ? (
@@ -225,21 +213,25 @@ const ObjectHandled = ({
225
213
) }
226
214
</ span >
227
215
< span
228
- className = { clsx ( classes . headItem , {
229
- [ classes . completedError ] : objectToDisplay . failed ,
230
- } ) }
216
+ className = { ` headItem $ {
217
+ objectToDisplay . failed ? " completedError" : ""
218
+ } ` }
231
219
>
232
220
{ prefix }
233
221
</ span >
234
- </ div >
222
+ </ ObjectInformation >
235
223
</ Tooltip >
236
- < span className = { classes . bucketName } >
224
+ < Box className = { "muted bucketName" } >
237
225
< strong > Bucket: </ strong >
238
226
{ objectToDisplay . bucketName }
239
- </ span >
240
- </ div >
241
- </ div >
242
- < div className = { classes . progressContainer } >
227
+ </ Box >
228
+ </ Box >
229
+ </ Box >
230
+ < Box
231
+ sx = { {
232
+ marginTop : 5 ,
233
+ } }
234
+ >
243
235
{ objectToDisplay . waitingForFile ? (
244
236
< ProgressBarWrapper indeterminate value = { 0 } ready = { false } />
245
237
) : (
@@ -256,10 +248,10 @@ const ObjectHandled = ({
256
248
}
257
249
/>
258
250
) }
259
- </ div >
260
- </ div >
251
+ </ Box >
252
+ </ Box >
261
253
</ Fragment >
262
254
) ;
263
255
} ;
264
256
265
- export default withStyles ( styles ) ( ObjectHandled ) ;
257
+ export default ObjectHandled ;
0 commit comments