Skip to content

[Global Pins] Added a disabling global pins feature #6831

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

Merged
merged 8 commits into from
Apr 19, 2024

Conversation

roseayeon
Copy link
Contributor

@roseayeon roseayeon commented Apr 16, 2024

Motivation for features / changes

Following #6828,

Since global pins are applied automatically, this PR allows users disable the global pin feature.

Technical description of changes

2cf2b11 Added savingPinsEnabled in the MetricsSettings

  • Also added a selector getting settings.savingPinsEnabled value from the store.

dec6a63 Introduced new action metricsEnableSavingPinsToggled

  • If metricsEnableSavingPinsToggled is dispatched, it toggles the savingPinsEnabled store value.

6ea22fd Added a checkbox UI to the settings view component.

  • Also added a feature flag guard to the component. If check box is clicked, it dispatched metricsEnableSavingPinsToggled action.

568febf Added a new effect disableSavingPins

  • When metricsEnableSavingPinsToggled action is called, this effect will call removeAllScalarPins method if savingPinsEnabled value is false.

bbf9050 Added saving pins feature in persistent settings to preserve user preferences.

3ff7cd2 Add buildMetricsSettingsOverrides util in the testing to use in tbcorp

Screenshots of UI changes (or N/A)

image

Detailed steps to verify changes work correctly (as executed by you)

Unit test passes + created a cl/625208577 to pass TAP Presubmit tests

Alternate designs / implementations considered (or N/A)

N/A

Action Items in the next PR

In the next PR, I'll add a "confirmation dialog" that appears when the user unchecks the checkbox to make the user aware that local storage is disappearing.

  • Add the confirmation dialog

@roseayeon roseayeon marked this pull request as draft April 16, 2024 07:41
@roseayeon roseayeon marked this pull request as ready for review April 16, 2024 08:50
@@ -59,6 +59,7 @@ export function buildMetricsSettingsState(
imageContrastInMilli: 123,
imageShowActualSize: true,
histogramMode: HistogramMode.OFFSET,
savingPinsEnabled: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change in MetricsSettings required tbcorp change so I created cl/625208577

@roseayeon roseayeon requested review from hoonji and bmd3k April 16, 2024 09:28
<mat-icon
class="info"
svgIcon="help_outline_24px"
title="When saving pins are enabled, pinned cards will be shared across multiple experiments."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Instead of "shared across" perhaps "visible across"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied!

align-items: center;
display: flex;

.info {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be the same as L86-92. Can we just move the rule to a place where it only needs to be defined once? (make it a sibling to .saving-pins and .scalars-partition-x rules perhaps?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied! Changed it to be defined with .scalars-partition-x using a comma.

@roseayeon roseayeon force-pushed the disable-global-pins branch from f23dbee to 74cc62d Compare April 17, 2024 05:42
Copy link
Contributor Author

@roseayeon roseayeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick review!

<mat-icon
class="info"
svgIcon="help_outline_24px"
title="When saving pins are enabled, pinned cards will be shared across multiple experiments."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied!

align-items: center;
display: flex;

.info {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied! Changed it to be defined with .scalars-partition-x using a comma.

@hoonji
Copy link
Member

hoonji commented Apr 17, 2024

Sorry for the delay! I should be able to do a full review later tonight.

@@ -1298,6 +1298,18 @@ describe('metrics selectors', () => {
);
expect(selectors.getMetricsCardMinWidth(state)).toBe(400);
});

it('returns savingPinsEnabled when called getMetricsSavingPinsEnabled', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the test isn't very robust, as many different expressions could evaluate to false. A easy, succinct way to test both true/false can be parameterized testing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

})
);

private readonly disableSavingPins$ = this.actions$.pipe(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a bit confused by the naming at first because the effect doesn't actually disable (disabling is done elsewhere), this just removes pins.

WDYT of a naming that describes the actual action, like removeOnDisable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed to removeSavedPinsOnDisable 👍

on(actions.metricsEnableSavingPinsToggled, (state) => {
const nextSavingPinsEnabled = !(
state.settingOverrides.savingPinsEnabled ??
state.settings.savingPinsEnabled
Copy link
Member

@hoonji hoonji Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional] I'm curious, did you find out anything about the "legacy reasons" why we need settings as well as settingsOverrides?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be mistaken, but based on my understanding, the settings property is used for setting default values and loading persistent settings, while the property settingsOverrides is used when a user makes changes, such as toggling a checkbox.

In the code, the settingsOverrides is used to override the original setting store value. I'm not sure why these properties are separated, but that's what I discovered while examining the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that makes it clearer!

@@ -1232,6 +1232,21 @@ describe('metrics reducers', () => {
expect(thirdState.settings.hideEmptyCards).toBe(false);
expect(thirdState.settingOverrides.hideEmptyCards).toBe(false);
});

it('changes savingPinsEnabled on metricsEnableSavingPinsToggled', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this tests a "toggle", could we have at least two test cases minimum here? One changing from true -> false, another from false -> true (parameterized tests may help - please see other comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some states to make it true -> false -> true.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: interleaving act and assert steps is explicitly forbidden by our style guide and I think we should follow it unless there's a very strong reason not to. Can we just create separate tests for true->false and false->true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied. Thanks for reminding me! I just followed this interleaving act and assert steps because it was commonly used in this test codebase

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the cleanup! My readability meta-mentor linked me to this when I asked if consistency is important: https://peps.python.org/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds

My stance now is the right thing > consistency, unless inconsistency causes big problems

@roseayeon roseayeon force-pushed the disable-global-pins branch from 370132c to 38d9b67 Compare April 18, 2024 14:19
Copy link
Contributor Author

@roseayeon roseayeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review!

@roseayeon roseayeon requested a review from hoonji April 18, 2024 14:32
@@ -1232,6 +1232,21 @@ describe('metrics reducers', () => {
expect(thirdState.settings.hideEmptyCards).toBe(false);
expect(thirdState.settingOverrides.hideEmptyCards).toBe(false);
});

it('changes savingPinsEnabled on metricsEnableSavingPinsToggled', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: interleaving act and assert steps is explicitly forbidden by our style guide and I think we should follow it unless there's a very strong reason not to. Can we just create separate tests for true->false and false->true?

@roseayeon roseayeon force-pushed the disable-global-pins branch from 38d9b67 to bb40a23 Compare April 19, 2024 02:51
@@ -1232,6 +1232,21 @@ describe('metrics reducers', () => {
expect(thirdState.settings.hideEmptyCards).toBe(false);
expect(thirdState.settingOverrides.hideEmptyCards).toBe(false);
});

it('changes savingPinsEnabled on metricsEnableSavingPinsToggled', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the cleanup! My readability meta-mentor linked me to this when I asked if consistency is important: https://peps.python.org/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds

My stance now is the right thing > consistency, unless inconsistency causes big problems

@roseayeon roseayeon merged commit 9ff1585 into tensorflow:master Apr 19, 2024
roseayeon added a commit that referenced this pull request Apr 24, 2024
…6840)

## Motivation for features / changes

This PR fixes the renaming in #6831 and adds test cases to make the test
robust.

## Technical description of changes

* Tried to rename `disableSavingPins` to `removeSavedPinsOnDisable`, but
#6831 accidentally changed `removeAllPins` to
`removeSavedPinsOnDisable`.

## Screenshots of UI changes (or N/A)

## Detailed steps to verify changes work correctly (as executed by you)
* Added test cases + cl TAP presubmit passes
## Alternate designs / implementations considered (or N/A)
roseayeon added a commit that referenced this pull request Apr 30, 2024
…in feature (#6843)

## Motivation for features / changes
Regarding #6831 , this PR adds confirmation dialog" that appears when
the user clears the checkbox to make the user aware that local storage
is disappearing.

## Technical description of changes
0e63b07 created a `saving pins dialog` component

05e06f5 Created a `saving pins checkbox` component
* The Save Pin checkbox prevents the default click and must be done
after confirmation in the modal. So I added
`MAT_CHECKBOX_DEFAULT_OPTIONS`
(https://v15.material.angular.io/comComponents/checkbox/overview#click-action-config)
to prevent the default click event. However, if I add this directly to
the `settings view component`, all checkboxes will be disabled,
including other unwanted ones. So, I created a separate checkbox for the
Save Pin checkbox. Please let me know is there any other good way to do
this.

6ba778e Make the dialog shows up when user clears the checkbox
* Passes to `onEnableSavingPinsToggled` whether the checkbox is
selected.
* If the checkbox is selected and user clicks it, it means that the user
disables the global pin, so a dialog box is displayed.
* If the checkbox is not checked but is clicked, it means the user is
trying to enable a global pin and no dialog box will be displayed.
* `onEnableSavingPinsToggled` and `isSavingPinsEnabled` is passed to
`saving-pins-checkbox` component.

## Screenshots of UI changes (or N/A)

![image](https://github.com/tensorflow/tensorboard/assets/24772412/eb442565-4f39-45e7-b893-4866ee3fc1e4)

## Detailed steps to verify changes work correctly (as executed by you)
unit test passes + TAP presubmit passes 
## Alternate designs / implementations considered (or N/A)
AnuarTB pushed a commit to AnuarTB/tensorboard that referenced this pull request May 3, 2024
## Motivation for features / changes
Following tensorflow#6828,

Since global pins are applied automatically, this PR allows users
disable the global pin feature.

## Technical description of changes
2cf2b11 Added `savingPinsEnabled` in the `MetricsSettings`
* Also added a selector getting `settings.savingPinsEnabled` value from
the store.

dec6a63 Introduced new action `metricsEnableSavingPinsToggled`
* If `metricsEnableSavingPinsToggled` is dispatched, it toggles the
`savingPinsEnabled` store value.

6ea22fd Added a checkbox UI to the settings view component.
* Also added a feature flag guard to the component. If check box is
clicked, it dispatched `metricsEnableSavingPinsToggled` action.

568febf Added a new effect `disableSavingPins`
* When `metricsEnableSavingPinsToggled` action is called, this effect
will call `removeAllScalarPins` method if `savingPinsEnabled` value is
false.
 
bbf9050 Added saving pins feature in persistent settings to preserve
user preferences.

3ff7cd2 Add buildMetricsSettingsOverrides util in the testing to use in
tbcorp

## Screenshots of UI changes (or N/A)

![image](https://github.com/tensorflow/tensorboard/assets/24772412/874dbc2b-f01f-4112-b34b-6b07330ea31f)

## Detailed steps to verify changes work correctly (as executed by you)
Unit test passes + created a cl/625208577 to pass TAP Presubmit tests
## Alternate designs / implementations considered (or N/A)
N/A

## Action Items in the next PR
In the next PR, I'll add a "confirmation dialog" that appears when the
user unchecks the checkbox to make the user aware that local storage is
disappearing.

- [ ] Add the confirmation dialog
AnuarTB pushed a commit to AnuarTB/tensorboard that referenced this pull request May 3, 2024
…ensorflow#6840)

## Motivation for features / changes

This PR fixes the renaming in tensorflow#6831 and adds test cases to make the test
robust.

## Technical description of changes

* Tried to rename `disableSavingPins` to `removeSavedPinsOnDisable`, but
tensorflow#6831 accidentally changed `removeAllPins` to
`removeSavedPinsOnDisable`.

## Screenshots of UI changes (or N/A)

## Detailed steps to verify changes work correctly (as executed by you)
* Added test cases + cl TAP presubmit passes
## Alternate designs / implementations considered (or N/A)
AnuarTB pushed a commit to AnuarTB/tensorboard that referenced this pull request May 3, 2024
…in feature (tensorflow#6843)

## Motivation for features / changes
Regarding tensorflow#6831 , this PR adds confirmation dialog" that appears when
the user clears the checkbox to make the user aware that local storage
is disappearing.

## Technical description of changes
0e63b07 created a `saving pins dialog` component

05e06f5 Created a `saving pins checkbox` component
* The Save Pin checkbox prevents the default click and must be done
after confirmation in the modal. So I added
`MAT_CHECKBOX_DEFAULT_OPTIONS`
(https://v15.material.angular.io/comComponents/checkbox/overview#click-action-config)
to prevent the default click event. However, if I add this directly to
the `settings view component`, all checkboxes will be disabled,
including other unwanted ones. So, I created a separate checkbox for the
Save Pin checkbox. Please let me know is there any other good way to do
this.

6ba778e Make the dialog shows up when user clears the checkbox
* Passes to `onEnableSavingPinsToggled` whether the checkbox is
selected.
* If the checkbox is selected and user clicks it, it means that the user
disables the global pin, so a dialog box is displayed.
* If the checkbox is not checked but is clicked, it means the user is
trying to enable a global pin and no dialog box will be displayed.
* `onEnableSavingPinsToggled` and `isSavingPinsEnabled` is passed to
`saving-pins-checkbox` component.

## Screenshots of UI changes (or N/A)

![image](https://github.com/tensorflow/tensorboard/assets/24772412/eb442565-4f39-45e7-b893-4866ee3fc1e4)

## Detailed steps to verify changes work correctly (as executed by you)
unit test passes + TAP presubmit passes 
## Alternate designs / implementations considered (or N/A)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants