diff --git a/x-pack/legacy/plugins/infra/public/components/waffle/custom_field_panel.tsx b/x-pack/legacy/plugins/infra/public/components/waffle/custom_field_panel.tsx index 01bff0b4f96e1..15d8b8b0e42b8 100644 --- a/x-pack/legacy/plugins/infra/public/components/waffle/custom_field_panel.tsx +++ b/x-pack/legacy/plugins/infra/public/components/waffle/custom_field_panel.tsx @@ -8,10 +8,12 @@ import { EuiButton, EuiComboBox, EuiForm, EuiFormRow } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import React from 'react'; import { IFieldType } from 'src/plugins/data/public'; +import { InfraGroupByOptions } from '../../lib/lib'; interface Props { onSubmit: (field: string) => void; fields: IFieldType[]; + currentOptions: InfraGroupByOptions[]; } interface SelectedOption { @@ -28,10 +30,16 @@ export const CustomFieldPanel = class extends React.PureComponent public static displayName = 'CustomFieldPanel'; public readonly state: State = initialState; public render() { - const { fields } = this.props; + const { fields, currentOptions } = this.props; const options = fields - .filter(f => f.aggregatable && f.type === 'string') + .filter( + f => + f.aggregatable && + f.type === 'string' && + !(currentOptions && currentOptions.some(o => o.field === f.name)) + ) .map(f => ({ label: f.name })); + const isSubmitDisabled = !this.state.selectedOptions.length; return (
@@ -57,7 +65,7 @@ export const CustomFieldPanel = class extends React.PureComponent /> = 2; + const maxGroupByTooltip = i18n.translate('xpack.infra.waffle.maxGroupByTooltip', { + defaultMessage: 'Only two groupings can be selected at a time', + }); const panels: EuiContextMenuPanelDescriptor[] = [ { id: 'firstPanel', @@ -72,6 +76,8 @@ export const WaffleGroupByControls = class extends React.PureComponent, + content: ( + + ), }, ]; const buttonBody = @@ -167,8 +183,8 @@ export const WaffleGroupByControls = class extends React.PureComponent