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
…7886)

(cherry picked from commit 6e0a632)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Aug 29, 2024
1 parent 3c5a506 commit 78259f0
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 8 deletions.

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

5 changes: 4 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 Expand Up @@ -105,3 +104,7 @@
.stretchedActionMenu {
width: 100%;
}

#globalHeaderBars {
border-bottom: 1px solid $euiColorLightShade;
}
1 change: 1 addition & 0 deletions src/core/public/chrome/ui/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ export function Header({
</EuiHeaderSection>
<EuiHeaderSection side="right">{renderRightControls()}</EuiHeaderSection>
</EuiHeader>
<div id="applicationHeaderFilterBar" />
</div>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
}

.globalFilterGroup__filterPrefix {
padding-top: $euiSizeS;
padding-right: $euiSizeS;
padding: $euiSizeM $euiSizeS 0 $euiSizeS;
}

.globalFilterGroup {
&--compressed {
margin-top: -$euiSizeS;
}
}
15 changes: 11 additions & 4 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;
isFilterBarPortable?: boolean;
}

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

const classes = classNames('globalFilterBar', props.className);
const filterBarPrefixText = i18n.translate('data.search.filterBar.filterBarPrefixText', {
defaultMessage: 'Filters: ',
defaultMessage: 'Filters',
});
const filterGroupClassName = classNames('globalFilterGroup', {
'globalFilterGroup--compressed': useNewHeader && props.isFilterBarPortable,
});

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

<EuiFlexItem className="globalFilterGroup__filterFlexItem">
<EuiFlexGroup
className={classes}
Expand All @@ -210,6 +214,9 @@ function FilterBarUI(props: Props) {
</EuiFlexItem>
</EuiFlexGroup>
);
return useNewHeader && props.isFilterBarPortable
? 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}
isFilterBarPortable={props.isFilterBarPortable}
{...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;
isFilterBarPortable?: 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!}
isFilterBarPortable={this.props.isFilterBarPortable}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export function TopNavMenu(props: TopNavMenuProps): ReactElement | null {
<EuiText size="s">{screenTitle}</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>{renderMenu(menuClassName)}</EuiFlexItem>
<EuiFlexItem>{renderSearchBar()}</EuiFlexItem>
<EuiFlexItem>{renderSearchBar({ isFilterBarPortable: true })}</EuiFlexItem>
</EuiFlexGroup>
</MountPointPortal>
</>
Expand Down

0 comments on commit 78259f0

Please sign in to comment.