@@ -69,8 +69,6 @@ class EscalationChainsPage extends React.Component<EscalationChainsPageProps, Es
69
69
70
70
const { escalationChainStore } = store ;
71
71
72
- const searchResult = escalationChainStore . getSearchResult ( ) ;
73
-
74
72
let selectedEscalationChain : EscalationChain [ 'id' ] ;
75
73
if ( id ) {
76
74
let escalationChain = await escalationChainStore
@@ -87,22 +85,25 @@ class EscalationChainsPage extends React.Component<EscalationChainsPageProps, Es
87
85
}
88
86
}
89
87
90
- if ( ! selectedEscalationChain ) {
91
- selectedEscalationChain = searchResult [ 0 ] ?. id ;
92
- }
93
-
94
88
if ( selectedEscalationChain ) {
95
89
this . enrichExtraEscalationChainsAndSelect ( selectedEscalationChain ) ;
90
+ } else {
91
+ this . setState ( { selectedEscalationChain : undefined } ) ;
96
92
}
97
93
} ;
98
94
95
+ handleEsclalationSelect = ( id : EscalationChain [ 'id' ] ) => {
96
+ const { history } = this . props ;
97
+
98
+ history . push ( `${ PLUGIN_ROOT } /escalations/${ id } ${ window . location . search } ` ) ;
99
+ } ;
100
+
99
101
setSelectedEscalationChain = async ( escalationChainId : EscalationChain [ 'id' ] ) => {
100
- const { store, history } = this . props ;
102
+ const { store } = this . props ;
101
103
102
104
const { escalationChainStore } = store ;
103
105
104
106
this . setState ( { selectedEscalationChain : escalationChainId } , ( ) => {
105
- history . push ( `${ PLUGIN_ROOT } /escalations/${ escalationChainId || '' } ${ window . location . search } ` ) ;
106
107
if ( escalationChainId ) {
107
108
escalationChainStore . updateEscalationChainDetails ( escalationChainId ) ;
108
109
}
@@ -167,7 +168,7 @@ class EscalationChainsPage extends React.Component<EscalationChainsPageProps, Es
167
168
selectedId = { selectedEscalationChain }
168
169
items = { data }
169
170
itemKey = "id"
170
- onSelect = { this . setSelectedEscalationChain }
171
+ onSelect = { this . handleEsclalationSelect }
171
172
>
172
173
{ ( item ) => < EscalationChainCard id = { item . id } /> }
173
174
</ GList >
@@ -234,8 +235,14 @@ class EscalationChainsPage extends React.Component<EscalationChainsPageProps, Es
234
235
}
235
236
236
237
handleFiltersChange = ( filters : FiltersValues , isOnMount = false ) => {
238
+ const {
239
+ match : {
240
+ params : { id } ,
241
+ } ,
242
+ } = this . props ;
243
+
237
244
this . setState ( { escalationChainsFilters : filters , extraEscalationChains : undefined } , ( ) => {
238
- if ( isOnMount ) {
245
+ if ( isOnMount && id ) {
239
246
this . applyFilters ( ) . then ( this . parseQueryParams ) ;
240
247
} else {
241
248
this . applyFilters ( ) . then ( this . autoSelectEscalationChain ) ;
@@ -244,14 +251,15 @@ class EscalationChainsPage extends React.Component<EscalationChainsPageProps, Es
244
251
} ;
245
252
246
253
autoSelectEscalationChain = ( ) => {
247
- const { store } = this . props ;
254
+ const { store, history } = this . props ;
248
255
const { selectedEscalationChain } = this . state ;
249
256
const { escalationChainStore } = store ;
250
257
251
258
const searchResult = escalationChainStore . getSearchResult ( ) ;
252
259
253
260
if ( ! searchResult . find ( ( escalationChain : EscalationChain ) => escalationChain . id === selectedEscalationChain ) ) {
254
- this . setSelectedEscalationChain ( searchResult [ 0 ] ?. id ) ;
261
+ const id = searchResult [ 0 ] ?. id ;
262
+ history . push ( `${ PLUGIN_ROOT } /escalations/${ id || '' } ${ window . location . search } ` ) ;
255
263
}
256
264
} ;
257
265
@@ -358,7 +366,11 @@ class EscalationChainsPage extends React.Component<EscalationChainsPageProps, Es
358
366
} ;
359
367
360
368
handleEscalationChainCreate = async ( id : EscalationChain [ 'id' ] ) => {
361
- this . enrichExtraEscalationChainsAndSelect ( id ) ;
369
+ const { history } = this . props ;
370
+
371
+ await this . applyFilters ( ) ;
372
+
373
+ history . push ( `${ PLUGIN_ROOT } /escalations/${ id } ${ window . location . search } ` ) ;
362
374
} ;
363
375
364
376
enrichExtraEscalationChainsAndSelect = async ( id : EscalationChain [ 'id' ] ) => {
@@ -389,7 +401,7 @@ class EscalationChainsPage extends React.Component<EscalationChainsPageProps, Es
389
401
} ;
390
402
391
403
handleDeleteEscalationChain = ( ) => {
392
- const { store } = this . props ;
404
+ const { store, history } = this . props ;
393
405
const { escalationChainStore } = store ;
394
406
const { selectedEscalationChain, extraEscalationChains } = this . state ;
395
407
@@ -413,7 +425,7 @@ class EscalationChainsPage extends React.Component<EscalationChainsPageProps, Es
413
425
414
426
const newSelected = escalationChains [ index - 1 ] || escalationChains [ 0 ] ;
415
427
416
- this . setSelectedEscalationChain ( newSelected ?. id ) ;
428
+ history . push ( ` ${ PLUGIN_ROOT } /escalations/ ${ newSelected ?. id || '' } ${ window . location . search } ` ) ;
417
429
} ) ;
418
430
} ;
419
431
0 commit comments