Skip to content

Commit

Permalink
[Page Header]Render filter bar in full width with application header
Browse files Browse the repository at this point in the history
Signed-off-by: Zhongnan Su <[email protected]>
  • Loading branch information
zhongnansu committed Aug 28, 2024
1 parent 5e0ce2b commit d229335
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/core/public/chrome/ui/header/header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

&.primaryApplicationHeader {
padding-top: $euiSizeM - $euiSizeXS;
border-bottom: 1px solid $euiColorLightShade;

&:last-child {
margin-bottom: 0;
Expand Down
3 changes: 3 additions & 0 deletions src/core/public/chrome/ui/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
EuiHeaderSectionItem,
EuiHeaderSectionItemButton,
EuiHideFor,
EuiHorizontalRule,
EuiIcon,
EuiShowFor,
EuiTitle,
Expand Down Expand Up @@ -447,6 +448,8 @@ export function Header({
</EuiHeaderSection>
<EuiHeaderSection side="right">{renderRightControls()}</EuiHeaderSection>
</EuiHeader>
<div id="applicationHeaderFilterBar" />
<EuiHorizontalRule margin="none" />
</div>
);

Expand Down
10 changes: 7 additions & 3 deletions src/plugins/data/public/ui/filter_bar/filter_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
import { FormattedMessage, InjectedIntl, injectI18n } from '@osd/i18n/react';
import classNames from 'classnames';
import React, { useState } from 'react';
import { createPortal } from 'react-dom';
import { stringify } from '@osd/std';

import { FilterEditor } from './filter_editor';
Expand All @@ -55,6 +56,7 @@ interface Props {
className: string;
indexPatterns: IIndexPattern[];
intl: InjectedIntl;
fixFilterBar?: boolean;
}

const maxFilterWidth = 600;
Expand Down Expand Up @@ -171,10 +173,10 @@ function FilterBarUI(props: Props) {

const classes = classNames('globalFilterBar', props.className);
const filterBarPrefixText = i18n.translate('data.search.filterBar.filterBarPrefixText', {
defaultMessage: 'Filters: ',
defaultMessage: 'Filters',
});

return (
const filterBar = (
<EuiFlexGroup
className="globalFilterGroup"
gutterSize="none"
Expand All @@ -195,7 +197,6 @@ function FilterBarUI(props: Props) {
/>
)}
</EuiFlexItem>

<EuiFlexItem className="globalFilterGroup__filterFlexItem">
<EuiFlexGroup
className={classes}
Expand All @@ -210,6 +211,9 @@ function FilterBarUI(props: Props) {
</EuiFlexItem>
</EuiFlexGroup>
);
return useNewHeader && !props.fixFilterBar
? createPortal(filterBar, document.getElementById('applicationHeaderFilterBar')!)
: filterBar;
}

export const FilterBar = injectI18n(FilterBarUI);
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ export function createSearchBar({ core, storage, data }: StatefulSearchBarDeps)
onSavedQueryUpdated={defaultOnSavedQueryUpdated(props, setSavedQuery)}
onSaved={defaultOnSavedQueryUpdated(props, setSavedQuery)}
datePickerRef={props.datePickerRef}
fixFilterBar={props.fixFilterBar}
{...overrideDefaultBehaviors(props)}
/>
</OpenSearchDashboardsContextProvider>
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/data/public/ui/search_bar/search_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface SearchBarOwnProps {
showQueryBar?: boolean;
showQueryInput?: boolean;
showFilterBar?: boolean;
fixFilterBar?: boolean;
showDatePicker?: boolean;
showAutoRefreshOnly?: boolean;
filters?: Filter[];
Expand Down Expand Up @@ -479,6 +480,7 @@ class SearchBarUI extends Component<SearchBarProps, State> {
filters={this.props.filters!}
onFiltersUpdated={this.props.onFiltersUpdated}
indexPatterns={this.props.indexPatterns!}
fixFilterBar={this.props.fixFilterBar}
/>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/navigation/public/top_nav_menu/top_nav_menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export function TopNavMenu(props: TopNavMenuProps): ReactElement | null {
</EuiFlexItem>
</EuiFlexGroup>
</MountPointPortal>
{renderSearchBar({ datePickerRef })}
{renderSearchBar({ datePickerRef, fixFilterBar: true })}
</>
);
}
Expand All @@ -226,7 +226,7 @@ export function TopNavMenu(props: TopNavMenuProps): ReactElement | null {
<MountPointPortal setMountPoint={setMenuMountPoint}>
{renderMenu(menuClassName)}
</MountPointPortal>
{renderSearchBar()}
{renderSearchBar({ fixFilterBar: true })}
</>
);
}
Expand All @@ -238,15 +238,15 @@ export function TopNavMenu(props: TopNavMenuProps): ReactElement | null {
<MountPointPortal setMountPoint={setMenuMountPoint}>
{renderMenu(menuClassName)}
</MountPointPortal>
{renderSearchBar()}
{renderSearchBar({ fixFilterBar: true })}
</>
);
}

return (
<>
{renderMenu(menuClassName)}
{renderSearchBar()}
{renderSearchBar({ fixFilterBar: true })}
</>
);
}
Expand Down

0 comments on commit d229335

Please sign in to comment.