Skip to content
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

Sidebar design update #76868

Closed
wants to merge 18 commits into from
Closed

Sidebar design update #76868

wants to merge 18 commits into from

Conversation

natemoo-re
Copy link
Member

@natemoo-re natemoo-re commented Sep 3, 2024

This PR updates the sidebar design across the Sentry frontend, behind the navigation-sidebar-v2 flag. This PR supercedes #76577.

TODO

  • handle alpha / beta badges
  • add subnav panel
  • regression tests
  • mobile (maintain previous UI)

Follow-up

  • overlays (what's new, onboarding) as modal dialogs
  • new mobile designs

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Sep 3, 2024
Copy link

codecov bot commented Sep 3, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
7761 1 7760 0
View the top 1 failed tests by shortest run time
Sidebar Stacked navigation with navigation-sidebar-v2 flag does not render secondary subnav for projects Sidebar Stacked navigation with navigation-sidebar-v2 flag does not render secondary subnav for projects
Stack Traces | 0.06s run time
Error: expect(element).not.toBeInTheDocument()

expected document not to contain element, found <div aria-label="Secondary Navigation" class="css-bz8ur1-SidebarSecondaryWrapper e1pyhmmi0" /> instead
    at Object.<anonymous> (.../components/sidebar/index.spec.tsx:368:93)

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

/>
);
if (hasNewNav && hasOrganization) {
issues = (
<SubnavMenu
Copy link
Member Author

Choose a reason for hiding this comment

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

Most of the functional markup changes are handled by a new SubnavMenu component, which projects children into the secondary sidebar panel as needed

Comment on lines +325 to +343
// issue subnav matches against issue groups in search params
if (location.pathname.startsWith('/issues/') && item?.to?.includes('/issues/')) {
const search = new URLSearchParams(location.search);
const itemSearch = new URLSearchParams(item.search);
const itemQuery = itemSearch.get('query');
const query = search.get('query');
if (item?.label === 'All') {
return !query && !itemQuery;
}
if (itemQuery && query) {
let match = false;
for (const key of itemQuery?.split(' ')) {
match = query.includes(key);
if (!match) break;
}
return match;
}
return !itemQuery;
}
Copy link
Member Author

@natemoo-re natemoo-re Sep 10, 2024

Choose a reason for hiding this comment

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

This is new "active" matching logic for the Issues subnav which required special consideration of search params.

See also: #76868 (comment)

Comment on lines 25 to 32
useLayoutEffect(() => {
if (!containerRef.current) return;
if (containerRef.current.children.length === 0) {
document.body.dataset.navLevel = '1';
} else {
document.body.dataset.navLevel = '2';
}
});
Copy link
Member Author

Choose a reason for hiding this comment

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

Not the cleanest pattern, but since the sidebar uses position: fixed, we need an effect that surfaces how many navigation levels are active so we can adjust the static app layout from inside the render tree.

Copy link
Contributor

Choose a reason for hiding this comment

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

heh
would there ever be a world where we have more layers than just 2?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question! I don't imagine there would be, so this could be treated as a boolean attribute or class name.

Comment on lines +811 to +812
v2_width: '80px',
v2_panelWidth: '160px',
Copy link
Member Author

Choose a reason for hiding this comment

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

Slight adjustments from the spec'd designs to accommodate font rendering differences

static/app/views/issueList/utils.tsx Show resolved Hide resolved
Copy link
Contributor

@nhsiehgit nhsiehgit left a comment

Choose a reason for hiding this comment

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

buncha nit comments!

{issues}
{projects}
</SidebarSection>
<SidebarWrapper>
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah i see
iiuc, we're using the SubnavContainer component here as the main panel? (then in the children determines, whether to render a secondary panel OR the accordion?)

Do we need this wrapper anymore then or can we move the styles here to the container/primary wrapper?

Also - wonder if we should rename the SubnavContainer to just be NavContainer 😅

)}
{hasOrganization && (
<SidebarSectionGroup hasNewNav={hasNewNav}>
{/* What are the onboarding sidebars? */}
Copy link
Contributor

Choose a reason for hiding this comment

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

oops - was this a comment i left?? 😅
can probably remove

const SidebarSectionGroup = styled('div')<{hasNewNav?: boolean}>`
${responsiveFlex};
flex-shrink: 0; /* prevents shrinking on Safari */
gap: 1px;
${p => p.hasNewNav && `align-items: center;`}
gap: 8px;
Copy link
Contributor

Choose a reason for hiding this comment

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

do we have any consts for this? maybe space(1) or something?

exact?: boolean
): boolean {
// issue subnav matches against issue groups in search params
if (location.pathname.startsWith('/issues/') && item?.to?.includes('/issues/')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this only be relevant for issues subnav?
Will we ever need to implement logic for other routes?

wondering about scalability and how we might structure this or break this out to be more composable 🤷

Comment on lines 25 to 32
useLayoutEffect(() => {
if (!containerRef.current) return;
if (containerRef.current.children.length === 0) {
document.body.dataset.navLevel = '1';
} else {
document.body.dataset.navLevel = '2';
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

heh
would there ever be a world where we have more layers than just 2?

organization: {...organization, features: ['navigation-sidebar-v2']},
});

expect(await screen.findByText('Issues')).toBeInTheDocument();
Copy link
Member

Choose a reason for hiding this comment

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

Should it be findByRole('link', {name: 'Issues'})? Or is it a button findByRole('button', {name: 'Issues'})

Copy link

codecov bot commented Sep 10, 2024

Bundle Report

Changes will increase total bundle size by 35.6kB (0.12%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
app-webpack-bundle-array-push 30.28MB 35.6kB ⬆️

Copy link
Member

Choose a reason for hiding this comment

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

The profiling flamechart might do something similar to this. I remember they had a full-screen view first then replay did something similar afterwards.
I'm not confident that old code survived or not, but that'd be a view to double-check.

@natemoo-re natemoo-re mentioned this pull request Sep 17, 2024
2 tasks
@natemoo-re
Copy link
Member Author

Closing in favor of #77665. The new PR should be much easier to review, since it introduces entirely new components for the navigation.

@natemoo-re natemoo-re closed this Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants