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

Project Side Navigation: Use EuiCollapsibleNavBeta component #164910

Merged
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
1dd5538
fix unused prop isOpen for app menu bar
tsullivan Aug 25, 2023
05f17d2
remove custom css additions
tsullivan Aug 25, 2023
2c72811
Use EuiCollapsibleNavBeta stories
tsullivan Aug 25, 2023
8af45c4
Fix recently accessed bucket
tsullivan Aug 25, 2023
05b592d
Add silly ts-expect-error
tsullivan Aug 25, 2023
a73bf8e
replace EuiCollapsibleNavGroup with EuiCollapsibleNavItem & EuiSideNa…
tsullivan Aug 25, 2023
fc4f32a
Replace EuiFlexGroups with EuiFlyoutBody & EuiFlyoutFooter
tsullivan Aug 25, 2023
d3ffd20
Remove empty root items from storybook
tsullivan Aug 25, 2023
2e0156c
Remove empty title parents from preset links
tsullivan Aug 25, 2023
17312a7
Remove empty groups from stories
tsullivan Aug 25, 2023
6e9cf28
Incorporate isGroupTitle
tsullivan Aug 26, 2023
cd48e35
remove close button wrappers in core chrome-browser
tsullivan Aug 26, 2023
44d6fa3
fix hierarchy of svl search project settings
tsullivan Aug 26, 2023
a9ecb12
fix hierarchy of observablility side nav
tsullivan Aug 26, 2023
824b2c0
Merge branch 'main' into serverless-chrome/use-EuiCollapsibleNavBeta
tsullivan Sep 14, 2023
c449de2
expose accordionProps and disable collapsing in main solution sections
tsullivan Sep 14, 2023
9ddf71b
track collapsed state in local storage
tsullivan Sep 15, 2023
a117c92
Merge remote-tracking branch 'elastic/main' into serverless-chrome/us…
tsullivan Sep 18, 2023
ab38910
Merge branch 'main' into serverless-chrome/use-EuiCollapsibleNavBeta
tsullivan Sep 19, 2023
879b29f
Completely hide the side bar in collapsed state
tsullivan Sep 19, 2023
1f95d3c
Remove renderItem support
tsullivan Sep 19, 2023
24dd860
Merge branch 'main' into serverless-chrome/use-EuiCollapsibleNavBeta
tsullivan Sep 20, 2023
aff25b1
fix warnings in test file
tsullivan Sep 20, 2023
575cdf4
fix unit tests
tsullivan Sep 20, 2023
39f175c
Add FIXME item for expanding active accordions
tsullivan Sep 20, 2023
314890f
fix more unit tests
tsullivan Sep 20, 2023
2dd2585
Merge branch 'main' into serverless-chrome/use-EuiCollapsibleNavBeta
tsullivan Sep 20, 2023
42f6b33
fix solutions group titles
tsullivan Sep 21, 2023
03888d6
fix more tests
tsullivan Sep 21, 2023
3e629b7
Merge branch 'main' into serverless-chrome/use-EuiCollapsibleNavBeta
tsullivan Sep 21, 2023
640361c
update storybooks to give an updating state example
tsullivan Sep 21, 2023
2ca3474
wip
tsullivan Sep 22, 2023
d5bb496
More storybook
tsullivan Sep 22, 2023
f3d8911
wip2
tsullivan Sep 22, 2023
8ba97ab
Updating state storybook
tsullivan Sep 22, 2023
011632d
cleanup
tsullivan Sep 22, 2023
9161c10
Merge branch 'main' into serverless-chrome/use-EuiCollapsibleNavBeta
tsullivan Sep 22, 2023
07a62ab
silence a minor TS error
tsullivan Sep 22, 2023
426b2ac
Merge branch 'main' into serverless-chrome/use-EuiCollapsibleNavBeta
tsullivan Sep 22, 2023
c608c2a
update navigation isSectionOpen ftr function
tsullivan Sep 22, 2023
2ba9ba3
temporary search nav tree fix for functional tests
tsullivan Sep 22, 2023
52f8596
Merge branch 'main' into serverless-chrome/use-EuiCollapsibleNavBeta
tsullivan Sep 22, 2023
ab1e040
Revert "temporary search nav tree fix for functional tests"
tsullivan Sep 23, 2023
d423cbf
Merge branch 'main' into serverless-chrome/use-EuiCollapsibleNavBeta
tsullivan Sep 23, 2023
99844c6
fix serverless search navigation tests
tsullivan Sep 25, 2023
4d4fe73
Merge branch 'main' into serverless-chrome/use-EuiCollapsibleNavBeta
tsullivan Sep 25, 2023
e9e8114
fix serverless search navigation tests
tsullivan Sep 25, 2023
d5f4d9e
temporarily remove ability to close accordions
tsullivan Sep 25, 2023
50716a3
fix EuiCollapsibleNav as button
tsullivan Sep 25, 2023
87b8965
Merge branch 'serverless-chrome/use-EuiCollapsibleNavBeta' of github.…
tsullivan Sep 26, 2023
59cdc95
Merge branch 'main' into serverless-chrome/use-EuiCollapsibleNavBeta
tsullivan Sep 26, 2023
1cbfce9
remove debug comments
tsullivan Sep 26, 2023
bb9684c
update navigation tree tests with .toBeVisible checks
tsullivan Sep 26, 2023
6adddb3
update ML default navigation to have no root parent for top-level items
tsullivan Sep 27, 2023
34f193f
Merge branch 'main' into serverless-chrome/use-EuiCollapsibleNavBeta
tsullivan Sep 27, 2023
68102bc
update snapshot
tsullivan Sep 27, 2023
f6b0195
Merge branch 'main' into serverless-chrome/use-EuiCollapsibleNavBeta
sebelga Sep 27, 2023
698cfc7
Merge branch 'main' into serverless-chrome/use-EuiCollapsibleNavBeta
tsullivan Sep 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import React from 'react';
import { HeaderActionMenu } from '../header/header_action_menu';

interface AppMenuBarProps {
isOpen: boolean;
headerActionMenuMounter: { mount: MountPoint<HTMLElement> | undefined };
}
export const AppMenuBar = ({ headerActionMenuMounter }: AppMenuBarProps) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import {
EuiHeaderLogo,
EuiHeaderSection,
EuiHeaderSectionItem,
EuiHeaderSectionItemButton,
EuiIcon,
EuiLoadingSpinner,
htmlIdGenerator,
useEuiTheme,
EuiThemeComputed,
} from '@elastic/eui';
Expand All @@ -35,8 +32,7 @@ import { MountPoint } from '@kbn/core-mount-utils-browser';
import { i18n } from '@kbn/i18n';
import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app';
import { Router } from '@kbn/shared-ux-router';
import React, { createRef, useCallback, useState } from 'react';
import useLocalStorage from 'react-use/lib/useLocalStorage';
import React, { useCallback } from 'react';
import useObservable from 'react-use/lib/useObservable';
import { debounceTime, Observable, of } from 'rxjs';
import { useHeaderActionMenuMounter } from '../header/header_action_menu';
Expand Down Expand Up @@ -66,13 +62,6 @@ const getHeaderCss = ({ size }: EuiThemeComputed) => ({
top: 2px;
`,
},
nav: {
toggleNavButton: css`
border-right: 1px solid #d3dae6;
margin-left: -1px;
padding-right: ${size.xs};
`,
},
});

type HeaderCss = ReturnType<typeof getHeaderCss>;
Expand Down Expand Up @@ -116,7 +105,6 @@ export interface Props {
prependBasePath: (url: string) => string;
}

const LOCAL_STORAGE_IS_OPEN_KEY = 'PROJECT_NAVIGATION_OPEN' as const;
const LOADING_DEBOUNCE_TIME = 80;

type LogoProps = Pick<Props, 'application' | 'homeHref$' | 'loadingCount$' | 'prependBasePath'> & {
Expand Down Expand Up @@ -179,9 +167,6 @@ export const ProjectHeader = ({
docLinks,
...observables
}: Props) => {
const [navId] = useState(htmlIdGenerator()());
const [isOpen, setIsOpen] = useLocalStorage(LOCAL_STORAGE_IS_OPEN_KEY, true);
cee-chen marked this conversation as resolved.
Show resolved Hide resolved
const toggleCollapsibleNavRef = createRef<HTMLButtonElement & { euiAnimate: () => void }>();
const headerActionMenuMounter = useHeaderActionMenuMounter(observables.actionMenu$);
const projectsUrl = useObservable(observables.projectsUrl$);
const { euiTheme } = useEuiTheme();
Expand All @@ -202,34 +187,9 @@ export const ProjectHeader = ({
<div id="globalHeaderBars" data-test-subj="headerGlobalNav" className="header__bars">
<EuiHeader position="fixed" className="header__firstBar">
<EuiHeaderSection grow={false}>
<EuiHeaderSectionItem css={headerCss.nav.toggleNavButton}>
<Router history={application.history}>
<ProjectNavigation
isOpen={isOpen!}
closeNav={() => {
setIsOpen(false);
if (toggleCollapsibleNavRef.current) {
toggleCollapsibleNavRef.current.focus();
}
}}
button={
<EuiHeaderSectionItemButton
data-test-subj="toggleNavButton"
aria-label={headerStrings.nav.closeNavAriaLabel}
onClick={() => setIsOpen(!isOpen)}
aria-expanded={isOpen!}
aria-pressed={isOpen!}
aria-controls={navId}
ref={toggleCollapsibleNavRef}
>
<EuiIcon type={isOpen ? 'menuLeft' : 'menuRight'} size="m" />
</EuiHeaderSectionItemButton>
}
>
{children}
</ProjectNavigation>
</Router>
</EuiHeaderSectionItem>
<Router history={application.history}>
<ProjectNavigation>{children}</ProjectNavigation>
</Router>

<EuiHeaderSectionItem>
<Logo
Expand Down Expand Up @@ -285,7 +245,7 @@ export const ProjectHeader = ({
</header>

{headerActionMenuMounter.mount && (
<AppMenuBar isOpen={isOpen ?? false} headerActionMenuMounter={headerActionMenuMounter} />
<AppMenuBar headerActionMenuMounter={headerActionMenuMounter} />
)}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,16 @@
*/

import React from 'react';
import { css } from '@emotion/react';
import { EuiCollapsibleNav, EuiCollapsibleNavProps } from '@elastic/eui';

const SIZE_EXPANDED = 248;
const SIZE_COLLAPSED = 0;

export interface ProjectNavigationProps {
isOpen: boolean;
closeNav: () => void;
button: EuiCollapsibleNavProps['button'];
}

export const ProjectNavigation: React.FC<ProjectNavigationProps> = ({
children,
isOpen,
closeNav,
button,
}) => {
const collabsibleNavCSS = css`
border-inline-end-width: 1,
display: flex,
flex-direction: row,
`;

const DOCKED_BREAKPOINT = 's' as const;
const isVisible = isOpen;
import { EuiCollapsibleNavBeta } from '@elastic/eui';

export const ProjectNavigation: React.FC = ({ children }) => {
return (
<>
{
/* must render the tree to initialize the navigation, even if it shouldn't be visible */
!isOpen && <div hidden>{children}</div>
/* must render the tree to initialize the navigation, even if hidden internally in EUI */
<div hidden>{children}</div>
tsullivan marked this conversation as resolved.
Show resolved Hide resolved
}
<EuiCollapsibleNav
className="projectLayoutSideNav"
css={collabsibleNavCSS}
isOpen={isVisible /* only affects docked state */}
showButtonIfDocked={true}
onClose={closeNav}
isDocked={true}
size={isVisible ? SIZE_EXPANDED : SIZE_COLLAPSED}
hideCloseButton={false}
dockedBreakpoint={DOCKED_BREAKPOINT}
ownFocus={false}
button={button}
>
{isOpen && children}
</EuiCollapsibleNav>
<EuiCollapsibleNavBeta>{children}</EuiCollapsibleNavBeta>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export interface ChromeProjectNavigationNode {
deepLink?: ChromeNavLink;
/** Optional icon for the navigation node. Note: not all navigation depth will render the icon */
icon?: string;
/** Optional flag to indicate if the node must be treated as a group title */
isGroupTitle?: boolean;
/** Optional children of the navigation node */
children?: ChromeProjectNavigationNode[];
/**
Expand Down Expand Up @@ -139,6 +141,8 @@ export interface NodeDefinition<
cloudLink?: CloudLinkId;
/** Optional icon for the navigation node. Note: not all navigation depth will render the icon */
icon?: string;
/** Optional flag to indicate if the node must be treated as a group title */
isGroupTitle?: boolean;
/** Optional children of the navigation node */
children?: NonEmptyArray<NodeDefinition<LinkId, Id, ChildrenId>>;
/**
Expand Down
19 changes: 7 additions & 12 deletions packages/default-nav/analytics/default_navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,13 @@ export const defaultNavigation: AnalyticsNodeDefinition = {
icon: 'stats',
children: [
{
id: 'root',
children: [
{
link: 'discover',
},
{
link: 'dashboards',
},
{
link: 'visualize',
},
],
link: 'discover',
},
{
link: 'dashboards',
},
{
link: 'visualize',
},
],
};
25 changes: 10 additions & 15 deletions packages/default-nav/devtools/default_navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,16 @@ export const defaultNavigation: DevToolsNodeDefinition = {
icon: 'editorCodeBlock',
children: [
{
id: 'root',
children: [
{
link: 'dev_tools:console',
},
{
link: 'dev_tools:searchprofiler',
},
{
link: 'dev_tools:grokdebugger',
},
{
link: 'dev_tools:painless_lab',
},
],
link: 'dev_tools:console',
},
{
link: 'dev_tools:searchprofiler',
},
{
link: 'dev_tools:grokdebugger',
},
{
link: 'dev_tools:painless_lab',
},
],
};
8 changes: 1 addition & 7 deletions packages/default-nav/management/default_navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@ export const defaultNavigation: ManagementNodeDefinition = {
icon: 'gear',
children: [
{
id: 'root',
title: '',
children: [
{
link: 'monitoring',
},
],
link: 'monitoring',
},
{
id: 'integration_management',
Expand Down
Loading