File tree 3 files changed +17
-6
lines changed
apps/content-editor/src/app/views
3 files changed +17
-6
lines changed Original file line number Diff line number Diff line change 7
7
} from "@mui/material" ;
8
8
import { DeleteRounded } from "@mui/icons-material" ;
9
9
import { useHistory , useParams } from "react-router" ;
10
- import { useSelector } from "react-redux" ;
10
+ import { useDispatch , useSelector } from "react-redux" ;
11
11
import { AppState } from "../../../../../../../../shell/store/types" ;
12
12
import { ContentItem } from "../../../../../../../../shell/services/types" ;
13
13
import {
@@ -22,6 +22,7 @@ type DuplicateItemProps = {
22
22
} ;
23
23
24
24
export const DeleteItemDialog = ( { onClose } : DuplicateItemProps ) => {
25
+ const dispatch = useDispatch ( ) ;
25
26
const { modelZUID, itemZUID } = useParams < {
26
27
modelZUID : string ;
27
28
itemZUID : string ;
@@ -68,12 +69,21 @@ export const DeleteItemDialog = ({ onClose }: DuplicateItemProps) => {
68
69
data-cy = "DeleteContentItemConfirmButton"
69
70
variant = "contained"
70
71
color = "error"
71
- onClick = { ( ) =>
72
+ onClick = { ( ) => {
72
73
deleteContentItem ( {
73
74
modelZUID : modelZUID ,
74
75
itemZUID : itemZUID ,
75
- } ) . then ( ( ) => history . push ( `/content/${ modelZUID } ` ) )
76
- }
76
+ } ) . then ( ( ) => {
77
+ /**
78
+ * Remove the item from the store before redirecting
79
+ */
80
+ dispatch ( {
81
+ type : "REMOVE_ITEM" ,
82
+ itemZUID,
83
+ } ) ;
84
+ history . push ( `/content/${ modelZUID } ` ) ;
85
+ } ) ;
86
+ } }
77
87
loading = { isLoading }
78
88
>
79
89
Delete Item
Original file line number Diff line number Diff line change @@ -209,6 +209,7 @@ export default connect((state, props) => {
209
209
} )
210
210
) ,
211
211
] ) ;
212
+
212
213
if ( _isMounted . current ) {
213
214
// render 1st page of results
214
215
setShouldRunFilters ( true ) ;
@@ -220,6 +221,7 @@ export default connect((state, props) => {
220
221
// re-render after all pages fetched
221
222
setShouldRunFilters ( true ) ;
222
223
}
224
+
223
225
setBackgroundLoading ( false ) ;
224
226
}
225
227
} catch ( err ) {
Original file line number Diff line number Diff line change @@ -259,7 +259,6 @@ export function fetchItem(modelZUID, itemZUID) {
259
259
itemZUID,
260
260
} ) ;
261
261
}
262
-
263
262
return res ;
264
263
} ,
265
264
} ) ;
@@ -408,7 +407,7 @@ export function saveItem(itemZUID, action = "") {
408
407
item . web . metaDescription = item . web . metaDescription . slice ( 0 , 160 ) ;
409
408
}
410
409
411
- /*
410
+ /*
412
411
Nav item will not be found if item does exist in the nav such is the case
413
412
when the item is in a dataset
414
413
*/
You can’t perform that action at this time.
0 commit comments