-
Notifications
You must be signed in to change notification settings - Fork 196
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
feat: ability to share a preconfigured diff scene #1158
base: main
Are you sure you want to change the base?
Conversation
…config-difs-8-15 Merging filter sharing PR changes into main
(For @josephaxisa) I created a new branch from the previous PR. After making some final changes to that PR and merging it into |
APIX Tests 1 files ±0 86 suites +2 5m 36s ⏱️ +6s For more details on these failures, see this check. Results for commit 358c56c. ± Comparison against base commit 135dce3. |
@@ -54,9 +54,9 @@ export const SideNavMethods = styled( | |||
const _isOpen = !isOpen | |||
setIsOpen(_isOpen) | |||
if (_isOpen) { | |||
navigate(`/${specKey}/methods/${tag}`) | |||
navigate(`/${specKey}/methods/${tag}`, { opts: null }) |
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.
The scenario to consider here (and with the same change in SideNavTypes
): we are in a diff scene with selected options, and opts
param in the url. When we open the sideNav and open a method/tag scene, this opts parameter should no longer persist. The reason we don't use navigateWithGlobalParams
to remove this parameter is because if we started at a tag scene with a filter selected and want to select another tag, this filter should still persist when we open the new tag scene.
So, technically, the purpose of this line in plain english is more like "navigate to the tag scene and ONLY keep the tag filter variable if we have one in the URL"
This makes me reconsider what we initially had proposed where we have a specific navigateTo
methods. I think in the long term there will be 2 cases:
- We navigate to a scene, remove all scene-specific params first, then push global params (currently the case with
navigateWithGlobalParams
, etc) - We navigate to a scene, keeping ONLY specific parameters, and removing anything else in the URL.
To better account for case 2, I think having custom navigate methods makes the most sense. Here we'd explicitly have a navigateToTagScene
instead of having to explicitly nullify any extra parameters that could persist when navigating to a tag scene from the SideNav.
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.
const diffOptionsParam = getDiffOptionsFromUrl(params.get('opts')) | ||
if (diffOptionsParam) { | ||
setDiffOptionsAction({ diffOptions: diffOptionsParam }) | ||
navigate(location.pathname, { opts: diffOptionsParam.join(',') }) |
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.
The reason for this navigate
here, which contrasts from tagStoreSync
or globalStoreSync
where we only dispatch to the store, is in the case where we have a list of options in the url, but one or more of those are not actually valid comparison options for the diff scene (e.g. opts=missing%2CINVALID%2Ctype
)
getValidDiffOptions
does the job of filtering out invalid comparison options from the URL and navigate
does the job of updating the URL to only have the valid options out of those listed in the parameter.
APIX Tests0 files - 1 0 suites - 84 0s ⏱️ - 8m 16s Results for commit a6a47ca. ± Comparison against base commit 180cf20. This pull request removes 392 tests.
|
APIX Tests0 files - 1 0 suites - 84 0s ⏱️ - 8m 16s Results for commit d92df04. ± Comparison against base commit 180cf20. This pull request removes 392 tests.
|
APIX Tests0 files - 1 0 suites - 84 0s ⏱️ - 8m 16s Results for commit 377dac8. ± Comparison against base commit 180cf20. This pull request removes 392 tests.
|
APIX Tests0 files - 1 0 suites - 86 0s ⏱️ - 6m 34s Results for commit 73ca49c. ± Comparison against base commit a4ac3bc. This pull request removes 408 tests.
|
@@ -265,4 +270,70 @@ describe('Diff Scene', () => { | |||
expect(diff40to31Page1Methods).toHaveLength(15) | |||
expect(diff40to31Page1Methods).toContain('delete_board_item') | |||
}) | |||
|
|||
it('updates when a comparison option is toggled', async () => { |
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.
Can remove this, but I thought it would be nice to have an integration test ensuring the DiffScene operates properly other than the unit tests which I couldn't make comprehensive due to the spec file bug.
APIX Tests 1 files 88 suites 6m 9s ⏱️ Results for commit a8965ea. |
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 Niral. I noted some feedback below
@@ -55,9 +54,9 @@ export const SideNavMethods = styled( | |||
const _isOpen = !isOpen | |||
setIsOpen(_isOpen) | |||
if (_isOpen) { | |||
navigateWithGlobalParams(`/${specKey}/methods/${tag}`) | |||
navigate(`/${specKey}/methods/${tag}`, { opts: null }) |
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.
why not navigateWithGlobalParams
?
@@ -54,9 +54,9 @@ export const SideNavTypes = styled( | |||
const _isOpen = !isOpen | |||
setIsOpen(_isOpen) | |||
if (_isOpen) { | |||
navigate(`/${specKey}/types/${tag}`) | |||
navigate(`/${specKey}/types/${tag}`, { opts: null }) |
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.
ditto
} else { | ||
navigate(`/${specKey}/types`) | ||
navigate(`/${specKey}/types`, { opts: null }) |
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.
ditto
} else { | ||
navigateWithGlobalParams(`/${specKey}/methods`) | ||
navigate(`/${specKey}/methods`, { opts: null }) |
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.
ditto
expect(mockHistoryPush).toHaveBeenCalledWith(`/${specKey}/methods/${tag}`) | ||
expect(mockHistoryPush).toHaveBeenCalledWith({ | ||
pathname: `/${specKey}/methods/${tag}`, | ||
search: '', |
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 think this change won't be needed if navigateWithGlobalParams
is used.
expect(mockHistoryPush).toHaveBeenCalledWith({ | ||
pathname: `/${specKey}/methods`, | ||
search: '', | ||
}) |
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.
ditto
* Returns all valid diff options contained in list | ||
* @param opts url diff options parameter value | ||
*/ | ||
export const getValidDiffOptions = (opts: string | null) => { |
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.
can opts just be made an optional string arg here? is null
explicitly needed?
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 pass in searchParams.get('opts')
in both DiffScene and diffStoreSync. When the param doesn't exist in the URL it searchParams.get()
will return null, so this was just a way to be able to handle it without doing any explicit checks before passing it in as input.
APIX Tests 1 files 88 suites 7m 50s ⏱️ Results for commit 09a0666. |
APIX Tests 1 files 88 suites 6m 9s ⏱️ Results for commit c54f9b3. |
Selecting comparison options in diff scenes will update an
opts
parameter in the URL, which is used to drive the state of the selected options in the scene.