File tree Expand file tree Collapse file tree 7 files changed +27
-17
lines changed
key-details-remove-items/remove-list-elements Expand file tree Collapse file tree 7 files changed +27
-17
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,8 @@ import {
40
40
import styles from '../styles.module.scss'
41
41
42
42
export interface Props {
43
- onCancel : ( ) => void ;
43
+ onCancel : ( ) => void
44
+ onRemoveKey : ( ) => void
44
45
}
45
46
46
47
const optionsDestinations : EuiSuperSelectOption < string > [ ] = [
@@ -55,7 +56,7 @@ const optionsDestinations: EuiSuperSelectOption<string>[] = [
55
56
]
56
57
57
58
const RemoveListElements = ( props : Props ) => {
58
- const { onCancel } = props
59
+ const { onCancel, onRemoveKey } = props
59
60
60
61
const [ count , setCount ] = useState < string > ( '' )
61
62
const [ destination , setDestination ] = useState < ListElementDestination > ( TAIL_DESTINATION )
@@ -119,7 +120,8 @@ const RemoveListElements = (props: Props) => {
119
120
setIsPopoverOpen ( false )
120
121
}
121
122
122
- const onSuccessRemoved = ( ) => {
123
+ const onSuccessRemoved = ( newTotal : number ) => {
124
+ if ( newTotal <= 0 ) onRemoveKey ( )
123
125
onCancel ( )
124
126
sendEventTelemetry ( {
125
127
event : getBasedOnViewTypeEvent (
Original file line number Diff line number Diff line change @@ -123,8 +123,8 @@ const KeyDetails = ({ ...props }: Props) => {
123
123
}
124
124
125
125
const TypeDetails : any = {
126
- [ KeyTypes . ZSet ] : < ZSetDetails isFooterOpen = { isAddItemPanelOpen } /> ,
127
- [ KeyTypes . Set ] : < SetDetails isFooterOpen = { isAddItemPanelOpen } /> ,
126
+ [ KeyTypes . ZSet ] : < ZSetDetails isFooterOpen = { isAddItemPanelOpen } onRemoveKey = { onRemoveKey } /> ,
127
+ [ KeyTypes . Set ] : < SetDetails isFooterOpen = { isAddItemPanelOpen } onRemoveKey = { onRemoveKey } /> ,
128
128
[ KeyTypes . String ] : (
129
129
< StringDetails
130
130
isEditItem = { editItem }
@@ -224,7 +224,7 @@ const KeyDetails = ({ ...props }: Props) => {
224
224
{ isRemoveItemPanelOpen && (
225
225
< div className = { cx ( 'formFooterBar' , styles . contentActive ) } >
226
226
{ selectedKeyType === KeyTypes . List && (
227
- < RemoveListElements onCancel = { closeRemoveItemPanel } />
227
+ < RemoveListElements onCancel = { closeRemoveItemPanel } onRemoveKey = { onRemoveKey } />
228
228
) }
229
229
</ div >
230
230
) }
Original file line number Diff line number Diff line change @@ -51,10 +51,11 @@ const cellCache = new CellMeasurerCache({
51
51
52
52
export interface Props {
53
53
isFooterOpen : boolean
54
+ onRemoveKey : ( ) => void
54
55
}
55
56
56
57
const SetDetails = ( props : Props ) => {
57
- const { isFooterOpen } = props
58
+ const { isFooterOpen, onRemoveKey } = props
58
59
59
60
const { loading } = useSelector ( setSelector )
60
61
const { members : loadedMembers , total, nextCursor } = useSelector ( setDataSelector )
@@ -100,7 +101,8 @@ const SetDetails = (props: Props) => {
100
101
setDeleting ( `${ member + suffix } ` )
101
102
}
102
103
103
- const onSuccessRemoved = ( ) => {
104
+ const onSuccessRemoved = ( newTotal : number ) => {
105
+ newTotal === 0 && onRemoveKey ( )
104
106
sendEventTelemetry ( {
105
107
event : getBasedOnViewTypeEvent (
106
108
viewType ,
Original file line number Diff line number Diff line change @@ -61,10 +61,11 @@ interface IZsetMember extends ZsetMember {
61
61
62
62
export interface Props {
63
63
isFooterOpen : boolean
64
+ onRemoveKey : ( ) => void
64
65
}
65
66
66
67
const ZSetDetails = ( props : Props ) => {
67
- const { isFooterOpen } = props
68
+ const { isFooterOpen, onRemoveKey } = props
68
69
69
70
const { loading, searching } = useSelector ( zsetSelector )
70
71
const { loading : updateLoading } = useSelector ( updateZsetScoreStateSelector )
@@ -119,7 +120,8 @@ const ZSetDetails = (props: Props) => {
119
120
setDeleting ( `${ member + suffix } ` )
120
121
} , [ ] )
121
122
122
- const onSuccessRemoved = ( ) => {
123
+ const onSuccessRemoved = ( newTotal : number ) => {
124
+ newTotal === 0 && onRemoveKey ( )
123
125
sendEventTelemetry ( {
124
126
event : getBasedOnViewTypeEvent (
125
127
viewType ,
Original file line number Diff line number Diff line change @@ -429,7 +429,7 @@ export function insertListElementsAction(
429
429
// Asynchronous thunk action
430
430
export function deleteListElementsAction (
431
431
data : DeleteListElementsDto ,
432
- onSuccessAction ?: ( ) => void ,
432
+ onSuccessAction ?: ( newTotal : number ) => void ,
433
433
onFailAction ?: ( ) => void
434
434
) {
435
435
return async ( dispatch : AppDispatch , stateInit : ( ) => RootState ) => {
@@ -445,9 +445,11 @@ export function deleteListElementsAction(
445
445
{ data, params : { encoding } } ,
446
446
)
447
447
if ( isStatusSuccessful ( status ) ) {
448
- onSuccessAction ?.( )
448
+ const newTotal = state . browser . list . data ?. total - data . count
449
+
450
+ onSuccessAction ?.( newTotal )
449
451
dispatch ( deleteListElementsSuccess ( ) )
450
- if ( state . browser . list . data ?. total - data . count > 0 ) {
452
+ if ( newTotal > 0 ) {
451
453
dispatch < any > ( fetchKeyInfo ( data . keyName ) )
452
454
dispatch ( addMessageNotification (
453
455
successMessages . REMOVED_LIST_ELEMENTS (
Original file line number Diff line number Diff line change @@ -310,7 +310,7 @@ export function addSetMembersAction(
310
310
export function deleteSetMembers (
311
311
key : RedisResponseBuffer ,
312
312
members : RedisResponseBuffer [ ] ,
313
- onSuccessAction ?: ( ) => void ,
313
+ onSuccessAction ?: ( newTotal : number ) => void ,
314
314
) {
315
315
return async ( dispatch : AppDispatch , stateInit : ( ) => RootState ) => {
316
316
dispatch ( removeSetMembers ( ) )
@@ -333,8 +333,9 @@ export function deleteSetMembers(
333
333
)
334
334
335
335
if ( isStatusSuccessful ( status ) ) {
336
- onSuccessAction ?.( )
337
336
const newTotalValue = state . browser . set . data . total - data . affected
337
+
338
+ onSuccessAction ?.( newTotalValue )
338
339
dispatch ( removeSetMembersSuccess ( ) )
339
340
dispatch ( removeMembersFromList ( members ) )
340
341
if ( newTotalValue > 0 ) {
Original file line number Diff line number Diff line change @@ -351,7 +351,7 @@ export function fetchAddZSetMembers(
351
351
export function deleteZSetMembers (
352
352
key : RedisResponseBuffer ,
353
353
members : RedisResponseBuffer [ ] ,
354
- onSuccessAction ?: ( ) => void ,
354
+ onSuccessAction ?: ( newTotal : number ) => void ,
355
355
) {
356
356
return async ( dispatch : AppDispatch , stateInit : ( ) => RootState ) => {
357
357
dispatch ( removeZsetMembers ( ) )
@@ -372,8 +372,9 @@ export function deleteZSetMembers(
372
372
}
373
373
)
374
374
if ( isStatusSuccessful ( status ) ) {
375
- onSuccessAction ?.( )
376
375
const newTotalValue = state . browser . zset . data . total - data . affected
376
+
377
+ onSuccessAction ?.( newTotalValue )
377
378
dispatch ( removeZsetMembersSuccess ( ) )
378
379
dispatch ( removeMembersFromList ( members ) )
379
380
if ( newTotalValue > 0 ) {
You can’t perform that action at this time.
0 commit comments