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

Increase filters popover size and use full width in form components #352

Merged
merged 3 commits into from
Jul 20, 2021
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
1 change: 0 additions & 1 deletion src/plugins/data/public/ui/filter_bar/_index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@import 'variables';
@import 'global_filter_group';
@import 'global_filter_item';
@import 'filter_editor/index';
43 changes: 30 additions & 13 deletions src/plugins/data/public/ui/filter_bar/filter_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -121,20 +134,24 @@ function FilterBarUI(props: Props) {
withTitle
panelPaddingSize="none"
ownFocus={true}
initialFocus=".filterEditor__hiddenItem"
initialFocus=".globalFilterEditor__fieldInput input"
repositionOnScroll
>
<EuiFlexItem grow={false}>
<div style={{ width: 400 }}>
<FilterEditor
filter={newFilter}
indexPatterns={props.indexPatterns}
onSubmit={onAdd}
onCancel={() => setIsAddFilterPopoverOpen(false)}
key={JSON.stringify(newFilter)}
/>
</div>
</EuiFlexItem>
<EuiResizeObserver onResize={onResize}>
{(resizeRef) => (
<div style={{ width: maxFilterWidth, maxWidth: '100%' }} ref={resizeRef}>
<EuiFlexItem style={{ width: filterWidth }} grow={false}>
<FilterEditor
filter={newFilter}
indexPatterns={props.indexPatterns}
onSubmit={onAdd}
onCancel={() => setIsAddFilterPopoverOpen(false)}
key={JSON.stringify(newFilter)}
/>
</EuiFlexItem>
</div>
)}
</EuiResizeObserver>
</EuiPopover>
</EuiFlexItem>
);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,14 @@ class FilterEditorUI extends Component<Props, State> {
<div>
<EuiSpacer size="m" />
<EuiFormRow
fullWidth={true}
label={this.props.intl.formatMessage({
id: 'data.filter.filterEditor.createCustomLabelInputLabel',
defaultMessage: 'Custom label',
})}
>
<EuiFieldText
fullWidth={true}
value={`${this.state.customLabel}`}
onChange={this.onCustomLabelChange}
/>
Expand Down Expand Up @@ -283,6 +285,7 @@ class FilterEditorUI extends Component<Props, State> {
>
<FieldComboBox
id="fieldInput"
fullWidth={true}
isDisabled={!selectedIndexPattern}
placeholder={this.props.intl.formatMessage({
id: 'data.filter.filterEditor.fieldSelectPlaceholder',
Expand Down Expand Up @@ -342,6 +345,7 @@ class FilterEditorUI extends Component<Props, State> {
label={i18n.translate('data.filter.filterEditor.queryDslLabel', {
defaultMessage: 'OpenSearch Query DSL',
})}
fullWidth={true}
>
<EuiCodeEditor
value={this.state.queryDsl}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class PhraseValueInputUI extends PhraseSuggestorUI<Props> {
public render() {
return (
<EuiFormRow
fullWidth={true}
label={this.props.intl.formatMessage({
id: 'data.filter.filterEditor.valueInputLabel',
defaultMessage: 'Value',
Expand All @@ -58,6 +59,7 @@ class PhraseValueInputUI extends PhraseSuggestorUI<Props> {
this.renderWithSuggestions()
) : (
<ValueInputType
fullWidth={true}
placeholder={this.props.intl.formatMessage({
id: 'data.filter.filterEditor.valueInputPlaceholder',
defaultMessage: 'Enter a value',
Expand All @@ -83,6 +85,7 @@ class PhraseValueInputUI extends PhraseSuggestorUI<Props> {
id: 'data.filter.filterEditor.valueSelectPlaceholder',
defaultMessage: 'Select a value',
})}
fullWidth={true}
options={options}
getLabel={(option) => option}
selectedOptions={value ? [valueAsStr] : []}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class PhrasesValuesInputUI extends PhraseSuggestorUI<Props> {
const options = values ? uniq([...values, ...suggestions]) : suggestions;
return (
<EuiFormRow
fullWidth={true}
label={intl.formatMessage({
id: 'data.filter.filterEditor.valuesSelectLabel',
defaultMessage: 'Values',
Expand All @@ -61,6 +62,7 @@ class PhrasesValuesInputUI extends PhraseSuggestorUI<Props> {
id: 'data.filter.filterEditor.valuesSelectPlaceholder',
defaultMessage: 'Select values',
})}
fullWidth={true}
options={options}
getLabel={(option) => option}
selectedOptions={values || []}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function RangeValueInputUI(props: Props) {
return (
<div>
<EuiFormControlLayoutDelimited
fullWidth={true}
aria-label={props.intl.formatMessage({
id: 'data.filter.filterEditor.rangeInputLabel',
defaultMessage: 'Range',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ interface Props {
type: string;
onChange: (value: string | number | boolean) => void;
onBlur?: (value: string | number | boolean) => void;
fullWidth?: boolean;
placeholder: string;
intl: InjectedIntl;
controlOnly?: boolean;
Expand All @@ -55,6 +56,7 @@ class ValueInputTypeUI extends Component<Props> {
case 'string':
inputElement = (
<EuiFieldText
fullWidth={this.props.fullWidth}
placeholder={this.props.placeholder}
value={value}
onChange={this.onChange}
Expand All @@ -66,6 +68,7 @@ class ValueInputTypeUI extends Component<Props> {
case 'number':
inputElement = (
<EuiFieldNumber
fullWidth={this.props.fullWidth}
placeholder={this.props.placeholder}
value={typeof value === 'string' ? parseFloat(value) : value}
onChange={this.onChange}
Expand All @@ -77,6 +80,7 @@ class ValueInputTypeUI extends Component<Props> {
case 'date':
inputElement = (
<EuiFieldText
fullWidth={this.props.fullWidth}
placeholder={this.props.placeholder}
value={value}
onChange={this.onChange}
Expand All @@ -90,6 +94,7 @@ class ValueInputTypeUI extends Component<Props> {
case 'ip':
inputElement = (
<EuiFieldText
fullWidth={this.props.fullWidth}
placeholder={this.props.placeholder}
value={value}
onChange={this.onChange}
Expand All @@ -102,6 +107,7 @@ class ValueInputTypeUI extends Component<Props> {
case 'boolean':
inputElement = (
<EuiSelect
fullWidth={this.props.fullWidth}
options={[
{ value: undefined, text: this.props.placeholder },
{
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/ui/filter_bar/filter_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export function FilterItem(props: Props) {
},
{
id: 1,
width: 420,
width: 600,
content: (
<div>
<FilterEditor
Expand Down