fix(breadcrumbs): adjust LogViewer, Build Details and Test Details breadcrumb for new URL structure#1338
Conversation
b9f3f83 to
0a725b5
Compare
0a725b5 to
a8691ce
Compare
| select: s => s.location.state, | ||
| }); | ||
| const { treeName, branch, id } = historyState; | ||
| const treeId = id; |
There was a problem hiding this comment.
You can rename the variable directly on the destruct:
const { treeName, branch, id: treeId } = useRouterState({
select: s => s.location.state,
});;
| ? { treeName: treeName, branch: branch, hash: id } | ||
| : { treeId: id } |
There was a problem hiding this comment.
Use treeId instead of id to be consistent
| <BreadcrumbLink | ||
| to={`/tree/$treeId`} | ||
| params={{ treeId: treeId }} | ||
| to={canGoDirect ? '/tree/$treeName/$branch/$hash' : '/tree/$treeId'} |
There was a problem hiding this comment.
Nit: you can extract this and the params conditional to outside the component props for better readability (and add a memo on the params object)
There was a problem hiding this comment.
I don't see the change addressing the comment. Also, IMO the BreadcrumbLink could be extracted entirely to a useMemo.
There was a problem hiding this comment.
Pinged you on Slack. I have some questions on int.
| const { treeName, branch, id } = historyState; | ||
| const canGoDirect = treeName && branch && id; |
There was a problem hiding this comment.
Ditto about destruct - and you can remove the historyState.id from this file to use id directly
| const historyState = useRouterState({ select: s => s.location.state }); | ||
|
|
||
| const { treeName, branch, id } = historyState; |
There was a problem hiding this comment.
I did not got the intent here. Is to refactor to const { treeName, branch, id } = useRouterState(...)? This historyState is only used here.
There was a problem hiding this comment.
Yes, jest to keep the pattern between the files
5935a3c to
b9d7e94
Compare
MarceloRobert
left a comment
There was a problem hiding this comment.
Mostly working, but needs improvement
13b8bfa to
762d0a6
Compare
| const historyState = useRouterState({ | ||
| select: s => s.location.state, | ||
| }); | ||
|
|
||
| const { treeName, branch, id: treeId } = historyState; |
There was a problem hiding this comment.
nit: can destruct like the other files:
const { treeName, branch, id: treeId } = useRouterState({
select: s => s.location.state,
});
There was a problem hiding this comment.
Good catch. Resolved
| const treeParams: { | ||
| to: '/tree/$treeName/$branch/$hash' | '/tree/$treeId'; | ||
| params: | ||
| | { treeName?: string; branch?: string; hash?: string } | ||
| | { treeId?: string }; | ||
| } = useMemo( | ||
| () => | ||
| canGoDirect | ||
| ? { | ||
| to: '/tree/$treeName/$branch/$hash', | ||
| params: { treeName: treeName, branch: branch, hash: treeId }, | ||
| } | ||
| : { to: '/tree/$treeId', params: { treeId: treeId } }, | ||
| [canGoDirect, treeName, branch, treeId], | ||
| ); |
There was a problem hiding this comment.
You don't need to type the treeParams if you add as const to the objects
| const treeParams: { | |
| to: '/tree/$treeName/$branch/$hash' | '/tree/$treeId'; | |
| params: | |
| | { treeName?: string; branch?: string; hash?: string } | |
| | { treeId?: string }; | |
| } = useMemo( | |
| () => | |
| canGoDirect | |
| ? { | |
| to: '/tree/$treeName/$branch/$hash', | |
| params: { treeName: treeName, branch: branch, hash: treeId }, | |
| } | |
| : { to: '/tree/$treeId', params: { treeId: treeId } }, | |
| [canGoDirect, treeName, branch, treeId], | |
| ); | |
| const treeParams = useMemo( | |
| () => | |
| canGoDirect | |
| ? { | |
| to: '/tree/$treeName/$branch/$hash', | |
| params: { treeName: treeName, branch: branch, hash: treeId }, | |
| } as const | |
| : { to: '/tree/$treeId', params: { treeId: treeId } } as const, | |
| [canGoDirect, treeName, branch, treeId], | |
| ); |
There was a problem hiding this comment.
Nice, i didn't knew about this TS feature.
ae301a3 to
562ed74
Compare
MarceloRobert
left a comment
There was a problem hiding this comment.
All working on my tests, LGTM
…eadcrumb for new URL structure The breadcrumb was not resolving correctly after the route update. Now it correctly reflects the new path parameters. Closes #1314
562ed74 to
efe4df6
Compare
Description
This PR fixes the breadcrumb links for the BuildDetails, TestDetails and LogViewer pages to accommodate the updated URL structure.
Previously, breadcrumbs were not resolving correctly due to changes in the route parameters.
With this fix, the breadcrumb now accurately reflects the current path
Changes
How to test
Closes #1314