diff --git a/tensorboard/webapp/metrics/actions/index.ts b/tensorboard/webapp/metrics/actions/index.ts index 64300a0ed8..34bff789f6 100644 --- a/tensorboard/webapp/metrics/actions/index.ts +++ b/tensorboard/webapp/metrics/actions/index.ts @@ -189,6 +189,10 @@ export const useRangeSelectTimeToggled = createAction( '[Metrics] Use Range Select Time Toggle' ); +export const stepSelectorEnableToggled = createAction( + '[Metrics] Time Selector Enable Toggle' +); + export const metricsPromoDismissed = createAction( '[Metrics] Metrics Promo Dismissed' ); diff --git a/tensorboard/webapp/metrics/store/metrics_reducers.ts b/tensorboard/webapp/metrics/store/metrics_reducers.ts index 6d3adf906e..1c8a2619b2 100644 --- a/tensorboard/webapp/metrics/store/metrics_reducers.ts +++ b/tensorboard/webapp/metrics/store/metrics_reducers.ts @@ -259,6 +259,7 @@ const {initialState, reducers: namespaceContextedReducer} = tagGroupExpanded: new Map(), selectedTime: null, selectTimeEnabled: false, + stepSelectorEnabled: false, useRangeSelectTime: false, filteredPluginTypes: new Set(), stepMinMax: { @@ -1009,6 +1010,12 @@ const reducer = createReducer( useRangeSelectTime, }; }), + on(actions.stepSelectorEnableToggled, (state) => { + return { + ...state, + stepSelectorEnabled: !state.stepSelectorEnabled, + }; + }), on(actions.useRangeSelectTimeToggled, (state) => { return { ...state, diff --git a/tensorboard/webapp/metrics/store/metrics_reducers_test.ts b/tensorboard/webapp/metrics/store/metrics_reducers_test.ts index 16590bc5cb..68e0de67ed 100644 --- a/tensorboard/webapp/metrics/store/metrics_reducers_test.ts +++ b/tensorboard/webapp/metrics/store/metrics_reducers_test.ts @@ -2867,6 +2867,20 @@ describe('metrics reducers', () => { }); }); + describe('step selector features', () => { + it('toggles whether stepSelector is enabled or not', () => { + const state1 = buildMetricsState({ + stepSelectorEnabled: false, + }); + + const state2 = reducers(state1, actions.stepSelectorEnableToggled()); + expect(state2.stepSelectorEnabled).toBe(true); + + const state3 = reducers(state2, actions.stepSelectorEnableToggled()); + expect(state3.stepSelectorEnabled).toBe(false); + }); + }); + describe('plugin filtering feature', () => { describe('#metricsToggleVisiblePlugin', () => { it('toggles plugin types', () => { diff --git a/tensorboard/webapp/metrics/store/metrics_types.ts b/tensorboard/webapp/metrics/store/metrics_types.ts index de624731b9..3731a3ea32 100644 --- a/tensorboard/webapp/metrics/store/metrics_types.ts +++ b/tensorboard/webapp/metrics/store/metrics_types.ts @@ -165,6 +165,7 @@ export interface MetricsNamespacedState { tagGroupExpanded: Map; selectedTime: LinkedTime | null; selectTimeEnabled: boolean; + stepSelectorEnabled: boolean; useRangeSelectTime: boolean; // Empty Set would signify "show all". `filteredPluginTypes` will never have // all pluginTypes in the Set. diff --git a/tensorboard/webapp/metrics/testing.ts b/tensorboard/webapp/metrics/testing.ts index fad5f06e2c..b055ab5f81 100644 --- a/tensorboard/webapp/metrics/testing.ts +++ b/tensorboard/webapp/metrics/testing.ts @@ -100,6 +100,7 @@ function buildBlankState(): MetricsState { tagGroupExpanded: new Map(), selectedTime: null, selectTimeEnabled: false, + stepSelectorEnabled: false, useRangeSelectTime: false, filteredPluginTypes: new Set(), stepMinMax: {min: Infinity, max: -Infinity}, diff --git a/tensorboard/webapp/metrics/views/right_pane/right_pane_test.ts b/tensorboard/webapp/metrics/views/right_pane/right_pane_test.ts index f0f8018e3f..c5d564221d 100644 --- a/tensorboard/webapp/metrics/views/right_pane/right_pane_test.ts +++ b/tensorboard/webapp/metrics/views/right_pane/right_pane_test.ts @@ -550,6 +550,17 @@ describe('metrics right_pane', () => { ] ).toBe('false'); }); + + it('dispatches stepSelectorEnableToggled on toggle', () => { + const fixture = TestBed.createComponent(SettingsViewContainer); + fixture.detectChanges(); + + select(fixture, '.scalars-step-selector input').nativeElement.click(); + + expect(dispatchSpy).toHaveBeenCalledWith( + actions.stepSelectorEnableToggled() + ); + }); }); }); }); diff --git a/tensorboard/webapp/metrics/views/right_pane/settings_view_container.ts b/tensorboard/webapp/metrics/views/right_pane/settings_view_container.ts index 659570d8ef..de7fb4c291 100644 --- a/tensorboard/webapp/metrics/views/right_pane/settings_view_container.ts +++ b/tensorboard/webapp/metrics/views/right_pane/settings_view_container.ts @@ -33,6 +33,7 @@ import { metricsToggleIgnoreOutliers, metricsToggleImageShowActualSize, selectTimeEnableToggled, + stepSelectorEnableToggled, timeSelectionChanged, } from '../../actions'; import {HistogramMode, LinkedTime, TooltipSort, XAxisType} from '../../types'; @@ -197,7 +198,7 @@ export class SettingsViewContainer { } onStepSelectorEnableToggled() { - // TODO(japie1235813): Dispatch toggled event to update ngrx state. + this.store.dispatch(stepSelectorEnableToggled()); } onSelectTimeChanged(newValue: LinkedTime) {