File tree 3 files changed +60
-1
lines changed
tensorboard/webapp/metrics
3 files changed +60
-1
lines changed Original file line number Diff line number Diff line change @@ -316,6 +316,21 @@ export class MetricsEffects implements OnInitEffects {
316
316
} )
317
317
) ;
318
318
319
+ private readonly removeAllPins$ = this . actions$ . pipe (
320
+ ofType ( actions . metricsClearAllPinnedCards ) ,
321
+ withLatestFrom (
322
+ this . store . select ( selectors . getEnableGlobalPins ) ,
323
+ this . store . select ( selectors . getShouldPersistSettings )
324
+ ) ,
325
+ filter (
326
+ ( [ , enableGlobalPins , shouldPersistSettings ] ) =>
327
+ enableGlobalPins && shouldPersistSettings
328
+ ) ,
329
+ tap ( ( ) => {
330
+ this . savedPinsDataSource . removeAllScalarPins ( ) ;
331
+ } )
332
+ ) ;
333
+
319
334
/**
320
335
* In general, this effect dispatch the following actions:
321
336
*
@@ -356,7 +371,11 @@ export class MetricsEffects implements OnInitEffects {
356
371
/**
357
372
* Subscribes to: dashboard shown (initAction).
358
373
*/
359
- this . loadSavedPins$
374
+ this . loadSavedPins$ ,
375
+ /**
376
+ * Subscribes to: metricsClearAllPinnedCards.
377
+ */
378
+ this . removeAllPins$
360
379
) ;
361
380
} ,
362
381
{ dispatch : false }
Original file line number Diff line number Diff line change @@ -985,5 +985,43 @@ describe('metrics effects', () => {
985
985
expect ( actualActions ) . toEqual ( [ ] ) ;
986
986
} ) ;
987
987
} ) ;
988
+
989
+ describe ( 'removeAllPins' , ( ) => {
990
+ let removeAllScalarPinsSpy : jasmine . Spy ;
991
+
992
+ beforeEach ( ( ) => {
993
+ removeAllScalarPinsSpy = spyOn (
994
+ savedPinsDataSource ,
995
+ 'removeAllScalarPins'
996
+ ) ;
997
+ store . overrideSelector ( selectors . getEnableGlobalPins , true ) ;
998
+ store . refreshState ( ) ;
999
+ } ) ;
1000
+
1001
+ it ( 'removes all pins by calling removeAllScalarPins method' , ( ) => {
1002
+ console . log ( removeAllScalarPinsSpy , 'spyspy' ) ;
1003
+ actions$ . next ( actions . metricsClearAllPinnedCards ( ) ) ;
1004
+
1005
+ expect ( removeAllScalarPinsSpy ) . toHaveBeenCalled ( ) ;
1006
+ } ) ;
1007
+
1008
+ it ( 'does not remove pins if getEnableGlobalPins is false' , ( ) => {
1009
+ store . overrideSelector ( selectors . getEnableGlobalPins , false ) ;
1010
+ store . refreshState ( ) ;
1011
+
1012
+ actions$ . next ( actions . metricsClearAllPinnedCards ( ) ) ;
1013
+
1014
+ expect ( removeAllScalarPinsSpy ) . not . toHaveBeenCalled ( ) ;
1015
+ } ) ;
1016
+
1017
+ it ( 'does not remove pins if getShouldPersistSettings is false' , ( ) => {
1018
+ store . overrideSelector ( selectors . getShouldPersistSettings , false ) ;
1019
+ store . refreshState ( ) ;
1020
+
1021
+ actions$ . next ( actions . metricsClearAllPinnedCards ( ) ) ;
1022
+
1023
+ expect ( removeAllScalarPinsSpy ) . not . toHaveBeenCalled ( ) ;
1024
+ } ) ;
1025
+ } ) ;
988
1026
} ) ;
989
1027
} ) ;
Original file line number Diff line number Diff line change @@ -405,6 +405,8 @@ export class TestingSavedPinsDataSource {
405
405
getSavedScalarPins ( ) {
406
406
return [ ] ;
407
407
}
408
+
409
+ removeAllScalarPins ( ) { }
408
410
}
409
411
410
412
export function provideTestingSavedPinsDataSource ( ) {
You can’t perform that action at this time.
0 commit comments