Skip to content

Commit

Permalink
[Filter Bar] Widened Edit Filter popover (#85320)
Browse files Browse the repository at this point in the history
Closes #36409
  • Loading branch information
cchaos authored Dec 10, 2020
1 parent 7d0a7b7 commit b3706b1
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 17 deletions.
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';
1 change: 0 additions & 1 deletion src/plugins/data/public/ui/filter_bar/_variables.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
$kbnGlobalFilterItemBorderColor: tintOrShade($euiColorMediumShade, 35%, 20%);
$kbnGlobalFilterItemBorderColorExcluded: tintOrShade($euiColorDanger, 70%, 50%);
$kbnGlobalFilterItemPinnedColorExcluded: tintOrShade($euiColorDanger, 30%, 20%);
$kbnGlobalFilterItemEditorWidth: 420px; // if changing this make sure to also change `FILTER_EDITOR_WIDTH` in ./filter_item.tsx

This file was deleted.

This file was deleted.

13 changes: 12 additions & 1 deletion src/plugins/data/public/ui/filter_bar/filter_editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ class FilterEditorUI extends Component<Props, State> {
id: 'data.filter.filterEditor.createCustomLabelInputLabel',
defaultMessage: 'Custom label',
})}
fullWidth
>
<EuiFieldText
value={`${this.state.customLabel}`}
onChange={this.onCustomLabelChange}
fullWidth
/>
</EuiFormRow>
</div>
Expand Down Expand Up @@ -218,12 +220,14 @@ class FilterEditorUI extends Component<Props, State> {
<EuiFlexGroup>
<EuiFlexItem>
<EuiFormRow
fullWidth
label={this.props.intl.formatMessage({
id: 'data.filter.filterEditor.indexPatternSelectLabel',
defaultMessage: 'Index Pattern',
})}
>
<IndexPatternComboBox
fullWidth
placeholder={this.props.intl.formatMessage({
id: 'data.filter.filterBar.indexPatternSelectPlaceholder',
defaultMessage: 'Select an index pattern',
Expand Down Expand Up @@ -263,12 +267,14 @@ class FilterEditorUI extends Component<Props, State> {

return (
<EuiFormRow
fullWidth
label={this.props.intl.formatMessage({
id: 'data.filter.filterEditor.fieldSelectLabel',
defaultMessage: 'Field',
})}
>
<FieldComboBox
fullWidth
id="fieldInput"
isDisabled={!selectedIndexPattern}
placeholder={this.props.intl.formatMessage({
Expand All @@ -281,7 +287,6 @@ class FilterEditorUI extends Component<Props, State> {
onChange={this.onFieldChange}
singleSelection={{ asPlainText: true }}
isClearable={false}
className="globalFilterEditor__fieldInput"
data-test-subj="filterFieldSuggestionList"
/>
</EuiFormRow>
Expand All @@ -293,12 +298,14 @@ class FilterEditorUI extends Component<Props, State> {
const operators = selectedField ? getOperatorOptions(selectedField) : [];
return (
<EuiFormRow
fullWidth
label={this.props.intl.formatMessage({
id: 'data.filter.filterEditor.operatorSelectLabel',
defaultMessage: 'Operator',
})}
>
<OperatorComboBox
fullWidth
isDisabled={!selectedField}
placeholder={
selectedField
Expand Down Expand Up @@ -326,6 +333,7 @@ class FilterEditorUI extends Component<Props, State> {
private renderCustomEditor() {
return (
<EuiFormRow
fullWidth
label={i18n.translate('data.filter.filterEditor.queryDslLabel', {
defaultMessage: 'Elasticsearch Query DSL',
})}
Expand Down Expand Up @@ -358,6 +366,7 @@ class FilterEditorUI extends Component<Props, State> {
value={this.state.params}
onChange={this.onParamsChange}
data-test-subj="phraseValueInput"
fullWidth
/>
);
case 'phrases':
Expand All @@ -367,6 +376,7 @@ class FilterEditorUI extends Component<Props, State> {
field={this.state.selectedField}
values={this.state.params}
onChange={this.onParamsChange}
fullWidth
/>
);
case 'range':
Expand All @@ -375,6 +385,7 @@ class FilterEditorUI extends Component<Props, State> {
field={this.state.selectedField}
value={this.state.params}
onChange={this.onParamsChange}
fullWidth
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ interface Props extends PhraseSuggestorProps {
value?: string;
onChange: (value: string | number | boolean) => void;
intl: InjectedIntl;
fullWidth?: boolean;
}

class PhraseValueInputUI extends PhraseSuggestorUI<Props> {
public render() {
return (
<EuiFormRow
fullWidth={this.props.fullWidth}
label={this.props.intl.formatMessage({
id: 'data.filter.filterEditor.valueInputLabel',
defaultMessage: 'Value',
Expand All @@ -45,6 +47,7 @@ class PhraseValueInputUI extends PhraseSuggestorUI<Props> {
this.renderWithSuggestions()
) : (
<ValueInputType
fullWidth={this.props.fullWidth}
placeholder={this.props.intl.formatMessage({
id: 'data.filter.filterEditor.valueInputPlaceholder',
defaultMessage: 'Enter a value',
Expand All @@ -60,12 +63,13 @@ class PhraseValueInputUI extends PhraseSuggestorUI<Props> {

private renderWithSuggestions() {
const { suggestions } = this.state;
const { value, intl, onChange } = this.props;
const { value, intl, onChange, fullWidth } = this.props;
// there are cases when the value is a number, this would cause an exception
const valueAsStr = String(value);
const options = value ? uniq([valueAsStr, ...suggestions]) : suggestions;
return (
<StringComboBox
fullWidth={fullWidth}
placeholder={intl.formatMessage({
id: 'data.filter.filterEditor.valueSelectPlaceholder',
defaultMessage: 'Select a value',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,24 @@ interface Props extends PhraseSuggestorProps {
values?: string[];
onChange: (values: string[]) => void;
intl: InjectedIntl;
fullWidth?: boolean;
}

class PhrasesValuesInputUI extends PhraseSuggestorUI<Props> {
public render() {
const { suggestions } = this.state;
const { values, intl, onChange } = this.props;
const { values, intl, onChange, fullWidth } = this.props;
const options = values ? uniq([...values, ...suggestions]) : suggestions;
return (
<EuiFormRow
fullWidth={fullWidth}
label={intl.formatMessage({
id: 'data.filter.filterEditor.valuesSelectLabel',
defaultMessage: 'Values',
})}
>
<StringComboBox
fullWidth={fullWidth}
placeholder={intl.formatMessage({
id: 'data.filter.filterEditor.valuesSelectPlaceholder',
defaultMessage: 'Select values',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface Props {
value?: RangeParams;
onChange: (params: RangeParamsPartial) => void;
intl: InjectedIntl;
fullWidth?: boolean;
}

function RangeValueInputUI(props: Props) {
Expand Down Expand Up @@ -71,6 +72,7 @@ function RangeValueInputUI(props: Props) {
return (
<div>
<EuiFormControlLayoutDelimited
fullWidth={props.fullWidth}
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 @@ -32,6 +32,7 @@ interface Props {
intl: InjectedIntl;
controlOnly?: boolean;
className?: string;
fullWidth?: boolean;
}

class ValueInputTypeUI extends Component<Props> {
Expand All @@ -42,6 +43,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 @@ -53,6 +55,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 @@ -64,6 +67,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 @@ -77,6 +81,7 @@ class ValueInputTypeUI extends Component<Props> {
case 'ip':
inputElement = (
<EuiFieldText
fullWidth={this.props.fullWidth}
placeholder={this.props.placeholder}
value={value}
onChange={this.onChange}
Expand Down Expand Up @@ -109,6 +114,7 @@ class ValueInputTypeUI extends Component<Props> {
value={value}
onChange={this.onBoolChange}
className={this.props.className}
fullWidth={this.props.fullWidth}
/>
);
break;
Expand Down
7 changes: 1 addition & 6 deletions src/plugins/data/public/ui/filter_bar/filter_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,7 @@ export type FilterLabelStatus =
| typeof FILTER_ITEM_WARNING
| typeof FILTER_ITEM_ERROR;

/**
* @remarks
* if changing this make sure to also change
* $kbnGlobalFilterItemEditorWidth
*/
export const FILTER_EDITOR_WIDTH = 420;
export const FILTER_EDITOR_WIDTH = 800;

export function FilterItem(props: Props) {
const [isPopoverOpen, setIsPopoverOpen] = useState<boolean>(false);
Expand Down

0 comments on commit b3706b1

Please sign in to comment.