-
Notifications
You must be signed in to change notification settings - Fork 199
feat: Tag scene filter selection as URL search parameter #1140
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
APIX Tests 1 files 81 suites 6m 14s ⏱️ Results for commit 7fa7881. |
APIX Tests 1 files ±0 82 suites ±0 5m 22s ⏱️ -44s Results for commit e3b7e3d. ± Comparison against base commit ae59b95. This pull request removes 2 and adds 3 tests. Note that renamed tests count towards both.
|
APIX Tests 1 files ± 0 82 suites ±0 6m 2s ⏱️ -4s Results for commit 853531a. ± Comparison against base commit ae59b95. This pull request removes 2 and adds 16 tests. Note that renamed tests count towards both.
|
@@ -51,6 +51,9 @@ export const SelectorContainer: FC<SelectorContainerProps> = ({ | |||
...spaceProps | |||
}) => { | |||
const searchParams = new URLSearchParams(location.search) | |||
// TODO: noticing that there are certain pages where we must delete extra params | |||
// before pushing its link, what's a way we can handle this? |
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.
If this was not included here, navigating to the diffScene after selecting a filter will persist that parameter in the URL. I worry that there will be a growing number of scenes to render where certain parameters are no longer necessary and must be explicitly removed/nullified to avoid bloating the URL.
- What if we include an optional
toRemove
parameter to thebuildPath
functions, which is a list of strings corresponding to search params which we will remove from the URL? This could clean up my current changes inSideNavMethods.tsx
andSideNavTypes.tsx
.
searchParams.toString() | ||
)}`} | ||
to={() => { | ||
searchParams.delete('v') |
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.
Relates to prior comment about removing parameters from the URL in a cleaner fashion, pointing out for reviewers
@@ -141,6 +157,14 @@ export const ApiExplorer: FC<ApiExplorerProps> = ({ | |||
sdk: alias === allAlias ? null : alias, | |||
}) | |||
} | |||
|
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 gives code smell, as I can see it continually expanding as new parameters are added. I'm wondering if there is any insight on how to go about syncing multiple parameters at once in this initialization effect.
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 a good way to do this will be to augment initSettings
so that url parameters can be passed in and override persisted settings when applicable. As a result, this effect will then become a one liner that syncs the url with the store using navigate
.
APIX Tests 1 files ± 0 82 suites ±0 6m 2s ⏱️ -4s Results for commit 2d28c7f. ± Comparison against base commit ae59b95. This pull request removes 2 and adds 16 tests. Note that renamed tests count towards both.
|
@@ -51,6 +51,9 @@ export const SelectorContainer: FC<SelectorContainerProps> = ({ | |||
...spaceProps | |||
}) => { | |||
const searchParams = new URLSearchParams(location.search) | |||
// TODO: noticing that there are certain pages where we must delete extra params | |||
// before pushing its link, what's a way we can handle this? | |||
searchParams.delete('v') |
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.
could we replace the link component with say a Span
that behaves like a link and calls navigate
on click?
value === type.metaType.toString().toUpperCase()) && ( | ||
<Link key={index} to={buildTypePath(specKey, tag.name, type.name)}> | ||
(selectedTagFilter === 'ALL' || | ||
selectedTagFilter === type.metaType.toString().toUpperCase()) && ( |
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'm leaning towards not having this check. If user passes in an invalid value for a tag filter
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.
Did you mean to finish this comment? If a user passes in an invalid value for a tag filter, the expectation is that we handle this and default the user to have selected 'ALL', thus all of the options would show.
@@ -141,6 +157,14 @@ export const ApiExplorer: FC<ApiExplorerProps> = ({ | |||
sdk: alias === allAlias ? null : alias, | |||
}) | |||
} | |||
|
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 a good way to do this will be to augment initSettings
so that url parameters can be passed in and override persisted settings when applicable. As a result, this effect will then become a one liner that syncs the url with the store using navigate
.
* @param filter filter tag for page | ||
*/ | ||
export const isValidFilter = ( | ||
location: HLocation | Location, |
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.
@josephaxisa Given you preferred having the string pathname for the method getSceneType
, would you prefer changing this from a location object to a string?
Provides the ability to share a link to a method/type tag landing page with an applied filter. For example, being able to load a tag scene and have its methods already filtered on
POST
.