-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Navigation: New NavBar designs behind feature toggle #41045
Conversation
if (newNavigationEnabled) { | ||
return !item.hideFromMenu && !item.id?.startsWith('plugin-page-'); | ||
} |
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.
Is this something we can control in the backend instead?
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.
className?: string; | ||
} | ||
|
||
const NavBarSection = ({ children, className }: Props) => { |
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.
nit: we prefer function({...} : Props): ReactElement over const
); | ||
}; | ||
|
||
export default NavBarSection; |
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.
nit: we prefer export const NavBarSection over export defaults.
@@ -9,10 +14,69 @@ export const getForcedLoginUrl = (url: string) => { | |||
return `${getConfig().appSubUrl}${url.split('?')[0]}?${queryParams.toString()}`; | |||
}; | |||
|
|||
export const enrichConfigItems = ( |
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 function seems testable?
@hugohaggmark for the logo, good eyes 👀 now that it's a |
Because we use a feature toggle, things without the toggle should remain the same. |
visually this feels very complex to me all these separate sections and borders (where the navbar is not at the edge but actually lives 8px from the left edge) |
mmm that's fair feedback, fyi @lukasztyrala i think it still needs some usability testing so it's probably not the final design. that's the beauty of the toggle, we can iterate 😄 how do you feel about the functional changes @torkelo? |
But I think it sort of works as well (the left padding), but I am not sure separating the sections that much is helpful, we also want app plugins to feels like any other core Grafana feature |
We are putting this behind a feature flag to test with people. We want to validate some assumptions and directions. This is not final by any means/dimensions. :-) |
7f2928e
to
1909622
Compare
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.
Frontend code looks great and thanks for adding tests. Added some comments and would be good if someone in @grafana/backend-platform could review the backend parts too.
Id: "profile", | ||
Img: gravatarURL, | ||
Url: hs.Cfg.AppSubURL + "/profile", | ||
HideFromMenu: true, |
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.
nit: HideFromMenu
removed here, probably ok?
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.
yeah, now we've added the Section
property to the struct, this HideFromMenu
becomes redundant and a little confusing (since at the top level it never hid anything from the menu, it was used to control what appeared in TopSection
/BottomSection
).
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.
So when the feature toggle is the new "default" we need to revisit this and deprecate/remove HideFromMenu
.
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.
yeah, we probably need to separate out NavLink
and create NavLinkChild
or something. for NavLinkChild
it makes sense and behaves as expected. for a top level NavLink
it was kinda being repurposed
@@ -23,7 +89,7 @@ export const isLinkActive = (pathname: string, link: NavModelItem) => { | |||
// alert channel match | |||
// TODO refactor routes such that we don't need this custom logic | |||
return true; | |||
} else if (linkPathname === '/' && pathname.startsWith('/d/')) { | |||
} else if (linkPathname === dashboardLinkMatch && pathname.startsWith('/d/')) { |
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.
Any tests that need updating?
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.
there weren't, but that was a little concerning tbh so i've added some more tests 😄
|
||
{!newNavigationEnabled && ( | ||
<NavBarSection> | ||
<NavBarItem url={homeUrl} label="Home" className={styles.grafanaLogo} showMenu={false}> | ||
<Branding.MenuLogo /> | ||
</NavBarItem> | ||
<NavBarItem | ||
className={styles.search} | ||
isActive={activeItemId === 'search'} | ||
label="Search dashboards" | ||
onClick={onOpenSearch} | ||
> | ||
<Icon name="search" size="xl" /> | ||
</NavBarItem> | ||
</NavBarSection> | ||
)} | ||
{newNavigationEnabled && ( | ||
<NavBarSection> | ||
<NavBarItem url={homeUrl} label="Home" className={styles.grafanaLogo} showMenu={false}> | ||
<Branding.MenuLogo /> | ||
</NavBarItem> | ||
<NavBarItem | ||
className={styles.search} | ||
isActive={activeItemId === 'search'} | ||
label="Search dashboards" | ||
onClick={onOpenSearch} | ||
> | ||
<Icon name="search" size="xl" /> | ||
</NavBarItem> | ||
</NavBarSection> | ||
)} | ||
|
||
<NavBarSection> | ||
{coreItems.map((link, index) => ( | ||
<NavBarItem | ||
key={`${link.id}-${index}`} | ||
isActive={activeItemId === link.id} | ||
label={link.text} | ||
menuItems={link.children} | ||
target={link.target} | ||
url={link.url} | ||
> | ||
{link.icon && <Icon name={link.icon as IconName} size="xl" />} | ||
{link.img && <img src={link.img} alt={`${link.text} logo`} />} | ||
</NavBarItem> | ||
))} | ||
</NavBarSection> | ||
|
||
{pluginItems.length > 0 && ( | ||
<NavBarSection> | ||
{pluginItems.map((link, index) => ( | ||
<NavBarItem | ||
key={`${link.id}-${index}`} | ||
isActive={activeItemId === link.id} | ||
label={link.text} | ||
menuItems={link.children} | ||
menuSubTitle={newNavigationEnabled ? link.subTitle : undefined} | ||
onClick={link.onClick} | ||
target={link.target} | ||
url={link.url} | ||
> | ||
{link.icon && <Icon name={link.icon as IconName} size="xl" />} | ||
{link.img && <img src={link.img} alt={`${link.text} logo`} />} | ||
</NavBarItem> | ||
))} | ||
</NavBarSection> | ||
)} | ||
|
||
<div className={styles.spacer} /> | ||
|
||
<NavBarSection> | ||
{configItems.map((link, index) => ( | ||
<NavBarItem | ||
key={`${link.id}-${index}`} | ||
isActive={activeItemId === link.id} | ||
label={link.text} | ||
menuItems={link.children} | ||
menuSubTitle={link.subTitle} | ||
onClick={link.onClick} | ||
reverseMenuDirection | ||
target={link.target} | ||
url={link.url} | ||
> | ||
{link.icon && <Icon name={link.icon as IconName} size="xl" />} | ||
{link.img && <img src={link.img} alt={`${link.text} logo`} />} | ||
</NavBarItem> | ||
))} | ||
</NavBarSection> | ||
|
||
{showSwitcherModal && <OrgSwitcher onDismiss={toggleSwitcherModal} />} |
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.
nit: I think I would create 2 separate NavBar components one for the current and one for the feature toggle. I think that makes it a lot cleaner.
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.
Agree with this one.
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.
Looks really great! Exiting stuff.
Question: what is the long-term plan for the navModel? Something we can get rid of/enhance in Grafana 9?
great question @mckn, it's part of what we're trying to tackle with the configurable nav bar proposals that are sort of bubbling in the background right now.
would love any input/suggestions you have on that. think it's fair to say it's the part we're struggling the most on right now. |
* Navigation: Remove plus button behind feature toggle * Navigation: Add home button behind feature toggle * Navigation: Move settings/admin to bottom section behind feature toggle * Navigation: Refactor grafana logo to be a NavBarItem * Navigation: Create new PluginSection and styling changes to support new sections * Navigation: Hack to use mobile menu as a mega menu for now * Navigation: Only render plugin section if there are items * Navigation: mobile menu is always 100% width if toggle is off * Navigation: Reset width back to 48 and fix broken css property * Navigation: Create generic NavBarSection component to reduce repetition * Navigation: Don't show sublinks for core items * Navigation: Comments from UX review * Navigation: Remove mobile menu hack * Navigation: Unit tests for enrichConfigItems and other minor review comments * Navigation: Move section logic to backend * Navigation: Refactor alerting links out into a separate function * Navigation: More tests for isLinkActive * Linting... * Navigation: Create new NavBar component for when feature toggle is enabled
What this PR does / why we need it:
implements the new NavBar designs behind the
newNavigation
feature toggle. changes:Home
link from the dashboard menu and adds it as a standalone item in the NavBar+
button from the NavBar and adds the actions to the dashboard menuServer Admin
+Configuration
to the config/settings (bottom) sectionNavBarItem
, same as everything elseNavBarSection
component and removed the existingTopSection
/BottomSection
in favour of thisBottomSection
into a util functionenrichConfigItems
BottomSection
/TopSection
respectively)Which issue(s) this PR fixes:
For #37961
Special notes for your reviewer: