TopNav: Make it possible to to have sections without children (#57815)

This commit is contained in:
Torkel Ödegaard 2022-10-31 11:01:34 +01:00 committed by GitHub
parent 656f159ae9
commit 19b961465c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 1 deletions

View File

@ -19,6 +19,10 @@ export interface NavLinkDTO {
hideFromTabs?: boolean;
showIconInNavbar?: boolean;
roundIcon?: boolean;
/**
* This is true for some sections that have no children (but is still a section)
**/
isSection?: boolean;
children?: NavLinkDTO[];
highlightText?: string;
emptyMessageId?: string;

View File

@ -62,6 +62,7 @@ type NavLink struct {
HideFromTabs bool `json:"hideFromTabs,omitempty"`
ShowIconInNavbar bool `json:"showIconInNavbar,omitempty"`
RoundIcon bool `json:"roundIcon,omitempty"`
IsSection bool `json:"isSection,omitempty"`
Children []*NavLink `json:"children,omitempty"`
HighlightText string `json:"highlightText,omitempty"`
HighlightID string `json:"highlightId,omitempty"`

View File

@ -71,6 +71,7 @@ func (s *ServiceImpl) processAppPlugin(plugin plugins.PluginDTO, c *models.ReqCo
Img: plugin.Info.Logos.Small,
Section: navtree.NavSectionPlugin,
SortWeight: navtree.WeightPlugin,
IsSection: true,
}
if topNavEnabled {

View File

@ -24,7 +24,7 @@ export function SectionNavItem({ item, isSectionRoot = false }: Props) {
const linkClass = cx({
[styles.link]: true,
[styles.activeStyle]: item.active,
[styles.isSection]: Boolean(children?.length),
[styles.isSection]: Boolean(children?.length) || item.isSection,
[styles.hasActiveChild]: hasActiveChild,
[styles.isSectionRoot]: isSectionRoot,
[styles.noRootMargin]: noRootMargin,