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

[navigation-next]fix: breadcrumb issue found in data source management and other similar cases. #7401

Merged
Prev Previous commit
Next Next commit
feat: hide expand icon in left navigation
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
  • Loading branch information
SuZhou-Joe committed Jul 24, 2024
commit 942e2aa2d006b8284fb662d7e7c7ee39070df7d5
148 changes: 148 additions & 0 deletions src/core/public/chrome/ui/header/__snapshots__/header.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions src/core/public/chrome/ui/header/header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,22 @@ describe('Header', () => {

expect(component.find('CollapsibleNavGroupEnabled').exists()).toBeTruthy();
});

it('show hide expand icon in top left navigation when workspace enabled + homepage + new navigation enabled', () => {
const branding = {
useExpandedHeader: false,
};
const props = {
...mockProps(),
branding,
};
props.application.currentAppId$ = new BehaviorSubject('home');
props.application.capabilities = { ...props.application.capabilities };
(props.application.capabilities.workspaces as Record<string, unknown>) = {};
(props.application.capabilities.workspaces as Record<string, unknown>).enabled = true;

const component = mountWithIntl(<Header {...props} navGroupEnabled />);

expect(component.find('.header__toggleNavButtonSection').exists()).toBeFalsy();
});
});
54 changes: 32 additions & 22 deletions src/core/public/chrome/ui/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,17 @@ export function Header({
}: HeaderProps) {
const isVisible = useObservable(observables.isVisible$, false);
const isLocked = useObservable(observables.isLocked$, false);
const appId = useObservable(application.currentAppId$, '');
const [isNavOpen, setIsNavOpen] = useState(false);
const sidecarConfig = useObservable(observables.sidecarConfig$, undefined);

/**
* This is a workaround on 2.16 to hide the navigation items within left navigation
* when user is in homepage with workspace enabled + new navigation enabled
*/
const shouldHideExpandIcon =
navGroupEnabled && appId === 'home' && application.capabilities.workspaces.enabled;

const sidecarPaddingStyle = useMemo(() => {
return getOsdSidecarPaddingStyle(sidecarConfig);
}, [sidecarConfig]);
Expand Down Expand Up @@ -198,29 +206,31 @@ export function Header({

<EuiHeader position="fixed" className="primaryHeader" style={sidecarPaddingStyle}>
<EuiHeaderSection grow={false}>
<EuiHeaderSectionItem border="right" className="header__toggleNavButtonSection">
<EuiToolTip
content={i18n.translate('core.ui.primaryNav.menu', {
defaultMessage: 'Menu',
})}
delay="long"
position="bottom"
>
<EuiHeaderSectionItemButton
data-test-subj="toggleNavButton"
aria-label={i18n.translate('core.ui.primaryNav.toggleNavAriaLabel', {
defaultMessage: 'Toggle primary navigation',
{shouldHideExpandIcon ? null : (
<EuiHeaderSectionItem border="right" className="header__toggleNavButtonSection">
<EuiToolTip
content={i18n.translate('core.ui.primaryNav.menu', {
defaultMessage: 'Menu',
})}
onClick={() => setIsNavOpen(!isNavOpen)}
aria-expanded={isNavOpen}
aria-pressed={isNavOpen}
aria-controls={navId}
ref={toggleCollapsibleNavRef}
delay="long"
position="bottom"
>
<EuiIcon type="menu" size="m" />
</EuiHeaderSectionItemButton>
</EuiToolTip>
</EuiHeaderSectionItem>
<EuiHeaderSectionItemButton
data-test-subj="toggleNavButton"
aria-label={i18n.translate('core.ui.primaryNav.toggleNavAriaLabel', {
defaultMessage: 'Toggle primary navigation',
})}
onClick={() => setIsNavOpen(!isNavOpen)}
aria-expanded={isNavOpen}
aria-pressed={isNavOpen}
aria-controls={navId}
ref={toggleCollapsibleNavRef}
>
<EuiIcon type="menu" size="m" />
</EuiHeaderSectionItemButton>
</EuiToolTip>
</EuiHeaderSectionItem>
)}

<EuiHeaderSectionItem border="right">
<HeaderNavControls side="left" navControls$={observables.navControlsLeft$} />
Expand Down Expand Up @@ -293,7 +303,7 @@ export function Header({
id={navId}
isLocked={isLocked}
navLinks$={observables.navLinks$}
isNavOpen={isNavOpen}
isNavOpen={shouldHideExpandIcon ? false : isNavOpen}
basePath={basePath}
navigateToApp={application.navigateToApp}
navigateToUrl={application.navigateToUrl}
Expand Down
Loading