-
Notifications
You must be signed in to change notification settings - Fork 3
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: Remove default values from URL #666
base: main
Are you sure you want to change the base?
Conversation
525eb27
to
aa6f0b3
Compare
@@ -146,7 +163,8 @@ export const zTreeInformation = z | |||
commitName: z.string().optional().catch(''), |
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.
another ticket for you, create a ticket to remove parameters that does not need to be in the URL
the URL is to remember user choices, this can be inferred from the sql query response
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 #671
const zHardwareSchema = z.object({ | ||
intervalInDays: makeZIntervalInDays(DEFAULT_HARDWARE_INTERVAL_IN_DAYS), | ||
hardwareSearch: z.string().optional().catch(undefined), | ||
hardwareSearch: z.string().optional().catch(''), |
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.
from what I'm understanding with stripSerach poarameters you don't need .optional
anymore
dashboard/src/routes/tree/route.tsx
Outdated
export const RootSearchSchema = z.object({ | ||
intervalInDays: makeZIntervalInDays(DEFAULT_TIME_SEARCH), | ||
treeSearch: z.string().optional().catch(''), |
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 about optional
const { isLoading, data, error } = useTreeDetails({ | ||
treeId: treeId ?? '', | ||
filter: reqFilter, | ||
}); | ||
|
||
const { tableFilter, diffFilter } = useSearch({ | ||
from: '/tree/$treeId/', | ||
from: '/tree/$treeId', |
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 did you change this?
/
is suppose to be the leaf, and that is the more exact place in this current route
@@ -35,14 +35,14 @@ interface TestsTabProps { | |||
} | |||
|
|||
const TestsTab = ({ reqFilter }: TestsTabProps): JSX.Element => { | |||
const { treeId } = useParams({ from: '/tree/$treeId/' }); | |||
const { treeId } = useParams({ from: '/tree/$treeId' }); |
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 about leaf
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.
From my tests, it seems that the buildDetails page still receives an empty diffFilter, and the hardwareDetails page is behaving weirdly, I can't deselect trees and it seems laggy
aa6f0b3
to
811eefb
Compare
- Added the search middleware `stripSearchParams` to remove search params with default values from the URL - Changed `from` options to use route instead of index e.g from `/tree/$treeId/` to `/tree/$treeId` - Added some default clauses to zod types to make the default values of search params be returned when they are stripped from the URL. Without this clause the returned value would be undefined Closes #656
811eefb
to
8c661c2
Compare
stripSearchParams
to remove search params with default values from the URLfrom
options to use route instead of index e.g from/tree/$treeId/
to/tree/$treeId
Closes #656
How to test
Navigate through the app, verifying that default values aren't being shown in the URL while keeping the same behaviour. Also note that when changing something, the search params goes back to the URL.