From 811a83b67d9464de57945fd2dd36ab0604e475f3 Mon Sep 17 00:00:00 2001 From: Gal Angel Date: Tue, 20 Jul 2021 20:33:10 +0300 Subject: [PATCH] [1.x] Increase filters popover size and use full width in form components * use full width * Update width * observer Backport PR: https://github.com/opensearch-project/OpenSearch-Dashboards/pull/352 Signed-off-by: galangel --- .../data/public/ui/filter_bar/_index.scss | 1 - .../data/public/ui/filter_bar/filter_bar.tsx | 41 +++++++++++++------ .../filter_editor/_filter_editor.scss | 3 -- .../ui/filter_bar/filter_editor/_index.scss | 1 - .../ui/filter_bar/filter_editor/index.tsx | 4 ++ .../filter_editor/phrase_value_input.tsx | 3 ++ .../filter_editor/phrases_values_input.tsx | 2 + .../filter_editor/range_value_input.tsx | 1 + .../filter_editor/value_input_type.tsx | 6 +++ .../data/public/ui/filter_bar/filter_item.tsx | 2 +- 10 files changed, 46 insertions(+), 18 deletions(-) delete mode 100644 src/plugins/data/public/ui/filter_bar/filter_editor/_filter_editor.scss delete mode 100644 src/plugins/data/public/ui/filter_bar/filter_editor/_index.scss diff --git a/src/plugins/data/public/ui/filter_bar/_index.scss b/src/plugins/data/public/ui/filter_bar/_index.scss index 9e2478cb0704..5333aff8b87d 100644 --- a/src/plugins/data/public/ui/filter_bar/_index.scss +++ b/src/plugins/data/public/ui/filter_bar/_index.scss @@ -1,4 +1,3 @@ @import 'variables'; @import 'global_filter_group'; @import 'global_filter_item'; -@import 'filter_editor/index'; diff --git a/src/plugins/data/public/ui/filter_bar/filter_bar.tsx b/src/plugins/data/public/ui/filter_bar/filter_bar.tsx index e78224bce343..1ecea0442f81 100644 --- a/src/plugins/data/public/ui/filter_bar/filter_bar.tsx +++ b/src/plugins/data/public/ui/filter_bar/filter_bar.tsx @@ -30,7 +30,13 @@ * GitHub history for details. */ -import { EuiButtonEmpty, EuiFlexGroup, EuiFlexItem, EuiPopover } from '@elastic/eui'; +import { + EuiButtonEmpty, + EuiFlexGroup, + EuiFlexItem, + EuiPopover, + EuiResizeObserver, +} from '@elastic/eui'; import { FormattedMessage, InjectedIntl, injectI18n } from '@osd/i18n/react'; import classNames from 'classnames'; import React, { useState } from 'react'; @@ -60,9 +66,12 @@ interface Props { intl: InjectedIntl; } +const maxFilterWidth = 600; + function FilterBarUI(props: Props) { const [isAddFilterPopoverOpen, setIsAddFilterPopoverOpen] = useState(false); const opensearchDashboards = useOpenSearchDashboards(); + const [filterWidth, setFilterWidth] = useState(maxFilterWidth); const uiSettings = opensearchDashboards.services.uiSettings; if (!uiSettings) return null; @@ -89,6 +98,10 @@ function FilterBarUI(props: Props) { )); } + function onResize(dimensions: { height: number; width: number }) { + setFilterWidth(dimensions.width); + } + function renderAddFilter() { const isPinned = uiSettings!.get(UI_SETTINGS.FILTERS_PINNED_BY_DEFAULT); const [indexPattern] = props.indexPatterns; @@ -124,17 +137,21 @@ function FilterBarUI(props: Props) { initialFocus=".globalFilterEditor__fieldInput input" repositionOnScroll > - -
- setIsAddFilterPopoverOpen(false)} - key={JSON.stringify(newFilter)} - /> -
-
+ + {(resizeRef) => ( +
+ + setIsAddFilterPopoverOpen(false)} + key={JSON.stringify(newFilter)} + /> + +
+ )} +
); diff --git a/src/plugins/data/public/ui/filter_bar/filter_editor/_filter_editor.scss b/src/plugins/data/public/ui/filter_bar/filter_editor/_filter_editor.scss deleted file mode 100644 index a5fac10e4693..000000000000 --- a/src/plugins/data/public/ui/filter_bar/filter_editor/_filter_editor.scss +++ /dev/null @@ -1,3 +0,0 @@ -.globalFilterEditor__fieldInput { - max-width: $euiSize * 13; -} diff --git a/src/plugins/data/public/ui/filter_bar/filter_editor/_index.scss b/src/plugins/data/public/ui/filter_bar/filter_editor/_index.scss deleted file mode 100644 index 3d416aade9a5..000000000000 --- a/src/plugins/data/public/ui/filter_bar/filter_editor/_index.scss +++ /dev/null @@ -1 +0,0 @@ -@import 'filter_editor'; diff --git a/src/plugins/data/public/ui/filter_bar/filter_editor/index.tsx b/src/plugins/data/public/ui/filter_bar/filter_editor/index.tsx index e099ebf72042..4fa7b6d1c339 100644 --- a/src/plugins/data/public/ui/filter_bar/filter_editor/index.tsx +++ b/src/plugins/data/public/ui/filter_bar/filter_editor/index.tsx @@ -163,12 +163,14 @@ class FilterEditorUI extends Component {
@@ -283,6 +285,7 @@ class FilterEditorUI extends Component { > { label={i18n.translate('data.filter.filterEditor.queryDslLabel', { defaultMessage: 'OpenSearch Query DSL', })} + fullWidth={true} > { public render() { return ( { this.renderWithSuggestions() ) : ( { id: 'data.filter.filterEditor.valueSelectPlaceholder', defaultMessage: 'Select a value', })} + fullWidth={true} options={options} getLabel={(option) => option} selectedOptions={value ? [valueAsStr] : []} diff --git a/src/plugins/data/public/ui/filter_bar/filter_editor/phrases_values_input.tsx b/src/plugins/data/public/ui/filter_bar/filter_editor/phrases_values_input.tsx index cc2c3b1f366d..0481c4297eb3 100644 --- a/src/plugins/data/public/ui/filter_bar/filter_editor/phrases_values_input.tsx +++ b/src/plugins/data/public/ui/filter_bar/filter_editor/phrases_values_input.tsx @@ -51,6 +51,7 @@ class PhrasesValuesInputUI extends PhraseSuggestorUI { const options = values ? uniq([...values, ...suggestions]) : suggestions; return ( { id: 'data.filter.filterEditor.valuesSelectPlaceholder', defaultMessage: 'Select values', })} + fullWidth={true} options={options} getLabel={(option) => option} selectedOptions={values || []} diff --git a/src/plugins/data/public/ui/filter_bar/filter_editor/range_value_input.tsx b/src/plugins/data/public/ui/filter_bar/filter_editor/range_value_input.tsx index e57f18332e92..778e65b15d28 100644 --- a/src/plugins/data/public/ui/filter_bar/filter_editor/range_value_input.tsx +++ b/src/plugins/data/public/ui/filter_bar/filter_editor/range_value_input.tsx @@ -84,6 +84,7 @@ function RangeValueInputUI(props: Props) { return (
void; onBlur?: (value: string | number | boolean) => void; + fullWidth?: boolean; placeholder: string; intl: InjectedIntl; controlOnly?: boolean; @@ -55,6 +56,7 @@ class ValueInputTypeUI extends Component { case 'string': inputElement = ( { case 'number': inputElement = ( { case 'date': inputElement = ( { case 'ip': inputElement = ( { case 'boolean': inputElement = (