@@ -2,29 +2,32 @@ import Button from '@material-ui/core/Button';
22import Dialog from '@material-ui/core/Dialog' ;
33import DialogActions from '@material-ui/core/DialogActions' ;
44import DialogTitle from '@material-ui/core/DialogTitle' ;
5+ import { compose } from 'redux' ;
56
6- import { shapetag as api } from '@vidispine/vdt-api' ;
7+ import { shapetag as ShapeTagApi } from '@vidispine/vdt-api' ;
78
8- export default function ShapeTagRemove ( { closeModal, isOpen, tagName, history, openSnackBar } ) {
9+ import withUI from '../../hoc/withUI' ;
10+
11+ function ShapeTagRemove ( { tagName, open, onClose, onSuccess, onFail, openSnackBar } ) {
912 const onRemove = ( ) => {
10- api
11- . removeShapeTag ( { tagName } )
12- . then ( ( ) => {
13+ ShapeTagApi . removeShapeTag ( { tagName } )
14+ . then ( ( response ) => {
1315 const messageContent = `Shape Tag ${ tagName } Removed` ;
1416 openSnackBar ( { messageContent } ) ;
15- history . push ( '/shape-tag/' ) ;
16- closeModal ( ) ;
17+ if ( onSuccess ) onSuccess ( response ) ;
18+ onClose ( ) ;
1719 } )
18- . catch ( ( ) => {
20+ . catch ( ( error ) => {
1921 const messageContent = 'Error Removing Shape Tag' ;
2022 openSnackBar ( { messageContent, messageColor : 'secondary' } ) ;
23+ if ( onFail ) onFail ( error ) ;
2124 } ) ;
2225 } ;
2326 return (
24- < Dialog open = { isOpen } onClose = { closeModal } fullWidth maxWidth = { false } >
27+ < Dialog open = { open } onClose = { onClose } fullWidth maxWidth = { false } >
2528 < DialogTitle > { `Remove Shape Tag "${ tagName } "?` } </ DialogTitle >
2629 < DialogActions >
27- < Button onClick = { closeModal } color = "primary" >
30+ < Button onClick = { onClose } color = "primary" >
2831 Cancel
2932 </ Button >
3033 < Button variant = "text" onClick = { onRemove } color = "secondary" autoFocus >
@@ -34,3 +37,5 @@ export default function ShapeTagRemove({ closeModal, isOpen, tagName, history, o
3437 </ Dialog >
3538 ) ;
3639}
40+
41+ export default compose ( withUI ) ( ShapeTagRemove ) ;
0 commit comments