Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

step selector: add step selector toggle state and action #5742

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tensorboard/webapp/metrics/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
Expand Down
7 changes: 7 additions & 0 deletions tensorboard/webapp/metrics/store/metrics_reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ const {initialState, reducers: namespaceContextedReducer} =
tagGroupExpanded: new Map<string, boolean>(),
selectedTime: null,
selectTimeEnabled: false,
stepSelectorEnabled: false,
useRangeSelectTime: false,
filteredPluginTypes: new Set(),
stepMinMax: {
Expand Down Expand Up @@ -1009,6 +1010,12 @@ const reducer = createReducer(
useRangeSelectTime,
};
}),
on(actions.stepSelectorEnableToggled, (state) => {
return {
...state,
stepSelectorEnabled: !state.stepSelectorEnabled,
};
}),
on(actions.useRangeSelectTimeToggled, (state) => {
return {
...state,
Expand Down
14 changes: 14 additions & 0 deletions tensorboard/webapp/metrics/store/metrics_reducers_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
1 change: 1 addition & 0 deletions tensorboard/webapp/metrics/store/metrics_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export interface MetricsNamespacedState {
tagGroupExpanded: Map<string, boolean>;
selectedTime: LinkedTime | null;
selectTimeEnabled: boolean;
stepSelectorEnabled: boolean;
useRangeSelectTime: boolean;
// Empty Set would signify "show all". `filteredPluginTypes` will never have
// all pluginTypes in the Set.
Expand Down
1 change: 1 addition & 0 deletions tensorboard/webapp/metrics/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
11 changes: 11 additions & 0 deletions tensorboard/webapp/metrics/views/right_pane/right_pane_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
metricsToggleIgnoreOutliers,
metricsToggleImageShowActualSize,
selectTimeEnableToggled,
stepSelectorEnableToggled,
timeSelectionChanged,
} from '../../actions';
import {HistogramMode, LinkedTime, TooltipSort, XAxisType} from '../../types';
Expand Down Expand Up @@ -197,7 +198,7 @@ export class SettingsViewContainer {
}

onStepSelectorEnableToggled() {
// TODO(japie1235813): Dispatch toggled event to update ngrx state.
this.store.dispatch(stepSelectorEnableToggled());
}

onSelectTimeChanged(newValue: LinkedTime) {
Expand Down