Skip to content

Commit

Permalink
Allow screenTitle to be present when SearchBar is not in Applicatio…
Browse files Browse the repository at this point in the history
…n header (#7721) (#7722)

* Allow `screenTitle` to be present when SearchBar is not



* Changeset file for PR #7721 created/updated

---------



(cherry picked from commit 577b3ec)

Signed-off-by: Miki <miki@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Aug 19, 2024
1 parent 4a7375b commit 12bc633
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
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

0 comments on commit 12bc633

Please sign in to comment.