Skip to content

fix(breadcrumbs): adjust LogViewer, Build Details and Test Details breadcrumb for new URL structure#1338

Merged
danieldiasbarbo merged 1 commit into
mainfrom
fix/breacrumbs-on-log-viewer
Jul 11, 2025
Merged

fix(breadcrumbs): adjust LogViewer, Build Details and Test Details breadcrumb for new URL structure#1338
danieldiasbarbo merged 1 commit into
mainfrom
fix/breacrumbs-on-log-viewer

Conversation

@danieldiasbarbo
Copy link
Copy Markdown
Contributor

@danieldiasbarbo danieldiasbarbo commented Jul 7, 2025

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

  • Remanaged the routerState in pages like LogViewer, BuildDetails, and TestDetails
  • Updated breadcrumb logic to consistently resolve to the correct TreeDetails url

How to test

  1. Navigate to a TreeDetails page via TreeListing or directly via URL
  2. From there, open related pages such as LogViewer, BuildDetails and TestDetails
  3. Verify that the breadcrumb displays correctly in each case and accurately reflects the full path back to the TreeDetails
  4. Ensure no breadcrumb segment is broken or missing

Closes #1314

@danieldiasbarbo danieldiasbarbo changed the title fix(breadcrumbs): adjust LogViewer breadcrumb for new URL structure WIP: fix(breadcrumbs): adjust LogViewer breadcrumb for new URL structure Jul 7, 2025
@danieldiasbarbo danieldiasbarbo force-pushed the fix/breacrumbs-on-log-viewer branch 3 times, most recently from b9f3f83 to 0a725b5 Compare July 10, 2025 12:16
@danieldiasbarbo danieldiasbarbo changed the title WIP: fix(breadcrumbs): adjust LogViewer breadcrumb for new URL structure fix(breadcrumbs): adjust LogViewer breadcrumb for new URL structure Jul 10, 2025
@danieldiasbarbo danieldiasbarbo changed the title fix(breadcrumbs): adjust LogViewer breadcrumb for new URL structure fix(breadcrumbs): adjust LogViewer, Build Details and Test Details breadcrumb for new URL structure Jul 10, 2025
@danieldiasbarbo danieldiasbarbo force-pushed the fix/breacrumbs-on-log-viewer branch from 0a725b5 to a8691ce Compare July 10, 2025 12:28
@danieldiasbarbo danieldiasbarbo marked this pull request as ready for review July 10, 2025 12:28
select: s => s.location.state,
});
const { treeName, branch, id } = historyState;
const treeId = id;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can rename the variable directly on the destruct:

const { treeName, branch, id: treeId } = useRouterState({
    select: s => s.location.state,
  });;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +44 to +45
? { treeName: treeName, branch: branch, hash: id }
: { treeId: id }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use treeId instead of id to be consistent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

<BreadcrumbLink
to={`/tree/$treeId`}
params={{ treeId: treeId }}
to={canGoDirect ? '/tree/$treeName/$branch/$hash' : '/tree/$treeId'}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the change addressing the comment. Also, IMO the BreadcrumbLink could be extracted entirely to a useMemo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinged you on Slack. I have some questions on int.

Comment on lines +64 to +65
const { treeName, branch, id } = historyState;
const canGoDirect = treeName && branch && id;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto about destruct - and you can remove the historyState.id from this file to use id directly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +33 to +35
const historyState = useRouterState({ select: s => s.location.state });

const { treeName, branch, id } = historyState;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not got the intent here. Is to refactor to const { treeName, branch, id } = useRouterState(...)? This historyState is only used here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, jest to keep the pattern between the files

@danieldiasbarbo danieldiasbarbo force-pushed the fix/breacrumbs-on-log-viewer branch 2 times, most recently from 5935a3c to b9d7e94 Compare July 10, 2025 17:04
Copy link
Copy Markdown
Contributor

@MarceloRobert MarceloRobert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly working, but needs improvement

Comment thread dashboard/src/pages/TreeDetails/Tabs/Build/TreeDetailsBuildsTable.tsx Outdated
Comment thread dashboard/src/pages/TreeDetails/Tabs/Boots/BootsTab.tsx
Comment thread dashboard/src/pages/TreeDetails/Tabs/Tests/TestsTab.tsx
@danieldiasbarbo danieldiasbarbo force-pushed the fix/breacrumbs-on-log-viewer branch 4 times, most recently from 13b8bfa to 762d0a6 Compare July 11, 2025 14:13
Comment on lines +25 to +29
const historyState = useRouterState({
select: s => s.location.state,
});

const { treeName, branch, id: treeId } = historyState;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can destruct like the other files:

const { treeName, branch, id: treeId } = useRouterState({
    select: s => s.location.state,
  });

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Resolved

Comment on lines +32 to +43
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],
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to type the treeParams if you add as const to the objects

Suggested change
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],
);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, i didn't knew about this TS feature.

@danieldiasbarbo danieldiasbarbo force-pushed the fix/breacrumbs-on-log-viewer branch 3 times, most recently from ae301a3 to 562ed74 Compare July 11, 2025 18:21
Copy link
Copy Markdown
Contributor

@MarceloRobert MarceloRobert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@danieldiasbarbo danieldiasbarbo force-pushed the fix/breacrumbs-on-log-viewer branch from 562ed74 to efe4df6 Compare July 11, 2025 18:51
@danieldiasbarbo danieldiasbarbo merged commit efe4df6 into main Jul 11, 2025
2 checks passed
@danieldiasbarbo danieldiasbarbo deleted the fix/breacrumbs-on-log-viewer branch July 11, 2025 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: treeDetails breadcrumb breaks on new url

3 participants