From e82e53655d97763bbb8cbf48297d30f5e1b59ffe Mon Sep 17 00:00:00 2001 From: Marta Bondyra Date: Fri, 21 Aug 2020 12:06:46 +0200 Subject: [PATCH 01/32] checkpoint --- .../config_panel/_layer_panel.scss | 18 + .../config_panel/dimension_popover.tsx | 1 + .../dimension_panel/popover_editor.scss | 11 + .../indexpattern_datasource/indexpattern.tsx | 1 + .../definitions/filters/filter_popover.tsx | 247 ++++++++ .../definitions/filters/filters.test.tsx | 528 ++++++++++++++++++ .../definitions/filters/filters_dnd.tsx | 123 ++++ .../operations/definitions/filters/index.tsx | 210 +++++++ .../operations/definitions/index.ts | 3 + .../state_helpers.test.ts | 1 + 10 files changed, 1143 insertions(+) create mode 100644 x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filter_popover.tsx create mode 100644 x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters.test.tsx create mode 100644 x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filters_dnd.tsx create mode 100644 x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/index.tsx diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/_layer_panel.scss b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/_layer_panel.scss index 4e13fd95d1961..893bb96b83156 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/_layer_panel.scss +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/_layer_panel.scss @@ -35,6 +35,24 @@ min-height: $euiSizeXXL; } +.lnsLayerPanel__panel { + position: relative; +} + +.lnsLayerPanel__anchor { + width: 100%; +} + +.lnsLayerPanel__dndGrab { + padding: $euiSizeS; +} + +.lnsLayerPanel__filterLink { + width: 100%; + align-self: flex-start; + word-break: break-word; +} + .lnsLayerPanel__styleEditor { width: $euiSize * 30; padding: $euiSizeS; diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/dimension_popover.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/dimension_popover.tsx index 8d31e1bcc2e6a..899ef56eb2e74 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/dimension_popover.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/dimension_popover.tsx @@ -31,6 +31,7 @@ export function DimensionPopover({ { + const [isPopoverOpen, setIsPopoverOpen] = useState(false); + const [tempFilter, setTempFilter] = useState(filter); + const [errorMessage, setErrorMessage] = useState(undefined); + + const labelRef = useRef(); + const onQueryChange = (input: Query) => setTempFilter({ ...tempFilter, input }); + const onLabelChange = (label: string) => setTempFilter({ ...tempFilter, label }); + const onSubmit = (input: Query) => { + let filterQuery; + // try { + if (input.language === SEARCH_QUERY_LANGUAGE.KUERY) { + filterQuery = esKuery.toElasticsearchQuery( + esKuery.fromKueryExpression(input.query), + indexPattern + ); + } else if (input.language === SEARCH_QUERY_LANGUAGE.LUCENE) { + filterQuery = esQuery.luceneStringToDsl(input.query); + } else { + filterQuery = {}; + } + if (input.query.length) { + if (tempFilter.label) { + setFilter(tempFilter); + setIsPopoverOpen(false); + } else { + if (labelRef?.current?.focus) { + labelRef.current.focus(); + } + } + } + }; + + return ( + { + setIsPopoverOpen(false); + setTempFilter(filter); + }} + button={