-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[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
Conversation
@@ -59,6 +59,7 @@ export function buildMetricsSettingsState( | |||
imageContrastInMilli: 123, | |||
imageShowActualSize: true, | |||
histogramMode: HistogramMode.OFFSET, | |||
savingPinsEnabled: true, |
There was a problem hiding this comment.
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
<mat-icon | ||
class="info" | ||
svgIcon="help_outline_24px" | ||
title="When saving pins are enabled, pinned cards will be shared across multiple experiments." |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
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.
f23dbee
to
74cc62d
Compare
There was a problem hiding this 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." |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
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', () => { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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', () => { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
370132c
to
38d9b67
Compare
There was a problem hiding this 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!
@@ -1232,6 +1232,21 @@ describe('metrics reducers', () => { | |||
expect(thirdState.settings.hideEmptyCards).toBe(false); | |||
expect(thirdState.settingOverrides.hideEmptyCards).toBe(false); | |||
}); | |||
|
|||
it('changes savingPinsEnabled on metricsEnableSavingPinsToggled', () => { |
There was a problem hiding this comment.
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?
38d9b67
to
bb40a23
Compare
@@ -1232,6 +1232,21 @@ describe('metrics reducers', () => { | |||
expect(thirdState.settings.hideEmptyCards).toBe(false); | |||
expect(thirdState.settingOverrides.hideEmptyCards).toBe(false); | |||
}); | |||
|
|||
it('changes savingPinsEnabled on metricsEnableSavingPinsToggled', () => { |
There was a problem hiding this comment.
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
…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)
…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)  ## Detailed steps to verify changes work correctly (as executed by you) unit test passes + TAP presubmit passes ## Alternate designs / implementations considered (or N/A)
## 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)  ## 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
…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)
…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)  ## Detailed steps to verify changes work correctly (as executed by you) unit test passes + TAP presubmit passes ## Alternate designs / implementations considered (or N/A)
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 theMetricsSettings
settings.savingPinsEnabled
value from the store.dec6a63 Introduced new action
metricsEnableSavingPinsToggled
metricsEnableSavingPinsToggled
is dispatched, it toggles thesavingPinsEnabled
store value.6ea22fd Added a checkbox UI to the settings view component.
metricsEnableSavingPinsToggled
action.568febf Added a new effect
disableSavingPins
metricsEnableSavingPinsToggled
action is called, this effect will callremoveAllScalarPins
method ifsavingPinsEnabled
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)
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.