1
- import React from "react" ;
1
+ import React , { useCallback , useState } from "react" ;
2
2
import Typography from "@mui/material/Typography" ;
3
3
import LinearProgress from "@mui/material/LinearProgress" ;
4
4
import Box from "@mui/material/Box" ;
@@ -10,16 +10,38 @@ import { faSync } from "@fortawesome/free-solid-svg-icons/faSync";
10
10
import ListItemText from "@mui/material/ListItemText" ;
11
11
import CustomizedToolTip from "../../../helpers/CustomizedToolTip" ;
12
12
import { get } from "lodash" ;
13
+ import ConfirmationDialog from "../../../helpers/ConfirmationDialog" ;
14
+ import { common , red } from "@mui/material/colors" ;
15
+ import RemoveCircleIcon from "@mui/icons-material/RemoveCircle" ;
16
+ import { interruptTransfer } from "../../../store/actions" ;
17
+ import { useFirebase } from "react-redux-firebase" ;
13
18
14
19
/**
15
20
*
16
21
* @param {object } data
17
22
* @param {object } classes
23
+ * @param {string } dbPath
18
24
* @param {string } id
19
25
* @returns {JSX.Element }
20
26
* @constructor
21
27
*/
22
- const TransferringItem = ( { data, classes, id } ) => {
28
+ const TransferringItem = ( { data, classes, dbPath, id } ) => {
29
+ const [ open , setOpen ] = useState ( false ) ;
30
+ const firebase = useFirebase ( ) ;
31
+
32
+ const handleClose = useCallback ( ( ) => {
33
+ setOpen ( false ) ;
34
+ } , [ ] ) ;
35
+
36
+ const onInterruptTransfer = useCallback (
37
+ ( ) => interruptTransfer ( dbPath , id ) ( firebase ) ,
38
+ [ firebase , dbPath , id ]
39
+ ) ;
40
+
41
+ const handleInterruptions = useCallback ( ( ) => {
42
+ setOpen ( true ) ;
43
+ } , [ ] ) ;
44
+
23
45
return (
24
46
< React . Fragment key = { id } >
25
47
< ListItem alignItems = "flex-start" className = { classes . glass } >
@@ -72,6 +94,40 @@ const TransferringItem = ({ data, classes, id }) => {
72
94
</ React . Fragment >
73
95
}
74
96
/>
97
+ < ListItemAvatar
98
+ sx = { {
99
+ display : "flex" ,
100
+ justifyContent : "flex-end" ,
101
+ } }
102
+ >
103
+ < ConfirmationDialog
104
+ id = "interrupt-transfer"
105
+ keepMounted
106
+ open = { open }
107
+ onClose = { handleClose }
108
+ primaryMessage = { "Interrupt transfer" }
109
+ secondaryMessage = {
110
+ "Now you are going to interrupt the transferring job"
111
+ }
112
+ action = { onInterruptTransfer }
113
+ />
114
+ < CustomizedToolTip arrow placement = "top" title = "Remove" >
115
+ < Avatar
116
+ sx = { {
117
+ width : 24 ,
118
+ height : 24 ,
119
+ bgcolor : common [ "black" ] ,
120
+ cursor : "pointer" ,
121
+ } }
122
+ onClick = { handleInterruptions }
123
+ >
124
+ < RemoveCircleIcon
125
+ sx = { { color : red [ "A700" ] } }
126
+ fontSize = "inherit"
127
+ />
128
+ </ Avatar >
129
+ </ CustomizedToolTip >
130
+ </ ListItemAvatar >
75
131
</ ListItem >
76
132
</ React . Fragment >
77
133
) ;
0 commit comments