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

Allow screenTitle to be present when SearchBar is not in Application header #7721

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions changelogs/fragments/7721.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- Allow `screenTitle` to be present when SearchBar is not in Application header ([#7721](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7721))
6 changes: 6 additions & 0 deletions src/plugins/navigation/public/top_nav_menu/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,9 @@
text-overflow: ellipsis;
}
}

// stylelint-disable-next-line @osd/stylelint/no_modifying_global_selectors
.osdTopNavMenuSpread .euiHeaderLinks__list {
width: 100%;
justify-content: space-between;
}
26 changes: 18 additions & 8 deletions src/plugins/navigation/public/top_nav_menu/top_nav_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,14 @@ export function TopNavMenu(props: TopNavMenuProps): ReactElement | null {
);
}

function renderMenu(className: string): ReactElement | null {
function renderMenu(className: string, spreadSections: boolean = false): ReactElement | null {
if ((!config || config.length === 0) && (!showDataSourceMenu || !dataSourceMenuConfig))
return null;

const menuClassName = classNames(className, { osdTopNavMenuSpread: spreadSections });

return (
<EuiHeaderLinks data-test-subj="top-nav" gutterSize="xs" className={className}>
<EuiHeaderLinks data-test-subj="top-nav" gutterSize="xs" className={menuClassName}>
{renderItems()}
{renderDataSourceMenu()}
</EuiHeaderLinks>
Expand Down Expand Up @@ -182,12 +185,19 @@ export function TopNavMenu(props: TopNavMenuProps): ReactElement | null {

case false:
case TopNavMenuItemRenderType.OMITTED:
return (
<>
<MountPointPortal setMountPoint={setMenuMountPoint}>
{renderMenu(menuClassName)}
</MountPointPortal>
</>
return screenTitle ? (
<MountPointPortal setMountPoint={setMenuMountPoint}>
<EuiFlexGroup alignItems="stretch" gutterSize="s">
<EuiFlexItem grow={false} className="osdTopNavMenuScreenTitle">
<EuiText size="s">{screenTitle}</EuiText>
</EuiFlexItem>
<EuiFlexItem>{renderMenu(menuClassName, true)}</EuiFlexItem>
</EuiFlexGroup>
</MountPointPortal>
) : (
<MountPointPortal setMountPoint={setMenuMountPoint}>
{renderMenu(menuClassName)}
</MountPointPortal>
);

// Show the SearchBar in-place
Expand Down
Loading