Skip to content

Commit

Permalink
[Web] Add resource kind-specific sidenav sections (#47882)
Browse files Browse the repository at this point in the history
* add resource kind-specific nav sections

* update eref
  • Loading branch information
rudream committed Oct 28, 2024
1 parent a168d92 commit 06f6dbd
Show file tree
Hide file tree
Showing 10 changed files with 439 additions and 28 deletions.
2 changes: 1 addition & 1 deletion e
Submodule e updated from 7e4638 to 03e3eb
24 changes: 22 additions & 2 deletions web/packages/teleport/src/Navigation/SideNavigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ import {
import { zIndexMap } from './zIndexMap';

import {
CustomNavigationSubcategory,
NAVIGATION_CATEGORIES,
STANDALONE_CATEGORIES,
SidenavCategory,
} from './categories';
import { SearchSection } from './Search';
import { ResourcesSection } from './ResourcesSection';

import type * as history from 'history';
import type { TeleportFeature } from 'teleport/types';
Expand Down Expand Up @@ -86,6 +87,20 @@ export type NavigationSubsection = {
icon: (props) => JSX.Element;
parent?: TeleportFeature;
searchableTags?: string[];
/**
* customRouteMatchFn is a custom function for determining whether this subsection is currently active,
* this is useful in cases where a simple base route match isn't sufficient.
*/
customRouteMatchFn?: (currentViewRoute: string) => boolean;
/**
* subCategory is the subcategory (ie. subsection grouping) this subsection should be under, if applicable.
* */
subCategory?: CustomNavigationSubcategory;
/**
* onClick is custom code that can be run when clicking on the subsection.
* Note that this is merely extra logic, and does not replace the default routing behaviour of a subsection which will navigate the user to the route.
*/
onClick?: () => void;
};

function getNavigationSections(
Expand All @@ -94,7 +109,6 @@ function getNavigationSections(
const navigationSections = NAVIGATION_CATEGORIES.map(category => ({
category,
subsections: getSubsectionsForCategory(category, features),
standalone: STANDALONE_CATEGORIES.indexOf(category) !== -1,
}));

return navigationSections;
Expand Down Expand Up @@ -292,6 +306,12 @@ export function Navigation() {
handleSetExpandedSection={handleSetExpandedSection}
currentView={currentView}
/>
<ResourcesSection
expandedSection={debouncedSection}
previousExpandedSection={previousExpandedSection}
handleSetExpandedSection={handleSetExpandedSection}
currentView={currentView}
/>
{navSections.map(section => (
<React.Fragment key={section.category}>
{section.category === 'Add New' && <Divider />}
Expand Down
Loading

0 comments on commit 06f6dbd

Please sign in to comment.