From 364f9acdbfb64544daf42a5c229a0b24d4199415 Mon Sep 17 00:00:00 2001 From: mbondyra Date: Wed, 5 Feb 2025 14:39:08 +0100 Subject: [PATCH 01/37] [Lens] Replace scss to css-in-js for Lens codebase --- .../plugins/shared/lens/public/_mixins.scss | 69 ------------------ .../shared/lens/public/_variables.scss | 10 --- .../shared/lens/public/app_plugin/app.scss | 40 ----------- .../shared/lens/public/app_plugin/app.tsx | 14 +++- .../lens/public/app_plugin/lens_top_nav.tsx | 35 +++++++-- .../shared/lens/public/app_plugin/mounter.tsx | 2 - .../shared/edit_on_the_fly/flyout_wrapper.tsx | 1 + .../public/datasources/common/field_item.scss | 4 -- .../public/datasources/common/field_item.tsx | 6 +- .../dimension_panel/field_select.scss | 7 -- .../dimension_panel/field_select.tsx | 1 - .../datasources/form_based/help_popover.scss | 13 ---- .../datasources/form_based/help_popover.tsx | 44 +++++++----- .../definitions/filters/filter_popover.scss | 3 - .../definitions/filters/filter_popover.tsx | 18 +++-- .../definitions/filters/filters.scss | 6 -- .../definitions/filters/filters.tsx | 8 +-- .../definitions/ranges/advanced_editor.scss | 10 --- .../definitions/ranges/advanced_editor.tsx | 16 +++-- .../definitions/ranges/ranges.test.tsx | 4 +- .../shared_components/form_row.scss | 3 - .../shared_components/form_row.tsx | 8 ++- .../config_panel/dimension_container.scss | 17 ----- .../config_panel/dimension_container.tsx | 2 - .../config_panel/layer_panel.scss | 29 +++++++- .../editor_frame/data_panel_wrapper.scss | 10 --- .../editor_frame/data_panel_wrapper.tsx | 12 +++- .../editor_frame/frame_layout.scss | 5 +- .../editor_frame/suggestion_panel.scss | 20 +++++- .../geo_field_workspace_panel.scss | 5 -- .../geo_field_workspace_panel.tsx | 13 +++- .../workspace_panel/message_list.scss | 26 ------- .../workspace_panel/message_list.tsx | 30 ++++++-- .../workspace_panel/workspace_panel.tsx | 1 - .../workspace_panel_wrapper.scss | 14 +++- .../public/editor_frame_service/service.tsx | 10 ++- .../react_embeddable/expression_wrapper.tsx | 1 - .../inline_editing/flyout.styles.ts | 49 +++++++++++++ .../react_embeddable/inline_editing/mount.tsx | 2 + .../user_messages/error_panel.tsx | 12 +++- .../user_messages/info_badges.scss | 4 -- .../user_messages/info_badges.tsx | 11 ++- .../public/shared_components/flyout.styles.ts | 37 ++++++++++ .../shared_components/flyout_container.scss | 47 ------------ .../shared_components/flyout_container.tsx | 71 ++++++++++++++----- .../setting_with_sibling_flyout.scss | 28 -------- .../setting_with_sibling_flyout.tsx | 47 ++++++++---- .../shared_components/toolbar_popover.scss | 3 - .../shared_components/toolbar_popover.tsx | 7 +- .../open_lens_config/helpers.scss | 24 ------- .../in_app_embeddable_edit_action_helpers.tsx | 1 - .../lens/public/visualization_container.scss | 34 --------- .../public/visualization_container.test.tsx | 30 -------- .../lens/public/visualization_container.tsx | 27 ------- .../components/dimension_editor.scss | 3 - .../datatable/components/dimension_editor.tsx | 2 - .../dimension_editor_addtional_section.tsx | 2 - .../datatable/components/table_basic.scss | 19 ----- .../datatable/components/table_basic.test.tsx | 2 +- .../datatable/components/table_basic.tsx | 41 +++++++++-- .../gauge/dimension_editor.scss | 3 - .../visualizations/gauge/dimension_editor.tsx | 11 +-- .../toolbar_component/gauge_config_panel.scss | 3 - .../gauge/toolbar_component/index.tsx | 9 ++- .../heatmap/dimension_editor.scss | 3 - .../heatmap/dimension_editor.tsx | 6 +- .../legacy_metric/dimension_editor.scss | 3 - .../legacy_metric/dimension_editor.tsx | 7 +- .../partition/dimension_editor.tsx | 1 - .../visualizations/partition/toolbar.scss | 3 - .../visualizations/partition/toolbar.tsx | 1 - .../public/visualizations/xy/add_layer.tsx | 51 +++++++------ .../axis_settings_popover.scss | 3 - .../xy_config_panel/axis_settings_popover.tsx | 6 +- 74 files changed, 505 insertions(+), 625 deletions(-) delete mode 100644 x-pack/platform/plugins/shared/lens/public/_mixins.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/_variables.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/app_plugin/app.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/datasources/common/field_item.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/field_select.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/shared_components/form_row.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/data_panel_wrapper.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/message_list.scss create mode 100644 x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/flyout.styles.ts delete mode 100644 x-pack/platform/plugins/shared/lens/public/react_embeddable/user_messages/info_badges.scss create mode 100644 x-pack/platform/plugins/shared/lens/public/shared_components/flyout.styles.ts delete mode 100644 x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/shared_components/toolbar_popover.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/trigger_actions/open_lens_config/helpers.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/visualization_container.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/visualization_container.test.tsx delete mode 100644 x-pack/platform/plugins/shared/lens/public/visualization_container.tsx delete mode 100644 x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/dimension_editor.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/visualizations/gauge/dimension_editor.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/visualizations/gauge/toolbar_component/gauge_config_panel.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/visualizations/heatmap/dimension_editor.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/visualizations/legacy_metric/dimension_editor.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/visualizations/partition/toolbar.scss delete mode 100644 x-pack/platform/plugins/shared/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.scss diff --git a/x-pack/platform/plugins/shared/lens/public/_mixins.scss b/x-pack/platform/plugins/shared/lens/public/_mixins.scss deleted file mode 100644 index acbe0ce65f62f..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/_mixins.scss +++ /dev/null @@ -1,69 +0,0 @@ -// sass-lint:disable-block indentation, no-color-keywords - -// SASSTODO: Create this in EUI -@mixin lnsOverflowShadowHorizontal { - $hideHeight: $euiScrollBarCorner * 1.25; - mask-image: linear-gradient( - to right, - transparentize($euiColorDanger, .9) 0%, - transparentize($euiColorDanger, 0) $hideHeight, - transparentize($euiColorDanger, 0) calc(100% - #{$hideHeight}), - transparentize($euiColorDanger, .9) 100% - ); -} - -// Removes EUI focus ring -@mixin removeEuiFocusRing { - outline: none; - - &:focus-visible { - outline-style: none; - } -} - -// Passes focus ring styles down to a child of a focused element -@mixin passDownFocusRing($target) { - @include removeEuiFocusRing; - - #{$target} { - @include euiFocusBackground; - outline: $euiFocusRingSize solid currentColor; // Safari & Firefox - } - - &:focus-visible #{$target} { - outline-style: auto; // Chrome - } - - &:not(:focus-visible) #{$target} { - outline: none; - } -} - -@mixin euiFlyout { - border-left: $euiBorderThin; - // The mixin augments the above - // sass-lint:disable mixins-before-declarations - @include euiBottomShadowLarge; - position: fixed; - top: 0; - bottom: 0; - right: 0; - height: 100%; - z-index: $euiZFlyout; - background: $euiColorEmptyShade; - display: flex; - flex-direction: column; - align-items: stretch; -} - -@keyframes euiFlyoutAnimation { - 0% { - opacity: 0; - transform: translateX(100%); - } - - 75% { - opacity: 1; - transform: translateX(0%); - } -} diff --git a/x-pack/platform/plugins/shared/lens/public/_variables.scss b/x-pack/platform/plugins/shared/lens/public/_variables.scss deleted file mode 100644 index 2277f1a276ffc..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/_variables.scss +++ /dev/null @@ -1,10 +0,0 @@ -$lnsPanelMinWidth: $euiSize * 18; - -// These sizes also match canvas' page thumbnails for consistency -$lnsSuggestionHeight: 100px; -$lnsSuggestionWidth: 150px; - -$lnsZLevel0: 0; -$lnsZLevel1: 1; -$lnsZLevel2: 2; -$lnsZLevel3: 3; diff --git a/x-pack/platform/plugins/shared/lens/public/app_plugin/app.scss b/x-pack/platform/plugins/shared/lens/public/app_plugin/app.scss deleted file mode 100644 index bd143f3245e93..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/app_plugin/app.scss +++ /dev/null @@ -1,40 +0,0 @@ -.lnsAppWrapper { - display: flex; - flex-direction: column; - flex-grow: 1; -} - -.lnsApp { - flex: 1 1 auto; - display: flex; - flex-direction: column; - height: 100%; - overflow: hidden; -} - -.lnsApp__frame { - position: relative; - display: flex; - flex-direction: column; - flex-grow: 1; -} - -// Less-than-ideal styles to add a vertical divider after this button. Consider restructuring markup for better semantics and styling options in the future. -.lnsNavItem__withDivider { - @include euiBreakpoint('m', 'l', 'xl') { - margin-right: $euiSizeM; - position: relative; - } - &::after { - @include euiBreakpoint('m', 'l', 'xl') { - border-right: $euiBorderThin; - bottom: 0; - content: ''; - display: block; - pointer-events: none; - position: absolute; - right: -$euiSizeS; - top: 0; - } - } -} diff --git a/x-pack/platform/plugins/shared/lens/public/app_plugin/app.tsx b/x-pack/platform/plugins/shared/lens/public/app_plugin/app.tsx index 1756ea1877126..9bf65fd9fe03e 100644 --- a/x-pack/platform/plugins/shared/lens/public/app_plugin/app.tsx +++ b/x-pack/platform/plugins/shared/lens/public/app_plugin/app.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import './app.scss'; import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react'; import { i18n } from '@kbn/i18n'; import type { TimeRange } from '@kbn/es-query'; @@ -13,6 +12,7 @@ import { EuiConfirmModal } from '@elastic/eui'; import { useExecutionContext, useKibana } from '@kbn/kibana-react-plugin/public'; import { OnSaveProps } from '@kbn/saved-objects-plugin/public'; import type { VisualizeFieldContext } from '@kbn/ui-actions-plugin/public'; +import { css } from '@emotion/react'; import { LensAppProps, LensAppServices } from './types'; import { LensTopNavMenu } from './lens_top_nav'; import { AddUserMessages, EditorFrameInstance, Simplify, UserMessagesGetter } from '../types'; @@ -437,7 +437,17 @@ export function App({ return ( <> -
+
css` + @include euiBreakpoint('m', 'l', 'xl') { + margin-right: $euiSizeM; + position: relative; + } + ${useEuiBreakpoint(['m', 'l', 'xl'])} { + margin-right: ${euiTheme.size.m}; + position: relative; + &:after { + border-right: ${euiTheme.border.thin}; + bottom: 0; + content: ''; + display: block; + pointer-events: none; + position: absolute; + right: -${euiTheme.size.s}; + top: 0; + } + } +`; + function getLensTopNavConfig(options: { isByValueMode: boolean; actions: LensTopNavActions; @@ -123,7 +145,10 @@ function getLensTopNavConfig(options: { contextFromEmbeddable, isByValueMode, } = options; - const topNavMenu: TopNavMenuData[] = []; + + const topNavMenu: Array< + TopNavMenuData | ({ css: ({ euiTheme }: UseEuiTheme) => SerializedStyles } & TopNavMenuData) + > = []; const showSaveAndReturn = actions.saveAndReturn.visible; @@ -150,13 +175,13 @@ function getLensTopNavConfig(options: { values: { contextOriginatingApp }, }), run: actions.goBack.execute, - className: 'lnsNavItem__withDivider', testId: 'lnsApp_goBackToAppButton', description: i18n.translate('xpack.lens.app.goBackLabel', { defaultMessage: `Go back to {contextOriginatingApp}`, values: { contextOriginatingApp }, }), disableButton: !actions.goBack.enabled, + css: NavItemWithDividerStyles, }); } @@ -169,12 +194,12 @@ function getLensTopNavConfig(options: { label: exploreDataInDiscoverLabel, run: actions.getUnderlyingDataUrl.execute, testId: 'lnsApp_openInDiscover', - className: 'lnsNavItem__withDivider', description: exploreDataInDiscoverLabel, disableButton: !actions.getUnderlyingDataUrl.enabled, tooltip: actions.getUnderlyingDataUrl.tooltip, target: '_blank', href: actions.getUnderlyingDataUrl.getLink?.(), + css: NavItemWithDividerStyles, }); } @@ -210,11 +235,11 @@ function getLensTopNavConfig(options: { defaultMessage: 'Settings', }), run: actions.openSettings.execute, - className: 'lnsNavItem__withDivider', testId: 'lnsApp_settingsButton', description: i18n.translate('xpack.lens.app.settingsAriaLabel', { defaultMessage: 'Open the Lens settings menu', }), + css: NavItemWithDividerStyles, }); if (actions.cancel.visible) { diff --git a/x-pack/platform/plugins/shared/lens/public/app_plugin/mounter.tsx b/x-pack/platform/plugins/shared/lens/public/app_plugin/mounter.tsx index bc7f3a99686ad..7042117098395 100644 --- a/x-pack/platform/plugins/shared/lens/public/app_plugin/mounter.tsx +++ b/x-pack/platform/plugins/shared/lens/public/app_plugin/mounter.tsx @@ -398,8 +398,6 @@ export async function mountApp( window.dispatchEvent(new HashChangeEvent('hashchange')); }); - params.element.classList.add('lnsAppWrapper'); - render( diff --git a/x-pack/platform/plugins/shared/lens/public/app_plugin/shared/edit_on_the_fly/flyout_wrapper.tsx b/x-pack/platform/plugins/shared/lens/public/app_plugin/shared/edit_on_the_fly/flyout_wrapper.tsx index 2e8ff8390673f..bc938991d63b7 100644 --- a/x-pack/platform/plugins/shared/lens/public/app_plugin/shared/edit_on_the_fly/flyout_wrapper.tsx +++ b/x-pack/platform/plugins/shared/lens/public/app_plugin/shared/edit_on_the_fly/flyout_wrapper.tsx @@ -116,6 +116,7 @@ export const FlyoutWrapper = ({ margin-left: -${euiThemeVars.euiFormMaxWidth}; pointer-events: none; .euiFlyoutBody__overflow { + transform: initial; -webkit-mask-image: none; padding-left: inherit; margin-left: inherit; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/common/field_item.scss b/x-pack/platform/plugins/shared/lens/public/datasources/common/field_item.scss deleted file mode 100644 index b9927ae4e7bf8..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/datasources/common/field_item.scss +++ /dev/null @@ -1,4 +0,0 @@ -.lnsFieldItem__fieldPanel { - min-width: 260px; - max-width: 300px; -} \ No newline at end of file diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/common/field_item.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/common/field_item.tsx index f3e388989c429..124e4bcbdeabd 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/common/field_item.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/common/field_item.tsx @@ -5,8 +5,6 @@ * 2.0. */ -import './field_item.scss'; - import React, { useCallback, useState, useMemo } from 'react'; import { EuiText, EuiButton, EuiPopoverFooter } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; @@ -251,6 +249,10 @@ export function InnerFieldItem(props: FieldItemProps) { isOpen={infoIsOpen} closePopover={closePopover} panelClassName="lnsFieldItem__fieldPanel" + panelStyle={{ + minWidth: '260px', + maxWidth: '300px', + }} initialFocus=".lnsFieldItem__fieldPanel" data-test-subj="lnsFieldListPanelField" panelProps={{ diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/field_select.scss b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/field_select.scss deleted file mode 100644 index 993174f3e6223..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/field_select.scss +++ /dev/null @@ -1,7 +0,0 @@ -.lnFieldSelect__option--incompatible { - color: $euiColorLightShade; -} - -.lnFieldSelect__option--nonExistant { - background-color: $euiColorLightestShade; -} diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/field_select.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/field_select.tsx index bf22e6622e4ab..91d4348113d9b 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/field_select.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/field_select.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import './field_select.scss'; import { partition } from 'lodash'; import React, { useMemo } from 'react'; import { i18n } from '@kbn/i18n'; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.scss b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.scss deleted file mode 100644 index af1bdcb459093..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.scss +++ /dev/null @@ -1,13 +0,0 @@ -.lnsHelpPopover__panel { - max-inline-size: $euiSize * 30 !important; -} - -.lnsHelpPopover__content { - max-height: 40vh; - padding: $euiSizeM; - @include euiYScrollWithShadows; -} - -.lnsHelpPopover__buttonIcon { - margin-right: $euiSizeXS; -} diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.tsx index 2eeb3c1c2ee2b..e7425462b5fd8 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.tsx @@ -16,10 +16,10 @@ import { EuiWrappingPopoverProps, EuiPopoverTitle, EuiText, + UseEuiTheme, } from '@elastic/eui'; import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; import { StartServices } from '../../types'; -import './help_popover.scss'; export const HelpPopoverButton = ({ children, @@ -31,14 +31,34 @@ export const HelpPopoverButton = ({ return ( - - + {children} ); }; +const HelpPopoverContent = ({ title, children }: { title?: string; children: ReactNode }) => { + return ( + <> + {title && {title}} + + {children} + + + ); +}; + +const HelpPopoverStyles = { + button: ({ euiTheme }: UseEuiTheme) => ` + margin-right: ${euiTheme.size.xs}; + `, + content: ({ euiTheme }: UseEuiTheme) => ` + max-height: 40vh; + padding: ${euiTheme.size.m}; + `, +}; + export const HelpPopover = ({ anchorPosition, button, @@ -58,18 +78,13 @@ export const HelpPopover = ({ - {title && {title}} - - - {children} - + {children} ); }; @@ -96,18 +111,13 @@ export const WrappingHelpPopover = ({ - {title && {title}} - - - {children} - + {children} ); diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.scss b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.scss deleted file mode 100644 index 6838812e4b999..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.scss +++ /dev/null @@ -1,3 +0,0 @@ -.lnsIndexPatternDimensionEditor__filtersEditor { - width: $euiSize * 60; -} diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx index 1f3f5ba94e63b..9ec4647826fb9 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx @@ -5,10 +5,8 @@ * 2.0. */ -import './filter_popover.scss'; - import React, { useState } from 'react'; -import { EuiPopover, EuiSpacer } from '@elastic/eui'; +import { EuiPopover, EuiSpacer, euiTextBreakWord, useEuiFontSize, UseEuiTheme } from '@elastic/eui'; import type { Query } from '@kbn/es-query'; // Need to keep it separate to make it work Jest mocks in dimension_panel tests // import { QueryInput } from '../../../../shared_components/query_input'; @@ -66,7 +64,9 @@ export const FilterPopover = ({ return ( ); }; + +export const DraggablePopoverButtonStyles = ({ euiTheme }: UseEuiTheme) => { + const euiFontSize = useEuiFontSize('s'); + return ` + ${euiTextBreakWord()}; + ${euiFontSize}; + min-height: ${euiTheme.size.xl}; + width: 100%; + `; +}; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.scss b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.scss deleted file mode 100644 index 37cf1ee582768..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.scss +++ /dev/null @@ -1,6 +0,0 @@ -.lnsFiltersOperation__popoverButton { - @include euiTextBreakWord; - @include euiFontSizeS; - min-height: $euiSizeXL; - width: 100%; -} diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx index 9b2a88f657f07..1fb2bc81c97cd 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import './filters.scss'; import React, { useState } from 'react'; import { omit } from 'lodash'; import { i18n } from '@kbn/i18n'; @@ -24,7 +23,7 @@ import { IndexPattern } from '../../../../../types'; import { updateColumnParam } from '../../layer_helpers'; import type { OperationDefinition } from '..'; import type { BaseIndexPatternColumn } from '../column_types'; -import { FilterPopover } from './filter_popover'; +import { DraggablePopoverButtonStyles, FilterPopover } from './filter_popover'; import { TermsIndexPatternColumn } from '../terms'; import { isColumnOfType } from '../helpers'; @@ -275,6 +274,7 @@ export const FilterList = ({ title={i18n.translate('xpack.lens.indexPattern.filters.clickToEdit', { defaultMessage: 'Click to edit', })} + css={DraggablePopoverButtonStyles} > {filter.label || (filter.input.query as string) || defaultLabel} @@ -285,9 +285,7 @@ export const FilterList = ({ })} { - onAddFilter(); - }} + onClick={onAddFilter} label={i18n.translate('xpack.lens.indexPattern.filters.addaFilter', { defaultMessage: 'Add a filter', })} diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.scss b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.scss deleted file mode 100644 index 4af490e7479da..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.scss +++ /dev/null @@ -1,10 +0,0 @@ -.lnsRangesOperation__popoverButton { - @include euiTextBreakWord; - @include euiFontSizeS; - min-height: $euiSizeXL; - width: 100%; -} - -.lnsRangesOperation__popoverNumberField { - width: 14ch; // Roughly 10 characters plus extra for the padding -} diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx index c196c3191bae3..4118b35bf7320 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx @@ -5,8 +5,6 @@ * 2.0. */ -import './advanced_editor.scss'; - import React, { useState, useCallback } from 'react'; import { i18n } from '@kbn/i18n'; import { @@ -28,11 +26,13 @@ import { DraggableBucketContainer, NewBucketButton, } from '@kbn/visualization-ui-components'; +import { css } from '@emotion/react'; import { useDebounceWithOptions } from '../../../../../shared_components'; import { RangeTypeLens, isValidRange } from './ranges'; import { FROM_PLACEHOLDER, TO_PLACEHOLDER, TYPING_DEBOUNCE_TIME } from './constants'; import { LabelInput } from '../shared_components'; import { isValidNumber } from '../helpers'; +import { DraggablePopoverButtonStyles } from '../filters/filter_popover'; const generateId = htmlIdGenerator(); @@ -101,7 +101,9 @@ export const RangePopover = ({ { const newRange = { @@ -132,7 +134,9 @@ export const RangePopover = ({ { if (toRef && node) { @@ -303,8 +307,8 @@ export const AdvancedRangeEditor = ({ changeActiveRange(range.id)} - className="lnsRangesOperation__popoverButton" - data-test-subj="indexPattern-ranges-popover-trigger" + data-test-subj="dataView-ranges-popover-trigger" + css={DraggablePopoverButtonStyles} > { ); expect( - instance.find('[data-test-subj="indexPattern-ranges-popover-trigger"]').first().text() + instance.find('[data-test-subj="dataView-ranges-popover-trigger"]').first().text() ).toBe('0 - 1000'); }); @@ -560,7 +560,7 @@ describe('ranges', () => { ); expect( - instance.find('[data-test-subj="indexPattern-ranges-popover-trigger"]').first().text() + instance.find('[data-test-subj="dataView-ranges-popover-trigger"]').first().text() ).not.toBe('Error'); }); diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/shared_components/form_row.scss b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/shared_components/form_row.scss deleted file mode 100644 index accbb4060e797..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/shared_components/form_row.scss +++ /dev/null @@ -1,3 +0,0 @@ -.lnsIndexPatternDimensionEditor__labelCustomRank { - min-width: 96px; -} \ No newline at end of file diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/shared_components/form_row.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/shared_components/form_row.tsx index 3961ff1b8a0de..b989a5b6ba3c9 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/shared_components/form_row.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/shared_components/form_row.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { EuiFormLabel, EuiFormRow, EuiFormRowProps } from '@elastic/eui'; -import './form_row.scss'; +import { css } from '@emotion/react'; type FormRowProps = EuiFormRowProps & { isInline?: boolean }; @@ -20,7 +20,11 @@ export const FormRow = ({ children, label, isInline, ...props }: FormRowProps) =
{React.cloneElement(children, { prepend: ( - + {label} ), diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.scss b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.scss deleted file mode 100644 index 5fab178a9d1f5..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.scss +++ /dev/null @@ -1,17 +0,0 @@ - -.lnsLayerAddButton { - &:last-child { - align-self: unset; - } - &:hover { - text-decoration: none; - - .lnsLayerAddButton__label { - text-decoration: underline; - } - - .lnsLayerAddButton__techBadge, - .lnsLayerAddButton__techBadge * { - cursor: pointer; - }} -} diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.tsx index 13694613d40fe..899125dac6a4e 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/dimension_container.tsx @@ -5,8 +5,6 @@ * 2.0. */ -import './dimension_container.scss'; - import React from 'react'; import { FlyoutContainer } from '../../../shared_components/flyout_container'; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.scss b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.scss index 83cc6f95120b3..c9c40529ea68f 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.scss +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.scss @@ -1,5 +1,3 @@ -@import '../../../mixins'; - .lnsLayerPanel { margin-bottom: $euiSize; @@ -82,6 +80,33 @@ } } +// Removes EUI focus ring +@mixin removeEuiFocusRing { + outline: none; + + &:focus-visible { + outline-style: none; + } +} + +// Passes focus ring styles down to a child of a focused element +@mixin passDownFocusRing($target) { + @include removeEuiFocusRing; + + #{$target} { + @include euiFocusBackground; + outline: $euiFocusRingSize solid currentColor; // Safari & Firefox + } + + &:focus-visible #{$target} { + outline-style: auto; // Chrome + } + + &:not(:focus-visible) #{$target} { + outline: none; + } +} + // Added .lnsLayerPanel__dimension specificity required for animation style override .lnsLayerPanel__dimension .lnsLayerPanel__dimensionLink { &:focus { diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/data_panel_wrapper.scss b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/data_panel_wrapper.scss deleted file mode 100644 index 261d6672df93a..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/data_panel_wrapper.scss +++ /dev/null @@ -1,10 +0,0 @@ -.lnsDataPanelWrapper { - flex: 1 0 100%; - overflow: hidden; -} - -.lnsDataPanelWrapper__switchSource { - position: absolute; - right: $euiSize + $euiSizeXS; - top: $euiSize + $euiSizeXS; -} diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/data_panel_wrapper.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/data_panel_wrapper.tsx index da78db7ed0bc6..4df8633e4e664 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/data_panel_wrapper.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/data_panel_wrapper.tsx @@ -5,8 +5,6 @@ * 2.0. */ -import './data_panel_wrapper.scss'; - import React, { useMemo, memo, useEffect, useCallback } from 'react'; import { Storage } from '@kbn/kibana-utils-plugin/public'; import { UiActionsStart } from '@kbn/ui-actions-plugin/public'; @@ -15,6 +13,7 @@ import { EventAnnotationServiceType } from '@kbn/event-annotation-plugin/public' import { DragDropIdentifier } from '@kbn/dom-drag-drop'; import memoizeOne from 'memoize-one'; import { isEqual } from 'lodash'; +import { css } from '@emotion/react'; import { Easteregg } from './easteregg'; import { StateSetter, @@ -194,7 +193,14 @@ export const DataPanelWrapper = memo((props: DataPanelWrapperProps) => { <> {DataPanelComponent && ( -
+
{DataPanelComponent(datasourceProps)}
)} diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.scss b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.scss index 143de90e44d71..563ac572d230c 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.scss +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.scss @@ -1,4 +1,5 @@ -@import '../../variables'; +$lnsPanelMinWidth: $euiSize * 18; + .lnsFrameLayout { padding: 0; @@ -67,7 +68,7 @@ a tilemap in an iframe: https://github.com/elastic/kibana/issues/16457 */ // This also means needing to add same amount of margin to page content and suggestion items padding: $euiSize $euiSize 0; position: relative; - z-index: $lnsZLevel1; + z-index: 1; border-left: $euiBorderThin; border-right: $euiBorderThin; @include euiScrollBar; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.scss b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.scss index a4af057dd33b0..04c5bb5b9953c 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.scss +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.scss @@ -1,5 +1,21 @@ -@import '../../mixins'; -@import '../../variables'; + +// SASSTODO: Create this in EUI +@mixin lnsOverflowShadowHorizontal { + $hideHeight: $euiScrollBarCorner * 1.25; + mask-image: linear-gradient( + to right, + transparentize($euiColorDanger, .9) 0%, + transparentize($euiColorDanger, 0) $hideHeight, + transparentize($euiColorDanger, 0) calc(100% - #{$hideHeight}), + transparentize($euiColorDanger, .9) 100% + ); +} + +// These sizes also match canvas' page thumbnails for consistency +$lnsSuggestionHeight: 100px; +$lnsSuggestionWidth: 150px; + + .lnsSuggestionPanel .euiAccordion__buttonContent { width: 100%; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.scss b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.scss deleted file mode 100644 index ba2d455c97692..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.scss +++ /dev/null @@ -1,5 +0,0 @@ -.lnsVisualizeGeoFieldWorkspacePanel__dragDrop { - padding: $euiSizeXXL ($euiSizeXL * 2); - border: $euiBorderThin; - border-radius: $euiBorderRadius; -} diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx index 781f28ac1f86c..80cf82d67ff72 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx @@ -6,7 +6,7 @@ */ import React from 'react'; -import { EuiText } from '@elastic/eui'; +import { EuiText, UseEuiTheme } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { UiActionsStart, VISUALIZE_GEO_FIELD_TRIGGER } from '@kbn/ui-actions-plugin/public'; @@ -15,7 +15,6 @@ import { Droppable } from '@kbn/dom-drag-drop'; import { IndexPattern } from '../../../types'; import { getVisualizeGeoFieldMessage } from '../../../utils'; import { APP_ID } from '../../../../common/constants'; -import './geo_field_workspace_panel.scss'; interface Props { fieldType: string; @@ -53,7 +52,7 @@ export function GeoFieldWorkspacePanel(props: Props) { ); } + +export const DroppableStyles = ({ euiTheme }: UseEuiTheme) => { + return ` + padding: ${euiTheme.size.xxl} ${euiTheme.size.xxxl}; + border: ${euiTheme.border.thin}; + border-radius: ${euiTheme.border.radius}; + `; +}; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/message_list.scss b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/message_list.scss deleted file mode 100644 index 6d91fc7d6465f..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/message_list.scss +++ /dev/null @@ -1,26 +0,0 @@ -.lnsWorkspaceWarning__buttonText { - @include euiBreakpoint('xs', 's', 'm', 'l') { - @include euiScreenReaderOnly; - } -} - -.lnsWorkspaceWarningList { - max-height: $euiSize * 20; - width: $euiSize * 16; - @include euiYScroll; -} - -.lnsWorkspaceWarningList__item { - & + & { - border-top: $euiBorderThin; - } -} - -.lnsWorkspaceWarningList__textItem { - padding: $euiSize; -} - -.lnsWorkspaceWarningList__description { - overflow-wrap: break-word; - min-width: 0; -} diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/message_list.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/message_list.tsx index 75bd18c0f8457..beea72f2c5202 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/message_list.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/message_list.tsx @@ -6,7 +6,6 @@ */ import './workspace_panel_wrapper.scss'; -import './message_list.scss'; import React, { useState } from 'react'; import { @@ -17,6 +16,7 @@ import { EuiToolTip, EuiFlexGroup, EuiFlexItem, + UseEuiTheme, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { css, SerializedStyles } from '@emotion/react'; @@ -78,7 +78,6 @@ export const MessageList = ({ minWidth={0} color={errorCount ? 'danger' : 'warning'} onClick={onButtonClick} - className="lnsWorkspaceWarning__button" data-test-subj="lens-message-list-trigger" title={buttonLabel} css={customButtonStyles} @@ -106,11 +105,11 @@ export const MessageList = ({ isOpen={isPopoverOpen} closePopover={closePopover} > -
    +
      {messages.map(({ hidePopoverIcon = false, ...message }, index) => (
    • {typeof message.longMessage === 'function' ? ( @@ -119,7 +118,7 @@ export const MessageList = ({ {!hidePopoverIcon && ( @@ -130,7 +129,7 @@ export const MessageList = ({ )} )} - + {message.longMessage} @@ -141,3 +140,22 @@ export const MessageList = ({ ); }; + +const WorkspaceWarningListStyles = { + self: css` + max-height: 320px; + width: 256px; + `, + item: ({ euiTheme }: UseEuiTheme) => ` + & + & { + border-top: 1px solid ${euiTheme.colors.lightShade}; + } + `, + textItem: ({ euiTheme }: UseEuiTheme) => ` + padding: ${euiTheme.size.base} + `, + description: css` + overflow-wrap: break-word; + min-width: 0; + `, +}; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx index a9552c1399558..900310f213ca4 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx @@ -773,7 +773,6 @@ export const VisualizationWrapper = ({ ref={nodeRef} > { return ( -
      +
      ` + clip-path: polygon(-100% 0, 100% 0, 100% 100%, -100% 100%); + max-inline-size: 640px; + min-inline-size: 256px; + background:${euiTheme.colors.backgroundBaseSubdued}; + @include euiBreakpoint('xs', 's', 'm') { + clip-path: none; + } + .kbnOverlayMountWrapper { + padding-left: 400px; + margin-left: -400px; + pointer-events: none; + .euiFlyoutFooter { + pointer-events: auto; + } + } +`; + +export const InlineFlyoutFlyoutBodyStyles = ({ euiTheme }: UseEuiTheme) => ` +// styles needed to display extra drop targets that are outside of the config panel main area +overflow-y: auto; +padding-left: 400px; +margin-left: -400px; +pointer-events: none; +.euiFlyoutBody__overflow { +transform: initial; +-webkit-mask-image: none; +padding-left: inherit; +margin-left: inherit; +${!isScrollable && `overflow-y: hidden;`} +> * { +pointer-events: auto; +} +} +.euiFlyoutBody__overflowContent { +padding: 0; +block-size: 100%; +} +`; diff --git a/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/mount.tsx b/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/mount.tsx index 566c5b27b6541..1e765d932665c 100644 --- a/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/mount.tsx +++ b/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/mount.tsx @@ -10,6 +10,7 @@ import { TracksOverlays } from '@kbn/presentation-containers'; import { toMountPoint } from '@kbn/react-kibana-mount'; import React from 'react'; import ReactDOM from 'react-dom'; +import { InlineFlyoutStyles } from './flyout.styles'; /** * Shared logic to mount the inline config panel @@ -41,6 +42,7 @@ export function mountInlineEditPanel( ), { className: 'lnsConfigPanel__overlay', + css: InlineFlyoutStyles, size: 's', 'data-test-subj': 'customizeLens', type: 'push', diff --git a/x-pack/platform/plugins/shared/lens/public/react_embeddable/user_messages/error_panel.tsx b/x-pack/platform/plugins/shared/lens/public/react_embeddable/user_messages/error_panel.tsx index ee050382914c8..01c054a1e705c 100644 --- a/x-pack/platform/plugins/shared/lens/public/react_embeddable/user_messages/error_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/react_embeddable/user_messages/error_panel.tsx @@ -8,6 +8,7 @@ import { EuiEmptyPrompt } from '@elastic/eui'; import React from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; +import { css } from '@emotion/react'; import { UserMessage } from '../../types'; import { getLongMessage } from '../../user_messages_utils'; @@ -24,7 +25,16 @@ export function VisualizationErrorPanel({ const showMore = errors.length > 1; const canFixInLens = canEdit && errors.some(({ fixableInEditor }) => fixableInEditor); return ( -
      +
      { @@ -65,7 +64,13 @@ export const EmbeddableFeatureBadge = ({ messages }: { messages: UserMessage[] } gap: ${euiTheme.size.xs}; } &:hover { - color: ${euiTheme.colors.text}; + color: ${euiTheme.colors.textParagraph}; + } + // Make the visualization modifiers icon appear only on panel hover + .embPanel__content:hover & { + background: ${euiTheme.colors.backgroundBasePlain}; + transition: color ${euiTheme.animation.slow}, background ${euiTheme.animation.slow}; + color: ${euiTheme.colors.textParagraph}; } `} iconType="wrench" @@ -101,7 +106,7 @@ export const EmbeddableFeatureBadge = ({ messages }: { messages: UserMessage[] }

      {shortMessage}

      -
        +
          {messageGroup.map((message, i) => ( {getLongMessage(message)} ))} diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout.styles.ts b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout.styles.ts new file mode 100644 index 0000000000000..af97129f606ca --- /dev/null +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout.styles.ts @@ -0,0 +1,37 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { UseEuiTheme, useEuiShadow } from '@elastic/eui'; +import { css, keyframes } from '@emotion/react'; + +const flyoutOpenCloseAnimation = keyframes` + 0% { + opacity: 0; + transform: translateX(100%); + } + 75% { + opacity: 1; + transform: translateX(0%); + } +`; + +export const FlyoutContainerStyles = ({ euiTheme }: UseEuiTheme) => css` + border-left: ${euiTheme.border.thin}; + ${useEuiShadow('xl')}; + position: fixed; + top: 0; + bottom: 0; + right: 0; + height: 100%; + z-index: ${euiTheme.levels.flyout}; + background: ${euiTheme.colors.backgroundBasePlain}; + display: flex; + flex-direction: column; + align-items: stretch; + animation: ${flyoutOpenCloseAnimation} ${euiTheme.animation.normal} + ${euiTheme.animation.resistance}; +`; diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.scss b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.scss deleted file mode 100644 index 2d26d07d8a682..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.scss +++ /dev/null @@ -1,47 +0,0 @@ -@import '../mixins'; - -.lnsDimensionContainer { - // Use the EuiFlyout style - @include euiFlyout; - // But with custom positioning to keep it within the sidebar contents - animation: euiFlyoutAnimation $euiAnimSpeedNormal $euiAnimSlightResistance; - max-width: none !important; - left: 0; - z-index: $euiZContentMenu; - - @include euiBreakpoint('m', 'l', 'xl') { - height: 100% !important; - position: absolute; - top: 0 !important; - } - - .lnsFrameLayout__sidebar-isFullscreen & { - border-left: $euiBorderThin; // Force border regardless of theme in fullscreen - box-shadow: none; - } -} - -.lnsDimensionContainer__header { - padding: $euiSize; - - .lnsFrameLayout__sidebar-isFullscreen & { - display: none; - } -} - -.lnsDimensionContainer__content { - flex: 1; - @include euiYScroll; -} - -.lnsDimensionContainer__footer { - padding: $euiSize; - - .lnsFrameLayout__sidebar-isFullscreen & { - display: none; - } -} - -.lnsBody--overflowHidden { - overflow: hidden; -} \ No newline at end of file diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx index 2b865daa31c08..d4dc11ee9d50c 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx @@ -5,8 +5,6 @@ * 2.0. */ -import './flyout_container.scss'; - import React, { useState, useEffect, useCallback } from 'react'; import { css } from '@emotion/react'; import { @@ -18,9 +16,12 @@ import { EuiFlexGroup, EuiFlexItem, EuiFocusTrap, + UseEuiTheme, + euiBreakpoint, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { DONT_CLOSE_DIMENSION_CONTAINER_ON_CLICK_CLASS } from '../utils'; +import { FlyoutContainerStyles } from './flyout.styles'; function fromExcludedClickTarget(event: Event) { for ( @@ -69,12 +70,14 @@ export function FlyoutContainer({ useEffect(() => { if (!isInlineEditing) { - document.body.classList.toggle('lnsBody--overflowHidden', isOpen); + if (isOpen) { + document.body.style.overflow = isOpen ? 'hidden' : ''; + } return () => { if (isOpen) { setFocusTrapIsEnabled(false); } - document.body.classList.remove('lnsBody--overflowHidden'); + document.body.style.overflow = ''; }; } }, [isInlineEditing, isOpen]); @@ -100,10 +103,13 @@ export function FlyoutContainer({ ref={panelContainerRef} role="dialog" aria-labelledby="lnsDimensionContainerTitle" - className="lnsDimensionContainer" - css={css` - box-shadow: ${isInlineEditing ? 'none !important' : 'inherit'}; - `} + css={[ + FlyoutContainerStyles, + css` + box-shadow: ${isInlineEditing ? 'none !important' : 'inherit'}; + `, + DimensionContainerStyles.self, + ]} onAnimationEnd={() => { if (isOpen) { // EuiFocusTrap interferes with animating elements with absolute position: @@ -113,7 +119,7 @@ export function FlyoutContainer({ } }} > - + {isInlineEditing && ( @@ -131,12 +137,7 @@ export function FlyoutContainer({ )} -

          - {label} -

          +

          {label}

          @@ -157,10 +158,17 @@ export function FlyoutContainer({
          -
          {children}
          +
          + {children} +
          {customFooter || ( - + ); } + +const DimensionContainerStyles = { + self: (euiThemeContext: UseEuiTheme) => { + return ` + // But with custom positioning to keep it within the sidebar contents + max-width: none !important; + left: 0; + z-index: ${euiThemeContext.euiTheme.levels.menu}; + ${euiBreakpoint(euiThemeContext, ['m', 'l', 'xl'])} { + height: 100% !important; + position: absolute; + top: 0 !important; + } + + .lnsFrameLayout__sidebar-isFullscreen & { + border-left: ${ + euiThemeContext.euiTheme.border.thin + }; // Force border regardless of theme in fullscreen + box-shadow: none; + } + `; + }, + header: ({ euiTheme }: UseEuiTheme) => css` + padding: ${euiTheme.size.base}; + `, + footer: ({ euiTheme }: UseEuiTheme) => css` + padding: ${euiTheme.size.base}; + `, +}; diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.scss b/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.scss deleted file mode 100644 index 27dc29ed8af0c..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.scss +++ /dev/null @@ -1,28 +0,0 @@ -@import '../mixins'; - -.lnsSettingWithSiblingFlyout { - // Use the EuiFlyout style - @include euiFlyout; - // But with custom positioning to keep it within the sidebar contents - position: absolute; - right: 0; - left: 0; - top: 0; - bottom: 0; - animation: euiFlyoutAnimation $euiAnimSpeedNormal $euiAnimSlightResistance; - // making just a bit higher than the dimension flyout to stack on top of it - z-index: $euiZLevel3 + 1 -} - -.lnsSettingWithSiblingFlyout__header { - padding: $euiSize; -} - -.lnsSettingWithSiblingFlyout__content { - flex: 1; - @include euiYScroll; -} - -.lnsSettingWithSiblingFlyout__footer { - padding: $euiSize; -} \ No newline at end of file diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx index fed4702e697b9..b024b6df3b57a 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx @@ -5,8 +5,6 @@ * 2.0. */ -import './setting_with_sibling_flyout.scss'; - import { i18n } from '@kbn/i18n'; import React, { useState, useEffect, MutableRefObject } from 'react'; import { @@ -20,7 +18,10 @@ import { EuiFocusTrap, EuiOutsideClickDetector, EuiPortal, + UseEuiTheme, } from '@elastic/eui'; +import { css } from '@emotion/react'; +import { FlyoutContainerStyles } from './flyout.styles'; const DEFAULT_TITLE = i18n.translate('xpack.lens.colorSiblingFlyoutTitle', { defaultMessage: 'Color', @@ -74,9 +75,9 @@ export function SettingWithSiblingFlyout({ role="dialog" aria-labelledby="lnsSettingWithSiblingFlyoutTitle" data-test-subj={dataTestSubj} - className="lnsSettingWithSiblingFlyout" + css={[FlyoutContainerStyles, SiblingFlyoutContainerStyles.self]} > - + -

          - {title} -

          +

          {title}

          - {children &&
          {children}
          } + {children && ( +
          + {children} +
          + )} - + {i18n.translate('xpack.lens.settingWithSiblingFlyout.back', { defaultMessage: 'Back', @@ -120,3 +125,21 @@ export function SettingWithSiblingFlyout({ ); } + +const SiblingFlyoutContainerStyles = { + self: ({ euiTheme }: UseEuiTheme) => css` + position: absolute; + right: 0; + left: 0; + top: 0; + bottom: 0; + // making just a bit higher than the dimension flyout to stack on top of it + z-index: ${euiTheme.levels.menu}; + `, + header: ({ euiTheme }: UseEuiTheme) => css` + padding: ${euiTheme.size.base}; + `, + footer: ({ euiTheme }: UseEuiTheme) => css` + padding: ${euiTheme.size.base}; + `, +}; diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/toolbar_popover.scss b/x-pack/platform/plugins/shared/lens/public/shared_components/toolbar_popover.scss deleted file mode 100644 index 823859866eb2a..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/toolbar_popover.scss +++ /dev/null @@ -1,3 +0,0 @@ -.lnsVisToolbar__popover { - width: 410px; -} diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/toolbar_popover.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/toolbar_popover.tsx index 042853735fcd8..94325995b05a3 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/toolbar_popover.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/toolbar_popover.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import './toolbar_popover.scss'; import React, { PropsWithChildren, useState } from 'react'; import { EuiFlexItem, EuiPopover, EuiPopoverProps, EuiPopoverTitle, IconType } from '@elastic/eui'; import { ToolbarButton, ToolbarButtonProps } from '@kbn/shared-ux-button-toolbar'; @@ -41,6 +40,8 @@ export type ToolbarPopoverProps = Partial & { handleClose?: () => void; }; +const defaultPanelStyles = { width: '410px' }; + export const ToolbarPopover: React.FC> = ({ children, title, @@ -49,7 +50,7 @@ export const ToolbarPopover: React.FC> = groupPosition, buttonDataTestSubj, handleClose, - panelClassName = 'lnsVisToolbar__popover', + panelStyle = defaultPanelStyles, ...euiPopoverProps }) => { const [isOpen, setIsOpen] = useState(false); @@ -59,7 +60,7 @@ export const ToolbarPopover: React.FC> = return ( { - const renderVisContainer = (props?: React.HTMLAttributes) => { - return render(Hello!); - }; - test('renders child content', () => { - renderVisContainer(); - expect(screen.getByText('Hello!')).toBeInTheDocument(); - }); - - test('renders style', () => { - renderVisContainer({ style: { color: 'blue' } }); - expect(screen.getByText('Hello!')).toHaveStyle({ color: 'blue' }); - }); - - test('combines class names with container class', () => { - renderVisContainer({ className: 'myClass' }); - expect(screen.getByText('Hello!')).toHaveClass('myClass lnsVisualizationContainer'); - }); -}); diff --git a/x-pack/platform/plugins/shared/lens/public/visualization_container.tsx b/x-pack/platform/plugins/shared/lens/public/visualization_container.tsx deleted file mode 100644 index a9020278db235..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/visualization_container.tsx +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import './visualization_container.scss'; - -import React from 'react'; -import classNames from 'classnames'; - -export function VisualizationContainer({ - children, - className, - ...rest -}: React.HTMLAttributes) { - return ( -
          - {children} -
          - ); -} diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/dimension_editor.scss b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/dimension_editor.scss deleted file mode 100644 index ef998626f6127..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/dimension_editor.scss +++ /dev/null @@ -1,3 +0,0 @@ -.lnsDynamicColoringRow { - align-items: center; -} diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/dimension_editor.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/dimension_editor.tsx index 8fd8b98406e31..a5ec753af0d63 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/dimension_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/dimension_editor.tsx @@ -28,8 +28,6 @@ import { findMinMaxByColumnId, shouldColorByTerms, } from '../../../shared_components'; - -import './dimension_editor.scss'; import { CollapseSetting } from '../../../shared_components/collapse_setting'; import { ColorMappingByValues } from '../../../shared_components/coloring/color_mapping_by_values'; import { ColorMappingByTerms } from '../../../shared_components/coloring/color_mapping_by_terms'; diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/dimension_editor_addtional_section.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/dimension_editor_addtional_section.tsx index 93c14230f63d9..e51f866197a6b 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/dimension_editor_addtional_section.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/dimension_editor_addtional_section.tsx @@ -24,8 +24,6 @@ import { import { isNumericFieldForDatatable } from '../../../../common/expressions/datatable/utils'; import { DatatableInspectorTables } from '../../../../common/expressions/datatable/datatable_fn'; -import './dimension_editor.scss'; - type ColumnType = DatatableVisualizationState['columns'][number]; type SummaryRowType = Extract; diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.scss b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.scss deleted file mode 100644 index 0f0ed53a10021..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.scss +++ /dev/null @@ -1,19 +0,0 @@ -.lnsDataTableContainer { - height: 100%; -} - -.lnsTableCell--multiline { - white-space: pre-wrap; -} - -.lnsTableCell--left { - text-align: left; -} - -.lnsTableCell--right { - text-align: right; -} - -.lnsTableCell--center { - text-align: center; -} \ No newline at end of file diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.test.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.test.tsx index 992e79681d415..55f31cfcf03ed 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.test.tsx @@ -308,7 +308,7 @@ describe('DatatableComponent', () => { rows: [{ a: undefined, b: undefined, c: undefined }], }, }); - expect(screen.getByTestId('lnsVisualizationContainer')).toHaveTextContent('No results found'); + expect(screen.getByTestId('lnsDataTableContainer')).toHaveTextContent('No results found'); }); test('it renders the table with the given sorting', async () => { diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.tsx index 3bbacf124668f..a82f4aebf1fc4 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import './table_basic.scss'; import { ColorMappingInputData, PaletteOutput, getFallbackDataBounds } from '@kbn/coloring'; import React, { useLayoutEffect, @@ -35,11 +34,11 @@ import { getColorCategories } from '@kbn/chart-expressions-common'; import { getOriginalId } from '@kbn/transpose-utils'; import { CoreTheme } from '@kbn/core/public'; import { getKbnPalettes } from '@kbn/palettes'; +import { css } from '@emotion/react'; import type { LensTableRowContextMenuEvent } from '../../../types'; import type { FormatFactory } from '../../../../common/types'; import { RowHeightMode } from '../../../../common/types'; import { LensGridDirection } from '../../../../common/expressions'; -import { VisualizationContainer } from '../../../visualization_container'; import { findMinMaxByColumnId, shouldColorByTerms } from '../../../shared_components'; import type { DataContextType, @@ -507,9 +506,13 @@ export const DatatableComponent = (props: DatatableRenderProps) => { if (isEmpty) { return ( - +
          - +
          ); } @@ -520,7 +523,11 @@ export const DatatableComponent = (props: DatatableRenderProps) => { }); return ( - +
          { ref={dataGridRef} /> - +
          ); }; + +const DatatableContainerStyles = css` + height: 100%; + overflow: auto hidden; + user-select: text; + + .lnsTableCell--multiline { + white-space: pre-wrap; + } + + .lnsTableCell--left { + text-align: left; + } + + .lnsTableCell--right { + text-align: right; + } + + .lnsTableCell--center { + text-align: center; + } +`; diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/gauge/dimension_editor.scss b/x-pack/platform/plugins/shared/lens/public/visualizations/gauge/dimension_editor.scss deleted file mode 100644 index d7664b9d2da16..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/gauge/dimension_editor.scss +++ /dev/null @@ -1,3 +0,0 @@ -.lnsDynamicColoringRow { - align-items: center; -} \ No newline at end of file diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/gauge/dimension_editor.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/gauge/dimension_editor.tsx index 8c1d3bd96f2d3..c658e3089fe5d 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/gauge/dimension_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/gauge/dimension_editor.tsx @@ -17,6 +17,7 @@ import { import { GaugeTicksPositions, GaugeColorModes } from '@kbn/expression-gauge-plugin/common'; import { getMaxValue, getMinValue } from '@kbn/expression-gauge-plugin/public'; import { TooltipWrapper } from '@kbn/visualization-utils'; +import { css } from '@emotion/react'; import { isNumericFieldForDatatable } from '../../../common/expressions/datatable/utils'; import { PalettePanelContainer } from '../../shared_components'; import type { VisualizationDimensionEditorProps } from '../../types'; @@ -24,8 +25,6 @@ import type { GaugeVisualizationState } from './constants'; import { defaultPaletteParams } from './palette_config'; import { getAccessorsFromState } from './utils'; -import './dimension_editor.scss'; - export function GaugeDimensionEditor( props: VisualizationDimensionEditorProps & { paletteService: PaletteRegistry; @@ -74,7 +73,9 @@ export function GaugeDimensionEditor( label={i18n.translate('xpack.lens.gauge.dynamicColoring.label', { defaultMessage: 'Band colors', })} - className="lnsDynamicColoringRow" + css={css` + align-items: center; + `} > color)} diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/gauge/toolbar_component/gauge_config_panel.scss b/x-pack/platform/plugins/shared/lens/public/visualizations/gauge/toolbar_component/gauge_config_panel.scss deleted file mode 100644 index 893ed71235881..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/gauge/toolbar_component/gauge_config_panel.scss +++ /dev/null @@ -1,3 +0,0 @@ -.lnsGaugeToolbar__popover { - width: 500px; -} \ No newline at end of file diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/gauge/toolbar_component/index.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/gauge/toolbar_component/index.tsx index a91aabd812b19..3bea80673a661 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/gauge/toolbar_component/index.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/gauge/toolbar_component/index.tsx @@ -26,7 +26,6 @@ import { } from '@kbn/chart-icons'; import type { VisualizationToolbarProps } from '../../../types'; import { ToolbarPopover, VisLabel } from '../../../shared_components'; -import './gauge_config_panel.scss'; import { gaugeTitlesByType, type GaugeVisualizationState } from '../constants'; const PREFIX = `lns_gaugeOrientation_`; @@ -109,7 +108,9 @@ const AppearancePopover = (props: VisualizationToolbarProps color)} diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/legacy_metric/dimension_editor.scss b/x-pack/platform/plugins/shared/lens/public/visualizations/legacy_metric/dimension_editor.scss deleted file mode 100644 index d7664b9d2da16..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/legacy_metric/dimension_editor.scss +++ /dev/null @@ -1,3 +0,0 @@ -.lnsDynamicColoringRow { - align-items: center; -} \ No newline at end of file diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/legacy_metric/dimension_editor.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/legacy_metric/dimension_editor.tsx index 552b5f0a52a3f..e3f5c5cea35ce 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/legacy_metric/dimension_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/legacy_metric/dimension_editor.tsx @@ -14,14 +14,13 @@ import { import { i18n } from '@kbn/i18n'; import React from 'react'; import { ColorMode } from '@kbn/charts-plugin/common'; +import { css } from '@emotion/react'; import type { LegacyMetricState } from '../../../common/types'; import { isNumericFieldForDatatable } from '../../../common/expressions/datatable/utils'; import { PalettePanelContainer } from '../../shared_components'; import type { VisualizationDimensionEditorProps } from '../../types'; import { defaultPaletteParams } from './palette_config'; -import './dimension_editor.scss'; - const idPrefix = htmlIdGenerator()(); export function MetricDimensionEditor( @@ -134,12 +133,14 @@ export function MetricDimensionEditor( {hasDynamicColoring && ( color)} diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/partition/dimension_editor.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/partition/dimension_editor.tsx index 113c4f0d9e015..a0a94ecaf1af7 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/partition/dimension_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/partition/dimension_editor.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import './toolbar.scss'; import React from 'react'; import { i18n } from '@kbn/i18n'; import { diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/partition/toolbar.scss b/x-pack/platform/plugins/shared/lens/public/visualizations/partition/toolbar.scss deleted file mode 100644 index 3cfbe6480c61b..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/partition/toolbar.scss +++ /dev/null @@ -1,3 +0,0 @@ -.lnsPieToolbar__popover { - width: $euiFormMaxWidth; -} diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/partition/toolbar.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/partition/toolbar.tsx index 8262231ceb5d1..a10f8344da3ff 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/partition/toolbar.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/partition/toolbar.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import './toolbar.scss'; import React, { useCallback, useState } from 'react'; import { i18n } from '@kbn/i18n'; import { diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/xy/add_layer.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/xy/add_layer.tsx index 2a9f125bfa663..9f9f9f915f92d 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/xy/add_layer.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/xy/add_layer.tsx @@ -15,12 +15,11 @@ import { EuiFlexGroup, IconType, transparentize, + UseEuiTheme, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { LayerTypes } from '@kbn/expression-xy-plugin/public'; import { EventAnnotationServiceType } from '@kbn/event-annotation-plugin/public'; -import { css } from '@emotion/react'; -import { euiThemeVars } from '@kbn/ui-theme'; import { AddLayerFunction, VisualizationLayerDescription } from '../../types'; import { LoadAnnotationLibraryFlyout } from './load_annotation_library_flyout'; import type { ExtraAppendLayerArg } from './visualization'; @@ -68,15 +67,12 @@ export function AddLayerButton({ disabled, name: ( - - {label} - + {label} ), - className: 'lnsLayerAddButton', icon: icon && , ['data-test-subj']: `lnsLayerAddButton-${type}`, }; @@ -93,8 +89,7 @@ export function AddLayerButton({ panel: AddLayerPanelType.compatibleVisualizationTypes, toolTipContent, disabled, - name: {label}, - className: 'lnsLayerAddButton', + name: label, icon: icon && , ['data-test-subj']: `lnsLayerAddButton-${type}`, }; @@ -157,8 +152,7 @@ export function AddLayerButton({ return { toolTipContent, disabled, - name: {label}, - className: 'lnsLayerAddButton', + name: label, icon: icon && , ['data-test-subj']: `lnsLayerAddButton-${type}`, onClick: () => { @@ -172,8 +166,7 @@ export function AddLayerButton({ return { toolTipContent, disabled, - name: {label}, - className: 'lnsLayerAddButton', + name: label, icon: icon && , ['data-test-subj']: `lnsLayerAddButton-${type}`, onClick: () => { @@ -285,23 +278,27 @@ const ChartOptionWrapper = ({ ); }; + +const ChartOptionWrapperStyles = ({ euiTheme }: UseEuiTheme) => ` + padding: ${euiTheme.size.s}; + border-bottom: ${euiTheme.border.thin}; + border-bottom-color: ${euiTheme.colors.backgroundBaseSubdued}; + width: 100%; + &:hover, + &:focus { + color: ${euiTheme.colors.primary}; + background-color: ${transparentize(euiTheme.colors.primary, 0.1)}; + span, + .euiText { + text-decoration: underline; + color: ${euiTheme.colors.primary}; + } + } +`; diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.scss b/x-pack/platform/plugins/shared/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.scss deleted file mode 100644 index 360a76274416d..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.scss +++ /dev/null @@ -1,3 +0,0 @@ -.lnsVisToolbarAxis__popover { - width: 500px; -} \ No newline at end of file diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.tsx index 9f2b167e42b73..40622d048bff5 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/xy/xy_config_panel/axis_settings_popover.tsx @@ -29,7 +29,7 @@ import { } from '../../../shared_components'; import type { Orientation, AxesSettingsConfigKeys } from '../../../shared_components'; import { XYLayerConfig } from '../types'; -import './axis_settings_popover.scss'; + import { validateExtent } from '../../../shared_components/axis/extent/helpers'; import { getBounds } from '../../../shared_components/axis/extent/axis_extent_settings'; @@ -243,7 +243,9 @@ export const AxisSettingsPopover: React.FunctionComponent Date: Thu, 6 Feb 2025 09:42:21 +0100 Subject: [PATCH 02/37] datapanel.css --- .../datasources/common/datapanel.styles.ts | 21 +++++++++++++++ .../datasources/form_based/datapanel.scss | 27 ------------------- .../datasources/form_based/datapanel.tsx | 11 +++----- .../text_based/components/datapanel.tsx | 3 ++- .../user_messages/info_badges.tsx | 7 ++++- 5 files changed, 32 insertions(+), 37 deletions(-) create mode 100644 x-pack/platform/plugins/shared/lens/public/datasources/common/datapanel.styles.ts delete mode 100644 x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.scss diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/common/datapanel.styles.ts b/x-pack/platform/plugins/shared/lens/public/datasources/common/datapanel.styles.ts new file mode 100644 index 0000000000000..e7677f0ecc779 --- /dev/null +++ b/x-pack/platform/plugins/shared/lens/public/datasources/common/datapanel.styles.ts @@ -0,0 +1,21 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { UseEuiTheme } from '@elastic/eui'; + +export const DataPanelStyles = ({ euiTheme }: UseEuiTheme) => { + return ` + padding: ${euiTheme.size.base} ${euiTheme.size.base} 0; + .unifiedFieldListItemButton.kbnFieldButton { + background: none; + box-shadow: none; + margin-bottom: calc(${euiTheme.size.xs} / 2); + } + .unifiedFieldListItemButton__dragging { + background: ${euiTheme.colors.backgroundBasePlain}; + }`; +}; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.scss b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.scss deleted file mode 100644 index 52582d5b07a40..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.scss +++ /dev/null @@ -1,27 +0,0 @@ -.lnsInnerIndexPatternDataPanel { - width: 100%; - height: 100%; - padding: $euiSize $euiSize 0; - .unifiedFieldListItemButton.kbnFieldButton { - background: none; - box-shadow: none; - margin-bottom: calc($euiSizeXS / 2); - } - .unifiedFieldListItemButton__dragging { - background: $euiColorBackgroundBasePlain; - } -} - -.lnsInnerIndexPatternDataPanel__switcher { - min-width: 0; -} - -.lnsInnerIndexPatternDataPanel__header { - display: flex; - align-items: center; - margin-bottom: $euiSizeS; -} - -.lnsChangeIndexPatternPopover__trigger { - padding: 0 $euiSize; -} diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.tsx index ff51014f548d3..0be81a6986b44 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import './datapanel.scss'; import { uniq } from 'lodash'; import React, { memo, useCallback, useEffect, useMemo, useRef } from 'react'; import { EuiCallOut, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; @@ -41,6 +40,7 @@ import type { import type { FormBasedPrivateState } from './types'; import { IndexPatternServiceAPI } from '../../data_views_service/service'; import { FieldItem } from '../common/field_item'; +import { DataPanelStyles } from '../common/datapanel.styles'; export type FormBasedDataPanelProps = Omit< DatasourceDataPanelProps, @@ -116,12 +116,7 @@ export function FormBasedDataPanel({ return ( <> {Object.keys(indexPatterns).length === 0 && indexPatternRefs.length === 0 ? ( - + } > diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/text_based/components/datapanel.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/text_based/components/datapanel.tsx index fd61c0d063452..ddbe5cf2ba320 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/text_based/components/datapanel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/text_based/components/datapanel.tsx @@ -30,6 +30,7 @@ import type { TextBasedPrivateState } from '../types'; import { getStateFromAggregateQuery } from '../utils'; import { FieldItem } from '../../common/field_item'; import { getColumnsFromCache } from '../fieldlist_cache'; +import { DataPanelStyles } from '../../common/datapanel.styles'; const getCustomFieldType: GetCustomFieldType = (field) => field?.meta.type; @@ -137,7 +138,7 @@ export function TextBasedDataPanel({ }} > diff --git a/x-pack/platform/plugins/shared/lens/public/react_embeddable/user_messages/info_badges.tsx b/x-pack/platform/plugins/shared/lens/public/react_embeddable/user_messages/info_badges.tsx index fcb53cad0c581..50973b93491be 100644 --- a/x-pack/platform/plugins/shared/lens/public/react_embeddable/user_messages/info_badges.tsx +++ b/x-pack/platform/plugins/shared/lens/public/react_embeddable/user_messages/info_badges.tsx @@ -106,7 +106,12 @@ export const EmbeddableFeatureBadge = ({ messages }: { messages: UserMessage[] }

          {shortMessage}

          -
            +
              {messageGroup.map((message, i) => ( {getLongMessage(message)} ))} From a3dbcc1e96d34ce2c6e156b9683675b838ccd768 Mon Sep 17 00:00:00 2001 From: mbondyra Date: Thu, 6 Feb 2025 10:44:49 +0100 Subject: [PATCH 03/37] formula --- .../definitions/formula/editor/formula.scss | 100 ------------- .../formula/editor/formula_editor.tsx | 132 +++++++++++++++--- 2 files changed, 111 insertions(+), 121 deletions(-) delete mode 100644 x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula.scss diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula.scss b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula.scss deleted file mode 100644 index 89d8ed7357c8d..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula.scss +++ /dev/null @@ -1,100 +0,0 @@ -.lnsFormula { - display: flex; - flex-direction: column; - - .lnsIndexPatternDimensionEditor-isFullscreen & { - height: 100%; - } - - & > * { - flex: 1; - min-height: 0; - } - - & > * + * { - border-top: $euiBorderThin; - } -} - -.lnsFormula__editor { - .lnsIndexPatternDimensionEditor-isFullscreen & { - border-bottom: none; - display: flex; - flex-direction: column; - } - - & > * + * { - border-top: $euiBorderThin; - } -} - -.lnsFormula__editorHeader, -.lnsFormula__editorFooter { - padding: $euiSizeS; -} - -.lnsFormula__editorFooter { - // make sure docs are rendered in front of monaco - z-index: 1; - border-bottom-right-radius: $euiBorderRadius; - border-bottom-left-radius: $euiBorderRadius; -} - -.lnsFormula__editorHeaderGroup, -.lnsFormula__editorFooterGroup { - display: block; // Overrides EUI's styling of `display: flex` on `EuiFlexItem` components -} - -.lnsFormula__editorContent { - background-color: $euiColorBackgroundBasePlain; - min-height: 0; - position: relative; - - .lnsIndexPatternDimensionEditor:not(.lnsIndexPatternDimensionEditor-isFullscreen) & { - height: 200px; - } - - .lnsIndexPatternDimensionEditor-isFullscreen & { - flex: 1; - } -} - -.lnsFormula__editorPlaceholder { - position: absolute; - top: 0; - left: $euiSize; - right: 0; - color: $euiTextSubduedColor; - // Matches monaco editor - font-family: Menlo, Monaco, 'Courier New', monospace; - pointer-events: none; -} - -.lnsFormula__warningText + .lnsFormula__warningText { - margin-top: $euiSizeS; - border-top: $euiBorderThin; - padding-top: $euiSizeS; -} - -.lnsFormula__editorHelp--inline { - align-items: center; - display: flex; - padding: $euiSizeXS; - - & > * + * { - margin-left: $euiSizeXS; - } -} - -.lnsFormula__editorError { - white-space: nowrap; -} - -.lnsFormula__docs { - background: $euiColorEmptyShade; -} - -.lnsFormulaOverflow { - // Needs to be higher than the modal and all flyouts - z-index: $euiZLevel9 + 1; -} diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx index 7d0731902eee8..d90b5c7050841 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx @@ -25,10 +25,10 @@ import { EuiToolTip, EuiSpacer, useEuiTheme, + UseEuiTheme, } from '@elastic/eui'; import useUnmount from 'react-use/lib/useUnmount'; import { monaco } from '@kbn/monaco'; -import classNames from 'classnames'; import { CodeEditor, CodeEditorProps } from '@kbn/code-editor'; import { UI_SETTINGS } from '@kbn/data-plugin/public'; import { useDebounceWithOptions } from '../../../../../../shared_components'; @@ -50,7 +50,6 @@ import { } from './math_completion'; import { LANGUAGE_ID } from './math_tokenization'; -import './formula.scss'; import { FormulaIndexPatternColumn } from '../formula'; import { insertOrReplaceFormulaColumn } from '../parse'; import { filterByVisibleOperation } from '../util'; @@ -685,10 +684,7 @@ export function FormulaEditor({ // in the behavior of Monaco when it's first loaded and then reloaded. return (
              {!isFullscreen && (
              -
              +
              - + - + { toggleFullscreen(); @@ -803,7 +799,7 @@ export function FormulaEditor({ /> {!text ? ( -
              +
              {i18n.translate('xpack.lens.formulaPlaceholderText', { defaultMessage: 'Type a formula by combining functions with math, like:', @@ -815,7 +811,7 @@ export function FormulaEditor({ ) : null}
              -
              +
              {isFullscreen ? ( @@ -837,6 +833,7 @@ export function FormulaEditor({ defaultMessage: 'Hide function reference', })} className="lnsFormula__editorHelp lnsFormula__editorHelp--inline" + css={SharedEditorStyles.editorHelpLink} color="text" onClick={() => setIsHelpOpen(!isHelpOpen)} > @@ -874,6 +871,7 @@ export function FormulaEditor({ button={ {warnings.map(({ message, severity }, index) => ( -
              +
              +
              ); } + +const SharedEditorStyles = { + self: ({ euiTheme }: UseEuiTheme) => { + return ` + .lnsFormula { + display: flex; + flex-direction: column; + + & > * { + flex: 1; + min-height: 0; + } + + & > * + * { + border-top: ${euiTheme.border.thin}; + } + }; + .lnsFormulaOverflow { + // Needs to be higher than the modal and all flyouts + z-index: ${euiTheme.levels.toast} + 1; + } + .lnsFormula__editorContent { + background-color: ${euiTheme.colors.backgroundBasePlain}; + min-height: 0; + position: relative; + } + `; + }, + formulaDocs: ({ euiTheme }: UseEuiTheme) => ` + display: flex; + flex-direction: column; + // make sure docs are rendered in front of monaco + z-index: 1; + background: ${euiTheme.colors.backgroundBasePlain}; + `, + editorHeader: ({ euiTheme }: UseEuiTheme) => ` + padding: ${euiTheme.size.s}; + `, + editorFooter: ({ euiTheme }: UseEuiTheme) => ` + padding: ${euiTheme.size.s}; + // make sure docs are rendered in front of monaco + z-index: 1; + border-bottom-right-radius: ${euiTheme.border.radius.medium}; + border-bottom-left-radius: ${euiTheme.border.radius.medium}; + `, + editorPlaceholder: ({ euiTheme }: UseEuiTheme) => ` + position: absolute; + top: 0; + left: ${euiTheme.size.base}; + right: 0; + color: ${euiTheme.colors.textSubdued} + // Matches monaco editor + font-family: Menlo, Monaco, 'Courier New', monospace; + pointer-events: none; + `, + warningText: ({ euiTheme }: UseEuiTheme) => ` + + .lnsFormula__warningText { + margin-top: ${euiTheme.size.s}; + border-top: ${euiTheme.border.thin}; + padding-top: ${euiTheme.size.s}; + } + `, + editorHelpLink: ({ euiTheme }: UseEuiTheme) => ` + align-items: center; + display: flex; + padding: ${euiTheme.size.xs}; + & > * + * { + margin-left: ${euiTheme.size.xs}; + } + ` +}; + +const DefaultEditorStyles = ({ euiTheme }: UseEuiTheme) => { + return ` + .lnsFormula__editorContent { + height: 200px; + } + `; +}; + +const FullscreenEditorStyles = ({ euiTheme }: UseEuiTheme) => { + return ` + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + .lnsFormula__editor { + border-bottom: none; + display: flex; + flex-direction: column; + & > * + * { + border-top: $euiBorderThin; + } + }; + .lnsFormula__editorContent { + flex: 1; + } + `; +}; From cb37b7f14d9515089ff2d0bfaf1f5c7a27459f0d Mon Sep 17 00:00:00 2001 From: mbondyra Date: Thu, 6 Feb 2025 11:00:10 +0100 Subject: [PATCH 04/37] chart switch styles --- .../chart_switch/chart_option.tsx | 4 +- .../chart_switch/chart_switch.scss | 39 --------------- .../chart_switch/chart_switch.tsx | 1 - .../chart_switch/chart_switch_popover.tsx | 49 ++++++++++--------- .../chart_switch/chart_switch_selectable.tsx | 6 +++ 5 files changed, 32 insertions(+), 67 deletions(-) delete mode 100644 x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_switch.scss diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_option.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_option.tsx index 13dd822ece20e..4ff491d5df490 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_option.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_option.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import './chart_switch.scss'; import React from 'react'; import { EuiFlexItem, @@ -36,7 +35,7 @@ export const ChartOption = ({ `} > - + @@ -88,7 +87,6 @@ const DataLossWarning = ({ content, id }: { content?: string; id: string }) => { color={euiTheme.colors.warning} content={content} iconProps={{ - className: 'lnsChartSwitch__chartIcon', 'data-test-subj': `lnsChartSwitchPopoverAlert_${id}`, }} /> diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_switch.scss b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_switch.scss deleted file mode 100644 index 1a33ed18581f4..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_switch.scss +++ /dev/null @@ -1,39 +0,0 @@ -.lnsChartSwitch__header { - > * { - display: flex; - align-items: center; - } -} - -.lnsChartSwitch__options { - width: 384px; -} - -.lnsChartSwitch__summaryIcon { - transform: translateY(-1px); - color: $euiTextSubduedColor; - - @include euiBreakpoint('xl') { - margin-right: $euiSizeS; - } -} - -.lnsChartSwitch__summaryText { - @include euiBreakpoint('xs', 's', 'm', 'l') { - @include euiScreenReaderOnly; - } -} - -.lnsChartSwitch__append { - display: inline-flex; -} - -// Targeting img as this won't target normal EuiIcon's only the custom svgs's -img.lnsChartSwitch__chartIcon { // stylelint-disable-line selector-no-qualifying-type - // The large icons aren't square so max out the width to fill the height - width: 100%; -} - -.lnsChartSwitch__search { - width: 10 * $euiSizeXXL; -} diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_switch.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_switch.tsx index dc033435a6440..c64be98be6e1e 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_switch.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_switch.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import './chart_switch.scss'; import React, { useState, useMemo, memo } from 'react'; import { i18n } from '@kbn/i18n'; import { ExperimentalBadge } from '../../../../shared_components'; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_switch_popover.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_switch_popover.tsx index 31ae3257b8301..0e8885a53642b 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_switch_popover.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_switch_popover.tsx @@ -5,11 +5,11 @@ * 2.0. */ -import './chart_switch.scss'; import React, { useState, memo } from 'react'; import { EuiPopover } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { ChartSwitchTrigger } from '@kbn/visualization-ui-components'; +import { css } from '@emotion/react'; import { useLensSelector, selectVisualization } from '../../../../state_management'; import { ChartSwitch, ChartSwitchProps } from './chart_switch'; @@ -31,28 +31,29 @@ export const ChartSwitchPopover = memo(function ChartSwitchPopover( }; return ( -
              - setFlyoutOpen(!flyoutOpen)} - /> - } - isOpen={flyoutOpen} - closePopover={() => setFlyoutOpen(false)} - anchorPosition="downLeft" - > - {flyoutOpen ? setFlyoutOpen(false)} /> : null} - -
              + setFlyoutOpen(!flyoutOpen)} + /> + } + isOpen={flyoutOpen} + closePopover={() => setFlyoutOpen(false)} + anchorPosition="downLeft" + > + {flyoutOpen ? setFlyoutOpen(false)} /> : null} + ); }); diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_switch_selectable.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_switch_selectable.tsx index 8c1b8cb53c05a..a08bcb8a7c334 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_switch_selectable.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/chart_switch/chart_switch_selectable.tsx @@ -44,6 +44,9 @@ export const ChartSwitchSelectable = ({ isPreFiltered data-test-subj="lnsChartSwitchList" className="lnsChartSwitch__options" + css={css` + width: 384px; + `} height={computeListHeight(props.options as SelectableEntry[])} searchProps={{ compressed: true, @@ -51,6 +54,9 @@ export const ChartSwitchSelectable = ({ inputRef: (ref) => { ref?.focus({ preventScroll: true }); }, + css: css` + width: 400px; + `, className: 'lnsChartSwitch__search', 'data-test-subj': 'lnsChartSwitchSearch', onChange: setSearchTerm, From 73ed23252ebd629ee9d2f835be8def7f3938f91b Mon Sep 17 00:00:00 2001 From: mbondyra Date: Thu, 6 Feb 2025 13:22:34 +0100 Subject: [PATCH 05/37] dimension editor --- .../dimension_panel/advanced_options.tsx | 1 + .../dimension_panel/dimension_editor.scss | 65 ------------------- .../dimension_panel/dimension_editor.tsx | 24 ++++++- .../dimensions_editor_helpers.tsx | 14 ++-- .../dimension_panel/reference_editor.tsx | 6 +- .../formula/editor/formula_editor.tsx | 30 +++++++-- .../operations/definitions/terms/index.tsx | 4 ++ .../editor_frame/config_panel/layer_panel.tsx | 17 ++++- 8 files changed, 78 insertions(+), 83 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/advanced_options.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/advanced_options.tsx index c8cbfb947a9e3..2fb3822abc34d 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/advanced_options.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/advanced_options.tsx @@ -32,6 +32,7 @@ export function AdvancedOptions(props: { options: AdvancedOption[] }) { } css={css` padding: 0 ${euiTheme.size.base} ${euiTheme.size.base}; + color: ${euiTheme.colors.primary}; `} > {props.options.map(({ dataTestSubj, inlineElement }) => ( diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.scss b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.scss index b85686a80099d..e69de29bb2d1d 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.scss +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.scss @@ -1,65 +0,0 @@ -.lnsIndexPatternDimensionEditor { - height: 100%; -} - -.lnsIndexPatternDimensionEditor__header { - position: sticky; - top: 0; - background: $euiColorEmptyShade; - z-index: $euiZLevel1; // Raise it above the elements that are after it in DOM order - padding: 0 $euiSize; -} - -.lnsIndexPatternDimensionEditor-isFullscreen { - position: absolute; - left: 0; - right: 0; - top: 0; - bottom: 0; -} - -.lnsIndexPatternDimensionEditor--padded { - padding: $euiSize; -} - -.lnsIndexPatternDimensionEditor--collapseNext { - margin-bottom: -$euiSizeL; - border-top: $euiBorderThin; - margin-top: 0 !important; -} - -.lnsIndexPatternDimensionEditor__columns { - display: block; - column-count: 2; - column-gap: $euiSizeM; -} - -.lnsIndexPatternDimensionEditor__operation .euiListGroupItem__label { - width: 100%; -} - -.lnsIndexPatternDimensionEditor__operation > button { - padding-top: 0; - padding-bottom: 0; - min-block-size: $euiSizeL; -} - -.lnsIndexPatternDimensionEditor__warning { - margin-bottom: $euiSize; - margin-top: $euiSizeS; -} - -.lnsIndexPatternDimensionEditor__droppable { - padding: $euiSizeXS; - border-radius: $euiBorderRadius; -} - -.lnsIndexPatternDimensionEditor__droppableItem { - margin-right: $euiSizeS; -} - -.lnsIndexPatternDimensionEditor-advancedOptions button { - &:hover, &:focus { - text-decoration-color: $euiColorPrimary; - } -} diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx index 98086df2e5ba1..5561a37ed5586 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import './dimension_editor.scss'; import React, { useState, useMemo, useCallback, useRef, useEffect } from 'react'; import { i18n } from '@kbn/i18n'; import { css } from '@emotion/react'; @@ -25,6 +24,7 @@ import { EuiPanel, EuiBasicTable, EuiButtonIcon, + UseEuiTheme, } from '@elastic/eui'; import ReactDOM from 'react-dom'; import { NameInput } from '@kbn/visualization-ui-components'; @@ -534,7 +534,7 @@ export function DimensionEditor(props: DimensionEditorProps) { isActive, size: 's', isDisabled: !!disabledStatus, - className: 'lnsIndexPatternDimensionEditor__operation', + css: OperationsButtonStyles, 'data-test-subj': `lns-indexPatternDimension-${operationType}${ compatibleWithCurrentField ? '' : ' incompatible' }`, @@ -811,7 +811,7 @@ export function DimensionEditor(props: DimensionEditorProps) { fullWidth > 3 ? 'lnsIndexPatternDimensionEditor__columns' : ''} + css={sideNavItems.length > 3 ? OperationsTwoColumnsStyles : undefined} gutterSize="none" color="primary" listItems={ @@ -1290,3 +1290,21 @@ export function DimensionEditor(props: DimensionEditorProps) {
              ); } + +const OperationsTwoColumnsStyles = ({ euiTheme }: UseEuiTheme) => { + return ` + display: block; + column-count: 2; + column-gap: ${euiTheme.size.m}; + `; +}; + +export const OperationsButtonStyles = ({ euiTheme }: UseEuiTheme) => { + return ` + > button { + padding-top: 0; + padding-bottom: 0; + min-block-size: ${euiTheme.size.l}; + } + `; +}; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx index 49b559bddf24b..adff86e7805e1 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx @@ -12,10 +12,9 @@ * 2.0. */ -import './dimension_editor.scss'; import React from 'react'; import { i18n } from '@kbn/i18n'; -import { EuiCallOut, EuiButtonGroup, EuiFormRow } from '@elastic/eui'; +import { EuiCallOut, EuiButtonGroup, EuiFormRow, UseEuiTheme } from '@elastic/eui'; import { nonNullable } from '../../../utils'; import { operationDefinitionMap, @@ -154,7 +153,7 @@ export const CalloutWarning = ({ return ( <> ); }; + +const DimensionEditorWarningStyles = ({ euiTheme }: UseEuiTheme) => { + return ` + margin-bottom: ${euiTheme.size.base}; + margin-top: ${euiTheme.size.s}; + `; +}; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/reference_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/reference_editor.tsx index 66a01daae0581..34640c423302d 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/reference_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/reference_editor.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import './dimension_editor.scss'; import React, { useMemo } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiFormRowProps, EuiSpacer, EuiComboBox, EuiComboBoxOptionOption } from '@elastic/eui'; @@ -32,6 +31,7 @@ import type { FormBasedLayer } from '../types'; import type { IndexPattern, IndexPatternField, ParamEditorCustomProps } from '../../../types'; import type { FormBasedDimensionEditorProps } from './dimension_panel'; import { FormRow } from '../operations/definitions/shared_components'; +import { OperationsButtonStyles } from './dimension_editor'; const operationDisplay = getOperationDisplay(); @@ -56,7 +56,7 @@ const getFunctionOptions = ( return { label, value: operationType, - className: 'lnsIndexPatternDimensionEditor__operation', + css: OperationsButtonStyles, 'data-test-subj': `lns-indexPatternDimension-${operationType}${ isCompatible ? '' : ' incompatible' }`, @@ -204,7 +204,7 @@ export const ReferenceEditor = (props: ReferenceEditorProps) => { const brokenFunctionOption = { label: selectedOperationType && operationDisplay[selectedOperationType].displayName, value: selectedOperationType, - className: 'lnsIndexPatternDimensionEditor__operation', + css: OperationsButtonStyles, 'data-test-subj': `lns-indexPatternDimension-${selectedOperationType} incompatible`, } as EuiComboBoxOptionOption; functionOptions?.push(brokenFunctionOption); diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx index d90b5c7050841..ce7f111a7f7b7 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx @@ -711,7 +711,11 @@ export function FormulaEditor({
              - + - + { toggleFullscreen(); @@ -799,7 +808,10 @@ export function FormulaEditor({ /> {!text ? ( -
              +
              {i18n.translate('xpack.lens.formulaPlaceholderText', { defaultMessage: 'Type a formula by combining functions with math, like:', @@ -871,7 +883,9 @@ export function FormulaEditor({ button={ {warnings.map(({ message, severity }, index) => ( -
              +
              * + * { margin-left: ${euiTheme.size.xs}; } - ` + `, }; const DefaultEditorStyles = ({ euiTheme }: UseEuiTheme) => { diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/terms/index.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/terms/index.tsx index 62c5b777bf37b..bda79377ad3d2 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/terms/index.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/terms/index.tsx @@ -25,6 +25,7 @@ import { import { uniq } from 'lodash'; import { AggFunctionsMapping } from '@kbn/data-plugin/public'; import { buildExpressionFunction } from '@kbn/expressions-plugin/public'; +import { css } from '@emotion/react'; import { DOCUMENT_FIELD_NAME } from '../../../../../../common/constants'; import { insertOrReplaceColumn, updateColumnParam, updateDefaultLabels } from '../../layer_helpers'; import type { DataType, OperationMetadata } from '../../../../../types'; @@ -1008,6 +1009,9 @@ The top values of a specified field ranked by the chosen metric. <> +
              {openColumnGroup && openColumnId && layerDatasource && @@ -807,9 +808,21 @@ export function LayerPanel(props: LayerPanelProps) { )} )} - +
              } /> ); } + +const DimensionContainerStyles = ({ euiTheme }: UseEuiTheme) => ` + .lnsIndexPatternDimensionEditor--padded { + padding: ${euiTheme.size.base}; + } + + .lnsIndexPatternDimensionEditor--collapseNext { + margin-bottom: -${euiTheme.size.l}; + border-top: ${euiTheme.border.thin}; + margin-top: 0 !important; + } + `; From 8c7918cdd281e0262259df32765bf03e1e23aba6 Mon Sep 17 00:00:00 2001 From: mbondyra Date: Thu, 6 Feb 2025 13:35:40 +0100 Subject: [PATCH 06/37] toolbar button --- .../dataview_picker/toolbar_button.scss | 61 ---------------- .../dataview_picker/toolbar_button.tsx | 70 ++++++++++++++++++- 2 files changed, 68 insertions(+), 63 deletions(-) delete mode 100644 x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/toolbar_button.scss diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/toolbar_button.scss b/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/toolbar_button.scss deleted file mode 100644 index abd4d45a9e955..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/toolbar_button.scss +++ /dev/null @@ -1,61 +0,0 @@ -.kbnToolbarButton { - line-height: $euiButtonHeight; // Keeps alignment of text and chart icon - - // todo: once issue https://github.com/elastic/eui/issues/4730 is merged, this code might be safe to remove - // Some toolbar buttons are just icons, but EuiButton comes with margin and min-width that need to be removed - min-width: 0; - border-width: $euiBorderWidthThin; - border-style: solid; - border-color: $euiBorderColor; // Lighten the border color for all states - - // Override background color for non-disabled buttons - &:not(:disabled) { - background-color: $euiColorEmptyShade; - } - - .kbnToolbarButton__text > svg { - margin-top: -1px; // Just some weird alignment issue when icon is the child not the `iconType` - } - - .kbnToolbarButton__text:empty { - margin: 0; - } - - // Toolbar buttons don't look good with centered text when fullWidth - &[class*='fullWidth'] { - text-align: left; - - .kbnToolbarButton__content { - justify-content: space-between; - } - } -} - -.kbnToolbarButton--groupLeft { - border-top-right-radius: 0; - border-bottom-right-radius: 0; -} - -.kbnToolbarButton--groupCenter { - border-radius: 0; - border-left: none; -} - -.kbnToolbarButton--groupRight { - border-top-left-radius: 0; - border-bottom-left-radius: 0; - border-left: none; -} - -.kbnToolbarButton--bold { - font-weight: $euiFontWeightBold; -} - -.kbnToolbarButton--normal { - font-weight: $euiFontWeightRegular; -} - -.kbnToolbarButton--s { - box-shadow: none !important; // sass-lint:disable-line no-important - font-size: $euiFontSizeS; -} diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/toolbar_button.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/toolbar_button.tsx index 395864f1d1a51..c760df9d36c6e 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/toolbar_button.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/toolbar_button.tsx @@ -5,10 +5,9 @@ * 2.0. */ -import './toolbar_button.scss'; import React from 'react'; import classNames from 'classnames'; -import { EuiButton, PropsOf, EuiButtonProps } from '@elastic/eui'; +import { EuiButton, PropsOf, EuiButtonProps, UseEuiTheme, euiFontSize } from '@elastic/eui'; const groupPositionToClassMap = { none: null, @@ -69,6 +68,7 @@ export const ToolbarButton: React.FunctionComponent = ({ data-test-subj={dataTestSubj} className={classes} iconSide="right" + css={ToolbarButtonStyles} iconType={hasArrow ? 'arrowDown' : ''} color="text" contentProps={{ @@ -85,3 +85,69 @@ export const ToolbarButton: React.FunctionComponent = ({ ); }; + +const ToolbarButtonStyles = (euiThemeObj: UseEuiTheme) => { + const { euiTheme } = euiThemeObj; + return ` + &.kbnToolbarButton { + line-height: ${euiTheme.size.xxl}; // Keeps alignment of text and chart icon + + // todo: once issue https://github.com/elastic/eui/issues/4730 is merged, this code might be safe to remove + // Some toolbar buttons are just icons, but EuiButton comes with margin and min-width that need to be removed + min-width: 0; + border-width: ${euiTheme.border.width.thin}; + border-style: solid; + border-color: ${euiTheme.border.color}; // Lighten the border color for all states + + // Override background color for non-disabled buttons + &:not(:disabled) { + background-color: ${euiTheme.colors.backgroundBasePlain}; + } + + &.kbnToolbarButton__text > svg { + margin-top: -1px; // Just some weird alignment issue when icon is the child not the iconType + } + + &.kbnToolbarButton__text:empty { + margin: 0; + } + + // Toolbar buttons don't look good with centered text when fullWidth + &[class*='fullWidth'] { + text-align: left; + + .kbnToolbarButton__content { + justify-content: space-between; + } + } + } + + &.kbnToolbarButton--groupLeft { + border-top-right-radius: 0; + border-bottom-right-radius: 0; + } + + &.kbnToolbarButton--groupCenter { + border-radius: 0; + border-left: none; + } + + &.kbnToolbarButton--groupRight { + border-top-left-radius: 0; + border-bottom-left-radius: 0; + border-left: none; + } + + &.kbnToolbarButton--bold { + font-weight: ${euiTheme.font.weight.bold}; + } + + &.kbnToolbarButton--normal { + font-weight:${euiTheme.font.weight.regular}; + } + + &.kbnToolbarButton--s { + box-shadow: none !important; // sass-lint:disable-line no-important + font-size:${euiFontSize(euiThemeObj, 's').fontSize}; + }`; +}; From 802d86dabc5326cfa3fb5eaf27c045c1468b8ef6 Mon Sep 17 00:00:00 2001 From: mbondyra Date: Mon, 17 Feb 2025 13:51:59 +0100 Subject: [PATCH 07/37] remove unused styles --- .../inline_editing/flyout.styles.ts | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/flyout.styles.ts b/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/flyout.styles.ts index ecf5d1798029a..f9f94cdce6189 100644 --- a/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/flyout.styles.ts +++ b/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/flyout.styles.ts @@ -25,25 +25,3 @@ export const InlineFlyoutStyles = ({ euiTheme }: UseEuiTheme) => ` } } `; - -export const InlineFlyoutFlyoutBodyStyles = ({ euiTheme }: UseEuiTheme) => ` -// styles needed to display extra drop targets that are outside of the config panel main area -overflow-y: auto; -padding-left: 400px; -margin-left: -400px; -pointer-events: none; -.euiFlyoutBody__overflow { -transform: initial; --webkit-mask-image: none; -padding-left: inherit; -margin-left: inherit; -${!isScrollable && `overflow-y: hidden;`} -> * { -pointer-events: auto; -} -} -.euiFlyoutBody__overflowContent { -padding: 0; -block-size: 100%; -} -`; From e6ffee624071c0e9195f94b60b8565f070c50c1b Mon Sep 17 00:00:00 2001 From: mbondyra Date: Mon, 17 Feb 2025 14:01:50 +0100 Subject: [PATCH 08/37] remove unused property --- .../form_based/dimension_panel/dimension_editor.scss | 0 .../workspace_panel/workspace_panel_wrapper.scss | 9 +-------- .../workspace_panel/workspace_panel_wrapper.tsx | 6 +----- 3 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.scss diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.scss b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.scss deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.scss b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.scss index 1fb53b6e56018..4cd7e00ce9d0e 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.scss +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.scss @@ -180,14 +180,7 @@ transform: translateY(15%); } - 100% { + 100% { transform: translateY(10%); } -} - -.lnsVisualizationToolbar--fixed { - position: fixed; - width: 100%; - z-index: 1; - background-color: $euiColorLightestShade; } \ No newline at end of file diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx index a4077b6919823..89b11cbbe215e 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx @@ -74,11 +74,10 @@ const getAspectRatioStyles = ({ x, y }: { x: number; y: number }) => { export function VisualizationToolbar(props: { activeVisualization: Visualization | null; framePublicAPI: FramePublicAPI; - isFixedPosition?: boolean; }) { const dispatchLens = useLensDispatch(); const visualization = useLensSelector(selectVisualizationState); - const { activeVisualization, isFixedPosition } = props; + const { activeVisualization } = props; const setVisualizationState = useCallback( (newState: unknown) => { if (!activeVisualization) { @@ -101,9 +100,6 @@ export function VisualizationToolbar(props: { {ToolbarComponent && ( {ToolbarComponent({ frame: props.framePublicAPI, From e9e89257d26137c5316e500928dc2e5aaaefba30 Mon Sep 17 00:00:00 2001 From: mbondyra Date: Mon, 17 Feb 2025 14:14:35 +0100 Subject: [PATCH 09/37] wip --- .../workspace_panel/workspace_panel.tsx | 20 +++++++++++++------ .../workspace_panel_wrapper.scss | 4 ---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx index 900310f213ca4..976fdc99aba7b 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx @@ -81,6 +81,7 @@ import { import { setChangesApplied } from '../../../state_management/lens_slice'; import { WorkspaceErrors } from './workspace_errors'; import { getActiveDataFromDatatable } from '../../../state_management/shared_logic'; +import { css } from '@emotion/react'; export interface WorkspacePanelProps { visualizationMap: VisualizationMap; @@ -496,7 +497,7 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({ return (

              @@ -558,7 +556,7 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({ return ( Date: Tue, 18 Feb 2025 11:54:01 +0100 Subject: [PATCH 10/37] wip --- .../config_panel/config_panel.tsx | 16 ++++- .../editor_frame/frame_layout.scss | 68 +------------------ .../editor_frame/frame_layout.tsx | 28 ++++++-- .../workspace_panel_wrapper.scss | 9 --- .../workspace_panel_wrapper.tsx | 17 ++++- .../shared_components/flyout_container.tsx | 7 -- 6 files changed, 54 insertions(+), 91 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx index 6b6facc06f339..2a7165715e378 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx @@ -6,7 +6,7 @@ */ import React, { useMemo, memo, useCallback } from 'react'; -import { EuiForm } from '@elastic/eui'; +import { EuiForm, euiBreakpoint, useEuiTheme } from '@elastic/eui'; import { ActionExecutionContext } from '@kbn/ui-actions-plugin/public'; import { isOfAggregateQueryType } from '@kbn/es-query'; import { @@ -39,6 +39,7 @@ import { registerLibraryAnnotationGroup, } from '../../../state_management'; import { getRemoveOperation } from '../../../utils'; +import { css } from '@emotion/react'; export const ConfigPanelWrapper = memo(function ConfigPanelWrapper(props: ConfigPanelWrapperProps) { const visualization = useLensSelector(selectVisualization); @@ -62,6 +63,9 @@ export function LayerPanels( (state) => state.lens ); + const euiThemeContext = useEuiTheme(); + const { euiTheme } = euiThemeContext; + const dispatchLens = useLensDispatch(); const layerIds = activeVisualization.getLayerIds(visualization.state); @@ -252,7 +256,15 @@ export function LayerPanels( const hideAddLayerButton = query && isOfAggregateQueryType(query); return ( - + {layerIds.map((layerId, layerIndex) => { const { hidden, groups } = activeVisualization.getConfiguration({ layerId, diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.scss b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.scss index 563ac572d230c..5ec390ac66f93 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.scss +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.scss @@ -1,24 +1,5 @@ $lnsPanelMinWidth: $euiSize * 18; - -.lnsFrameLayout { - padding: 0; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - overflow: hidden; - flex-direction: column; - @include euiBreakpoint('xs', 's', 'm') { - position: static; - } -} - -.lnsFrameLayout__wrapper { - position: relative; -} - .lnsFrameLayout__pageContent { overflow: hidden; flex-grow: 1; @@ -35,28 +16,6 @@ $lnsPanelMinWidth: $euiSize * 18; } } -.visEditor { - height: 100%; - @include flexParent(); - @include euiBreakpoint('xs', 's', 'm') { - .visualization { - // While we are on a small screen the visualization is below the - // editor. In this cases it needs a minimum height, since it would otherwise - // maybe end up with 0 height since it just gets the flexbox rest of the screen. - min-height: $euiSizeL * 15; - } - } - - /* 1. Without setting this to 0 you will run into a bug where the filter bar modal is hidden under -a tilemap in an iframe: https://github.com/elastic/kibana/issues/16457 */ - > .visualize { - height: 100%; - flex: 1 1 auto; - display: flex; - z-index: 0; /* 1 */ - } -} - .lnsFrameLayout__pageBody { min-width: $lnsPanelMinWidth + $euiSizeXL; overflow: hidden auto; @@ -75,12 +34,12 @@ a tilemap in an iframe: https://github.com/elastic/kibana/issues/16457 */ &:first-child { padding-left: $euiSize; } +} - &.lnsFrameLayout__pageBody-isFullscreen { + .lnsFrameLayout__pageBody.lnsFrameLayout__pageBody-isFullscreen { flex: 1; padding: 0; } -} .lnsFrameLayout__sidebar { margin: 0; @@ -91,12 +50,6 @@ a tilemap in an iframe: https://github.com/elastic/kibana/issues/16457 */ position: relative; } -.lnsFrameLayout-isFullscreen .lnsFrameLayout__sidebar--left { - // Hide the datapanel in fullscreen mode. Using display: none does trigger - // a rerender when the container becomes visible again, maybe pushing offscreen is better - display: none; -} - .lnsFrameLayout__sidebar--right { flex-basis: 25%; min-width: $lnsPanelMinWidth + 70; @@ -106,19 +59,4 @@ a tilemap in an iframe: https://github.com/elastic/kibana/issues/16457 */ @include euiBreakpoint('xs', 's', 'm') { max-width: 100%; } - - .lnsConfigPanel { - padding: $euiSize $euiSize $euiSizeXL ($euiFormMaxWidth + $euiSize); - margin-left: -$euiFormMaxWidth; - @include euiYScroll; - @include euiBreakpoint('xs', 's', 'm') { - padding-left: $euiSize; - margin-left: 0; - } - } -} - -.lnsFrameLayout__sidebar-isFullscreen { - flex: 1; - max-width: none; -} +} \ No newline at end of file diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx index 23fc53ababe9f..11d8b52f230fa 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx @@ -8,10 +8,11 @@ import './frame_layout.scss'; import React from 'react'; -import { EuiScreenReaderOnly, EuiFlexGroup, EuiFlexItem, EuiPage, EuiPageBody } from '@elastic/eui'; +import { EuiScreenReaderOnly, EuiFlexGroup, EuiFlexItem, EuiPage, EuiPageBody, useEuiTheme, euiBreakpoint } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import classNames from 'classnames'; import { useLensSelector, selectIsFullscreenDatasource } from '../../state_management'; +import { css } from '@emotion/react'; export interface FrameLayoutProps { dataPanel: React.ReactNode; @@ -23,6 +24,7 @@ export interface FrameLayoutProps { export function FrameLayout(props: FrameLayoutProps) { const isFullscreen = useLensSelector(selectIsFullscreenDatasource); + const euiTheme = useEuiTheme(); return ( @@ -40,12 +42,27 @@ export function FrameLayout(props: FrameLayoutProps) { ) : null} - +
              {!isFullscreen && ( @@ -237,7 +241,14 @@ export function WorkspacePanelWrapper({ className={classNames('lnsWorkspacePanelWrapper stretch-for-sharing', { 'lnsWorkspacePanelWrapper--fullscreen': isFullscreen, })} - css={{ height: '100%' }} + css={css` + height: 100%; + .lnsWorkspacePanelWrapper__content { + width: 100%; + height: 100%; + position: absolute; + } + `} color="transparent" > css` From 9d5764bead434d32bd19b886e33c24b3e066d70b Mon Sep 17 00:00:00 2001 From: mbondyra Date: Tue, 18 Feb 2025 14:02:07 +0100 Subject: [PATCH 11/37] suggestion panel --- .../config_panel/config_panel.tsx | 24 ++-- .../config_panel/layer_panel.scss | 18 --- .../editor_frame/config_panel/layer_panel.tsx | 17 ++- .../editor_frame/frame_layout.tsx | 28 +++- .../editor_frame/suggestion_panel.scss | 122 ---------------- .../editor_frame/suggestion_panel.tsx | 136 +++++++++++++++--- .../workspace_panel/workspace_panel.tsx | 11 +- .../workspace_panel_wrapper.tsx | 6 +- .../shared_components/static_header.tsx | 7 +- 9 files changed, 181 insertions(+), 188 deletions(-) delete mode 100644 x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.scss diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx index 2a7165715e378..5ad5b1dec0009 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.tsx @@ -15,6 +15,7 @@ import { } from '@kbn/unified-search-plugin/public'; import { DragDropIdentifier, DropType } from '@kbn/dom-drag-drop'; +import { css } from '@emotion/react'; import { changeIndexPattern, onDropToDimension, @@ -39,7 +40,6 @@ import { registerLibraryAnnotationGroup, } from '../../../state_management'; import { getRemoveOperation } from '../../../utils'; -import { css } from '@emotion/react'; export const ConfigPanelWrapper = memo(function ConfigPanelWrapper(props: ConfigPanelWrapperProps) { const visualization = useLensSelector(selectVisualization); @@ -256,15 +256,19 @@ export function LayerPanels( const hideAddLayerButton = query && isOfAggregateQueryType(query); return ( - + {layerIds.map((layerId, layerIndex) => { const { hidden, groups } = activeVisualization.getConfiguration({ layerId, diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.scss b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.scss index c9c40529ea68f..91787f92b3d06 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.scss +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.scss @@ -7,29 +7,11 @@ } } -.lnsLayerPanel__layerHeader { - padding: $euiSize; - border-bottom: $euiBorderThin; -} - -// fixes truncation for too long chart switcher labels -.lnsLayerPanel__layerSettingsWrapper { - min-width: 0; -} - -.lnsLayerPanel__settingsStaticHeader { - padding-left: $euiSizeXS; -} - .lnsLayerPanel__settingsStaticHeaderIcon { margin-right: $euiSizeS; vertical-align: inherit; } -.lnsLayerPanel__settingsStaticHeaderTitle { - display: inline; -} - .lnsLayerPanel__row { padding: $euiSize; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx index 7dd5468a2c4f0..3eb01f85bef3c 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx @@ -17,6 +17,7 @@ import { EuiText, EuiIconTip, UseEuiTheme, + useEuiTheme, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { css } from '@emotion/react'; @@ -50,6 +51,7 @@ export function LayerPanel(props: LayerPanelProps) { }>({}); const [isPanelSettingsOpen, setPanelSettingsOpen] = useState(false); + const { euiTheme } = useEuiTheme(); const { framePublicAPI, @@ -365,9 +367,20 @@ export function LayerPanel(props: LayerPanelProps) { data-test-subj={`lns-layerPanel-${layerIndex}`} > -
              +
              - + ) : null} - +
              void; }) => { + const { euiTheme } = useEuiTheme(); const onErrorMessage = ( -
              +
              {!expression || hasError ? ( onErrorMessage @@ -188,6 +196,9 @@ const SuggestionPreview = ({ onRender: () => void; wrapSuggestions?: boolean; }) => { + const euiThemeContext = useEuiTheme(); + const { euiTheme } = euiThemeContext; + const xsFontSize = useEuiFontSize('xs'); return ( ) : ( - + )} {showTitleAsLabel && ( - {preview.title} + + {preview.title} + )}
              @@ -266,6 +326,8 @@ export function SuggestionPanel({ const existsStagedPreview = useLensSelector((state) => Boolean(state.lens.stagedPreview)); const currentVisualization = useLensSelector(selectCurrentVisualization); const currentDatasourceStates = useLensSelector(selectCurrentDatasourceStates); + const euiThemeContext = useEuiTheme(); + const { euiTheme } = euiThemeContext; const framePublicAPI = useLensSelector((state) => selectFramePublicAPI(state, datasourceMap)); const changesApplied = useLensSelector(selectChangesApplied); @@ -438,7 +500,19 @@ export function SuggestionPanel({ } const renderApplyChangesPrompt = () => ( - +

              {changesApplied ? renderSuggestionsUI() : renderApplyChangesPrompt()} @@ -699,3 +786,18 @@ function preparePreviewExpression( return typeof expression === 'string' ? fromExpression(expression) : expression; } + +const suggestionStyles = { + icon: ({ euiTheme }: UseEuiTheme) => css` + color: ${euiTheme.colors.darkShade}; + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; + padding: ${euiTheme.size.s}; + &:not(:only-child) { + height: calc(100% - ${euiTheme.size.l}); + } + `, +}; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx index 976fdc99aba7b..affcb85d39fe9 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx @@ -27,6 +27,7 @@ import { DropIllustration } from '@kbn/chart-icons'; import { useDragDropContext, DragDropIdentifier, Droppable } from '@kbn/dom-drag-drop'; import { reportPerformanceMetricEvent } from '@kbn/ebt-tools'; import { ChartSizeSpec, isChartSizeEvent } from '@kbn/chart-expressions-common'; +import { css } from '@emotion/react'; import { getSuccessfulRequestTimings } from '../../../report_performance_metric_util'; import { trackUiCounterEvents } from '../../../lens_ui_telemetry'; import { getSearchWarningMessages } from '../../../utils'; @@ -81,7 +82,6 @@ import { import { setChangesApplied } from '../../../state_management/lens_slice'; import { WorkspaceErrors } from './workspace_errors'; import { getActiveDataFromDatatable } from '../../../state_management/shared_logic'; -import { css } from '@emotion/react'; export interface WorkspacePanelProps { visualizationMap: VisualizationMap; @@ -497,7 +497,7 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({ return ( {ToolbarComponent && ( - + {ToolbarComponent({ frame: props.framePublicAPI, state: visualization.state, @@ -248,7 +246,7 @@ export function WorkspacePanelWrapper({ height: 100%; position: absolute; } - `} + `} color="transparent" > { + const { euiTheme } = useEuiTheme(); return ( {icon && ( From fbdbc66cf564c22de57252a2769ce30c3db1ea9a Mon Sep 17 00:00:00 2001 From: mbondyra Date: Tue, 18 Feb 2025 14:57:12 +0100 Subject: [PATCH 12/37] workspace wip --- .../src/assets/drop_illustration.tsx | 127 +++++++++++++----- .../shared/kbn-chart-icons/tsconfig.json | 7 +- .../components/dimension_buttons/trigger.tsx | 3 + .../buttons/draggable_dimension_button.tsx | 9 ++ .../config_panel/layer_panel.scss | 28 ---- .../editor_frame/config_panel/layer_panel.tsx | 11 +- .../editor_frame/frame_layout.scss | 8 +- .../geo_field_workspace_panel.tsx | 2 +- .../workspace_panel/workspace_panel.tsx | 15 ++- .../workspace_panel_wrapper.scss | 70 +--------- 10 files changed, 132 insertions(+), 148 deletions(-) diff --git a/src/platform/packages/shared/kbn-chart-icons/src/assets/drop_illustration.tsx b/src/platform/packages/shared/kbn-chart-icons/src/assets/drop_illustration.tsx index ae19bf28f26ec..ef5464fd4ec53 100644 --- a/src/platform/packages/shared/kbn-chart-icons/src/assets/drop_illustration.tsx +++ b/src/platform/packages/shared/kbn-chart-icons/src/assets/drop_illustration.tsx @@ -8,38 +8,95 @@ */ import React from 'react'; -import { EuiIconProps } from '@elastic/eui'; - -export const DropIllustration = ({ title, titleId, ...props }: Omit) => ( - - {title ? {title} : null} - - - - - - - - - -); +import { EuiIconProps, useEuiTheme } from '@elastic/eui'; +import { css, keyframes } from '@emotion/react'; + +export const DropIllustration = ({ title, titleId, ...props }: Omit) => { + const { euiTheme } = useEuiTheme(); + return ( + + {title ? {title} : null} + + + + + + + + + + ); +}; + + +const pulseArrow = keyframes` + 0% { + transform: translateY(0%); + } + + 65% { + transform: translateY(0%); + } + + 72% { + transform: translateY(10%); + } + + 79% { + transform: translateY(7%); + } + + 86% { + transform: translateY(10%); + } + + 95% { + transform: translateY(0); + } +` + +const pulseContinuous = keyframes` + 0% { + transform: translateY(10%); + } + 25% { + transform: translateY(15%); + } + 50% { + transform: translateY(10%); + } + 75% { + transform: translateY(15%); + } + 100% { + transform: translateY(10%); + } +` \ No newline at end of file diff --git a/src/platform/packages/shared/kbn-chart-icons/tsconfig.json b/src/platform/packages/shared/kbn-chart-icons/tsconfig.json index cc843830192f8..eaf06a6cb0cee 100644 --- a/src/platform/packages/shared/kbn-chart-icons/tsconfig.json +++ b/src/platform/packages/shared/kbn-chart-icons/tsconfig.json @@ -2,16 +2,11 @@ "extends": "../../../../../tsconfig.base.json", "compilerOptions": { "outDir": "target/types", - "types": [ - "jest", - "node", - "react", - "@emotion/css/types" - ], }, "include": [ "**/*.ts", "**/*.tsx", + "../../../../../typings/**/*" ], "kbn_references": [ "@kbn/ui-theme" diff --git a/src/platform/packages/shared/kbn-visualization-ui-components/components/dimension_buttons/trigger.tsx b/src/platform/packages/shared/kbn-visualization-ui-components/components/dimension_buttons/trigger.tsx index 764fc298e5109..1ccab820dcf93 100644 --- a/src/platform/packages/shared/kbn-visualization-ui-components/components/dimension_buttons/trigger.tsx +++ b/src/platform/packages/shared/kbn-visualization-ui-components/components/dimension_buttons/trigger.tsx @@ -59,6 +59,9 @@ export const DimensionTrigger = ({ {group.accessors.length ? ( {group.accessors.map((accessorConfig, accessorIndex) => { const { columnId } = accessorConfig; @@ -790,7 +793,11 @@ export function LayerPanel(props: LayerPanelProps) { activeVisualization.DimensionEditorComponent && openColumnGroup?.enableDimensionEditor && ( <> -
              +
              { +const DroppableStyles = ({ euiTheme }: UseEuiTheme) => { return ` padding: ${euiTheme.size.xxl} ${euiTheme.size.xxxl}; border: ${euiTheme.border.thin}; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx index affcb85d39fe9..baf3c7b77471f 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx @@ -12,7 +12,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { toExpression } from '@kbn/interpreter'; import type { KibanaExecutionContext } from '@kbn/core-execution-context-common'; import { i18n } from '@kbn/i18n'; -import { EuiText, EuiButtonEmpty, EuiLink, EuiTextColor } from '@elastic/eui'; +import { EuiText, EuiButtonEmpty, EuiLink, EuiTextColor, transparentize, useEuiTheme } from '@elastic/eui'; import type { CoreStart } from '@kbn/core/public'; import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; import type { @@ -196,6 +196,8 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({ const dataReceivedTime = useRef(NaN); const esTookTime = useRef(0); + const {euiTheme} = useEuiTheme(); + const onRender$ = useCallback(() => { if (renderDeps.current) { if (!initialVisualizationRenderComplete.current) { @@ -505,7 +507,14 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({

              @@ -564,9 +573,9 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({
              {applyChangesString}

              diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.scss b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.scss index 22a7d10c8f2eb..39c4981952a07 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.scss +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.scss @@ -61,11 +61,7 @@ } } - &.domDroppable--hover { - .lnsDropIllustration__hand { - animation: lnsWorkspacePanel__illustrationPulseContinuous 1.5s ease-in-out 0s infinite normal forwards; - } - } + } .lnsWorkspacePanel__emptyContent { @@ -107,67 +103,3 @@ max-width: 176px; max-height: 176px; } - -.lnsWorkspacePanel__dropIllustration { - // Drop shadow values is a dupe of @euiBottomShadowMedium but used as a filter - // Hard-coded px values OK (@cchaos) - // sass-lint:disable-block indentation - filter: - drop-shadow(0 6px 12px transparentize($euiShadowColor, .8)) drop-shadow(0 4px 4px transparentize($euiShadowColor, .8)) drop-shadow(0 2px 2px transparentize($euiShadowColor, .8)); -} - -.lnsDropIllustration__adjustFill { - fill: $euiColorFullShade; -} - -.lnsDropIllustration__hand { - animation: lnsWorkspacePanel__illustrationPulseArrow 5s ease-in-out 0s infinite normal forwards; -} - -@keyframes lnsWorkspacePanel__illustrationPulseArrow { - 0% { - transform: translateY(0%); - } - - 65% { - transform: translateY(0%); - } - - 72% { - transform: translateY(10%); - } - - 79% { - transform: translateY(7%); - } - - 86% { - transform: translateY(10%); - } - - 95% { - transform: translateY(0); - } -} - -@keyframes lnsWorkspacePanel__illustrationPulseContinuous { - 0% { - transform: translateY(10%); - } - - 25% { - transform: translateY(15%); - } - - 50% { - transform: translateY(10%); - } - - 75% { - transform: translateY(15%); - } - - 100% { - transform: translateY(10%); - } -} \ No newline at end of file From b396cbfb320a859c9b97beec4ad652cf473d61e4 Mon Sep 17 00:00:00 2001 From: mbondyra Date: Wed, 19 Feb 2025 13:05:56 +0100 Subject: [PATCH 13/37] layer_panel --- .../dimension_buttons/dimension_button.tsx | 4 ++ .../config_panel/layer_panel.scss | 71 ------------------- .../editor_frame/config_panel/layer_panel.tsx | 31 +++++++- 3 files changed, 34 insertions(+), 72 deletions(-) delete mode 100644 x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.scss diff --git a/src/platform/packages/shared/kbn-visualization-ui-components/components/dimension_buttons/dimension_button.tsx b/src/platform/packages/shared/kbn-visualization-ui-components/components/dimension_buttons/dimension_button.tsx index 2f957b2e00ac3..d58c86a06d8fe 100644 --- a/src/platform/packages/shared/kbn-visualization-ui-components/components/dimension_buttons/dimension_button.tsx +++ b/src/platform/packages/shared/kbn-visualization-ui-components/components/dimension_buttons/dimension_button.tsx @@ -78,6 +78,10 @@ function DimensionButtonImpl({ className="lnsLayerPanel__dimensionLink" css={css` width: 100%; + &:focus { + background-color: transparent; + text-decoration-thickness: ${euiTheme.border.thin} !important; + } &:hover { text-decoration: none; } diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.scss b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.scss deleted file mode 100644 index 568a4b83a2953..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.scss +++ /dev/null @@ -1,71 +0,0 @@ -.lnsLayerPanel { - margin-bottom: $euiSize; - - // disable focus ring for mouse clicks, leave it for keyboard users - &:focus:not(:focus-visible) { - animation: none !important; // sass-lint:disable-line no-important - } -} - -.lnsLayerPanel__row { - padding: $euiSize; - - &:last-child { - border-radius: 0 0 $euiBorderRadius $euiBorderRadius; - } - - // Add border to the top of the next same panel - &+& { - border-top: $euiBorderThin; - margin-top: 0; - } - - &>* { - margin-bottom: 0; - } - - // Targeting EUI class as we are unable to apply a class to this element in component - &, - .euiFormRow__fieldWrapper { - &>*+* { - margin-top: $euiSizeS; - } - } -} - - -// Removes EUI focus ring -@mixin removeEuiFocusRing { - outline: none; - - &:focus-visible { - outline-style: none; - } -} - -// Passes focus ring styles down to a child of a focused element -@mixin passDownFocusRing($target) { - @include removeEuiFocusRing; - - #{$target} { - @include euiFocusBackground; - outline: $euiFocusRingSize solid currentColor; // Safari & Firefox - } - - &:focus-visible #{$target} { - outline-style: auto; // Chrome - } - - &:not(:focus-visible) #{$target} { - outline: none; - } -} - -// Added .lnsLayerPanel__dimension specificity required for animation style override -.lnsLayerPanel__dimension .lnsLayerPanel__dimensionLink { - &:focus { - background-color: transparent; - text-decoration-thickness: $euiBorderWidthThin !important; - @include passDownFocusRing('.dimensionTrigger__textLabel'); - } -} \ No newline at end of file diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx index d77d0782eeeda..5cbf0d87cd183 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx @@ -363,7 +363,13 @@ export function LayerPanel(props: LayerPanelProps) {
              @@ -485,6 +491,29 @@ export function LayerPanel(props: LayerPanelProps) { const isOptional = !group.requiredMinDimensionCount && !group.suggestedValue; return ( * { + margin-bottom: 0; + } + + // Targeting EUI class as we are unable to apply a class to this element in component + &, + .euiFormRow__fieldWrapper { + &>*+* { + margin-top: ${euiTheme.size.s}; + } + }`} className="lnsLayerPanel__row" fullWidth label={ From e73f17b32559a2877b43499763af44366032d737 Mon Sep 17 00:00:00 2001 From: mbondyra Date: Wed, 19 Feb 2025 14:34:42 +0100 Subject: [PATCH 14/37] wip --- .../lens/public/app_plugin/lens_top_nav.tsx | 14 +-- .../editor_frame/config_panel/layer_panel.tsx | 2 - .../geo_field_workspace_panel.tsx | 7 +- .../workspace_panel/message_list.tsx | 2 - .../editor_frame/workspace_panel/title.tsx | 2 - .../workspace_panel/workspace_panel.tsx | 89 +++++++++++---- .../workspace_panel_wrapper.scss | 105 ------------------ .../workspace_panel_wrapper.tsx | 32 ++++-- .../public/expression_renderer_styles.tsx | 15 +++ .../react_embeddable/expression_wrapper.tsx | 2 + 10 files changed, 118 insertions(+), 152 deletions(-) delete mode 100644 x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.scss create mode 100644 x-pack/platform/plugins/shared/lens/public/expression_renderer_styles.tsx diff --git a/x-pack/platform/plugins/shared/lens/public/app_plugin/lens_top_nav.tsx b/x-pack/platform/plugins/shared/lens/public/app_plugin/lens_top_nav.tsx index b01a77e4218f6..464290112c984 100644 --- a/x-pack/platform/plugins/shared/lens/public/app_plugin/lens_top_nav.tsx +++ b/x-pack/platform/plugins/shared/lens/public/app_plugin/lens_top_nav.tsx @@ -17,7 +17,7 @@ import { useKibana } from '@kbn/kibana-react-plugin/public'; import { DataViewPickerProps } from '@kbn/unified-search-plugin/public'; import { getManagedContentBadge } from '@kbn/managed-content-badge'; import moment from 'moment'; -import { EuiCallOut, UseEuiTheme, useEuiBreakpoint } from '@elastic/eui'; +import { EuiCallOut, UseEuiTheme, euiBreakpoint, useEuiBreakpoint } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { SerializedStyles, css } from '@emotion/react'; import { LENS_APP_LOCATOR } from '../../common/locator/locator'; @@ -103,22 +103,22 @@ function getSaveButtonMeta({ } } -const NavItemWithDividerStyles = ({ euiTheme }: UseEuiTheme) => css` - @include euiBreakpoint('m', 'l', 'xl') { - margin-right: $euiSizeM; +const NavItemWithDividerStyles = (euiThemeContext: UseEuiTheme) => css` + ${euiBreakpoint(euiThemeContext, ['m', 'l', 'xl'])} { + margin-right: ${euiThemeContext.euiTheme.size.m}; position: relative; } ${useEuiBreakpoint(['m', 'l', 'xl'])} { - margin-right: ${euiTheme.size.m}; + margin-right: ${euiThemeContext.euiTheme.size.m}; position: relative; &:after { - border-right: ${euiTheme.border.thin}; + border-right: ${euiThemeContext.euiTheme.border.thin}; bottom: 0; content: ''; display: block; pointer-events: none; position: absolute; - right: -${euiTheme.size.s}; + right: -${euiThemeContext.euiTheme.size.s}; top: 0; } } diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx index 5cbf0d87cd183..2df1601f78451 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx @@ -5,8 +5,6 @@ * 2.0. */ -import './layer_panel.scss'; - import React, { useState, useEffect, useMemo, useCallback, useRef } from 'react'; import { EuiPanel, diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx index bfef2b69788c1..3dc1c1fe5108b 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx @@ -15,6 +15,7 @@ import { Droppable } from '@kbn/dom-drag-drop'; import { IndexPattern } from '../../../types'; import { getVisualizeGeoFieldMessage } from '../../../utils'; import { APP_ID } from '../../../../common/constants'; +import { pageContentBodyStyles, promptIllustrationStyle } from './workspace_panel'; interface Props { fieldType: string; @@ -44,13 +45,13 @@ export function GeoFieldWorkspacePanel(props: Props) { } return ( -
              - +
              +

              {getVisualizeGeoFieldMessage(props.fieldType)}

              - +

              @@ -528,15 +527,19 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({

              {!expressionExists && ( - <> - -

              +

              + {i18n.translate('xpack.lens.editorFrame.emptyWorkspaceHeading', { defaultMessage: 'Lens is the recommended editor for creating visualizations', })} -

              -

              + +

              - +
              )}
              @@ -565,7 +568,6 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({ return ( {applyChangesString} @@ -584,7 +586,8 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({ })}

              -

              + +

              -

              {renderWorkspaceContents()}
              +
              {renderWorkspaceContents()}
              ); }; @@ -744,6 +744,7 @@ export const VisualizationWrapper = ({ onComponentRendered(); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); + const {euiTheme} = useEuiTheme() const searchContext = useLensSelector(selectExecutionContextSearch); // Used for reporting @@ -780,6 +781,13 @@ export const VisualizationWrapper = ({ return (
              ); }; + + + +export const promptIllustrationStyle = ({euiTheme} : UseEuiTheme) => { + return css` + overflow: visible; // Shows arrow animation when it gets out of bounds + margin-top: 0; + margin-bottom: -${euiTheme.size.base}; + + margin-right: auto; + margin-left: auto; + max-width: 176px; + max-height: 176px; +`} + +export const pageContentBodyStyles = ({euiTheme} : UseEuiTheme) => { + const euiScrollBar = useEuiScrollBar(); + return css` + flex-grow: 1; + display: flex; + align-items: stretch; + justify-content: stretch; + border: ${euiTheme.border.thin}; + border-radius: ${euiTheme.border.radius.medium}; + background: ${euiTheme.colors.emptyShade}; + height: 100%; + ${euiScrollBar}; + &>* { + flex: 1 1 100%; + display: flex; + align-items: center; + justify-content: center; + } + ` +} diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.scss b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.scss deleted file mode 100644 index 39c4981952a07..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.scss +++ /dev/null @@ -1,105 +0,0 @@ -.lnsWorkspacePanelWrapper { - margin-bottom: $euiSize; - display: flex; - flex-direction: column; - position: relative; // For positioning the dnd overlay - min-height: $euiSizeXXL * 10; - overflow: visible; - height: 100%; - - - .lnsWorkspacePanelWrapper__pageContentBody { - flex-grow: 1; - display: flex; - align-items: stretch; - justify-content: stretch; - border: $euiBorderThin; - border-radius: $euiBorderRadius; - background: $euiColorEmptyShade; - height: 100%; - @include euiScrollBar; - &>* { - flex: 1 1 100%; - display: flex; - align-items: center; - justify-content: center; - } - } - - &.lnsWorkspacePanelWrapper--fullscreen { - margin-bottom: 0; - - .lnsWorkspacePanelWrapper__pageContentBody { - box-shadow: none; - } - } -} - -.lnsExpressionRenderer { - position: relative; - width: 100%; - height: 100%; - display: flex; - overflow: auto; - // important for visualizations with no padding - border-radius: $euiBorderRadius; - @include euiScrollBar; -} - - -.lnsWorkspacePanel__dragDrop { - &.domDroppable--active { - p { - transition: filter $euiAnimSpeedFast ease-in-out; - filter: blur(5px); - } - - .lnsExpressionRenderer { - transition: filter $euiAnimSpeedNormal ease-in-out, opacity $euiAnimSpeedNormal ease-in-out; - filter: blur($euiSizeXS); - opacity: .25; - } - } - - -} - -.lnsWorkspacePanel__emptyContent { - position: absolute; - left: 0; - right: 0; - bottom: 0; - top: 0; - display: flex; - justify-content: center; - align-items: center; - transition: background-color $euiAnimSpeedFast ease-in-out; - - .lnsWorkspacePanel__actions { - margin-top: $euiSizeL; - } -} - -.lnsWorkspacePanelWrapper__toolbar--fullscreen { - background-color: $euiColorEmptyShade; - justify-content: flex-end; - margin-bottom: 0; - padding: $euiSizeS $euiSizeS 0; -} - -.lnsWorkspacePanelWrapper__applyButton .euiButton__text { - @include euiBreakpoint('xs', 's', 'm', 'l') { - @include euiScreenReaderOnly; - } -} - -.lnsWorkspacePanel__promptIllustration { - overflow: visible; // Shows arrow animation when it gets out of bounds - margin-top: 0; - margin-bottom: -$euiSize; - - margin-right: auto; - margin-left: auto; - max-width: 176px; - max-height: 176px; -} diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx index 44e601954d1ba..09d77fe103ebb 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx @@ -5,7 +5,6 @@ * 2.0. */ -import './workspace_panel_wrapper.scss'; import React, { useCallback } from 'react'; import { EuiPageTemplate, EuiFlexGroup, EuiFlexItem, EuiButton, useEuiTheme } from '@elastic/eui'; @@ -121,7 +120,9 @@ export function WorkspacePanelWrapper({ displayOptions, }: WorkspacePanelWrapperProps) { const dispatchLens = useLensDispatch(); - const { euiTheme } = useEuiTheme(); + + const euiThemeContext = useEuiTheme(); + const {euiTheme} = euiThemeContext; const changesApplied = useLensSelector(selectChangesApplied); const autoApplyEnabled = useLensSelector(selectAutoApplyEnabled); @@ -175,11 +176,14 @@ export function WorkspacePanelWrapper({ alignItems="flexEnd" gutterSize="s" direction="row" - className={classNames({ - 'lnsWorkspacePanelWrapper__toolbar--fullscreen': isFullscreen, - })} css={css` margin-bottom: ${euiTheme.size.xs}; + ${isFullscreen && ` + background-color: ${euiTheme.colors.emptyShade}; + justify-content: flex-end; + margin-bottom: 0; + padding: ${euiTheme.size.s} ${euiTheme.size.s} 0; + `} `} responsive={false} > @@ -236,16 +240,28 @@ export function WorkspacePanelWrapper({ contentProps={{ className: 'lnsWorkspacePanelWrapper__content', }} - className={classNames('lnsWorkspacePanelWrapper stretch-for-sharing', { - 'lnsWorkspacePanelWrapper--fullscreen': isFullscreen, - })} + className={classNames('lnsWorkspacePanelWrapper stretch-for-sharing')} css={css` height: 100%; + margin-bottom: ${euiTheme.size.base}; + display: flex; + flex-direction: column; + position: relative; // For positioning the dnd overlay + min-height: 400px; + overflow: visible; + height: 100%; + .lnsWorkspacePanelWrapper__content { width: 100%; height: 100%; position: absolute; } + ${isFullscreen && ` + margin-bottom: 0; + .lnsWorkspacePanelWrapper__pageContentBody { + box-shadow: none; + border-radius: 0; + }`} `} color="transparent" > diff --git a/x-pack/platform/plugins/shared/lens/public/expression_renderer_styles.tsx b/x-pack/platform/plugins/shared/lens/public/expression_renderer_styles.tsx new file mode 100644 index 0000000000000..189c60c62c71f --- /dev/null +++ b/x-pack/platform/plugins/shared/lens/public/expression_renderer_styles.tsx @@ -0,0 +1,15 @@ +import { UseEuiTheme, useEuiScrollBar } from "@elastic/eui" +import { css } from "@emotion/react" + + +export const lnsExpressionRendererStyle = (euiThemeContext : UseEuiTheme) => { + return css` + position: relative; + width: 100%; + height: 100%; + display: flex; + overflow: auto; + // important for visualizations with no padding + border-radius: ${euiThemeContext.euiTheme.border.radius.medium}; + ${useEuiScrollBar()}; +`} diff --git a/x-pack/platform/plugins/shared/lens/public/react_embeddable/expression_wrapper.tsx b/x-pack/platform/plugins/shared/lens/public/react_embeddable/expression_wrapper.tsx index 986be7d7e9c7e..1a21366199269 100644 --- a/x-pack/platform/plugins/shared/lens/public/react_embeddable/expression_wrapper.tsx +++ b/x-pack/platform/plugins/shared/lens/public/react_embeddable/expression_wrapper.tsx @@ -18,6 +18,7 @@ import classNames from 'classnames'; import { getOriginalRequestErrorMessages } from '../editor_frame_service/error_helper'; import { LensInspector } from '../lens_inspector_service'; import { UserMessage } from '../types'; +import { lnsExpressionRendererStyle } from '../expression_renderer_styles'; export interface ExpressionWrapperProps { ExpressionRenderer: ReactExpressionRendererType; @@ -77,6 +78,7 @@ export function ExpressionWrapper({ return (
              From 48d28ab54bc71c340f537ef2e4aa2225d3b93a2d Mon Sep 17 00:00:00 2001 From: mbondyra Date: Wed, 19 Feb 2025 15:28:00 +0100 Subject: [PATCH 15/37] wip --- .../editor_frame/config_panel/layer_panel.tsx | 16 +- .../editor_frame/frame_layout.scss | 62 -------- .../editor_frame/frame_layout.tsx | 93 ++++++++---- .../geo_field_workspace_panel.tsx | 2 +- .../workspace_panel/workspace_panel.tsx | 139 +++++++++--------- .../workspace_panel_wrapper.tsx | 13 +- .../public/expression_renderer_styles.tsx | 31 ++-- 7 files changed, 177 insertions(+), 179 deletions(-) delete mode 100644 x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.scss diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx index 2df1601f78451..d19aed58beca7 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx @@ -362,7 +362,7 @@ export function LayerPanel(props: LayerPanelProps) { tabIndex={-1} ref={registerLayerRef} css={css` - margin-bottom: ${euiTheme.size.base}; + margin-bottom: ${euiTheme.size.base}; // disable focus ring for mouse clicks, leave it for keyboard users &:focus:not(:focus-visible) { animation: none !important; // sass-lint:disable-line no-important @@ -490,28 +490,30 @@ export function LayerPanel(props: LayerPanelProps) { return ( * { + & > * { margin-bottom: 0; } // Targeting EUI class as we are unable to apply a class to this element in component &, .euiFormRow__fieldWrapper { - &>*+* { + & > * + * { margin-top: ${euiTheme.size.s}; } - }`} + } + `} className="lnsLayerPanel__row" fullWidth label={ diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.scss b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.scss deleted file mode 100644 index a17f8f6621029..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.scss +++ /dev/null @@ -1,62 +0,0 @@ -$lnsPanelMinWidth: $euiSize * 18; - -.lnsFrameLayout__pageContent { - overflow: hidden; - flex-grow: 1; - flex-direction: row; - @include euiBreakpoint('xs', 's', 'm') { - flex-wrap: wrap; - overflow: auto; - > * { - flex-basis: 100%; - } - > .lnsFrameLayout__sidebar { - min-height: $euiSizeL * 15; - } - } -} - -.lnsFrameLayout__pageBody { - min-width: $lnsPanelMinWidth + $euiSizeXL; - overflow: hidden auto; - display: flex; - flex-direction: column; - flex: 1 1 100%; - // Leave out bottom padding so the suggestions scrollbar stays flush to window edge - // Leave out left padding so the left sidebar's focus states are visible outside of content bounds - // This also means needing to add same amount of margin to page content and suggestion items - padding: $euiSize $euiSize 0; - position: relative; - z-index: 1; - border-left: $euiBorderThin; - border-right: $euiBorderThin; - @include euiScrollBar; - &:first-child { - padding-left: $euiSize; - } -} - -.lnsFrameLayout__pageBody.lnsFrameLayout__pageBody-isFullscreen { - flex: 1; - padding: 0; -} - -.lnsFrameLayout__sidebar { - margin: 0; - flex: 1 0 18%; - min-width: $lnsPanelMinWidth + $euiSize; - display: flex; - flex-direction: column; - position: relative; -} - -.lnsFrameLayout__sidebar--right { - flex-basis: 25%; - min-width: $lnsPanelMinWidth + 70; - max-width: $euiFormMaxWidth + $euiSizeXXL; - max-height: 100%; - - @include euiBreakpoint('xs', 's', 'm') { - max-width: 100%; - } -} \ No newline at end of file diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx index b75f2ac311985..2e1b752eb7d97 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx @@ -5,8 +5,6 @@ * 2.0. */ -import './frame_layout.scss'; - import React from 'react'; import { EuiScreenReaderOnly, @@ -16,9 +14,9 @@ import { EuiPageBody, useEuiTheme, euiBreakpoint, + UseEuiTheme, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import classNames from 'classnames'; import { css } from '@emotion/react'; import { useLensSelector, selectIsFullscreenDatasource } from '../../state_management'; @@ -70,22 +68,35 @@ export function FrameLayout(props: FrameLayoutProps) { ${euiBreakpoint(euiTheme, ['xs', 's', 'm'])} { position: static; } - ${isFullscreen && - `.lnsFrameLayout__sidebar--left { - // Hide the datapanel in fullscreen mode. Using display: none does trigger - // a rerender when the container becomes visible again, maybe pushing offscreen is better - display: none; - }`} `} > * { + flex-basis: 100%; + } + } + `} >

              @@ -97,9 +108,28 @@ export function FrameLayout(props: FrameLayoutProps) { {props.dataPanel}

              {props.workspacePanel} -
              - {props.suggestionsPanel} -
              +
              {props.suggestionsPanel}
              @@ -142,3 +171,17 @@ export function FrameLayout(props: FrameLayoutProps) { ); } + +const sidebarStyles = (euiThemeContext: UseEuiTheme) => css` + margin: 0; + flex: 1 0 18%; + min-width: 304px; + display: flex; + flex-direction: column; + position: relative; + ${euiBreakpoint(euiThemeContext, ['xs', 's', 'm'])} { + > .lnsFrameLayout__sidebar { + min-height: ${euiThemeContext.euiTheme.size.l} * 15; + } + } +`; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx index 3dc1c1fe5108b..f0e32ee12d78a 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx @@ -51,7 +51,7 @@ export function GeoFieldWorkspacePanel(props: Props) {

              {getVisualizeGeoFieldMessage(props.fieldType)}

              - + (NaN); const esTookTime = useRef(0); - const {euiTheme} = useEuiTheme(); + const { euiTheme } = useEuiTheme(); const onRender$ = useCallback(() => { if (renderDeps.current) { @@ -499,21 +509,18 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({ } return ( - +

              @@ -527,18 +534,20 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({

              {!expressionExists && ( -
              +
              - {i18n.translate('xpack.lens.editorFrame.emptyWorkspaceHeading', { - defaultMessage: 'Lens is the recommended editor for creating visualizations', - })} + {i18n.translate('xpack.lens.editorFrame.emptyWorkspaceHeading', { + defaultMessage: 'Lens is the recommended editor for creating visualizations', + })} - +

              +

              - +

              -

              {renderWorkspaceContents()}
              +
              + {renderWorkspaceContents()} +
              ); }; @@ -744,7 +750,7 @@ export const VisualizationWrapper = ({ onComponentRendered(); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - const {euiTheme} = useEuiTheme() + const { euiTheme } = useEuiTheme(); const searchContext = useLensSelector(selectExecutionContextSearch); // Used for reporting @@ -781,12 +787,14 @@ export const VisualizationWrapper = ({ return (
              { +export const promptIllustrationStyle = ({ euiTheme }: UseEuiTheme) => { return css` - overflow: visible; // Shows arrow animation when it gets out of bounds - margin-top: 0; - margin-bottom: -${euiTheme.size.base}; - - margin-right: auto; - margin-left: auto; - max-width: 176px; - max-height: 176px; -`} + overflow: visible; // Shows arrow animation when it gets out of bounds + margin-top: 0; + margin-bottom: -${euiTheme.size.base}; + + margin-right: auto; + margin-left: auto; + max-width: 176px; + max-height: 176px; + `; +}; -export const pageContentBodyStyles = ({euiTheme} : UseEuiTheme) => { +export const pageContentBodyStyles = ({ euiTheme }: UseEuiTheme) => { const euiScrollBar = useEuiScrollBar(); return css` flex-grow: 1; - display: flex; - align-items: stretch; - justify-content: stretch; - border: ${euiTheme.border.thin}; - border-radius: ${euiTheme.border.radius.medium}; - background: ${euiTheme.colors.emptyShade}; - height: 100%; - ${euiScrollBar}; - &>* { - flex: 1 1 100%; display: flex; - align-items: center; - justify-content: center; - } - ` -} + align-items: stretch; + justify-content: stretch; + border: ${euiTheme.border.thin}; + border-radius: ${euiTheme.border.radius.medium}; + background: ${euiTheme.colors.emptyShade}; + height: 100%; + ${euiScrollBar}; + & > * { + flex: 1 1 100%; + display: flex; + align-items: center; + justify-content: center; + } + `; +}; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx index 09d77fe103ebb..3c0608cd7c6f2 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx @@ -5,7 +5,6 @@ * 2.0. */ - import React, { useCallback } from 'react'; import { EuiPageTemplate, EuiFlexGroup, EuiFlexItem, EuiButton, useEuiTheme } from '@elastic/eui'; import classNames from 'classnames'; @@ -120,9 +119,9 @@ export function WorkspacePanelWrapper({ displayOptions, }: WorkspacePanelWrapperProps) { const dispatchLens = useLensDispatch(); - - const euiThemeContext = useEuiTheme(); - const {euiTheme} = euiThemeContext; + + const euiThemeContext = useEuiTheme(); + const { euiTheme } = euiThemeContext; const changesApplied = useLensSelector(selectChangesApplied); const autoApplyEnabled = useLensSelector(selectAutoApplyEnabled); @@ -178,7 +177,8 @@ export function WorkspacePanelWrapper({ direction="row" css={css` margin-bottom: ${euiTheme.size.xs}; - ${isFullscreen && ` + ${isFullscreen && + ` background-color: ${euiTheme.colors.emptyShade}; justify-content: flex-end; margin-bottom: 0; @@ -256,7 +256,8 @@ export function WorkspacePanelWrapper({ height: 100%; position: absolute; } - ${isFullscreen && ` + ${isFullscreen && + ` margin-bottom: 0; .lnsWorkspacePanelWrapper__pageContentBody { box-shadow: none; diff --git a/x-pack/platform/plugins/shared/lens/public/expression_renderer_styles.tsx b/x-pack/platform/plugins/shared/lens/public/expression_renderer_styles.tsx index 189c60c62c71f..a431ecb30fa4b 100644 --- a/x-pack/platform/plugins/shared/lens/public/expression_renderer_styles.tsx +++ b/x-pack/platform/plugins/shared/lens/public/expression_renderer_styles.tsx @@ -1,15 +1,22 @@ -import { UseEuiTheme, useEuiScrollBar } from "@elastic/eui" -import { css } from "@emotion/react" +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import { UseEuiTheme, useEuiScrollBar } from '@elastic/eui'; +import { css } from '@emotion/react'; -export const lnsExpressionRendererStyle = (euiThemeContext : UseEuiTheme) => { +export const lnsExpressionRendererStyle = (euiThemeContext: UseEuiTheme) => { return css` - position: relative; - width: 100%; - height: 100%; - display: flex; - overflow: auto; - // important for visualizations with no padding - border-radius: ${euiThemeContext.euiTheme.border.radius.medium}; - ${useEuiScrollBar()}; -`} + position: relative; + width: 100%; + height: 100%; + display: flex; + overflow: auto; + // important for visualizations with no padding + border-radius: ${euiThemeContext.euiTheme.border.radius.medium}; + ${useEuiScrollBar()}; + `; +}; From 2e9eae12f293023edd68595374ab0bed338438a4 Mon Sep 17 00:00:00 2001 From: mbondyra Date: Wed, 19 Feb 2025 22:23:18 +0100 Subject: [PATCH 16/37] wip --- .../dimension_panel/dimension_panel.test.tsx | 5 +- .../form_based/layerpanel.test.tsx | 5 +- .../definitions/filters/filters.test.tsx | 9 +-- .../definitions/ranges/ranges.test.tsx | 34 +++++------ .../editor_frame/frame_layout.tsx | 37 ++++++----- .../editor_frame/suggestion_panel.test.tsx | 2 +- .../geo_field_workspace_panel.tsx | 5 +- .../workspace_panel/workspace_panel.tsx | 10 +-- .../workspace_panel_wrapper.tsx | 3 +- .../public/expression_renderer_styles.tsx | 3 +- .../shared/lens/public/mocks/store_mocks.tsx | 28 ++++----- .../react_embeddable/expression_wrapper.tsx | 2 +- .../dataview_picker/trigger.test.tsx | 19 +++--- .../lens/public/test_utils/test_utils.tsx | 61 +++++++++++++++++++ .../components/dimension_editor.test.tsx | 10 +-- .../legacy_metric/dimension_editor.test.tsx | 18 +++--- .../xy/xy_config_panel/layer_header.test.tsx | 8 +-- 17 files changed, 163 insertions(+), 96 deletions(-) create mode 100644 x-pack/platform/plugins/shared/lens/public/test_utils/test_utils.tsx diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_panel.test.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_panel.test.tsx index 3df7248ae3f3d..6ce9b88339bec 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_panel.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_panel.test.tsx @@ -7,7 +7,7 @@ import { ReactWrapper, ShallowWrapper, ComponentType, mount } from 'enzyme'; import React, { ChangeEvent } from 'react'; -import { screen, act, render, within } from '@testing-library/react'; +import { screen, act, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { findTestSubject } from '@elastic/eui/lib/test'; import { @@ -51,6 +51,7 @@ import { AdvancedOptions } from './advanced_options'; import { coreMock } from '@kbn/core/public/mocks'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import { LensAppServices } from '../../../app_plugin/types'; +import { renderWithProviders } from '../../../test_utils/test_utils'; jest.mock('./reference_editor', () => ({ ReferenceEditor: () => null, @@ -302,7 +303,7 @@ describe('FormBasedDimensionEditor', () => { ); }; - const rtlRender = render( + const rtlRender = renderWithProviders( , { wrapper: Wrapper, diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/layerpanel.test.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/layerpanel.test.tsx index 93902547dd603..0134124668613 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/layerpanel.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/layerpanel.test.tsx @@ -8,10 +8,11 @@ import React from 'react'; import { FormBasedPrivateState } from './types'; import { FormBasedLayerPanelProps, LayerPanel } from './layerpanel'; -import { fireEvent, render, screen, within } from '@testing-library/react'; +import { fireEvent, screen, within } from '@testing-library/react'; import { getFieldByNameFactory } from './pure_helpers'; import { TermsIndexPatternColumn } from './operations'; import userEvent from '@testing-library/user-event'; +import { renderWithProviders } from '../../test_utils/test_utils'; Object.defineProperty(HTMLElement.prototype, 'scrollWidth', { value: 400 }); Object.defineProperty(HTMLElement.prototype, 'offsetWidth', { value: 200 }); @@ -225,7 +226,7 @@ describe('Layer Data Panel', () => { }; }); - const renderLayerPanel = () => render(); + const renderLayerPanel = () => renderWithProviders(); it('should list all index patterns', async () => { renderLayerPanel(); diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.test.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.test.tsx index a742ce97168e0..e2eec91c91531 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.test.tsx @@ -13,12 +13,13 @@ import type { IUiSettingsClient, HttpSetup } from '@kbn/core/public'; import type { IStorageWrapper } from '@kbn/kibana-utils-plugin/public'; import { dataPluginMock } from '@kbn/data-plugin/public/mocks'; import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks'; -import { fireEvent, render, screen } from '@testing-library/react'; +import { fireEvent, screen } from '@testing-library/react'; import type { FiltersIndexPatternColumn } from '.'; import { filtersOperation } from '..'; import type { FormBasedLayer } from '../../../types'; import { createMockedIndexPattern } from '../../../mocks'; import userEvent from '@testing-library/user-event'; +import { renderWithProviders } from '../../../../../test_utils/test_utils'; const uiSettingsMock = {} as IUiSettingsClient; @@ -304,7 +305,7 @@ describe('filters', () => { // Workaround for timeout via https://github.com/testing-library/user-event/issues/833#issuecomment-1171452841 const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime }); const updateLayerSpy = jest.fn(); - render( + renderWithProviders( { describe('Modify filters', () => { it('should correctly show existing filters ', () => { const updateLayerSpy = jest.fn(); - render( + renderWithProviders( { const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime }); jest.useFakeTimers(); const updateLayerSpy = jest.fn(); - render( + renderWithProviders( { it('should start update the state with the default maxBars value', () => { const updateLayerSpy = jest.fn(); - const instance = mount( + const instance = mountWithProviders( { it('should update state when changing Max bars number', () => { const updateLayerSpy = jest.fn(); - const instance = mount( + const instance = mountWithProviders( { it('should update the state using the plus or minus buttons by the step amount', () => { const updateLayerSpy = jest.fn(); - const instance = mount( + const instance = mountWithProviders( { it('should show one range interval to start with', () => { const updateLayerSpy = jest.fn(); - const instance = mount( + const instance = mountWithProviders( { it('should use the parentFormat to create the trigger label', () => { const updateLayerSpy = jest.fn(); - const instance = mount( + const instance = mountWithProviders( { // we intercept the formatter without an id assigned an print "Error" const updateLayerSpy = jest.fn(); - const instance = mount( + const instance = mountWithProviders( { it('should add a new range', () => { const updateLayerSpy = jest.fn(); - const instance = mount( + const instance = mountWithProviders( { it('should add a new range with custom label', () => { const updateLayerSpy = jest.fn(); - const instance = mount( + const instance = mountWithProviders( { it('should open a popover to edit an existing range', () => { const updateLayerSpy = jest.fn(); - const instance = mount( + const instance = mountWithProviders( { it('should not accept invalid ranges', () => { const updateLayerSpy = jest.fn(); - const instance = mount( + const instance = mountWithProviders( { label: '', }); - const instance = mount( + const instance = mountWithProviders( { label: '', }); - const instance = mount( + const instance = mountWithProviders( { it('should correctly handle the default formatter for the field', () => { const updateLayerSpy = jest.fn(); - const instance = mount( + const instance = mountWithProviders( { params: { decimals: 0 }, }; - const instance = mount( + const instance = mountWithProviders( { it('should not update the state on mount', () => { const updateLayerSpy = jest.fn(); - mount( + mountWithProviders( { params: { decimals: 3 }, }; - const instance = mount( + const instance = mountWithProviders(

              @@ -126,7 +129,8 @@ export function FrameLayout(props: FrameLayoutProps) { &:first-child { padding-left: ${euiTheme.euiTheme.size.base}; } - ${isFullscreen && ` + ${isFullscreen && + ` flex: 1; padding: 0;`} `} @@ -143,16 +147,19 @@ export function FrameLayout(props: FrameLayoutProps) {
              {props.suggestionsPanel}
              diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx index 24fe5c971558c..979fcb4c5b9d3 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx @@ -219,7 +219,7 @@ describe('suggestion_panel', () => { expect(getSuggestionsMock).toHaveBeenCalledTimes(1); }); - it('should highlight currently active suggestion', async () => { + it.skip('should highlight currently active suggestion', async () => { const { instance } = await mountWithProvider(, { preloadedState, }); diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx index f0e32ee12d78a..46d4c24ba8747 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx @@ -45,7 +45,10 @@ export function GeoFieldWorkspacePanel(props: Props) { } return ( -
              +

              diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx index b49a0cd4c2e61..73825ec23047e 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx @@ -21,7 +21,6 @@ import { useEuiTheme, EuiSpacer, UseEuiTheme, - useEuiScrollBar, } from '@elastic/eui'; import type { CoreStart } from '@kbn/core/public'; import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; @@ -669,7 +668,10 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({ value={dropProps.value} order={dropProps.order} > -
              +
              {renderWorkspaceContents()}
              @@ -786,7 +788,7 @@ export const VisualizationWrapper = ({ return (
              { }; export const pageContentBodyStyles = ({ euiTheme }: UseEuiTheme) => { - const euiScrollBar = useEuiScrollBar(); return css` flex-grow: 1; display: flex; @@ -861,7 +862,6 @@ export const pageContentBodyStyles = ({ euiTheme }: UseEuiTheme) => { border-radius: ${euiTheme.border.radius.medium}; background: ${euiTheme.colors.emptyShade}; height: 100%; - ${euiScrollBar}; & > * { flex: 1 1 100%; display: flex; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx index 3c0608cd7c6f2..0d42ecd90b954 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx @@ -257,8 +257,7 @@ export function WorkspacePanelWrapper({ position: absolute; } ${isFullscreen && - ` - margin-bottom: 0; + ` margin-bottom: 0; .lnsWorkspacePanelWrapper__pageContentBody { box-shadow: none; border-radius: 0; diff --git a/x-pack/platform/plugins/shared/lens/public/expression_renderer_styles.tsx b/x-pack/platform/plugins/shared/lens/public/expression_renderer_styles.tsx index a431ecb30fa4b..b922d23366052 100644 --- a/x-pack/platform/plugins/shared/lens/public/expression_renderer_styles.tsx +++ b/x-pack/platform/plugins/shared/lens/public/expression_renderer_styles.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { UseEuiTheme, useEuiScrollBar } from '@elastic/eui'; +import { UseEuiTheme } from '@elastic/eui'; import { css } from '@emotion/react'; export const lnsExpressionRendererStyle = (euiThemeContext: UseEuiTheme) => { @@ -17,6 +17,5 @@ export const lnsExpressionRendererStyle = (euiThemeContext: UseEuiTheme) => { overflow: auto; // important for visualizations with no padding border-radius: ${euiThemeContext.euiTheme.border.radius.medium}; - ${useEuiScrollBar()}; `; }; diff --git a/x-pack/platform/plugins/shared/lens/public/mocks/store_mocks.tsx b/x-pack/platform/plugins/shared/lens/public/mocks/store_mocks.tsx index 87667c21fed20..d5c9a6c545007 100644 --- a/x-pack/platform/plugins/shared/lens/public/mocks/store_mocks.tsx +++ b/x-pack/platform/plugins/shared/lens/public/mocks/store_mocks.tsx @@ -6,12 +6,12 @@ */ import React, { PropsWithChildren, ReactElement } from 'react'; -import { ReactWrapper, mount } from 'enzyme'; +import { ReactWrapper } from 'enzyme'; import { Provider } from 'react-redux'; import { PreloadedState } from '@reduxjs/toolkit'; -import { RenderOptions, render } from '@testing-library/react'; -import { I18nProvider } from '@kbn/i18n-react'; +import { RenderOptions } from '@testing-library/react'; import { LensAppServices } from '../app_plugin/types'; +import { mountWithProviders, renderWithProviders } from '../test_utils/test_utils'; import { makeConfigureStore, LensAppState, LensState, LensStoreDeps } from '../state_management'; import { getResolvedDateRange } from '../utils'; import { DatasourceMap, VisualizationMap } from '../types'; @@ -86,17 +86,13 @@ export const renderWithReduxStore = ( const CustomWrapper = wrapper as React.ComponentType>; - const Wrapper: React.FC> = ({ children }) => { - return ( - - - {wrapper ? {children} : children} - - - ); - }; + const Wrapper: React.FC> = ({ children }) => ( + + {wrapper ? {children} : children} + + ); - const rtlRender = render(ui, { wrapper: Wrapper, ...options }); + const rtlRender = renderWithProviders(ui, { wrapper: Wrapper, ...options }); return { store, @@ -145,7 +141,7 @@ export const mountWithProvider = async ( } ) => { const { mountArgs, lensStore, deps } = getMountWithProviderParams(component, store, options); - const instance = mount(mountArgs.component, mountArgs.options); + const instance = mountWithProviders(mountArgs.component, mountArgs.options); return { instance, lensStore, deps }; }; @@ -161,9 +157,7 @@ const getMountWithProviderParams = ( const { store: lensStore, deps } = makeLensStore(store || {}); let wrappingComponent: React.FC> = ({ children }) => ( - - {children} - + {children} ); let restOptions: { diff --git a/x-pack/platform/plugins/shared/lens/public/react_embeddable/expression_wrapper.tsx b/x-pack/platform/plugins/shared/lens/public/react_embeddable/expression_wrapper.tsx index 1a21366199269..f402a55c78aad 100644 --- a/x-pack/platform/plugins/shared/lens/public/react_embeddable/expression_wrapper.tsx +++ b/x-pack/platform/plugins/shared/lens/public/react_embeddable/expression_wrapper.tsx @@ -77,7 +77,7 @@ export function ExpressionWrapper({ if (!expression) return null; return (
              { describe('base version (no icons)', () => { it('should render the basic button', () => { - render( + renderWithProviders( ); expect(screen.getByText('Trigger label')).toBeInTheDocument(); }); it('should render the title if provided', () => { - render( + renderWithProviders( { it('should call the toggle callback on click', async () => { const toggleFn = jest.fn(); - render( + renderWithProviders( { expect(toggleFn).toHaveBeenCalled(); }); - it('should render the main label as red if missing', () => { - render( + it.skip('should render the main label as red if missing', () => { + renderWithProviders( { describe('with icons', () => { it('should render one icon', () => { - render( + renderWithProviders( { it('should render multiple icons', () => { const indexes = [1, 2, 3]; - render( + renderWithProviders( { }); it('should render the value together with the provided component', () => { - render( + renderWithProviders( { + const { wrapper, ...options } = renderOptions || {}; + + const CustomWrapper = wrapper as React.ComponentType>; + + const Wrapper: React.FC> = ({ children }) => { + return ( + + + {wrapper ? {children} : children} + + + ); + }; + + const rtlRender = render(ui, { wrapper: Wrapper, ...options }); + + return rtlRender; +}; + +export const mountWithProviders = (component: React.ReactElement, options?: MountRendererProps) => { + const { wrappingComponent, wrappingComponentProps } = options || {}; + + const WrappingComponent = wrappingComponent as React.ComponentType>; + + const wrapper: React.FC> = ({ children }) => ( + + + {WrappingComponent ? ( + {children} + ) : ( + children + )} + + + ); + + const instance = mount(component, { + ...options, + wrappingComponent: wrapper as ComponentType>, + }); + return instance; +}; diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/dimension_editor.test.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/dimension_editor.test.tsx index ee8566df52ff0..e27489f9989a6 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/dimension_editor.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/dimension_editor.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { DEFAULT_COLOR_MAPPING_CONFIG } from '@kbn/coloring'; -import { act, render, screen } from '@testing-library/react'; +import { act, screen } from '@testing-library/react'; import userEvent, { type UserEvent } from '@testing-library/user-event'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; import { LayerTypes } from '@kbn/expression-xy-plugin/public'; @@ -18,9 +18,9 @@ import { createMockDatasource, createMockFramePublicAPI } from '../../../mocks'; import { TableDimensionEditor, TableDimensionEditorProps } from './dimension_editor'; import { ColumnState } from '../../../../common/expressions'; import { capitalize } from 'lodash'; -import { I18nProvider } from '@kbn/i18n-react'; import { DatatableColumnType } from '@kbn/expressions-plugin/common'; import { getKbnPalettes } from '@kbn/palettes'; +import { renderWithProviders } from '../../../test_utils/test_utils'; describe('data table dimension editor', () => { let user: UserEvent; @@ -111,12 +111,12 @@ describe('data table dimension editor', () => { }); const renderTableDimensionEditor = (overrideProps?: Partial) => { - return render(, { + return renderWithProviders(, { wrapper: ({ children }) => ( - + <>
              {children} - + ), }); }; diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/legacy_metric/dimension_editor.test.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/legacy_metric/dimension_editor.test.tsx index b4ac97cd5edd7..e6091bec0b5de 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/legacy_metric/dimension_editor.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/legacy_metric/dimension_editor.test.tsx @@ -9,7 +9,6 @@ import React from 'react'; import { EuiButtonGroup } from '@elastic/eui'; import { FramePublicAPI, VisualizationDimensionEditorProps } from '../../types'; import { createMockDatasource, createMockFramePublicAPI } from '../../mocks'; -import { mountWithIntl } from '@kbn/test-jest-helpers'; import { MetricDimensionEditor } from './dimension_editor'; import { chartPluginMock } from '@kbn/charts-plugin/public/mocks'; import { ColorMode } from '@kbn/charts-plugin/public'; @@ -25,6 +24,7 @@ import { PalettePanelContainer } from '../../shared_components'; import { LayerTypes } from '@kbn/expression-xy-plugin/public'; import type { LegacyMetricState } from '../../../common/types'; import { DatasourcePublicAPI } from '../..'; +import { mountWithProviders } from '../../test_utils/test_utils'; function paletteParamsContaining(paramsToCheck: PaletteOutput['params']) { return expect.objectContaining({ @@ -90,7 +90,7 @@ describe('metric dimension editor', () => { }); it('should not show the dynamic coloring option for non numeric columns', () => { - const instance = mountWithIntl(); + const instance = mountWithProviders(); expect( instance.find('[data-test-subj="lnsLegacyMetric_dynamicColoring_groups"]').exists() ).toBe(false); @@ -99,7 +99,7 @@ describe('metric dimension editor', () => { it('should set the dynamic coloring default to "none"', () => { frame.activeData!.first.columns[0].meta.type = 'number'; - const instance = mountWithIntl(); + const instance = mountWithProviders(); expect( instance .find('[data-test-subj="lnsLegacyMetric_dynamicColoring_groups"]') @@ -113,7 +113,7 @@ describe('metric dimension editor', () => { it('should show the dynamic palette display ony when colorMode is different from "none"', () => { frame.activeData!.first.columns[0].meta.type = 'number'; state.colorMode = ColorMode.Labels; - const instance = mountWithIntl(); + const instance = mountWithProviders(); expect( instance .find('[data-test-subj="lnsLegacyMetric_dynamicColoring_groups"]') @@ -126,7 +126,7 @@ describe('metric dimension editor', () => { it('should prefill the palette stops with some colors when enabling coloring', () => { frame.activeData!.first.columns[0].meta.type = 'number'; - const instance = mountWithIntl(); + const instance = mountWithProviders(); act(() => { instance @@ -146,7 +146,7 @@ describe('metric dimension editor', () => { it('should open the palette panel when "Settings" link is clicked in the palette input', () => { frame.activeData!.first.columns[0].meta.type = 'number'; state.colorMode = ColorMode.Background; - const instance = mountWithIntl(); + const instance = mountWithProviders(); act(() => { instance.find('[data-test-subj="lns_colorEditing_trigger"]').first().simulate('click'); @@ -160,7 +160,7 @@ describe('metric dimension editor', () => { frame.activeData!.first.columns[0].meta.type = 'number'; frame.activeData!.first.rows[0].foo = 0; state.colorMode = ColorMode.Background; - const instance = mountWithIntl(); + const instance = mountWithProviders(); act(() => { instance.find('[data-test-subj="lns_colorEditing_trigger"]').first().simulate('click'); @@ -174,7 +174,7 @@ describe('metric dimension editor', () => { frame.activeData!.first.columns[0].meta.type = 'number'; frame.activeData!.first.rows[0].foo = -1; state.colorMode = ColorMode.Background; - const instance = mountWithIntl(); + const instance = mountWithProviders(); act(() => { instance.find('[data-test-subj="lns_colorEditing_trigger"]').first().simulate('click'); @@ -189,7 +189,7 @@ describe('metric dimension editor', () => { frame.activeData!.first.rows[0].foo = 5; state.colorMode = ColorMode.None; state.palette = undefined; - const instance = mountWithIntl(); + const instance = mountWithProviders(); act(() => { instance diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/xy/xy_config_panel/layer_header.test.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/xy/xy_config_panel/layer_header.test.tsx index a6271fc868db1..c7567af36d70d 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/xy/xy_config_panel/layer_header.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/xy/xy_config_panel/layer_header.test.tsx @@ -8,7 +8,6 @@ import React from 'react'; import { FramePublicAPI } from '../../../types'; -import { mountWithIntl } from '@kbn/test-jest-helpers'; import { LayerHeader } from './layer_header'; import { XYByReferenceAnnotationLayerConfig, @@ -16,6 +15,7 @@ import { XYLayerConfig, XYState, } from '../types'; +import { mountWithProviders } from '../../../test_utils/test_utils'; describe('layer header', () => { describe('annotation layer header', () => { @@ -61,20 +61,20 @@ describe('layer header', () => { }; expect( - mountWithIntl() + mountWithProviders() .text() .trim() ).toBe('Annotations'); expect( - mountWithIntl() + mountWithProviders() .text() .trim() ).toBe(byRefGroupTitle); const cachedMetadata = { title: 'A cached title', description: '', tags: [] }; expect( - mountWithIntl( + mountWithProviders( ) .text() From e523c89243d15ad45b350b77b945643fd251f0d2 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 19 Feb 2025 21:48:02 +0000 Subject: [PATCH 17/37] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../shared/kbn-chart-icons/src/assets/drop_illustration.tsx | 5 ++--- .../components/dimension_buttons/dimension_button.tsx | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/platform/packages/shared/kbn-chart-icons/src/assets/drop_illustration.tsx b/src/platform/packages/shared/kbn-chart-icons/src/assets/drop_illustration.tsx index ef5464fd4ec53..d2d743f8f1211 100644 --- a/src/platform/packages/shared/kbn-chart-icons/src/assets/drop_illustration.tsx +++ b/src/platform/packages/shared/kbn-chart-icons/src/assets/drop_illustration.tsx @@ -56,7 +56,6 @@ export const DropIllustration = ({ title, titleId, ...props }: Omit Date: Wed, 19 Feb 2025 22:52:43 +0100 Subject: [PATCH 18/37] wip --- .../datasources/form_based/datapanel.test.tsx | 11 +- .../dimension_panel/dimension_panel.test.tsx | 198 +++++++----------- .../dimension_panel/format_selector.test.tsx | 39 +--- .../lens/public/test_utils/test_utils.tsx | 35 ++-- 4 files changed, 110 insertions(+), 173 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.test.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.test.tsx index 9208b0f4f7f25..adf7fb9adf570 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.test.tsx @@ -10,8 +10,7 @@ import { DataView } from '@kbn/data-views-plugin/public'; import { UI_SETTINGS } from '@kbn/data-plugin/public'; import { dataPluginMock } from '@kbn/data-plugin/public/mocks'; import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks'; -import { render, screen, within } from '@testing-library/react'; -import { I18nProvider } from '@kbn/i18n-react'; +import { screen, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { FormBasedDataPanel, FormBasedDataPanelProps } from './datapanel'; import * as UseExistingFieldsApi from '@kbn/unified-field-list/src/hooks/use_existing_fields'; @@ -28,6 +27,7 @@ import { uiActionsPluginMock } from '@kbn/ui-actions-plugin/public/mocks'; import { createIndexPatternServiceMock } from '../../mocks/data_views_service_mock'; import { createMockFramePublicAPI } from '../../mocks'; import { DataViewsState } from '../../state_management'; +import { renderWithProviders } from '../../test_utils/test_utils'; const user = userEvent.setup({ advanceTimers: jest.advanceTimersByTime }); @@ -241,11 +241,8 @@ const waitToLoad = async () => await act(async () => new Promise((resolve) => setTimeout(resolve, 0))); const renderFormBasedDataPanel = async (propsOverrides?: Partial) => { - const { rerender, ...rest } = render( - , - { - wrapper: ({ children }) => {children}, - } + const { rerender, ...rest } = renderWithProviders( + ); await waitToLoad(); return { diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_panel.test.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_panel.test.tsx index 6ce9b88339bec..134e3e278a1eb 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_panel.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_panel.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { ReactWrapper, ShallowWrapper, ComponentType, mount } from 'enzyme'; +import { ReactWrapper, ShallowWrapper } from 'enzyme'; import React, { ChangeEvent } from 'react'; import { screen, act, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; @@ -17,7 +17,6 @@ import { EuiRange, EuiSelect, EuiComboBoxProps, - EuiThemeProvider, } from '@elastic/eui'; import { unifiedSearchPluginMock } from '@kbn/unified-search-plugin/public/mocks'; import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks'; @@ -48,10 +47,7 @@ import { TimeShift } from './time_shift'; import { ReducedTimeRange } from './reduced_time_range'; import { DimensionEditor } from './dimension_editor'; import { AdvancedOptions } from './advanced_options'; -import { coreMock } from '@kbn/core/public/mocks'; -import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; -import { LensAppServices } from '../../../app_plugin/types'; -import { renderWithProviders } from '../../../test_utils/test_utils'; +import { mountWithProviders, renderWithProviders } from '../../../test_utils/test_utils'; jest.mock('./reference_editor', () => ({ ReferenceEditor: () => null, @@ -168,25 +164,6 @@ const bytesColumn: GenericIndexPatternColumn = { params: { format: { id: 'bytes' } }, }; -const wrappingComponent: React.FC<{ - children: React.ReactNode; -}> = ({ children }) => { - return ( - - {children} - - ); -}; - -function mountWithServices(component: React.ReactElement): ReactWrapper { - return mount(component, { - // This is an elegant way to wrap a component in Enzyme - // preserving the root at the component level rather than - // at the wrapper one - wrappingComponent: wrappingComponent as ComponentType<{}>, - }); -} - /** * The datasource exposes four main pieces of code which are tested at * an integration test level. The main reason for this fairly high level @@ -293,21 +270,8 @@ describe('FormBasedDimensionEditor', () => { }); const renderDimensionPanel = (propsOverrides = {}) => { - const Wrapper: React.FC<{ - children: React.ReactNode; - }> = ({ children }) => { - return ( - - {children} - - ); - }; - const rtlRender = renderWithProviders( - , - { - wrapper: Wrapper, - } + ); const getVisibleFieldSelectOptions = () => { @@ -397,14 +361,14 @@ describe('FormBasedDimensionEditor', () => { }; }); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); const options = getFieldSelectComboBox(wrapper).prop('options'); expect(options![1].options!.map(({ label }) => label)).toEqual(['timestampLabel', 'source']); }); it('should indicate fields which are incompatible for the operation of the current column', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( { }); it('should indicate operations which are incompatible for the field of the current column', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( { }); it('should indicate when a transition is invalid due to filterOperations', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( { }); it('should not display hidden operation types', () => { - wrapper = mountWithServices(); + wrapper = mountWithProviders(); const items: EuiListGroupItemProps[] = wrapper.find(EuiListGroup).prop('listItems') || []; @@ -483,7 +447,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should indicate that reference-based operations are not compatible when they are incomplete', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( { }); it('should indicate that reference-based operations are compatible sometimes', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( { it('should keep the operation when switching to another field compatible with this operation', async () => { const initialState: FormBasedPrivateState = getStateWithColumns({ col1: bytesColumn }); - wrapper = mountWithServices( + wrapper = mountWithProviders( ); @@ -602,7 +566,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should switch operations when selecting a field that requires another operation', async () => { - wrapper = mountWithServices(); + wrapper = mountWithProviders(); const comboBox = getFieldSelectComboBox(wrapper); const option = comboBox.prop('options')![1].options!.find(({ label }) => label === 'source')!; @@ -634,7 +598,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should keep the field when switching to another operation compatible for this field', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( { }); it('should not set the state if selecting the currently active operation', () => { - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { wrapper @@ -678,7 +642,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should update label and custom label flag on label input changes', () => { - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { wrapper @@ -706,7 +670,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should not keep the label as long as it is the default label', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( { }); it('should keep the label on operation change if it is custom', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( { }); it('should remove customLabel flag if label is set to default', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( { describe('transient invalid state', () => { it('should set the state if selecting an operation incompatible with the current field', async () => { - wrapper = mountWithServices(); + wrapper = mountWithProviders(); await act(async () => { await wrapper @@ -837,7 +801,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should show error message in invalid state', () => { - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { wrapper @@ -851,7 +815,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should leave error state if a compatible operation is selected', () => { - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { wrapper @@ -869,7 +833,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should leave error state if the original operation is re-selected', () => { - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { wrapper @@ -887,7 +851,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should leave error state when switching from incomplete state to fieldless operation', async () => { - wrapper = mountWithServices(); + wrapper = mountWithProviders(); await act(async () => { await wrapper @@ -902,7 +866,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should leave error state when re-selecting the original fieldless function', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( { }); it('should indicate fields compatible with selected operation', async () => { - wrapper = mountWithServices(); + wrapper = mountWithProviders(); await act(async () => { await wrapper @@ -955,7 +919,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should select compatible operation if field not compatible with selected operation', async () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( ); @@ -1023,7 +987,7 @@ describe('FormBasedDimensionEditor', () => { references: ['ref'], }, }); - wrapper = mountWithServices( + wrapper = mountWithProviders( ); @@ -1050,7 +1014,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should select the Records field when count is selected on non-existing column', async () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( { }); it('should indicate document and field compatibility with selected document operation', async () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( { }); it('should set datasource state if compatible field is selected for operation', async () => { - wrapper = mountWithServices(); + wrapper = mountWithProviders(); await act(async () => { await wrapper .find('button[data-test-subj="lns-indexPatternDimension-terms incompatible"]') @@ -1166,7 +1130,7 @@ describe('FormBasedDimensionEditor', () => { } it('should default to None if time scaling is not set', () => { - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { findTestSubject(wrapper, 'indexPattern-advanced-accordion').simulate('click'); }); @@ -1180,7 +1144,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should show current time scaling if set', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( ); act(() => { @@ -1196,7 +1160,7 @@ describe('FormBasedDimensionEditor', () => { it('should allow to set time scaling initially', () => { const props = getProps({}); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { findTestSubject(wrapper, 'indexPattern-advanced-accordion').simulate('click'); }); @@ -1233,7 +1197,7 @@ describe('FormBasedDimensionEditor', () => { operationType: 'sum', label: 'Sum of bytes per hour', }); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { wrapper.find('button[data-test-subj="lns-indexPatternDimension-count"]').simulate('click'); }); @@ -1262,7 +1226,7 @@ describe('FormBasedDimensionEditor', () => { operationType: 'sum', label: 'Sum of bytes per hour', }); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { wrapper .find('button[data-test-subj="lns-indexPatternDimension-average"]') @@ -1288,7 +1252,7 @@ describe('FormBasedDimensionEditor', () => { it('should allow to change time scaling', () => { const props = getProps({ timeScale: 's', label: 'Count of records per second' }); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { findTestSubject(wrapper, 'indexPattern-advanced-accordion').simulate('click'); }); @@ -1321,7 +1285,7 @@ describe('FormBasedDimensionEditor', () => { it('should not adjust label if it is custom', () => { const props = getProps({ timeScale: 's', customLabel: true, label: 'My label' }); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { wrapper .find('[data-test-subj="indexPattern-time-scaling-unit"] select') @@ -1391,7 +1355,7 @@ describe('FormBasedDimensionEditor', () => { }), columnId: 'col2', }; - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { findTestSubject(wrapper, 'indexPattern-advanced-accordion').simulate('click'); }); @@ -1401,7 +1365,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should show current reduced time range if set', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( ); expect( @@ -1411,7 +1375,7 @@ describe('FormBasedDimensionEditor', () => { it('should allow to set reduced time range initially', () => { const props = getProps({}); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { findTestSubject(wrapper, 'indexPattern-advanced-accordion').simulate('click'); }); @@ -1443,7 +1407,7 @@ describe('FormBasedDimensionEditor', () => { operationType: 'sum', label: 'Sum of bytes per hour', }); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { wrapper.find('button[data-test-subj="lns-indexPatternDimension-count"]').simulate('click'); }); @@ -1467,7 +1431,7 @@ describe('FormBasedDimensionEditor', () => { const props = getProps({ timeShift: '1d', }); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { wrapper.find(ReducedTimeRange).find(EuiComboBox).prop('onCreateOption')!('7m', []); }); @@ -1491,7 +1455,7 @@ describe('FormBasedDimensionEditor', () => { const props = getProps({ reducedTimeRange: '5 months', }); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); expect(wrapper.find(ReducedTimeRange).find(EuiComboBox).prop('isInvalid')).toBeTruthy(); @@ -1548,7 +1512,7 @@ describe('FormBasedDimensionEditor', () => { }), columnId: 'col2', }; - wrapper = mountWithServices( + wrapper = mountWithProviders( { }); it('should show custom options if time shift is available', () => { - wrapper = mountWithServices(); + wrapper = mountWithProviders(); expect( wrapper .find(DimensionEditor) @@ -1577,7 +1541,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should show current time shift if set', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( ); expect(wrapper.find(TimeShift).find(EuiComboBox).prop('selectedOptions')[0].value).toEqual( @@ -1587,7 +1551,7 @@ describe('FormBasedDimensionEditor', () => { it('should allow to set time shift initially', () => { const props = getProps({}); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { findTestSubject(wrapper, 'indexPattern-advanced-accordion').simulate('click'); }); @@ -1617,7 +1581,7 @@ describe('FormBasedDimensionEditor', () => { operationType: 'sum', label: 'Sum of bytes per hour', }); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { wrapper.find('button[data-test-subj="lns-indexPatternDimension-count"]').simulate('click'); }); @@ -1641,7 +1605,7 @@ describe('FormBasedDimensionEditor', () => { const props = getProps({ timeShift: '1d', }); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { wrapper.find(TimeShift).find(EuiComboBox).prop('onCreateOption')!('1h', []); }); @@ -1665,7 +1629,7 @@ describe('FormBasedDimensionEditor', () => { const props = getProps({ timeShift: '5 months', }); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); expect(wrapper.find(TimeShift).find(EuiComboBox).prop('isInvalid')).toBeTruthy(); @@ -1682,7 +1646,7 @@ describe('FormBasedDimensionEditor', () => { const props = getProps({ timeShift: 'startAt(2022-11-02T00:00:00.000Z)', }); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); expect(wrapper.find(TimeShift).find(EuiComboBox).prop('isInvalid')).toBeTruthy(); @@ -1726,7 +1690,7 @@ describe('FormBasedDimensionEditor', () => { } it('should not show custom options if time scaling is not available', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( { }); it('should show custom options if filtering is available', () => { - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { findTestSubject(wrapper, 'indexPattern-advanced-accordion').simulate('click'); }); @@ -1755,7 +1719,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should show current filter if set', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( @@ -1776,7 +1740,7 @@ describe('FormBasedDimensionEditor', () => { operationType: 'sum', label: 'Sum of bytes per hour', }); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { wrapper.find('button[data-test-subj="lns-indexPatternDimension-count"]').simulate('click'); }); @@ -1802,7 +1766,7 @@ describe('FormBasedDimensionEditor', () => { filter: { language: 'kuery', query: 'a: b' }, }); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { const { updateLayer, columnId, layer } = wrapper.find(Filtering).props(); @@ -1833,7 +1797,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should render invalid field if field reference is broken', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( { }); it('should support selecting the operation before the field', async () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( ); await act(async () => { @@ -1916,7 +1880,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should select operation directly if only one field is possible', async () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( { }); it('should select operation directly if only document is possible', async () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( ); await act(async () => { @@ -1992,7 +1956,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should indicate compatible fields when selecting the operation first', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( ); @@ -2016,7 +1980,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should indicate document compatibility when document operation is selected', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( { }); it('should not update when selecting the current field again', async () => { - wrapper = mountWithServices(); + wrapper = mountWithProviders(); const comboBox = getFieldSelectComboBox(wrapper); @@ -2054,7 +2018,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should show all operations that are not filtered out', () => { - wrapper = mountWithServices( + wrapper = mountWithProviders( !op.isBucketed && op.dataType === 'number'} @@ -2087,7 +2051,7 @@ describe('FormBasedDimensionEditor', () => { // Prevents field format from being loaded setState.mockImplementation(() => {}); - wrapper = mountWithServices( + wrapper = mountWithProviders( ); @@ -2130,7 +2094,7 @@ describe('FormBasedDimensionEditor', () => { const initialState: FormBasedPrivateState = getStateWithColumns({ col1: bytesColumn, }); - wrapper = mountWithServices( + wrapper = mountWithProviders( ); act(() => { @@ -2150,7 +2114,7 @@ describe('FormBasedDimensionEditor', () => { }); it('should keep the latest valid dimension when removing the selection in field combobox', () => { - wrapper = mountWithServices(); + wrapper = mountWithProviders(); act(() => { getFieldSelectComboBox(wrapper as ReactWrapper).prop('onChange')!([]); }); @@ -2170,7 +2134,7 @@ describe('FormBasedDimensionEditor', () => { }, }); - wrapper = mountWithServices( + wrapper = mountWithProviders( ); @@ -2214,7 +2178,7 @@ describe('FormBasedDimensionEditor', () => { }, }, }); - wrapper = mountWithServices( + wrapper = mountWithProviders( ); @@ -2255,7 +2219,7 @@ describe('FormBasedDimensionEditor', () => { }, }); - wrapper = mountWithServices( + wrapper = mountWithProviders( ); @@ -2287,7 +2251,7 @@ describe('FormBasedDimensionEditor', () => { it('should hide the top level field selector when switching from non-reference to reference', async () => { (generateId as jest.Mock).mockReturnValue(`second`); - wrapper = mountWithServices(); + wrapper = mountWithProviders(); expect(wrapper.find('ReferenceEditor')).toHaveLength(0); @@ -2312,7 +2276,7 @@ describe('FormBasedDimensionEditor', () => { }, }); - wrapper = mountWithServices( + wrapper = mountWithProviders( ); @@ -2338,7 +2302,7 @@ describe('FormBasedDimensionEditor', () => { }, }); - wrapper = mountWithServices( + wrapper = mountWithProviders( ); @@ -2363,7 +2327,7 @@ describe('FormBasedDimensionEditor', () => { }), }; - wrapper = mountWithServices( + wrapper = mountWithProviders( { }), }; - wrapper = mountWithServices( + wrapper = mountWithProviders( ); @@ -2445,7 +2409,7 @@ describe('FormBasedDimensionEditor', () => { }, }); - wrapper = mountWithServices( + wrapper = mountWithProviders( ); @@ -2466,7 +2430,7 @@ describe('FormBasedDimensionEditor', () => { }, }); - wrapper = mountWithServices( + wrapper = mountWithProviders( ); @@ -2485,7 +2449,7 @@ describe('FormBasedDimensionEditor', () => { }, }); - wrapper = mountWithServices( + wrapper = mountWithProviders( { it('should select the quick function tab by default', () => { const stateWithNoColumn: FormBasedPrivateState = getStateWithColumns({}); - wrapper = mountWithServices( + wrapper = mountWithProviders( ); @@ -2516,7 +2480,7 @@ describe('FormBasedDimensionEditor', () => { it('should select the static value tab when supported by default', () => { const stateWithNoColumn: FormBasedPrivateState = getStateWithColumns({}); - wrapper = mountWithServices( + wrapper = mountWithProviders( { }, }); - wrapper = mountWithServices( + wrapper = mountWithProviders( '0.0'); - return { - ...services, - docLinks: { - links: { - indexPatterns: { fieldFormattersNumber: '' }, - }, - }, - } as unknown as LensAppServices; -} - const renderFormatSelector = (propsOverrides?: Partial) => { - const WrappingComponent: React.FC<{ - children: React.ReactNode; - }> = ({ children }) => { - return ( - - {children} - - ); - }; - return render(, { - wrapper: WrappingComponent, - }); + return renderWithProviders(); }; -// Skipped for update of userEvent v14: https://github.com/elastic/kibana/pull/189949 -// It looks like the individual tests within each it block are not really pure, -// see for example the first two tests, they run the same code but expect -// different results. With the updated userEvent code the tests no longer work -// with this setup and should be refactored. describe('FormatSelector', () => { let user: UserEvent; diff --git a/x-pack/platform/plugins/shared/lens/public/test_utils/test_utils.tsx b/x-pack/platform/plugins/shared/lens/public/test_utils/test_utils.tsx index 536c58a916895..26e33239af3ea 100644 --- a/x-pack/platform/plugins/shared/lens/public/test_utils/test_utils.tsx +++ b/x-pack/platform/plugins/shared/lens/public/test_utils/test_utils.tsx @@ -6,11 +6,14 @@ */ import { EuiThemeProvider } from '@elastic/eui'; +import { coreMock } from '@kbn/core/public/mocks'; import { I18nProvider } from '@kbn/i18n-react'; +import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import { RenderOptions, render } from '@testing-library/react'; import { ComponentType, MountRendererProps, mount } from 'enzyme'; import React from 'react'; import { PropsWithChildren, ReactElement } from 'react'; +import { LensAppServices } from '../app_plugin/types'; export const renderWithProviders = ( ui: ReactElement, @@ -23,11 +26,13 @@ export const renderWithProviders = ( const Wrapper: React.FC> = ({ children }) => { return ( - - - {wrapper ? {children} : children} - - + + + + {wrapper ? {children} : children} + + + ); }; @@ -42,15 +47,17 @@ export const mountWithProviders = (component: React.ReactElement, options?: Moun const WrappingComponent = wrappingComponent as React.ComponentType>; const wrapper: React.FC> = ({ children }) => ( - - - {WrappingComponent ? ( - {children} - ) : ( - children - )} - - + + + + {WrappingComponent ? ( + {children} + ) : ( + children + )} + + + ); const instance = mount(component, { From 09eacd5bc65adc3eb25f342a5f2855b50bfd29ef Mon Sep 17 00:00:00 2001 From: mbondyra Date: Fri, 21 Feb 2025 09:25:36 +0100 Subject: [PATCH 19/37] tests --- .../shared/kbn-chart-icons/src/assets/drop_illustration.tsx | 1 - .../apps/dashboard/group6/dashboard_esql_no_data.ts | 2 +- .../test/functional/apps/lens/group2/persistent_context.ts | 2 +- x-pack/test/functional/page_objects/lens_page.ts | 6 +++--- x-pack/test/functional/services/ml/data_visualizer_table.ts | 2 +- .../async_search/save_search_session_relative_time.ts | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/platform/packages/shared/kbn-chart-icons/src/assets/drop_illustration.tsx b/src/platform/packages/shared/kbn-chart-icons/src/assets/drop_illustration.tsx index d2d743f8f1211..f66ab4f7d37fc 100644 --- a/src/platform/packages/shared/kbn-chart-icons/src/assets/drop_illustration.tsx +++ b/src/platform/packages/shared/kbn-chart-icons/src/assets/drop_illustration.tsx @@ -49,7 +49,6 @@ export const DropIllustration = ({ title, titleId, ...props }: Omit diff --git a/test/functional/apps/dashboard/group6/dashboard_esql_no_data.ts b/test/functional/apps/dashboard/group6/dashboard_esql_no_data.ts index 58fe8aa36d95f..46001ff6f57e4 100644 --- a/test/functional/apps/dashboard/group6/dashboard_esql_no_data.ts +++ b/test/functional/apps/dashboard/group6/dashboard_esql_no_data.ts @@ -31,7 +31,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await PageObjects.dashboard.waitForRenderComplete(); await PageObjects.dashboard.expectOnDashboard('New Dashboard'); - expect(await testSubjects.exists('lnsVisualizationContainer')).to.be(true); + expect(await testSubjects.exists('lnsDataTableContainer')).to.be(true); await panelActions.clickEdit(); const editorValue = await monacoEditor.getCodeEditorValue(); diff --git a/x-pack/test/functional/apps/lens/group2/persistent_context.ts b/x-pack/test/functional/apps/lens/group2/persistent_context.ts index b1e78d0ccb34d..487dc7c2684fc 100644 --- a/x-pack/test/functional/apps/lens/group2/persistent_context.ts +++ b/x-pack/test/functional/apps/lens/group2/persistent_context.ts @@ -45,7 +45,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await navigationalSearch.focus(); await navigationalSearch.searchFor('type:lens lnsTableVis'); await navigationalSearch.clickOnOption(0); - await lens.waitForWorkspaceWithVisualization(); + await lens.waitForDatatableVisualization(); }); it('filters, time and query reflect the visualization state', async () => { expect(await lens.getDatatableHeaderText(1)).to.equal('404 › Median of bytes'); diff --git a/x-pack/test/functional/page_objects/lens_page.ts b/x-pack/test/functional/page_objects/lens_page.ts index 47eacb2604983..f5c19383b31cf 100644 --- a/x-pack/test/functional/page_objects/lens_page.ts +++ b/x-pack/test/functional/page_objects/lens_page.ts @@ -347,9 +347,9 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont }); }, - async waitForWorkspaceWithVisualization() { + async waitForDatatableVisualization() { await retry.try(async () => { - await testSubjects.existOrFail(`lnsVisualizationContainer`); + await testSubjects.existOrFail(`lnsDataTableContainer`); }); }, @@ -1561,7 +1561,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont async waitForVisualization(visDataTestSubj?: string) { async function getRenderingCount() { const visualizationContainer = await testSubjects.find( - visDataTestSubj || 'lnsVisualizationContainer' + visDataTestSubj || 'lnsDataTableContainer' ); const renderingCount = await visualizationContainer.getAttribute('data-rendering-count'); return Number(renderingCount); diff --git a/x-pack/test/functional/services/ml/data_visualizer_table.ts b/x-pack/test/functional/services/ml/data_visualizer_table.ts index 9bf1baf4a33d5..ea91a231a96c7 100644 --- a/x-pack/test/functional/services/ml/data_visualizer_table.ts +++ b/x-pack/test/functional/services/ml/data_visualizer_table.ts @@ -563,7 +563,7 @@ export function MachineLearningDataVisualizerTableProvider( await testSubjects.clickWhenNotDisabledWithoutRetry( this.rowSelector(fieldName, 'dataVisualizerActionViewInLensButton') ); - await testSubjects.existOrFail(visualizationContainer ?? 'lnsVisualizationContainer', { + await testSubjects.existOrFail(visualizationContainer ?? 'lnsDataTableContainer', { timeout: 15 * 1000, }); }); diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session_relative_time.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session_relative_time.ts index a73594e3b805a..6fd1b6f949076 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session_relative_time.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session_relative_time.ts @@ -84,7 +84,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { log.debug('Checking no error labels'); await dashboardExpect.noErrorEmbeddablesPresent(); log.debug('Checking charts rendered'); - await elasticChart.waitForRenderComplete(visualizationContainer ?? 'lnsVisualizationContainer'); + await elasticChart.waitForRenderComplete(visualizationContainer ?? 'lnsDataTableContainer'); log.debug('Checking saved searches rendered'); await dashboardExpect.savedSearchRowCount(11); log.debug('Checking input controls rendered'); From 4776baa1d3d3dac6cb3a5ed342ef7df3c49728d2 Mon Sep 17 00:00:00 2001 From: mbondyra Date: Fri, 21 Feb 2025 10:57:47 +0100 Subject: [PATCH 20/37] wip --- .../dimension_buttons/dimension_button.tsx | 1 - .../group6/dashboard_esql_no_data.ts | 2 +- .../lens/public/app_plugin/lens_top_nav.tsx | 6 +----- .../editor_frame/suggestion_panel.test.tsx | 21 +++++++++---------- .../editor_frame/suggestion_panel.tsx | 9 ++++---- .../geo_field_workspace_panel.tsx | 5 +---- .../workspace_panel/workspace_panel.tsx | 11 ++++++++-- .../workspace_panel_wrapper.tsx | 7 +------ .../dataview_picker/trigger.test.tsx | 10 ++++++--- .../datatable/components/table_basic.test.tsx | 2 +- .../datatable/components/table_basic.tsx | 4 ++-- .../test/functional/page_objects/lens_page.ts | 4 ++-- .../services/ml/data_visualizer_table.ts | 2 +- .../save_search_session_relative_time.ts | 2 +- 14 files changed, 42 insertions(+), 44 deletions(-) diff --git a/src/platform/packages/shared/kbn-visualization-ui-components/components/dimension_buttons/dimension_button.tsx b/src/platform/packages/shared/kbn-visualization-ui-components/components/dimension_buttons/dimension_button.tsx index 594b83a3a20ea..3163f89e7dfd1 100644 --- a/src/platform/packages/shared/kbn-visualization-ui-components/components/dimension_buttons/dimension_button.tsx +++ b/src/platform/packages/shared/kbn-visualization-ui-components/components/dimension_buttons/dimension_button.tsx @@ -75,7 +75,6 @@ function DimensionButtonImpl({ css` - ${euiBreakpoint(euiThemeContext, ['m', 'l', 'xl'])} { - margin-right: ${euiThemeContext.euiTheme.size.m}; - position: relative; - } ${useEuiBreakpoint(['m', 'l', 'xl'])} { margin-right: ${euiThemeContext.euiTheme.size.m}; position: relative; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx index 979fcb4c5b9d3..21834fb14ab7a 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx @@ -13,7 +13,9 @@ import { createExpressionRendererMock, DatasourceMock, createMockFramePublicAPI, + renderWithReduxStore, } from '../../mocks'; +import { screen } from '@testing-library/react'; import { act } from 'react-dom/test-utils'; import { ReactExpressionRendererType } from '@kbn/expressions-plugin/public'; import { SuggestionPanel, SuggestionPanelProps, SuggestionPanelWrapper } from './suggestion_panel'; @@ -32,6 +34,7 @@ import { VisualizationState, } from '../../state_management'; import { setChangesApplied } from '../../state_management/lens_slice'; +import { userEvent } from '@testing-library/user-event'; const SELECTORS = { APPLY_CHANGES_BUTTON: 'button[data-test-subj="lnsApplyChanges__suggestions"]', @@ -219,19 +222,15 @@ describe('suggestion_panel', () => { expect(getSuggestionsMock).toHaveBeenCalledTimes(1); }); - it.skip('should highlight currently active suggestion', async () => { - const { instance } = await mountWithProvider(, { + it('should select currently active suggestion', async () => { + const getSuggestionByName = (name: string) => screen.getByRole('listitem', { name }); + + renderWithReduxStore(, undefined, { preloadedState, }); - act(() => { - instance.find(SELECTORS.SUGGESTION_TILE_BUTTON).at(2).simulate('click'); - }); - - instance.update(); - - expect(instance.find(SELECTORS.SUGGESTION_TILE_BUTTON).at(2).prop('className')).toContain( - 'lnsSuggestionPanel__button-isSelected' - ); + expect(getSuggestionByName('Current visualization')).toHaveAttribute('aria-current', 'true'); + await userEvent.click(getSuggestionByName('Suggestion1')); + expect(getSuggestionByName('Suggestion1')).toHaveAttribute('aria-current', 'true'); }); it('should rollback suggestion if current panel is clicked', async () => { diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx index 6c64559364590..c4a9fef1dfb81 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx @@ -129,9 +129,10 @@ const PreviewRenderer = ({ hasError: boolean; onRender: () => void; }) => { - const { euiTheme } = useEuiTheme(); + const euiThemeContext = useEuiTheme(); + const { euiTheme } = euiThemeContext; const onErrorMessage = ( -
              +
              ) : ( - + )} @@ -658,7 +659,7 @@ export function SuggestionPanel({ } >
              +

              diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx index 73825ec23047e..787ee2428a603 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx @@ -669,8 +669,15 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({ order={dropProps.order} >
              {renderWorkspaceContents()}
              diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx index 0d42ecd90b954..58c9521dc0e25 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx @@ -256,12 +256,7 @@ export function WorkspacePanelWrapper({ height: 100%; position: absolute; } - ${isFullscreen && - ` margin-bottom: 0; - .lnsWorkspacePanelWrapper__pageContentBody { - box-shadow: none; - border-radius: 0; - }`} + ${isFullscreen && `margin-bottom: 0;`} `} color="transparent" > diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/trigger.test.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/trigger.test.tsx index 8c9e6cfec769a..a305d9374e67d 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/trigger.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/trigger.test.tsx @@ -10,6 +10,7 @@ import { screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { TriggerButton } from './trigger'; import { renderWithProviders } from '../../test_utils/test_utils'; +import * as ToolbarButtonFile from './toolbar_button'; describe('TriggerButton', () => { describe('base version (no icons)', () => { @@ -47,7 +48,8 @@ describe('TriggerButton', () => { expect(toggleFn).toHaveBeenCalled(); }); - it.skip('should render the main label as red if missing', () => { + it('should render the main label as red if missing', () => { + const ToolbarButtonSpy = jest.spyOn(ToolbarButtonFile, 'ToolbarButton'); renderWithProviders( { isMissingCurrent /> ); - // EUI danger red: rgb(167, 22, 39) - expect(screen.getByTestId('test-id')).toHaveStyle({ color: 'rgb(167, 22, 39)' }); + expect(ToolbarButtonSpy).toHaveBeenCalledWith( + expect.objectContaining({ color: 'danger' }), + {} + ); }); }); diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.test.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.test.tsx index 55f31cfcf03ed..992e79681d415 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.test.tsx @@ -308,7 +308,7 @@ describe('DatatableComponent', () => { rows: [{ a: undefined, b: undefined, c: undefined }], }, }); - expect(screen.getByTestId('lnsDataTableContainer')).toHaveTextContent('No results found'); + expect(screen.getByTestId('lnsVisualizationContainer')).toHaveTextContent('No results found'); }); test('it renders the table with the given sorting', async () => { diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.tsx index a82f4aebf1fc4..e5f79357afb44 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.tsx @@ -509,7 +509,7 @@ export const DatatableComponent = (props: DatatableRenderProps) => {
              @@ -526,7 +526,7 @@ export const DatatableComponent = (props: DatatableRenderProps) => {
              { - await testSubjects.existOrFail(`lnsDataTableContainer`); + await testSubjects.existOrFail(`lnsVisualizationContainer`); }); }, @@ -1561,7 +1561,7 @@ export function LensPageProvider({ getService, getPageObjects }: FtrProviderCont async waitForVisualization(visDataTestSubj?: string) { async function getRenderingCount() { const visualizationContainer = await testSubjects.find( - visDataTestSubj || 'lnsDataTableContainer' + visDataTestSubj || 'lnsVisualizationContainer' ); const renderingCount = await visualizationContainer.getAttribute('data-rendering-count'); return Number(renderingCount); diff --git a/x-pack/test/functional/services/ml/data_visualizer_table.ts b/x-pack/test/functional/services/ml/data_visualizer_table.ts index ea91a231a96c7..9bf1baf4a33d5 100644 --- a/x-pack/test/functional/services/ml/data_visualizer_table.ts +++ b/x-pack/test/functional/services/ml/data_visualizer_table.ts @@ -563,7 +563,7 @@ export function MachineLearningDataVisualizerTableProvider( await testSubjects.clickWhenNotDisabledWithoutRetry( this.rowSelector(fieldName, 'dataVisualizerActionViewInLensButton') ); - await testSubjects.existOrFail(visualizationContainer ?? 'lnsDataTableContainer', { + await testSubjects.existOrFail(visualizationContainer ?? 'lnsVisualizationContainer', { timeout: 15 * 1000, }); }); diff --git a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session_relative_time.ts b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session_relative_time.ts index 6fd1b6f949076..a73594e3b805a 100644 --- a/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session_relative_time.ts +++ b/x-pack/test/search_sessions_integration/tests/apps/dashboard/async_search/save_search_session_relative_time.ts @@ -84,7 +84,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { log.debug('Checking no error labels'); await dashboardExpect.noErrorEmbeddablesPresent(); log.debug('Checking charts rendered'); - await elasticChart.waitForRenderComplete(visualizationContainer ?? 'lnsDataTableContainer'); + await elasticChart.waitForRenderComplete(visualizationContainer ?? 'lnsVisualizationContainer'); log.debug('Checking saved searches rendered'); await dashboardExpect.savedSearchRowCount(11); log.debug('Checking input controls rendered'); From 2fcdb8125ef27c95a1766f8d3171674c0e90e061 Mon Sep 17 00:00:00 2001 From: mbondyra Date: Fri, 21 Feb 2025 11:05:10 +0100 Subject: [PATCH 21/37] camelCase for styles objects --- .../lens/public/app_plugin/lens_top_nav.tsx | 8 ++++---- .../datasources/common/datapanel.styles.ts | 2 +- .../datasources/form_based/datapanel.tsx | 6 +++--- .../dimension_panel/dimension_editor.tsx | 8 ++++---- .../dimensions_editor_helpers.tsx | 6 +++--- .../dimension_panel/reference_editor.tsx | 6 +++--- .../datasources/form_based/help_popover.tsx | 6 +++--- .../definitions/filters/filter_popover.tsx | 2 +- .../definitions/filters/filters.tsx | 4 ++-- .../formula/editor/formula_editor.tsx | 20 +++++++++---------- .../definitions/ranges/advanced_editor.tsx | 4 ++-- .../text_based/components/datapanel.tsx | 4 ++-- .../editor_frame/config_panel/layer_panel.tsx | 4 ++-- .../geo_field_workspace_panel.tsx | 4 ++-- .../workspace_panel/message_list.tsx | 10 +++++----- .../inline_editing/flyout.styles.ts | 2 +- .../react_embeddable/inline_editing/mount.tsx | 4 ++-- .../dataview_picker/toolbar_button.tsx | 4 ++-- .../public/shared_components/flyout.styles.ts | 2 +- .../shared_components/flyout_container.tsx | 12 +++++------ .../setting_with_sibling_flyout.tsx | 10 +++++----- .../datatable/components/table_basic.tsx | 6 +++--- .../public/visualizations/xy/add_layer.tsx | 4 ++-- 23 files changed, 69 insertions(+), 69 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/app_plugin/lens_top_nav.tsx b/x-pack/platform/plugins/shared/lens/public/app_plugin/lens_top_nav.tsx index 00a8b5588a61c..70f3685fc989f 100644 --- a/x-pack/platform/plugins/shared/lens/public/app_plugin/lens_top_nav.tsx +++ b/x-pack/platform/plugins/shared/lens/public/app_plugin/lens_top_nav.tsx @@ -103,7 +103,7 @@ function getSaveButtonMeta({ } } -const NavItemWithDividerStyles = (euiThemeContext: UseEuiTheme) => css` +const navItemWithDividerStyles = (euiThemeContext: UseEuiTheme) => css` ${useEuiBreakpoint(['m', 'l', 'xl'])} { margin-right: ${euiThemeContext.euiTheme.size.m}; position: relative; @@ -177,7 +177,7 @@ function getLensTopNavConfig(options: { values: { contextOriginatingApp }, }), disableButton: !actions.goBack.enabled, - css: NavItemWithDividerStyles, + css: navItemWithDividerStyles, }); } @@ -195,7 +195,7 @@ function getLensTopNavConfig(options: { tooltip: actions.getUnderlyingDataUrl.tooltip, target: '_blank', href: actions.getUnderlyingDataUrl.getLink?.(), - css: NavItemWithDividerStyles, + css: navItemWithDividerStyles, }); } @@ -235,7 +235,7 @@ function getLensTopNavConfig(options: { description: i18n.translate('xpack.lens.app.settingsAriaLabel', { defaultMessage: 'Open the Lens settings menu', }), - css: NavItemWithDividerStyles, + css: navItemWithDividerStyles, }); if (actions.cancel.visible) { diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/common/datapanel.styles.ts b/x-pack/platform/plugins/shared/lens/public/datasources/common/datapanel.styles.ts index e7677f0ecc779..8dc302eeaea93 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/common/datapanel.styles.ts +++ b/x-pack/platform/plugins/shared/lens/public/datasources/common/datapanel.styles.ts @@ -7,7 +7,7 @@ import { UseEuiTheme } from '@elastic/eui'; -export const DataPanelStyles = ({ euiTheme }: UseEuiTheme) => { +export const dataPanelStyles = ({ euiTheme }: UseEuiTheme) => { return ` padding: ${euiTheme.size.base} ${euiTheme.size.base} 0; .unifiedFieldListItemButton.kbnFieldButton { diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.tsx index 0be81a6986b44..0c2505f5c18d5 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.tsx @@ -40,7 +40,7 @@ import type { import type { FormBasedPrivateState } from './types'; import { IndexPatternServiceAPI } from '../../data_views_service/service'; import { FieldItem } from '../common/field_item'; -import { DataPanelStyles } from '../common/datapanel.styles'; +import { dataPanelStyles } from '../common/datapanel.styles'; export type FormBasedDataPanelProps = Omit< DatasourceDataPanelProps, @@ -116,7 +116,7 @@ export function FormBasedDataPanel({ return ( <> {Object.keys(indexPatterns).length === 0 && indexPatternRefs.length === 0 ? ( - + } > diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx index 5561a37ed5586..482c6d42af7bb 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx @@ -534,7 +534,7 @@ export function DimensionEditor(props: DimensionEditorProps) { isActive, size: 's', isDisabled: !!disabledStatus, - css: OperationsButtonStyles, + css: operationsButtonStyles, 'data-test-subj': `lns-indexPatternDimension-${operationType}${ compatibleWithCurrentField ? '' : ' incompatible' }`, @@ -811,7 +811,7 @@ export function DimensionEditor(props: DimensionEditorProps) { fullWidth > 3 ? OperationsTwoColumnsStyles : undefined} + css={sideNavItems.length > 3 ? operationsTwoColumnsStyles : undefined} gutterSize="none" color="primary" listItems={ @@ -1291,7 +1291,7 @@ export function DimensionEditor(props: DimensionEditorProps) { ); } -const OperationsTwoColumnsStyles = ({ euiTheme }: UseEuiTheme) => { +const operationsTwoColumnsStyles = ({ euiTheme }: UseEuiTheme) => { return ` display: block; column-count: 2; @@ -1299,7 +1299,7 @@ const OperationsTwoColumnsStyles = ({ euiTheme }: UseEuiTheme) => { `; }; -export const OperationsButtonStyles = ({ euiTheme }: UseEuiTheme) => { +export const operationsButtonStyles = ({ euiTheme }: UseEuiTheme) => { return ` > button { padding-top: 0; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx index adff86e7805e1..74fe54d79f820 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx @@ -153,7 +153,7 @@ export const CalloutWarning = ({ return ( <> { +const dimensionEditorWarningStyles = ({ euiTheme }: UseEuiTheme) => { return ` margin-bottom: ${euiTheme.size.base}; margin-top: ${euiTheme.size.s}; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/reference_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/reference_editor.tsx index 34640c423302d..9b8504954fc01 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/reference_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/reference_editor.tsx @@ -31,7 +31,7 @@ import type { FormBasedLayer } from '../types'; import type { IndexPattern, IndexPatternField, ParamEditorCustomProps } from '../../../types'; import type { FormBasedDimensionEditorProps } from './dimension_panel'; import { FormRow } from '../operations/definitions/shared_components'; -import { OperationsButtonStyles } from './dimension_editor'; +import { operationsButtonStyles } from './dimension_editor'; const operationDisplay = getOperationDisplay(); @@ -56,7 +56,7 @@ const getFunctionOptions = ( return { label, value: operationType, - css: OperationsButtonStyles, + css: operationsButtonStyles, 'data-test-subj': `lns-indexPatternDimension-${operationType}${ isCompatible ? '' : ' incompatible' }`, @@ -204,7 +204,7 @@ export const ReferenceEditor = (props: ReferenceEditorProps) => { const brokenFunctionOption = { label: selectedOperationType && operationDisplay[selectedOperationType].displayName, value: selectedOperationType, - css: OperationsButtonStyles, + css: operationsButtonStyles, 'data-test-subj': `lns-indexPatternDimension-${selectedOperationType} incompatible`, } as EuiComboBoxOptionOption; functionOptions?.push(brokenFunctionOption); diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.tsx index e7425462b5fd8..e6da8f310c2b5 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.tsx @@ -31,7 +31,7 @@ export const HelpPopoverButton = ({ return ( - + {children} @@ -42,14 +42,14 @@ const HelpPopoverContent = ({ title, children }: { title?: string; children: Rea return ( <> {title && {title}} - + {children} ); }; -const HelpPopoverStyles = { +const helpPopoverStyles = { button: ({ euiTheme }: UseEuiTheme) => ` margin-right: ${euiTheme.size.xs}; `, diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx index 9ec4647826fb9..338aaf59982dc 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx @@ -101,7 +101,7 @@ export const FilterPopover = ({ ); }; -export const DraggablePopoverButtonStyles = ({ euiTheme }: UseEuiTheme) => { +export const draggablePopoverButtonStyles = ({ euiTheme }: UseEuiTheme) => { const euiFontSize = useEuiFontSize('s'); return ` ${euiTextBreakWord()}; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx index 1fb2bc81c97cd..fc7a880732e9f 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx @@ -23,7 +23,7 @@ import { IndexPattern } from '../../../../../types'; import { updateColumnParam } from '../../layer_helpers'; import type { OperationDefinition } from '..'; import type { BaseIndexPatternColumn } from '../column_types'; -import { DraggablePopoverButtonStyles, FilterPopover } from './filter_popover'; +import { draggablePopoverButtonStyles, FilterPopover } from './filter_popover'; import { TermsIndexPatternColumn } from '../terms'; import { isColumnOfType } from '../helpers'; @@ -274,7 +274,7 @@ export const FilterList = ({ title={i18n.translate('xpack.lens.indexPattern.filters.clickToEdit', { defaultMessage: 'Click to edit', })} - css={DraggablePopoverButtonStyles} + css={draggablePopoverButtonStyles} > {filter.label || (filter.input.query as string) || defaultLabel} diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx index ce7f111a7f7b7..90660a3c52ef7 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx @@ -684,7 +684,7 @@ export function FormulaEditor({ // in the behavior of Monaco when it's first loaded and then reloaded. return (
              {!isFullscreen && (
              -
              +
              {i18n.translate('xpack.lens.formulaPlaceholderText', { @@ -823,7 +823,7 @@ export function FormulaEditor({ ) : null}
              -
              +
              {isFullscreen ? ( @@ -845,7 +845,7 @@ export function FormulaEditor({ defaultMessage: 'Hide function reference', })} className="lnsFormula__editorHelp lnsFormula__editorHelp--inline" - css={SharedEditorStyles.editorHelpLink} + css={sharedEditorStyles.editorHelpLink} color="text" onClick={() => setIsHelpOpen(!isHelpOpen)} > @@ -919,7 +919,7 @@ export function FormulaEditor({
              +
              { return ` .lnsFormula { @@ -1024,7 +1024,7 @@ const SharedEditorStyles = { `, }; -const DefaultEditorStyles = ({ euiTheme }: UseEuiTheme) => { +const defaultEditorStyles = ({ euiTheme }: UseEuiTheme) => { return ` .lnsFormula__editorContent { height: 200px; @@ -1032,7 +1032,7 @@ const DefaultEditorStyles = ({ euiTheme }: UseEuiTheme) => { `; }; -const FullscreenEditorStyles = ({ euiTheme }: UseEuiTheme) => { +const fullscreenEditorStyles = ({ euiTheme }: UseEuiTheme) => { return ` position: absolute; left: 0; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx index 4118b35bf7320..4ec4f514f38b1 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx @@ -32,7 +32,7 @@ import { RangeTypeLens, isValidRange } from './ranges'; import { FROM_PLACEHOLDER, TO_PLACEHOLDER, TYPING_DEBOUNCE_TIME } from './constants'; import { LabelInput } from '../shared_components'; import { isValidNumber } from '../helpers'; -import { DraggablePopoverButtonStyles } from '../filters/filter_popover'; +import { draggablePopoverButtonStyles } from '../filters/filter_popover'; const generateId = htmlIdGenerator(); @@ -308,7 +308,7 @@ export const AdvancedRangeEditor = ({ color="text" onClick={() => changeActiveRange(range.id)} data-test-subj="dataView-ranges-popover-trigger" - css={DraggablePopoverButtonStyles} + css={draggablePopoverButtonStyles} > = (field) => field?.meta.type; @@ -138,7 +138,7 @@ export function TextBasedDataPanel({ }} > diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx index d19aed58beca7..cb391fcb1b636 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx @@ -776,7 +776,7 @@ export function LayerPanel(props: LayerPanelProps) { isInlineEditing={isInlineEditing} handleClose={closeDimensionEditor} panel={ -
              +
              {openColumnGroup && openColumnId && layerDatasource && @@ -864,7 +864,7 @@ export function LayerPanel(props: LayerPanelProps) { ); } -const DimensionContainerStyles = ({ euiTheme }: UseEuiTheme) => ` +const dimensionContainerStyles = ({ euiTheme }: UseEuiTheme) => ` .lnsIndexPatternDimensionEditor--padded { padding: ${euiTheme.size.base}; } diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx index 0d36ce69472bb..6f65a987c8372 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/geo_field_workspace_panel.tsx @@ -53,7 +53,7 @@ export function GeoFieldWorkspacePanel(props: Props) {

              { +const droppableStyles = ({ euiTheme }: UseEuiTheme) => { return ` padding: ${euiTheme.size.xxl} ${euiTheme.size.xxxl}; border: ${euiTheme.border.thin}; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/message_list.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/message_list.tsx index d17f71a58dfac..6d578b1e9f23b 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/message_list.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/message_list.tsx @@ -103,11 +103,11 @@ export const MessageList = ({ isOpen={isPopoverOpen} closePopover={closePopover} > -
                +
                  {messages.map(({ hidePopoverIcon = false, ...message }, index) => (
                • {typeof message.longMessage === 'function' ? ( @@ -116,7 +116,7 @@ export const MessageList = ({ {!hidePopoverIcon && ( @@ -127,7 +127,7 @@ export const MessageList = ({ )} )} - + {message.longMessage} @@ -139,7 +139,7 @@ export const MessageList = ({ ); }; -const WorkspaceWarningListStyles = { +const workspaceWarningListStyles = { self: css` max-height: 320px; width: 256px; diff --git a/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/flyout.styles.ts b/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/flyout.styles.ts index f9f94cdce6189..45322e7cf9038 100644 --- a/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/flyout.styles.ts +++ b/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/flyout.styles.ts @@ -8,7 +8,7 @@ import { UseEuiTheme } from '@elastic/eui'; // styles needed to display extra drop targets that are outside of the config panel main area while also allowing to scroll vertically -export const InlineFlyoutStyles = ({ euiTheme }: UseEuiTheme) => ` +export const inlineFlyoutStyles = ({ euiTheme }: UseEuiTheme) => ` clip-path: polygon(-100% 0, 100% 0, 100% 100%, -100% 100%); max-inline-size: 640px; min-inline-size: 256px; diff --git a/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/mount.tsx b/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/mount.tsx index 1e765d932665c..f5b42310ac57d 100644 --- a/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/mount.tsx +++ b/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/mount.tsx @@ -10,7 +10,7 @@ import { TracksOverlays } from '@kbn/presentation-containers'; import { toMountPoint } from '@kbn/react-kibana-mount'; import React from 'react'; import ReactDOM from 'react-dom'; -import { InlineFlyoutStyles } from './flyout.styles'; +import { inlineFlyoutStyles } from './flyout.styles'; /** * Shared logic to mount the inline config panel @@ -42,7 +42,7 @@ export function mountInlineEditPanel( ), { className: 'lnsConfigPanel__overlay', - css: InlineFlyoutStyles, + css: inlineFlyoutStyles, size: 's', 'data-test-subj': 'customizeLens', type: 'push', diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/toolbar_button.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/toolbar_button.tsx index c760df9d36c6e..e9c55348510ba 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/toolbar_button.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/toolbar_button.tsx @@ -68,7 +68,7 @@ export const ToolbarButton: React.FunctionComponent = ({ data-test-subj={dataTestSubj} className={classes} iconSide="right" - css={ToolbarButtonStyles} + css={toolbarButtonStyles} iconType={hasArrow ? 'arrowDown' : ''} color="text" contentProps={{ @@ -86,7 +86,7 @@ export const ToolbarButton: React.FunctionComponent = ({ ); }; -const ToolbarButtonStyles = (euiThemeObj: UseEuiTheme) => { +const toolbarButtonStyles = (euiThemeObj: UseEuiTheme) => { const { euiTheme } = euiThemeObj; return ` &.kbnToolbarButton { diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout.styles.ts b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout.styles.ts index af97129f606ca..fbd891160b602 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout.styles.ts +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout.styles.ts @@ -19,7 +19,7 @@ const flyoutOpenCloseAnimation = keyframes` } `; -export const FlyoutContainerStyles = ({ euiTheme }: UseEuiTheme) => css` +export const flyoutContainerStyles = ({ euiTheme }: UseEuiTheme) => css` border-left: ${euiTheme.border.thin}; ${useEuiShadow('xl')}; position: fixed; diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx index 7823469a0e31a..16386cbe1f576 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx @@ -21,7 +21,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { DONT_CLOSE_DIMENSION_CONTAINER_ON_CLICK_CLASS } from '../utils'; -import { FlyoutContainerStyles } from './flyout.styles'; +import { flyoutContainerStyles } from './flyout.styles'; function fromExcludedClickTarget(event: Event) { for ( @@ -104,11 +104,11 @@ export function FlyoutContainer({ role="dialog" aria-labelledby="lnsDimensionContainerTitle" css={[ - FlyoutContainerStyles, + flyoutContainerStyles, css` box-shadow: ${isInlineEditing ? 'none !important' : 'inherit'}; `, - DimensionContainerStyles.self, + dimensionContainerStyles.self, ]} onAnimationEnd={() => { if (isOpen) { @@ -119,7 +119,7 @@ export function FlyoutContainer({ } }} > - + {isInlineEditing && ( @@ -168,7 +168,7 @@ export function FlyoutContainer({
              {customFooter || ( - + { return ` // But with custom positioning to keep it within the sidebar contents diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx index b024b6df3b57a..6301e31af6d96 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx @@ -21,7 +21,7 @@ import { UseEuiTheme, } from '@elastic/eui'; import { css } from '@emotion/react'; -import { FlyoutContainerStyles } from './flyout.styles'; +import { flyoutContainerStyles } from './flyout.styles'; const DEFAULT_TITLE = i18n.translate('xpack.lens.colorSiblingFlyoutTitle', { defaultMessage: 'Color', @@ -75,9 +75,9 @@ export function SettingWithSiblingFlyout({ role="dialog" aria-labelledby="lnsSettingWithSiblingFlyoutTitle" data-test-subj={dataTestSubj} - css={[FlyoutContainerStyles, SiblingFlyoutContainerStyles.self]} + css={[flyoutContainerStyles, siblingFlyoutContainerStyles.self]} > - + )} - + {i18n.translate('xpack.lens.settingWithSiblingFlyout.back', { defaultMessage: 'Back', @@ -126,7 +126,7 @@ export function SettingWithSiblingFlyout({ ); } -const SiblingFlyoutContainerStyles = { +const siblingFlyoutContainerStyles = { self: ({ euiTheme }: UseEuiTheme) => css` position: absolute; right: 0; diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.tsx index e5f79357afb44..27f4d68ad0cdc 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/datatable/components/table_basic.tsx @@ -507,7 +507,7 @@ export const DatatableComponent = (props: DatatableRenderProps) => { if (isEmpty) { return (
              @@ -524,7 +524,7 @@ export const DatatableComponent = (props: DatatableRenderProps) => { return (
              @@ -576,7 +576,7 @@ export const DatatableComponent = (props: DatatableRenderProps) => { ); }; -const DatatableContainerStyles = css` +const datatableContainerStyles = css` height: 100%; overflow: auto hidden; user-select: text; diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/xy/add_layer.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/xy/add_layer.tsx index 9f9f9f915f92d..a08799c76c017 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/xy/add_layer.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/xy/add_layer.tsx @@ -279,14 +279,14 @@ const ChartOptionWrapper = ({ data-test-subj={`lnsXY_seriesType-${type}`} onClick={onClick} className="euiContextMenuItem" - css={ChartOptionWrapperStyles} + css={chartOptionWrapperStyles} > ); }; -const ChartOptionWrapperStyles = ({ euiTheme }: UseEuiTheme) => ` +const chartOptionWrapperStyles = ({ euiTheme }: UseEuiTheme) => ` padding: ${euiTheme.size.s}; border-bottom: ${euiTheme.border.thin}; border-bottom-color: ${euiTheme.colors.backgroundBaseSubdued}; From beb51b22e78fae590d6400fe74e6a53346ce8b3e Mon Sep 17 00:00:00 2001 From: mbondyra Date: Fri, 21 Feb 2025 11:49:40 +0100 Subject: [PATCH 22/37] revert some --- .../shared/lens/public/app_plugin/lens_top_nav.tsx | 8 ++++---- .../operations/definitions/filters/filter_popover.tsx | 2 +- .../form_based/operations/definitions/filters/filters.tsx | 4 ++-- .../operations/definitions/ranges/advanced_editor.tsx | 4 ++-- .../shared/lens/public/shared_components/flyout.styles.ts | 2 +- .../lens/public/shared_components/flyout_container.tsx | 4 ++-- .../shared_components/setting_with_sibling_flyout.tsx | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/app_plugin/lens_top_nav.tsx b/x-pack/platform/plugins/shared/lens/public/app_plugin/lens_top_nav.tsx index 70f3685fc989f..00a8b5588a61c 100644 --- a/x-pack/platform/plugins/shared/lens/public/app_plugin/lens_top_nav.tsx +++ b/x-pack/platform/plugins/shared/lens/public/app_plugin/lens_top_nav.tsx @@ -103,7 +103,7 @@ function getSaveButtonMeta({ } } -const navItemWithDividerStyles = (euiThemeContext: UseEuiTheme) => css` +const NavItemWithDividerStyles = (euiThemeContext: UseEuiTheme) => css` ${useEuiBreakpoint(['m', 'l', 'xl'])} { margin-right: ${euiThemeContext.euiTheme.size.m}; position: relative; @@ -177,7 +177,7 @@ function getLensTopNavConfig(options: { values: { contextOriginatingApp }, }), disableButton: !actions.goBack.enabled, - css: navItemWithDividerStyles, + css: NavItemWithDividerStyles, }); } @@ -195,7 +195,7 @@ function getLensTopNavConfig(options: { tooltip: actions.getUnderlyingDataUrl.tooltip, target: '_blank', href: actions.getUnderlyingDataUrl.getLink?.(), - css: navItemWithDividerStyles, + css: NavItemWithDividerStyles, }); } @@ -235,7 +235,7 @@ function getLensTopNavConfig(options: { description: i18n.translate('xpack.lens.app.settingsAriaLabel', { defaultMessage: 'Open the Lens settings menu', }), - css: navItemWithDividerStyles, + css: NavItemWithDividerStyles, }); if (actions.cancel.visible) { diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx index 338aaf59982dc..9ec4647826fb9 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx @@ -101,7 +101,7 @@ export const FilterPopover = ({ ); }; -export const draggablePopoverButtonStyles = ({ euiTheme }: UseEuiTheme) => { +export const DraggablePopoverButtonStyles = ({ euiTheme }: UseEuiTheme) => { const euiFontSize = useEuiFontSize('s'); return ` ${euiTextBreakWord()}; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx index fc7a880732e9f..1fb2bc81c97cd 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx @@ -23,7 +23,7 @@ import { IndexPattern } from '../../../../../types'; import { updateColumnParam } from '../../layer_helpers'; import type { OperationDefinition } from '..'; import type { BaseIndexPatternColumn } from '../column_types'; -import { draggablePopoverButtonStyles, FilterPopover } from './filter_popover'; +import { DraggablePopoverButtonStyles, FilterPopover } from './filter_popover'; import { TermsIndexPatternColumn } from '../terms'; import { isColumnOfType } from '../helpers'; @@ -274,7 +274,7 @@ export const FilterList = ({ title={i18n.translate('xpack.lens.indexPattern.filters.clickToEdit', { defaultMessage: 'Click to edit', })} - css={draggablePopoverButtonStyles} + css={DraggablePopoverButtonStyles} > {filter.label || (filter.input.query as string) || defaultLabel} diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx index 4ec4f514f38b1..4118b35bf7320 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx @@ -32,7 +32,7 @@ import { RangeTypeLens, isValidRange } from './ranges'; import { FROM_PLACEHOLDER, TO_PLACEHOLDER, TYPING_DEBOUNCE_TIME } from './constants'; import { LabelInput } from '../shared_components'; import { isValidNumber } from '../helpers'; -import { draggablePopoverButtonStyles } from '../filters/filter_popover'; +import { DraggablePopoverButtonStyles } from '../filters/filter_popover'; const generateId = htmlIdGenerator(); @@ -308,7 +308,7 @@ export const AdvancedRangeEditor = ({ color="text" onClick={() => changeActiveRange(range.id)} data-test-subj="dataView-ranges-popover-trigger" - css={draggablePopoverButtonStyles} + css={DraggablePopoverButtonStyles} > css` +export const FlyoutContainerStyles = ({ euiTheme }: UseEuiTheme) => css` border-left: ${euiTheme.border.thin}; ${useEuiShadow('xl')}; position: fixed; diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx index 16386cbe1f576..506dfd634689c 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx @@ -21,7 +21,7 @@ import { } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { DONT_CLOSE_DIMENSION_CONTAINER_ON_CLICK_CLASS } from '../utils'; -import { flyoutContainerStyles } from './flyout.styles'; +import { FlyoutContainerStyles } from './flyout.styles'; function fromExcludedClickTarget(event: Event) { for ( @@ -104,7 +104,7 @@ export function FlyoutContainer({ role="dialog" aria-labelledby="lnsDimensionContainerTitle" css={[ - flyoutContainerStyles, + FlyoutContainerStyles, css` box-shadow: ${isInlineEditing ? 'none !important' : 'inherit'}; `, diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx index 6301e31af6d96..9ff6d757fa20f 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx @@ -21,7 +21,7 @@ import { UseEuiTheme, } from '@elastic/eui'; import { css } from '@emotion/react'; -import { flyoutContainerStyles } from './flyout.styles'; +import { FlyoutContainerStyles } from './flyout.styles'; const DEFAULT_TITLE = i18n.translate('xpack.lens.colorSiblingFlyoutTitle', { defaultMessage: 'Color', @@ -75,7 +75,7 @@ export function SettingWithSiblingFlyout({ role="dialog" aria-labelledby="lnsSettingWithSiblingFlyoutTitle" data-test-subj={dataTestSubj} - css={[flyoutContainerStyles, siblingFlyoutContainerStyles.self]} + css={[FlyoutContainerStyles, siblingFlyoutContainerStyles.self]} > From e140913b3c448f3b51c3dcbba5ce8753874c2b1a Mon Sep 17 00:00:00 2001 From: mbondyra Date: Fri, 21 Feb 2025 12:24:37 +0100 Subject: [PATCH 23/37] change name --- .../config_panel/config_panel.test.tsx | 4 +- .../config_panel/layer_panel.test.tsx | 18 ++--- .../editor_frame/suggestion_panel.test.tsx | 24 +++--- .../workspace_panel/workspace_panel.test.tsx | 26 +++--- .../plugins/shared/lens/public/mocks/index.ts | 2 +- .../shared/lens/public/mocks/store_mocks.tsx | 79 ++++++------------- .../state_management/load_initial.test.tsx | 4 +- 7 files changed, 61 insertions(+), 96 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.test.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.test.tsx index 679de93b8ae1b..1266d032e1d48 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/config_panel.test.tsx @@ -24,7 +24,7 @@ import { coreMock } from '@kbn/core/public/mocks'; import { UiActionsStart } from '@kbn/ui-actions-plugin/public'; import { uiActionsPluginMock } from '@kbn/ui-actions-plugin/public/mocks'; import { generateId } from '../../../id_generator'; -import { mountWithProvider } from '../../../mocks'; +import { mountWithReduxStore } from '../../../mocks'; import { LayerTypes } from '@kbn/expression-xy-plugin/public'; import { ReactWrapper } from 'enzyme'; import { createIndexPatternServiceMock } from '../../../mocks/data_views_service_mock'; @@ -81,7 +81,7 @@ describe('ConfigPanel', () => { query?: Query | AggregateQuery ) { (generateId as jest.Mock).mockReturnValue(`newId`); - return mountWithProvider( + return mountWithReduxStore( , { preloadedState: { diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx index 9cfb1597ffdd4..22851f182215c 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx @@ -18,7 +18,7 @@ import { createMockVisualization, createMockFramePublicAPI, createMockDatasource, - mountWithProvider, + mountWithReduxStore, createMockedDragDropContext, renderWithReduxStore, } from '../../../mocks'; @@ -701,7 +701,7 @@ describe('LayerPanel', () => { target.columnId !== 'a' ? { dropTypes: ['field_replace'], nextLabel: '' } : undefined ); - const { instance } = await mountWithProvider( + const { instance } = await mountWithReduxStore( @@ -760,7 +760,7 @@ describe('LayerPanel', () => { nextLabel: '', }); - const { instance } = await mountWithProvider( + const { instance } = await mountWithReduxStore( @@ -820,7 +820,7 @@ describe('LayerPanel', () => { const holder = document.createElement('div'); document.body.appendChild(holder); - const { instance } = await mountWithProvider( + const { instance } = await mountWithReduxStore( , @@ -858,7 +858,7 @@ describe('LayerPanel', () => { ], }); - const { instance } = await mountWithProvider( + const { instance } = await mountWithReduxStore( @@ -895,7 +895,7 @@ describe('LayerPanel', () => { ], }); - const { instance } = await mountWithProvider( + const { instance } = await mountWithReduxStore( @@ -936,7 +936,7 @@ describe('LayerPanel', () => { mockDatasource.onDrop.mockReturnValue(true); const updateVisualization = jest.fn(); - const { instance } = await mountWithProvider( + const { instance } = await mountWithReduxStore( { mockDatasource.onDrop.mockReturnValue(false); const updateVisualization = jest.fn(); - const { instance } = await mountWithProvider( + const { instance } = await mountWithReduxStore( { mockDatasource.onDrop.mockReturnValue(true); - const { instance } = await mountWithProvider( + const { instance } = await mountWithReduxStore( diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx index 21834fb14ab7a..cf66ee709ae32 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx @@ -22,7 +22,7 @@ import { SuggestionPanel, SuggestionPanelProps, SuggestionPanelWrapper } from '. import { getSuggestions } from './suggestion_helpers'; import { EuiIcon, EuiPanel, EuiToolTip, EuiAccordion } from '@elastic/eui'; import { IconChartDatatable } from '@kbn/chart-icons'; -import { mountWithProvider } from '../../mocks'; +import { mountWithReduxStore } from '../../mocks'; import { coreMock } from '@kbn/core/public/mocks'; import { @@ -116,7 +116,7 @@ describe('suggestion_panel', () => { }); it('should avoid completely to render SuggestionPanel when in fullscreen mode', async () => { - const { instance, lensStore } = await mountWithProvider( + const { instance, lensStore } = await mountWithReduxStore( ); expect(instance.find(SuggestionPanel).exists()).toBe(true); @@ -131,7 +131,7 @@ describe('suggestion_panel', () => { }); it('should display apply-changes prompt when changes not applied', async () => { - const { instance, lensStore } = await mountWithProvider(, { + const { instance, lensStore } = await mountWithReduxStore(, { preloadedState: { ...preloadedState, visualization: { @@ -163,7 +163,7 @@ describe('suggestion_panel', () => { }); it('should list passed in suggestions', async () => { - const { instance } = await mountWithProvider(, { + const { instance } = await mountWithReduxStore(, { preloadedState, }); @@ -199,7 +199,7 @@ describe('suggestion_panel', () => { }); it('should not update suggestions if current state is moved to staged preview', async () => { - const { instance, lensStore } = await mountWithProvider( + const { instance, lensStore } = await mountWithReduxStore( , { preloadedState } ); @@ -210,7 +210,7 @@ describe('suggestion_panel', () => { }); it('should update suggestions if staged preview is removed', async () => { - const { instance, lensStore } = await mountWithProvider( + const { instance, lensStore } = await mountWithReduxStore( , { preloadedState } ); @@ -234,7 +234,7 @@ describe('suggestion_panel', () => { }); it('should rollback suggestion if current panel is clicked', async () => { - const { instance, lensStore } = await mountWithProvider( + const { instance, lensStore } = await mountWithReduxStore( ); @@ -261,7 +261,7 @@ describe('suggestion_panel', () => { }); it('should dispatch visualization switch action if suggestion is clicked', async () => { - const { instance, lensStore } = await mountWithProvider(, { + const { instance, lensStore } = await mountWithReduxStore(, { preloadedState, }); @@ -315,7 +315,7 @@ describe('suggestion_panel', () => { mockDatasource.toExpression.mockReturnValue('datasource_expression'); - const { instance } = await mountWithProvider(, { + const { instance } = await mountWithReduxStore(, { preloadedState, }); @@ -343,14 +343,14 @@ describe('suggestion_panel', () => { }, }; - const { instance } = await mountWithProvider(, { + const { instance } = await mountWithReduxStore(, { preloadedState: newPreloadedState, }); expect(instance.html()).toEqual(null); }); it('should hide the selections when the accordion is hidden', async () => { - const { instance } = await mountWithProvider(); + const { instance } = await mountWithReduxStore(); expect(instance.find(EuiAccordion)).toHaveLength(1); act(() => { instance.find(EuiAccordion).at(0).simulate('change'); @@ -385,7 +385,7 @@ describe('suggestion_panel', () => { .mockReturnValueOnce('test | expression'); mockDatasource.toExpression.mockReturnValue('datasource_expression'); - mountWithProvider(); + mountWithReduxStore(); expect(expressionRendererMock).toHaveBeenCalledTimes(1); const passedExpression = (expressionRendererMock as jest.Mock).mock.calls[0][0].expression; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx index b57d5dc022a53..a11f953616b69 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx @@ -17,7 +17,7 @@ import { renderWithReduxStore, } from '../../../mocks'; -import { mockDataPlugin, mountWithProvider } from '../../../mocks'; +import { mockDataPlugin, mountWithReduxStore } from '../../../mocks'; import { WorkspacePanel } from './workspace_panel'; import { ReactWrapper } from 'enzyme'; @@ -367,7 +367,7 @@ describe('workspace_panel', () => { const visualizationShowing = () => instance.exists(expressionRendererMock); - const mounted = await mountWithProvider( + const mounted = await mountWithReduxStore( { mockDatasource.getLayers.mockReturnValue(['first']); const props = defaultProps; - const mounted = await mountWithProvider( + const mounted = await mountWithReduxStore( { mockDatasource.getLayers.mockReturnValue(['first']); const props = defaultProps; - const mounted = await mountWithProvider( + const mounted = await mountWithReduxStore( { mockDatasource.getLayers.mockReturnValue(['first']); const props = defaultProps; - const mounted = await mountWithProvider( + const mounted = await mountWithReduxStore( { mockDatasource.toExpression.mockReturnValue('datasource'); mockDatasource.getLayers.mockReturnValue(['table1']); - const mounted = await mountWithProvider( + const mounted = await mountWithReduxStore( { expressionRendererMock = jest.fn((_arg) => ); - const mounted = await mountWithProvider( + const mounted = await mountWithReduxStore( { .mockReturnValueOnce('datasource second'); expressionRendererMock = jest.fn((_arg) => ); - const mounted = await mountWithProvider( + const mounted = await mountWithReduxStore( { const getUserMessages = jest.fn(() => messages); - const mounted = await mountWithProvider( + const mounted = await mountWithReduxStore( { let userMessages = [] as UserMessage[]; const getUserMessageFn = jest.fn(() => userMessages); - const mounted = await mountWithProvider( + const mounted = await mountWithReduxStore( { const mockAddUserMessages = jest.fn(() => mockRemoveUserMessages); const mockGetUserMessages = jest.fn(() => []); - const mounted = await mountWithProvider( + const mounted = await mountWithReduxStore( { first: mockDatasource.publicAPIMock, }; - const mounted = await mountWithProvider( + const mounted = await mountWithReduxStore( { framePublicAPI.datasourceLayers = { first: mockDatasource.publicAPIMock, }; - const mounted = await mountWithProvider( + const mounted = await mountWithReduxStore( ({ +export const mockStoreDeps = ({ + lensServices = makeDefaultServices(), + datasourceMap = mockDatasourceMap(), + visualizationMap = mockVisualizationMap(), +}: { + lensServices?: LensAppServices; + datasourceMap?: DatasourceMap; + visualizationMap?: VisualizationMap; +} = {}) => ({ datasourceMap, visualizationMap, lensServices, @@ -102,12 +96,10 @@ export const renderWithReduxStore = ( export function makeLensStore({ preloadedState, - dispatch, storeDeps = mockStoreDeps(), }: { storeDeps?: LensStoreDeps; preloadedState?: Partial; - dispatch?: jest.Mock; }) { const data = storeDeps.lensServices.data; const store = makeConfigureStore(storeDeps, { @@ -120,8 +112,7 @@ export function makeLensStore({ }, } as unknown as PreloadedState); - const origDispatch = store.dispatch; - store.dispatch = jest.fn(dispatch || origDispatch); + store.dispatch = jest.spyOn(store, 'dispatch') as jest.Mock; return { store, deps: storeDeps }; } @@ -131,21 +122,7 @@ export interface MountStoreProps { dispatch?: jest.Mock; } -export const mountWithProvider = async ( - component: React.ReactElement, - store?: MountStoreProps, - options?: { - wrappingComponent?: React.FC>; - wrappingComponentProps?: Record; - attachTo?: HTMLElement; - } -) => { - const { mountArgs, lensStore, deps } = getMountWithProviderParams(component, store, options); - const instance = mountWithProviders(mountArgs.component, mountArgs.options); - return { instance, lensStore, deps }; -}; - -const getMountWithProviderParams = ( +export const mountWithReduxStore = async ( component: React.ReactElement, store?: MountStoreProps, options?: { @@ -159,31 +136,19 @@ const getMountWithProviderParams = ( let wrappingComponent: React.FC> = ({ children }) => ( {children} ); - - let restOptions: { - attachTo?: HTMLElement | undefined; - } = {}; - if (options) { - const { wrappingComponent: _wrappingComponent, wrappingComponentProps, ...rest } = options; - restOptions = rest; - - if (_wrappingComponent) { - wrappingComponent = ({ children }) => { - return _wrappingComponent({ - ...wrappingComponentProps, - children: {children}, - }); - }; - } + if (options?.wrappingComponent) { + wrappingComponent = ({ children }) => { + return options?.wrappingComponent?.({ + ...options?.wrappingComponentProps, + children: wrappingComponent({ children }), + }); + }; } - const mountArgs = { - component, - options: { + const instance = mountWithProviders(component, { + ...options, wrappingComponent, - ...restOptions, - } as unknown as ReactWrapper, - }; + } as unknown as ReactWrapper); - return { mountArgs, lensStore, deps }; + return { instance, lensStore, deps }; }; diff --git a/x-pack/platform/plugins/shared/lens/public/state_management/load_initial.test.tsx b/x-pack/platform/plugins/shared/lens/public/state_management/load_initial.test.tsx index 0a47af299d136..f23b33eca7e98 100644 --- a/x-pack/platform/plugins/shared/lens/public/state_management/load_initial.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/state_management/load_initial.test.tsx @@ -118,13 +118,13 @@ describe('Initializing the store', () => { }, }); - const { store, deps } = makeLensStore({ + const { store } = makeLensStore({ storeDeps, preloadedState, }); await loadInitialAppState(store, defaultProps); - const { datasourceMap } = deps; + const { datasourceMap } = storeDeps; expect(datasourceMap.testDatasource.initialize).toHaveBeenCalledWith( datasource1State, From 230f0704d1fa258ee7d26213ed6dddb2be1da788 Mon Sep 17 00:00:00 2001 From: mbondyra Date: Fri, 21 Feb 2025 13:16:58 +0100 Subject: [PATCH 24/37] remove asynchronousity --- .../config_panel/layer_panel.test.tsx | 16 +++++----- .../editor_frame/suggestion_panel.test.tsx | 32 ++++++++----------- .../workspace_panel/workspace_panel.test.tsx | 24 +++++++------- .../shared/lens/public/mocks/store_mocks.tsx | 16 +++++----- .../state_management/lens_slice.test.ts | 2 +- .../lens/public/test_utils/test_utils.tsx | 1 + 6 files changed, 44 insertions(+), 47 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx index 22851f182215c..649a760cb0ac8 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx @@ -701,7 +701,7 @@ describe('LayerPanel', () => { target.columnId !== 'a' ? { dropTypes: ['field_replace'], nextLabel: '' } : undefined ); - const { instance } = await mountWithReduxStore( + const { instance } = mountWithReduxStore( @@ -760,7 +760,7 @@ describe('LayerPanel', () => { nextLabel: '', }); - const { instance } = await mountWithReduxStore( + const { instance } = mountWithReduxStore( @@ -820,7 +820,7 @@ describe('LayerPanel', () => { const holder = document.createElement('div'); document.body.appendChild(holder); - const { instance } = await mountWithReduxStore( + const { instance } = mountWithReduxStore( , @@ -858,7 +858,7 @@ describe('LayerPanel', () => { ], }); - const { instance } = await mountWithReduxStore( + const { instance } = mountWithReduxStore( @@ -895,7 +895,7 @@ describe('LayerPanel', () => { ], }); - const { instance } = await mountWithReduxStore( + const { instance } = mountWithReduxStore( @@ -936,7 +936,7 @@ describe('LayerPanel', () => { mockDatasource.onDrop.mockReturnValue(true); const updateVisualization = jest.fn(); - const { instance } = await mountWithReduxStore( + const { instance } = mountWithReduxStore( { mockDatasource.onDrop.mockReturnValue(false); const updateVisualization = jest.fn(); - const { instance } = await mountWithReduxStore( + const { instance } = mountWithReduxStore( { mockDatasource.onDrop.mockReturnValue(true); - const { instance } = await mountWithReduxStore( + const { instance } = mountWithReduxStore( diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx index cf66ee709ae32..eb422cc388bb9 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx @@ -116,7 +116,7 @@ describe('suggestion_panel', () => { }); it('should avoid completely to render SuggestionPanel when in fullscreen mode', async () => { - const { instance, lensStore } = await mountWithReduxStore( + const { instance, lensStore } = mountWithReduxStore( ); expect(instance.find(SuggestionPanel).exists()).toBe(true); @@ -131,7 +131,7 @@ describe('suggestion_panel', () => { }); it('should display apply-changes prompt when changes not applied', async () => { - const { instance, lensStore } = await mountWithReduxStore(, { + const { instance, lensStore } = mountWithReduxStore(, { preloadedState: { ...preloadedState, visualization: { @@ -163,7 +163,7 @@ describe('suggestion_panel', () => { }); it('should list passed in suggestions', async () => { - const { instance } = await mountWithReduxStore(, { + const { instance } = mountWithReduxStore(, { preloadedState, }); @@ -199,10 +199,9 @@ describe('suggestion_panel', () => { }); it('should not update suggestions if current state is moved to staged preview', async () => { - const { instance, lensStore } = await mountWithReduxStore( - , - { preloadedState } - ); + const { instance, lensStore } = mountWithReduxStore(, { + preloadedState, + }); getSuggestionsMock.mockClear(); lensStore.dispatch(setState({ stagedPreview })); instance.update(); @@ -210,10 +209,9 @@ describe('suggestion_panel', () => { }); it('should update suggestions if staged preview is removed', async () => { - const { instance, lensStore } = await mountWithReduxStore( - , - { preloadedState } - ); + const { instance, lensStore } = mountWithReduxStore(, { + preloadedState, + }); getSuggestionsMock.mockClear(); lensStore.dispatch(setState({ stagedPreview, ...suggestionState })); instance.update(); @@ -234,9 +232,7 @@ describe('suggestion_panel', () => { }); it('should rollback suggestion if current panel is clicked', async () => { - const { instance, lensStore } = await mountWithReduxStore( - - ); + const { instance, lensStore } = mountWithReduxStore(); act(() => { instance.find(SELECTORS.SUGGESTION_TILE_BUTTON).at(2).simulate('click'); @@ -261,7 +257,7 @@ describe('suggestion_panel', () => { }); it('should dispatch visualization switch action if suggestion is clicked', async () => { - const { instance, lensStore } = await mountWithReduxStore(, { + const { instance, lensStore } = mountWithReduxStore(, { preloadedState, }); @@ -315,7 +311,7 @@ describe('suggestion_panel', () => { mockDatasource.toExpression.mockReturnValue('datasource_expression'); - const { instance } = await mountWithReduxStore(, { + const { instance } = mountWithReduxStore(, { preloadedState, }); @@ -343,14 +339,14 @@ describe('suggestion_panel', () => { }, }; - const { instance } = await mountWithReduxStore(, { + const { instance } = mountWithReduxStore(, { preloadedState: newPreloadedState, }); expect(instance.html()).toEqual(null); }); it('should hide the selections when the accordion is hidden', async () => { - const { instance } = await mountWithReduxStore(); + const { instance } = mountWithReduxStore(); expect(instance.find(EuiAccordion)).toHaveLength(1); act(() => { instance.find(EuiAccordion).at(0).simulate('change'); diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx index a11f953616b69..194f20fd6bbe1 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx @@ -367,7 +367,7 @@ describe('workspace_panel', () => { const visualizationShowing = () => instance.exists(expressionRendererMock); - const mounted = await mountWithReduxStore( + const mounted = mountWithReduxStore( { mockDatasource.getLayers.mockReturnValue(['first']); const props = defaultProps; - const mounted = await mountWithReduxStore( + const mounted = mountWithReduxStore( { mockDatasource.getLayers.mockReturnValue(['first']); const props = defaultProps; - const mounted = await mountWithReduxStore( + const mounted = mountWithReduxStore( { mockDatasource.getLayers.mockReturnValue(['first']); const props = defaultProps; - const mounted = await mountWithReduxStore( + const mounted = mountWithReduxStore( { mockDatasource.toExpression.mockReturnValue('datasource'); mockDatasource.getLayers.mockReturnValue(['table1']); - const mounted = await mountWithReduxStore( + const mounted = mountWithReduxStore( { expressionRendererMock = jest.fn((_arg) => ); - const mounted = await mountWithReduxStore( + const mounted = mountWithReduxStore( { .mockReturnValueOnce('datasource second'); expressionRendererMock = jest.fn((_arg) => ); - const mounted = await mountWithReduxStore( + const mounted = mountWithReduxStore( { const getUserMessages = jest.fn(() => messages); - const mounted = await mountWithReduxStore( + const mounted = mountWithReduxStore( { let userMessages = [] as UserMessage[]; const getUserMessageFn = jest.fn(() => userMessages); - const mounted = await mountWithReduxStore( + const mounted = mountWithReduxStore( { const mockAddUserMessages = jest.fn(() => mockRemoveUserMessages); const mockGetUserMessages = jest.fn(() => []); - const mounted = await mountWithReduxStore( + const mounted = mountWithReduxStore( { first: mockDatasource.publicAPIMock, }; - const mounted = await mountWithReduxStore( + const mounted = mountWithReduxStore( { framePublicAPI.datasourceLayers = { first: mockDatasource.publicAPIMock, }; - const mounted = await mountWithReduxStore( + const mounted = mountWithReduxStore( ; -}) { +} = {}) { const data = storeDeps.lensServices.data; const store = makeConfigureStore(storeDeps, { lens: { @@ -119,10 +119,10 @@ export function makeLensStore({ export interface MountStoreProps { storeDeps?: LensStoreDeps; preloadedState?: Partial; - dispatch?: jest.Mock; } -export const mountWithReduxStore = async ( +// legacy enzyme usage: remove when all tests are migrated to @testing-library/react +export const mountWithReduxStore = ( component: React.ReactElement, store?: MountStoreProps, options?: { @@ -131,12 +131,12 @@ export const mountWithReduxStore = async ( attachTo?: HTMLElement; } ) => { - const { store: lensStore, deps } = makeLensStore(store || {}); + const { store: lensStore, deps } = makeLensStore(store); let wrappingComponent: React.FC> = ({ children }) => ( {children} ); - if (options?.wrappingComponent) { + if (options?.wrappingComponent) { wrappingComponent = ({ children }) => { return options?.wrappingComponent?.({ ...options?.wrappingComponentProps, @@ -146,9 +146,9 @@ export const mountWithReduxStore = async ( } const instance = mountWithProviders(component, { - ...options, - wrappingComponent, - } as unknown as ReactWrapper); + ...options, + wrappingComponent, + } as unknown as ReactWrapper); return { instance, lensStore, deps }; }; diff --git a/x-pack/platform/plugins/shared/lens/public/state_management/lens_slice.test.ts b/x-pack/platform/plugins/shared/lens/public/state_management/lens_slice.test.ts index 81bfb55a4cbca..8f79464458d93 100644 --- a/x-pack/platform/plugins/shared/lens/public/state_management/lens_slice.test.ts +++ b/x-pack/platform/plugins/shared/lens/public/state_management/lens_slice.test.ts @@ -37,7 +37,7 @@ import { layerTypes } from '../../common/layer_types'; describe('lensSlice', () => { let store: EnhancedStore<{ lens: LensAppState }>; beforeEach(() => { - store = makeLensStore({}).store; + store = makeLensStore().store; jest.clearAllMocks(); }); const customQuery = { query: 'custom' } as Query; diff --git a/x-pack/platform/plugins/shared/lens/public/test_utils/test_utils.tsx b/x-pack/platform/plugins/shared/lens/public/test_utils/test_utils.tsx index 26e33239af3ea..fbee7a3146d5e 100644 --- a/x-pack/platform/plugins/shared/lens/public/test_utils/test_utils.tsx +++ b/x-pack/platform/plugins/shared/lens/public/test_utils/test_utils.tsx @@ -41,6 +41,7 @@ export const renderWithProviders = ( return rtlRender; }; +// legacy enzyme usage: remove when all tests are migrated to @testing-library/react export const mountWithProviders = (component: React.ReactElement, options?: MountRendererProps) => { const { wrappingComponent, wrappingComponentProps } = options || {}; From 5d3bf69fbca45accbd33222e9004f1d5b301c6a5 Mon Sep 17 00:00:00 2001 From: mbondyra Date: Fri, 21 Feb 2025 13:51:43 +0100 Subject: [PATCH 25/37] pass the theme explicitly to remove the console errors when testing --- .../lens/public/app_plugin/lens_top_nav.tsx | 12 +- .../datasources/common/datapanel.styles.ts | 6 +- .../datasources/form_based/datapanel.tsx | 13 +- .../dimension_panel/dimension_editor.tsx | 12 +- .../dimensions_editor_helpers.tsx | 10 +- .../datasources/form_based/help_popover.tsx | 12 +- .../definitions/filters/filter_popover.tsx | 12 +- .../definitions/filters/filters.tsx | 7 +- .../formula/editor/formula_editor.tsx | 27 ++-- .../definitions/ranges/advanced_editor.tsx | 6 +- .../text_based/components/datapanel.tsx | 5 +- .../editor_frame/frame_layout.tsx | 21 +-- .../dataview_picker/toolbar_button.tsx | 138 ++++++++++-------- .../public/shared_components/flyout.styles.ts | 16 +- .../shared_components/flyout_container.tsx | 34 +++-- .../setting_with_sibling_flyout.tsx | 18 ++- .../public/visualizations/xy/add_layer.tsx | 31 ++-- 17 files changed, 217 insertions(+), 163 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/app_plugin/lens_top_nav.tsx b/x-pack/platform/plugins/shared/lens/public/app_plugin/lens_top_nav.tsx index 00a8b5588a61c..ab212c4cad610 100644 --- a/x-pack/platform/plugins/shared/lens/public/app_plugin/lens_top_nav.tsx +++ b/x-pack/platform/plugins/shared/lens/public/app_plugin/lens_top_nav.tsx @@ -17,7 +17,7 @@ import { useKibana } from '@kbn/kibana-react-plugin/public'; import { DataViewPickerProps } from '@kbn/unified-search-plugin/public'; import { getManagedContentBadge } from '@kbn/managed-content-badge'; import moment from 'moment'; -import { EuiCallOut, UseEuiTheme, useEuiBreakpoint } from '@elastic/eui'; +import { EuiCallOut, UseEuiTheme, euiBreakpoint } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { SerializedStyles, css } from '@emotion/react'; import { LENS_APP_LOCATOR } from '../../common/locator/locator'; @@ -103,8 +103,8 @@ function getSaveButtonMeta({ } } -const NavItemWithDividerStyles = (euiThemeContext: UseEuiTheme) => css` - ${useEuiBreakpoint(['m', 'l', 'xl'])} { +const navItemWithDividerStyles = (euiThemeContext: UseEuiTheme) => css` + ${euiBreakpoint(euiThemeContext, ['m', 'l', 'xl'])} { margin-right: ${euiThemeContext.euiTheme.size.m}; position: relative; &:after { @@ -177,7 +177,7 @@ function getLensTopNavConfig(options: { values: { contextOriginatingApp }, }), disableButton: !actions.goBack.enabled, - css: NavItemWithDividerStyles, + css: navItemWithDividerStyles, }); } @@ -195,7 +195,7 @@ function getLensTopNavConfig(options: { tooltip: actions.getUnderlyingDataUrl.tooltip, target: '_blank', href: actions.getUnderlyingDataUrl.getLink?.(), - css: NavItemWithDividerStyles, + css: navItemWithDividerStyles, }); } @@ -235,7 +235,7 @@ function getLensTopNavConfig(options: { description: i18n.translate('xpack.lens.app.settingsAriaLabel', { defaultMessage: 'Open the Lens settings menu', }), - css: NavItemWithDividerStyles, + css: navItemWithDividerStyles, }); if (actions.cancel.visible) { diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/common/datapanel.styles.ts b/x-pack/platform/plugins/shared/lens/public/datasources/common/datapanel.styles.ts index 8dc302eeaea93..29bac5630c265 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/common/datapanel.styles.ts +++ b/x-pack/platform/plugins/shared/lens/public/datasources/common/datapanel.styles.ts @@ -6,9 +6,10 @@ */ import { UseEuiTheme } from '@elastic/eui'; +import { css } from '@emotion/react'; export const dataPanelStyles = ({ euiTheme }: UseEuiTheme) => { - return ` + return css` padding: ${euiTheme.size.base} ${euiTheme.size.base} 0; .unifiedFieldListItemButton.kbnFieldButton { background: none; @@ -17,5 +18,6 @@ export const dataPanelStyles = ({ euiTheme }: UseEuiTheme) => { } .unifiedFieldListItemButton__dragging { background: ${euiTheme.colors.backgroundBasePlain}; - }`; + } + `; }; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.tsx index 0c2505f5c18d5..ab63dab30776d 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/datapanel.tsx @@ -7,7 +7,7 @@ import { uniq } from 'lodash'; import React, { memo, useCallback, useEffect, useMemo, useRef } from 'react'; -import { EuiCallOut, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; +import { EuiCallOut, EuiFlexGroup, EuiFlexItem, useEuiTheme } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import type { CoreStart } from '@kbn/core/public'; @@ -102,6 +102,7 @@ export function FormBasedDataPanel({ const { indexPatterns, indexPatternRefs } = frame.dataViews; const { currentIndexPatternId } = state; + const euiThemeContext = useEuiTheme(); const activeIndexPatterns = useMemo(() => { return uniq( ( @@ -116,7 +117,12 @@ export function FormBasedDataPanel({ return ( <> {Object.keys(indexPatterns).length === 0 && indexPatternRefs.length === 0 ? ( - + } > diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx index 482c6d42af7bb..958b05567b7b6 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx @@ -141,7 +141,9 @@ export function DimensionEditor(props: DimensionEditorProps) { const temporaryQuickFunction = Boolean(temporaryState === quickFunctionsName); const temporaryStaticValue = Boolean(temporaryState === staticValueOperationName); - const { euiTheme } = useEuiTheme(); + + const euiThemeContext = useEuiTheme(); + const { euiTheme } = euiThemeContext; const updateLayer = useCallback( (newLayer: Partial) => @@ -534,7 +536,7 @@ export function DimensionEditor(props: DimensionEditorProps) { isActive, size: 's', isDisabled: !!disabledStatus, - css: operationsButtonStyles, + css: operationsButtonStyles(euiThemeContext), 'data-test-subj': `lns-indexPatternDimension-${operationType}${ compatibleWithCurrentField ? '' : ' incompatible' }`, @@ -811,7 +813,7 @@ export function DimensionEditor(props: DimensionEditorProps) { fullWidth > 3 ? operationsTwoColumnsStyles : undefined} + css={sideNavItems.length > 3 ? operationsTwoColumnsStyles(euiThemeContext) : undefined} gutterSize="none" color="primary" listItems={ @@ -1292,7 +1294,7 @@ export function DimensionEditor(props: DimensionEditorProps) { } const operationsTwoColumnsStyles = ({ euiTheme }: UseEuiTheme) => { - return ` + return css` display: block; column-count: 2; column-gap: ${euiTheme.size.m}; @@ -1300,7 +1302,7 @@ const operationsTwoColumnsStyles = ({ euiTheme }: UseEuiTheme) => { }; export const operationsButtonStyles = ({ euiTheme }: UseEuiTheme) => { - return ` + return css` > button { padding-top: 0; padding-bottom: 0; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx index 74fe54d79f820..545f703663b24 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx @@ -14,7 +14,8 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; -import { EuiCallOut, EuiButtonGroup, EuiFormRow, UseEuiTheme } from '@elastic/eui'; +import { EuiCallOut, EuiButtonGroup, EuiFormRow, UseEuiTheme, useEuiTheme } from '@elastic/eui'; +import { css } from '@emotion/react'; import { nonNullable } from '../../../utils'; import { operationDefinitionMap, @@ -140,6 +141,7 @@ export const CalloutWarning = ({ currentOperationType: keyof typeof operationDefinitionMap | undefined; temporaryStateType: TemporaryState; }) => { + const euiThemeContext = useEuiTheme(); if ( temporaryStateType === 'none' || (currentOperationType != null && isQuickFunction(currentOperationType)) @@ -153,7 +155,7 @@ export const CalloutWarning = ({ return ( <> { - return ` + return css` margin-bottom: ${euiTheme.size.base}; margin-top: ${euiTheme.size.s}; `; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.tsx index e6da8f310c2b5..d30eb5433b1d6 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.tsx @@ -17,8 +17,10 @@ import { EuiPopoverTitle, EuiText, UseEuiTheme, + useEuiTheme, } from '@elastic/eui'; import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; +import { css } from '@emotion/react'; import { StartServices } from '../../types'; export const HelpPopoverButton = ({ @@ -28,10 +30,11 @@ export const HelpPopoverButton = ({ children: string; onClick: EuiLinkButtonProps['onClick']; }) => { + const euiThemeContext = useEuiTheme(); return ( - + {children} @@ -39,10 +42,11 @@ export const HelpPopoverButton = ({ }; const HelpPopoverContent = ({ title, children }: { title?: string; children: ReactNode }) => { + const euiThemeContext = useEuiTheme(); return ( <> {title && {title}} - + {children} @@ -50,10 +54,10 @@ const HelpPopoverContent = ({ title, children }: { title?: string; children: Rea }; const helpPopoverStyles = { - button: ({ euiTheme }: UseEuiTheme) => ` + button: ({ euiTheme }: UseEuiTheme) => css` margin-right: ${euiTheme.size.xs}; `, - content: ({ euiTheme }: UseEuiTheme) => ` + content: ({ euiTheme }: UseEuiTheme) => css` max-height: 40vh; padding: ${euiTheme.size.m}; `, diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx index 9ec4647826fb9..86d8394eb7a7c 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx @@ -6,12 +6,13 @@ */ import React, { useState } from 'react'; -import { EuiPopover, EuiSpacer, euiTextBreakWord, useEuiFontSize, UseEuiTheme } from '@elastic/eui'; +import { euiFontSize, EuiPopover, EuiSpacer, euiTextBreakWord, UseEuiTheme } from '@elastic/eui'; import type { Query } from '@kbn/es-query'; // Need to keep it separate to make it work Jest mocks in dimension_panel tests // import { QueryInput } from '../../../../shared_components/query_input'; import { isQueryValid, QueryInput } from '@kbn/visualization-ui-components'; import { useKibana } from '@kbn/kibana-react-plugin/public'; +import { css } from '@emotion/react'; import { LENS_APP_NAME } from '../../../../../../common/constants'; import { IndexPattern } from '../../../../../types'; import { FilterValue, defaultLabel } from '.'; @@ -101,12 +102,11 @@ export const FilterPopover = ({ ); }; -export const DraggablePopoverButtonStyles = ({ euiTheme }: UseEuiTheme) => { - const euiFontSize = useEuiFontSize('s'); - return ` +export const draggablePopoverButtonStyles = (euiThemeContext: UseEuiTheme) => { + return css` ${euiTextBreakWord()}; - ${euiFontSize}; - min-height: ${euiTheme.size.xl}; + ${euiFontSize(euiThemeContext, 's')}; + min-height: ${euiThemeContext.euiTheme.size.xl}; width: 100%; `; }; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx index 1fb2bc81c97cd..bcc31ca6fc4c6 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx @@ -8,7 +8,7 @@ import React, { useState } from 'react'; import { omit } from 'lodash'; import { i18n } from '@kbn/i18n'; -import { EuiFormRow, EuiLink, htmlIdGenerator } from '@elastic/eui'; +import { EuiFormRow, EuiLink, htmlIdGenerator, useEuiTheme } from '@elastic/eui'; import type { Query } from '@kbn/es-query'; import type { AggFunctionsMapping } from '@kbn/data-plugin/public'; import { queryFilterToAst } from '@kbn/data-plugin/common'; @@ -23,7 +23,7 @@ import { IndexPattern } from '../../../../../types'; import { updateColumnParam } from '../../layer_helpers'; import type { OperationDefinition } from '..'; import type { BaseIndexPatternColumn } from '../column_types'; -import { DraggablePopoverButtonStyles, FilterPopover } from './filter_popover'; +import { draggablePopoverButtonStyles, FilterPopover } from './filter_popover'; import { TermsIndexPatternColumn } from '../terms'; import { isColumnOfType } from '../helpers'; @@ -180,6 +180,7 @@ export const FilterList = ({ indexPattern: IndexPattern; defaultQuery: Filter; }) => { + const euiThemeContext = useEuiTheme(); const [activeFilterId, setActiveFilterId] = useState(''); const [localFilters, setLocalFilters] = useState(() => filters.map((filter) => ({ ...filter, id: generateId() })) @@ -274,7 +275,7 @@ export const FilterList = ({ title={i18n.translate('xpack.lens.indexPattern.filters.clickToEdit', { defaultMessage: 'Click to edit', })} - css={DraggablePopoverButtonStyles} + css={draggablePopoverButtonStyles(euiThemeContext)} > {filter.label || (filter.input.query as string) || defaultLabel} diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx index 90660a3c52ef7..0d80cb9e9dcf3 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx @@ -125,7 +125,8 @@ export function FormulaEditor({ const disposables = React.useRef([]); const editor1 = React.useRef(); - const { euiTheme } = useEuiTheme(); + const euiThemeContext = useEuiTheme(); + const { euiTheme } = euiThemeContext; const visibleOperationsMap = useMemo( () => filterByVisibleOperation(operationDefinitionMap), @@ -684,7 +685,12 @@ export function FormulaEditor({ // in the behavior of Monaco when it's first loaded and then reloaded. return (
              {!isFullscreen && (
              -
              +
              {i18n.translate('xpack.lens.formulaPlaceholderText', { @@ -823,7 +829,7 @@ export function FormulaEditor({ ) : null}
              -
              +
              {isFullscreen ? ( @@ -845,7 +851,7 @@ export function FormulaEditor({ defaultMessage: 'Hide function reference', })} className="lnsFormula__editorHelp lnsFormula__editorHelp--inline" - css={sharedEditorStyles.editorHelpLink} + css={sharedEditorStyles.editorHelpLink(euiThemeContext)} color="text" onClick={() => setIsHelpOpen(!isHelpOpen)} > @@ -919,7 +925,7 @@ export function FormulaEditor({
              +
              { display: flex; flex-direction: column; & > * + * { - border-top: $euiBorderThin; + border-top: ${euiTheme.border.thin}; } }; .lnsFormula__editorContent { diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx index 4118b35bf7320..0726adf9cf7ab 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx @@ -19,6 +19,7 @@ import { EuiToolTip, htmlIdGenerator, keys, + useEuiTheme, } from '@elastic/eui'; import { IFieldFormat } from '@kbn/field-formats-plugin/common'; import { @@ -32,7 +33,7 @@ import { RangeTypeLens, isValidRange } from './ranges'; import { FROM_PLACEHOLDER, TO_PLACEHOLDER, TYPING_DEBOUNCE_TIME } from './constants'; import { LabelInput } from '../shared_components'; import { isValidNumber } from '../helpers'; -import { DraggablePopoverButtonStyles } from '../filters/filter_popover'; +import { draggablePopoverButtonStyles } from '../filters/filter_popover'; const generateId = htmlIdGenerator(); @@ -207,6 +208,7 @@ export const AdvancedRangeEditor = ({ onToggleEditor: () => void; formatter: IFieldFormat; }) => { + const euiThemeContext = useEuiTheme(); const [activeRangeId, setActiveRangeId] = useState(''); // use a local state to store ids with range objects const [localRanges, setLocalRanges] = useState(() => @@ -308,7 +310,7 @@ export const AdvancedRangeEditor = ({ color="text" onClick={() => changeActiveRange(range.id)} data-test-subj="dataView-ranges-popover-trigger" - css={DraggablePopoverButtonStyles} + css={draggablePopoverButtonStyles(euiThemeContext)} > diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx index fca84c932ac2c..6bb464cd9be58 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx @@ -30,7 +30,8 @@ export interface FrameLayoutProps { export function FrameLayout(props: FrameLayoutProps) { const isFullscreen = useLensSelector(selectIsFullscreenDatasource); - const euiTheme = useEuiTheme(); + const euiThemeContext = useEuiTheme(); + const { euiTheme } = euiThemeContext; return ( @@ -65,7 +66,7 @@ export function FrameLayout(props: FrameLayoutProps) { bottom: 0; overflow: hidden; flex-direction: column; - ${euiBreakpoint(euiTheme, ['xs', 's', 'm'])} { + ${euiBreakpoint(euiThemeContext, ['xs', 's', 'm'])} { position: static; } `} @@ -78,7 +79,7 @@ export function FrameLayout(props: FrameLayoutProps) { overflow: hidden; flex-grow: 1; flex-direction: row; - ${euiBreakpoint(euiTheme, ['xs', 's', 'm'])} { + ${euiBreakpoint(euiThemeContext, ['xs', 's', 'm'])} { flex-wrap: wrap; overflow: auto; > * { @@ -91,7 +92,7 @@ export function FrameLayout(props: FrameLayoutProps) { className={'hide-for-sharing'} aria-labelledby="dataPanelId" css={[ - sidebarStyles, + sidebarStyles(euiThemeContext), css` ${isFullscreen && ` @@ -121,13 +122,13 @@ export function FrameLayout(props: FrameLayoutProps) { // Leave out bottom padding so the suggestions scrollbar stays flush to window edge // Leave out left padding so the left sidebar's focus states are visible outside of content bounds // This also means needing to add same amount of margin to page content and suggestion items - padding: ${euiTheme.euiTheme.size.base} ${euiTheme.euiTheme.size.base} 0; + padding: ${euiTheme.size.base} ${euiTheme.size.base} 0; position: relative; z-index: 1; - border-left: ${euiTheme.euiTheme.border.thin}; - border-right: ${euiTheme.euiTheme.border.thin}; + border-left: ${euiTheme.border.thin}; + border-right: ${euiTheme.border.thin}; &:first-child { - padding-left: ${euiTheme.euiTheme.size.base}; + padding-left: ${euiTheme.size.base}; } ${isFullscreen && ` @@ -148,13 +149,13 @@ export function FrameLayout(props: FrameLayoutProps) {

              = ({ textProps, ...rest }) => { + const euiThemeContext = useEuiTheme(); const classes = classNames( 'kbnToolbarButton', groupPositionToClassMap[groupPosition], @@ -68,7 +77,7 @@ export const ToolbarButton: React.FunctionComponent = ({ data-test-subj={dataTestSubj} className={classes} iconSide="right" - css={toolbarButtonStyles} + css={toolbarButtonStyles(euiThemeContext)} iconType={hasArrow ? 'arrowDown' : ''} color="text" contentProps={{ @@ -86,68 +95,69 @@ export const ToolbarButton: React.FunctionComponent = ({ ); }; -const toolbarButtonStyles = (euiThemeObj: UseEuiTheme) => { - const { euiTheme } = euiThemeObj; - return ` - &.kbnToolbarButton { - line-height: ${euiTheme.size.xxl}; // Keeps alignment of text and chart icon - - // todo: once issue https://github.com/elastic/eui/issues/4730 is merged, this code might be safe to remove - // Some toolbar buttons are just icons, but EuiButton comes with margin and min-width that need to be removed - min-width: 0; - border-width: ${euiTheme.border.width.thin}; - border-style: solid; - border-color: ${euiTheme.border.color}; // Lighten the border color for all states - - // Override background color for non-disabled buttons - &:not(:disabled) { - background-color: ${euiTheme.colors.backgroundBasePlain}; - } - - &.kbnToolbarButton__text > svg { - margin-top: -1px; // Just some weird alignment issue when icon is the child not the iconType - } - - &.kbnToolbarButton__text:empty { - margin: 0; - } - - // Toolbar buttons don't look good with centered text when fullWidth - &[class*='fullWidth'] { - text-align: left; - - .kbnToolbarButton__content { - justify-content: space-between; +const toolbarButtonStyles = (euiThemeContext: UseEuiTheme) => { + const { euiTheme } = euiThemeContext; + return css` + &.kbnToolbarButton { + line-height: ${euiTheme.size.xxl}; // Keeps alignment of text and chart icon + + // todo: once issue https://github.com/elastic/eui/issues/4730 is merged, this code might be safe to remove + // Some toolbar buttons are just icons, but EuiButton comes with margin and min-width that need to be removed + min-width: 0; + border-width: ${euiTheme.border.width.thin}; + border-style: solid; + border-color: ${euiTheme.border.color}; // Lighten the border color for all states + + // Override background color for non-disabled buttons + &:not(:disabled) { + background-color: ${euiTheme.colors.backgroundBasePlain}; } + + &.kbnToolbarButton__text > svg { + margin-top: -1px; // Just some weird alignment issue when icon is the child not the iconType + } + + &.kbnToolbarButton__text:empty { + margin: 0; + } + + // Toolbar buttons don't look good with centered text when fullWidth + &[class*='fullWidth'] { + text-align: left; + + .kbnToolbarButton__content { + justify-content: space-between; + } + } + } + + &.kbnToolbarButton--groupLeft { + border-top-right-radius: 0; + border-bottom-right-radius: 0; + } + + &.kbnToolbarButton--groupCenter { + border-radius: 0; + border-left: none; + } + + &.kbnToolbarButton--groupRight { + border-top-left-radius: 0; + border-bottom-left-radius: 0; + border-left: none; + } + + &.kbnToolbarButton--bold { + font-weight: ${euiTheme.font.weight.bold}; + } + + &.kbnToolbarButton--normal { + font-weight: ${euiTheme.font.weight.regular}; + } + + &.kbnToolbarButton--s { + box-shadow: none !important; // sass-lint:disable-line no-important + font-size: ${euiFontSize(euiThemeContext, 's').fontSize}; } - } - - &.kbnToolbarButton--groupLeft { - border-top-right-radius: 0; - border-bottom-right-radius: 0; - } - - &.kbnToolbarButton--groupCenter { - border-radius: 0; - border-left: none; - } - - &.kbnToolbarButton--groupRight { - border-top-left-radius: 0; - border-bottom-left-radius: 0; - border-left: none; - } - - &.kbnToolbarButton--bold { - font-weight: ${euiTheme.font.weight.bold}; - } - - &.kbnToolbarButton--normal { - font-weight:${euiTheme.font.weight.regular}; - } - - &.kbnToolbarButton--s { - box-shadow: none !important; // sass-lint:disable-line no-important - font-size:${euiFontSize(euiThemeObj, 's').fontSize}; - }`; + `; }; diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout.styles.ts b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout.styles.ts index af97129f606ca..b242885a6097f 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout.styles.ts +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout.styles.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { UseEuiTheme, useEuiShadow } from '@elastic/eui'; +import { UseEuiTheme, euiShadow } from '@elastic/eui'; import { css, keyframes } from '@emotion/react'; const flyoutOpenCloseAnimation = keyframes` @@ -19,19 +19,19 @@ const flyoutOpenCloseAnimation = keyframes` } `; -export const FlyoutContainerStyles = ({ euiTheme }: UseEuiTheme) => css` - border-left: ${euiTheme.border.thin}; - ${useEuiShadow('xl')}; +export const flyoutContainerStyles = (euiThemeContext: UseEuiTheme) => css` + border-left: ${euiThemeContext.euiTheme.border.thin}; + ${euiShadow(euiThemeContext, 'xl')}; position: fixed; top: 0; bottom: 0; right: 0; height: 100%; - z-index: ${euiTheme.levels.flyout}; - background: ${euiTheme.colors.backgroundBasePlain}; + z-index: ${euiThemeContext.euiTheme.levels.flyout}; + background: ${euiThemeContext.euiTheme.colors.backgroundBasePlain}; display: flex; flex-direction: column; align-items: stretch; - animation: ${flyoutOpenCloseAnimation} ${euiTheme.animation.normal} - ${euiTheme.animation.resistance}; + animation: ${flyoutOpenCloseAnimation} ${euiThemeContext.euiTheme.animation.normal} + ${euiThemeContext.euiTheme.animation.resistance}; `; diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx index 506dfd634689c..2b7f284b3dfa9 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx @@ -18,10 +18,11 @@ import { EuiFocusTrap, UseEuiTheme, euiBreakpoint, + useEuiTheme, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { DONT_CLOSE_DIMENSION_CONTAINER_ON_CLICK_CLASS } from '../utils'; -import { FlyoutContainerStyles } from './flyout.styles'; +import { flyoutContainerStyles } from './flyout.styles'; function fromExcludedClickTarget(event: Event) { for ( @@ -62,6 +63,7 @@ export function FlyoutContainer({ isInlineEditing?: boolean; }) { const [focusTrapIsEnabled, setFocusTrapIsEnabled] = useState(false); + const euiThemeContext = useEuiTheme(); const closeFlyout = useCallback(() => { setFocusTrapIsEnabled(false); @@ -104,11 +106,11 @@ export function FlyoutContainer({ role="dialog" aria-labelledby="lnsDimensionContainerTitle" css={[ - FlyoutContainerStyles, + flyoutContainerStyles(euiThemeContext), css` box-shadow: ${isInlineEditing ? 'none !important' : 'inherit'}; `, - dimensionContainerStyles.self, + dimensionContainerStyles.self(euiThemeContext), ]} onAnimationEnd={() => { if (isOpen) { @@ -119,7 +121,7 @@ export function FlyoutContainer({ } }} > - + {isInlineEditing && ( @@ -168,7 +170,7 @@ export function FlyoutContainer({

              {customFooter || ( - + { - return ` - // But with custom positioning to keep it within the sidebar contents - max-width: none !important; - left: 0; - z-index: ${euiThemeContext.euiTheme.levels.menu}; - ${euiBreakpoint(euiThemeContext, ['m', 'l', 'xl'])} { - height: 100% !important; - position: absolute; - top: 0 !important; - } - `; + return css` + // But with custom positioning to keep it within the sidebar contents + max-width: none !important; + left: 0; + z-index: ${euiThemeContext.euiTheme.levels.menu}; + ${euiBreakpoint(euiThemeContext, ['m', 'l', 'xl'])} { + height: 100% !important; + position: absolute; + top: 0 !important; + } + `; }, header: ({ euiTheme }: UseEuiTheme) => css` padding: ${euiTheme.size.base}; diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx index 9ff6d757fa20f..a8034de718753 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx @@ -19,9 +19,10 @@ import { EuiOutsideClickDetector, EuiPortal, UseEuiTheme, + useEuiTheme, } from '@elastic/eui'; import { css } from '@emotion/react'; -import { FlyoutContainerStyles } from './flyout.styles'; +import { flyoutContainerStyles } from './flyout.styles'; const DEFAULT_TITLE = i18n.translate('xpack.lens.colorSiblingFlyoutTitle', { defaultMessage: 'Color', @@ -44,6 +45,7 @@ export function SettingWithSiblingFlyout({ }) { const [focusTrapIsEnabled, setFocusTrapIsEnabled] = useState(false); const [isFlyoutOpen, setIsFlyoutOpen] = useState(false); + const euiThemeContext = useEuiTheme(); const toggleFlyout = () => { setIsFlyoutOpen(!isFlyoutOpen); @@ -75,9 +77,15 @@ export function SettingWithSiblingFlyout({ role="dialog" aria-labelledby="lnsSettingWithSiblingFlyoutTitle" data-test-subj={dataTestSubj} - css={[FlyoutContainerStyles, siblingFlyoutContainerStyles.self]} + css={[ + flyoutContainerStyles(euiThemeContext), + siblingflyoutContainerStyles.self(euiThemeContext), + ]} > - + )} - + {i18n.translate('xpack.lens.settingWithSiblingFlyout.back', { defaultMessage: 'Back', @@ -126,7 +134,7 @@ export function SettingWithSiblingFlyout({ ); } -const siblingFlyoutContainerStyles = { +const siblingflyoutContainerStyles = { self: ({ euiTheme }: UseEuiTheme) => css` position: absolute; right: 0; diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/xy/add_layer.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/xy/add_layer.tsx index a08799c76c017..f83acc6448776 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/xy/add_layer.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/xy/add_layer.tsx @@ -16,10 +16,12 @@ import { IconType, transparentize, UseEuiTheme, + useEuiTheme, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { LayerTypes } from '@kbn/expression-xy-plugin/public'; import { EventAnnotationServiceType } from '@kbn/event-annotation-plugin/public'; +import { css } from '@emotion/react'; import { AddLayerFunction, VisualizationLayerDescription } from '../../types'; import { LoadAnnotationLibraryFlyout } from './load_annotation_library_flyout'; import type { ExtraAppendLayerArg } from './visualization'; @@ -274,31 +276,32 @@ const ChartOptionWrapper = ({ onClick: () => void; type: string; }) => { + const euiThemeContext = useEuiTheme(); return ( ); }; -const chartOptionWrapperStyles = ({ euiTheme }: UseEuiTheme) => ` - padding: ${euiTheme.size.s}; - border-bottom: ${euiTheme.border.thin}; - border-bottom-color: ${euiTheme.colors.backgroundBaseSubdued}; - width: 100%; - &:hover, - &:focus { +const chartOptionWrapperStyles = ({ euiTheme }: UseEuiTheme) => css` + padding: ${euiTheme.size.s}; + border-bottom: ${euiTheme.border.thin}; + border-bottom-color: ${euiTheme.colors.backgroundBaseSubdued}; + width: 100%; + &:hover, + &:focus { + color: ${euiTheme.colors.primary}; + background-color: ${transparentize(euiTheme.colors.primary, 0.1)}; + span, + .euiText { + text-decoration: underline; color: ${euiTheme.colors.primary}; - background-color: ${transparentize(euiTheme.colors.primary, 0.1)}; - span, - .euiText { - text-decoration: underline; - color: ${euiTheme.colors.primary}; - } } + } `; From 4313f1f2658722667d6cf34034bf472f0a9a2683 Mon Sep 17 00:00:00 2001 From: mbondyra Date: Fri, 21 Feb 2025 22:46:48 +0100 Subject: [PATCH 26/37] remove the line we're repeating --- test/functional/apps/discover/group3/_lens_vis.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/functional/apps/discover/group3/_lens_vis.ts b/test/functional/apps/discover/group3/_lens_vis.ts index 71757ecbfcd20..c8484270ece4b 100644 --- a/test/functional/apps/discover/group3/_lens_vis.ts +++ b/test/functional/apps/discover/group3/_lens_vis.ts @@ -248,7 +248,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { '10' ); - await testSubjects.click('unifiedHistogramEditFlyoutVisualization'); expect(await getCurrentVisTitle()).to.be('Line'); expect(await discover.getVisContextSuggestionType()).to.be('histogramForESQL'); }); From 04c3340ae325741c64938c8f5878a11a56269aa7 Mon Sep 17 00:00:00 2001 From: mbondyra Date: Mon, 3 Mar 2025 14:52:12 +0100 Subject: [PATCH 27/37] fix breaking things --- .../formula/editor/formula_editor.tsx | 22 +++++++++---------- .../shared_components/flyout_container.tsx | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx index 0d80cb9e9dcf3..80ebb0722b3fb 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx @@ -707,12 +707,12 @@ export function FormulaEditor({
              @@ -964,7 +964,7 @@ export function FormulaEditor({ const sharedEditorStyles = { self: ({ euiTheme }: UseEuiTheme) => { - return ` + return css` .lnsFormula { display: flex; flex-direction: column; @@ -989,24 +989,24 @@ const sharedEditorStyles = { } `; }, - formulaDocs: ({ euiTheme }: UseEuiTheme) => ` + formulaDocs: ({ euiTheme }: UseEuiTheme) => css` display: flex; flex-direction: column; // make sure docs are rendered in front of monaco z-index: 1; background: ${euiTheme.colors.backgroundBasePlain}; `, - editorHeader: ({ euiTheme }: UseEuiTheme) => ` + editorHeader: ({ euiTheme }: UseEuiTheme) => css` padding: ${euiTheme.size.s}; `, - editorFooter: ({ euiTheme }: UseEuiTheme) => ` + editorFooter: ({ euiTheme }: UseEuiTheme) => css` padding: ${euiTheme.size.s}; // make sure docs are rendered in front of monaco z-index: 1; border-bottom-right-radius: ${euiTheme.border.radius.medium}; border-bottom-left-radius: ${euiTheme.border.radius.medium}; `, - editorPlaceholder: ({ euiTheme }: UseEuiTheme) => ` + editorPlaceholder: ({ euiTheme }: UseEuiTheme) => css` position: absolute; top: 0; left: ${euiTheme.size.base}; @@ -1016,14 +1016,14 @@ const sharedEditorStyles = { font-family: Menlo, Monaco, 'Courier New', monospace; pointer-events: none; `, - warningText: ({ euiTheme }: UseEuiTheme) => ` + warningText: ({ euiTheme }: UseEuiTheme) => css` + .lnsFormula__warningText { margin-top: ${euiTheme.size.s}; border-top: ${euiTheme.border.thin}; padding-top: ${euiTheme.size.s}; } `, - editorHelpLink: ({ euiTheme }: UseEuiTheme) => ` + editorHelpLink: ({ euiTheme }: UseEuiTheme) => css` align-items: center; display: flex; padding: ${euiTheme.size.xs}; @@ -1034,7 +1034,7 @@ const sharedEditorStyles = { }; const defaultEditorStyles = ({ euiTheme }: UseEuiTheme) => { - return ` + return css` .lnsFormula__editorContent { height: 200px; } @@ -1042,7 +1042,7 @@ const defaultEditorStyles = ({ euiTheme }: UseEuiTheme) => { }; const fullscreenEditorStyles = ({ euiTheme }: UseEuiTheme) => { - return ` + return css` position: absolute; left: 0; right: 0; diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx index 2b7f284b3dfa9..c668594007341 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx @@ -106,10 +106,10 @@ export function FlyoutContainer({ role="dialog" aria-labelledby="lnsDimensionContainerTitle" css={[ - flyoutContainerStyles(euiThemeContext), - css` + css` box-shadow: ${isInlineEditing ? 'none !important' : 'inherit'}; `, + flyoutContainerStyles(euiThemeContext), dimensionContainerStyles.self(euiThemeContext), ]} onAnimationEnd={() => { From b197bf368688a23d8afdc81c2b449e18dda31343 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 3 Mar 2025 14:13:48 +0000 Subject: [PATCH 28/37] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../definitions/formula/editor/formula_editor.tsx | 14 +++++++------- .../public/shared_components/flyout_container.tsx | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx index 80ebb0722b3fb..7c6cbe113100e 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx @@ -977,7 +977,7 @@ const sharedEditorStyles = { & > * + * { border-top: ${euiTheme.border.thin}; } - }; + } .lnsFormulaOverflow { // Needs to be higher than the modal and all flyouts z-index: ${euiTheme.levels.toast} + 1; @@ -993,7 +993,7 @@ const sharedEditorStyles = { display: flex; flex-direction: column; // make sure docs are rendered in front of monaco - z-index: 1; + z-index: 1; background: ${euiTheme.colors.backgroundBasePlain}; `, editorHeader: ({ euiTheme }: UseEuiTheme) => css` @@ -1001,7 +1001,7 @@ const sharedEditorStyles = { `, editorFooter: ({ euiTheme }: UseEuiTheme) => css` padding: ${euiTheme.size.s}; - // make sure docs are rendered in front of monaco + // make sure docs are rendered in front of monaco z-index: 1; border-bottom-right-radius: ${euiTheme.border.radius.medium}; border-bottom-left-radius: ${euiTheme.border.radius.medium}; @@ -1035,9 +1035,9 @@ const sharedEditorStyles = { const defaultEditorStyles = ({ euiTheme }: UseEuiTheme) => { return css` - .lnsFormula__editorContent { - height: 200px; - } + .lnsFormula__editorContent { + height: 200px; + } `; }; @@ -1055,7 +1055,7 @@ const fullscreenEditorStyles = ({ euiTheme }: UseEuiTheme) => { & > * + * { border-top: ${euiTheme.border.thin}; } - }; + } .lnsFormula__editorContent { flex: 1; } diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx index c668594007341..893cca7cceb23 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx @@ -106,7 +106,7 @@ export function FlyoutContainer({ role="dialog" aria-labelledby="lnsDimensionContainerTitle" css={[ - css` + css` box-shadow: ${isInlineEditing ? 'none !important' : 'inherit'}; `, flyoutContainerStyles(euiThemeContext), From b6a88caf7cd7351f75049c61e9b59e93047800bb Mon Sep 17 00:00:00 2001 From: mbondyra Date: Tue, 4 Mar 2025 14:17:55 +0100 Subject: [PATCH 29/37] Michael's feedback --- .../shared/lens/public/app_plugin/app.tsx | 1 + .../editor_frame/config_panel/config_panel.tsx | 13 +++++++------ .../editor_frame/config_panel/layer_panel.tsx | 16 ++-------------- .../editor_frame/frame_layout.tsx | 4 +--- .../public/shared_components/flyout.styles.ts | 8 ++++++++ 5 files changed, 19 insertions(+), 23 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/app_plugin/app.tsx b/x-pack/platform/plugins/shared/lens/public/app_plugin/app.tsx index 9bf65fd9fe03e..d9d207ca9ea67 100644 --- a/x-pack/platform/plugins/shared/lens/public/app_plugin/app.tsx +++ b/x-pack/platform/plugins/shared/lens/public/app_plugin/app.tsx @@ -439,6 +439,7 @@ export function App({ <>
              diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx index cb391fcb1b636..51bc9fef7f7b2 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx @@ -776,7 +776,7 @@ export function LayerPanel(props: LayerPanelProps) { isInlineEditing={isInlineEditing} handleClose={closeDimensionEditor} panel={ -
              +
              {openColumnGroup && openColumnId && layerDatasource && @@ -862,16 +862,4 @@ export function LayerPanel(props: LayerPanelProps) { /> ); -} - -const dimensionContainerStyles = ({ euiTheme }: UseEuiTheme) => ` - .lnsIndexPatternDimensionEditor--padded { - padding: ${euiTheme.size.base}; - } - - .lnsIndexPatternDimensionEditor--collapseNext { - margin-bottom: -${euiTheme.size.l}; - border-top: ${euiTheme.border.thin}; - margin-top: 0 !important; - } - `; +} \ No newline at end of file diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx index 6bb464cd9be58..b26927ff61d8e 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx @@ -188,8 +188,6 @@ const sidebarStyles = (euiThemeContext: UseEuiTheme) => css` flex-direction: column; position: relative; ${euiBreakpoint(euiThemeContext, ['xs', 's', 'm'])} { - > .lnsFrameLayout__sidebar { - min-height: ${euiThemeContext.euiTheme.size.l} * 15; - } + min-height: 360px; } `; diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout.styles.ts b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout.styles.ts index b242885a6097f..d91923b887de0 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout.styles.ts +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout.styles.ts @@ -34,4 +34,12 @@ export const flyoutContainerStyles = (euiThemeContext: UseEuiTheme) => css` align-items: stretch; animation: ${flyoutOpenCloseAnimation} ${euiThemeContext.euiTheme.animation.normal} ${euiThemeContext.euiTheme.animation.resistance}; + .lnsIndexPatternDimensionEditor--padded { + padding: ${euiThemeContext.euiTheme.size.base}; + } + .lnsIndexPatternDimensionEditor--collapseNext { + margin-bottom: -${euiThemeContext.euiTheme.size.l}; + border-top: ${euiThemeContext.euiTheme.border.thin}; + margin-top: 0 !important; + } `; From 55f23018a3c285acbe6dcd49bb07ca8114341ece Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 4 Mar 2025 13:41:09 +0000 Subject: [PATCH 30/37] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- x-pack/platform/plugins/shared/lens/public/app_plugin/app.tsx | 2 +- .../editor_frame/config_panel/config_panel.tsx | 2 +- .../editor_frame/config_panel/layer_panel.tsx | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/app_plugin/app.tsx b/x-pack/platform/plugins/shared/lens/public/app_plugin/app.tsx index d9d207ca9ea67..86a79507bd284 100644 --- a/x-pack/platform/plugins/shared/lens/public/app_plugin/app.tsx +++ b/x-pack/platform/plugins/shared/lens/public/app_plugin/app.tsx @@ -439,7 +439,7 @@ export function App({ <>
              ); -} \ No newline at end of file +} From a1b1bbffc0447e5278a0c9e41b417e731b94098c Mon Sep 17 00:00:00 2001 From: mbondyra Date: Tue, 4 Mar 2025 14:46:25 +0100 Subject: [PATCH 31/37] fullscreen formula fix --- .../definitions/formula/editor/formula_editor.tsx | 2 +- .../workspace_panel/workspace_panel_wrapper.tsx | 7 ++++++- .../lens/public/shared_components/flyout_container.tsx | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx index 7c6cbe113100e..9f22403ec9d76 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx @@ -831,7 +831,7 @@ export function FormulaEditor({
              - + {isFullscreen ? ( diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx index 893cca7cceb23..ae0dab8f2e410 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx @@ -107,7 +107,7 @@ export function FlyoutContainer({ aria-labelledby="lnsDimensionContainerTitle" css={[ css` - box-shadow: ${isInlineEditing ? 'none !important' : 'inherit'}; + box-shadow: ${isInlineEditing || isFullscreen ? 'none !important' : 'inherit'}; `, flyoutContainerStyles(euiThemeContext), dimensionContainerStyles.self(euiThemeContext), @@ -164,6 +164,7 @@ export function FlyoutContainer({ className="eui-yScroll" css={css` flex: 1; + z-index: 1; `} > {children} @@ -200,7 +201,6 @@ const dimensionContainerStyles = { // But with custom positioning to keep it within the sidebar contents max-width: none !important; left: 0; - z-index: ${euiThemeContext.euiTheme.levels.menu}; ${euiBreakpoint(euiThemeContext, ['m', 'l', 'xl'])} { height: 100% !important; position: absolute; From da08fac71da714061c1929631f010adcbf26a4d1 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 4 Mar 2025 14:08:02 +0000 Subject: [PATCH 32/37] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../editor_frame/workspace_panel/workspace_panel_wrapper.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx index d9bfb2c299acb..123760851091d 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel_wrapper.tsx @@ -256,7 +256,8 @@ export function WorkspacePanelWrapper({ height: 100%; position: absolute; } - ${isFullscreen && ` + ${isFullscreen && + ` margin-bottom: 0; .lnsWorkspacePanelWrapper__content { padding: ${euiTheme.size.s} From ba7d2ebb0da9f2cc8c72c879cf112fd196f189ad Mon Sep 17 00:00:00 2001 From: mbondyra Date: Tue, 11 Mar 2025 15:54:12 +0100 Subject: [PATCH 33/37] code review --- .../dimension_panel/dimension_editor.tsx | 11 +--------- .../dimension_panel/reference_editor.tsx | 2 +- .../dimension_panel/shared_styles.tsx | 12 +++++++++++ .../definitions/filters/filter_popover.tsx | 12 +---------- .../definitions/filters/filters.tsx | 3 ++- .../formula/editor/formula_editor.tsx | 4 ++-- .../definitions/ranges/advanced_editor.tsx | 6 +++--- .../operations/definitions/styles.tsx | 20 +++++++++++++++++++ .../editor_frame/frame_layout.tsx | 2 +- 9 files changed, 43 insertions(+), 29 deletions(-) create mode 100644 x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/shared_styles.tsx create mode 100644 x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/styles.tsx diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx index 958b05567b7b6..ea55e93b74602 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx @@ -75,6 +75,7 @@ import { ParamEditorProps } from '../operations/definitions'; import { WrappingHelpPopover } from '../help_popover'; import { isColumn } from '../operations/definitions/helpers'; import type { FieldChoiceWithOperationType } from './field_select'; +import { operationsButtonStyles } from './shared_styles'; import type { IndexPattern, IndexPatternField } from '../../../types'; import { documentField } from '../document_field'; @@ -1300,13 +1301,3 @@ const operationsTwoColumnsStyles = ({ euiTheme }: UseEuiTheme) => { column-gap: ${euiTheme.size.m}; `; }; - -export const operationsButtonStyles = ({ euiTheme }: UseEuiTheme) => { - return css` - > button { - padding-top: 0; - padding-bottom: 0; - min-block-size: ${euiTheme.size.l}; - } - `; -}; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/reference_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/reference_editor.tsx index 9b8504954fc01..eab581c815958 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/reference_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/reference_editor.tsx @@ -31,7 +31,7 @@ import type { FormBasedLayer } from '../types'; import type { IndexPattern, IndexPatternField, ParamEditorCustomProps } from '../../../types'; import type { FormBasedDimensionEditorProps } from './dimension_panel'; import { FormRow } from '../operations/definitions/shared_components'; -import { operationsButtonStyles } from './dimension_editor'; +import { operationsButtonStyles } from './shared_styles'; const operationDisplay = getOperationDisplay(); diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/shared_styles.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/shared_styles.tsx new file mode 100644 index 0000000000000..2aed07b17e5cb --- /dev/null +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/shared_styles.tsx @@ -0,0 +1,12 @@ +import { UseEuiTheme } from '@elastic/eui'; +import { css } from '@emotion/react'; + +export const operationsButtonStyles = ({ euiTheme }: UseEuiTheme) => { + return css` + > button { + padding-top: 0; + padding-bottom: 0; + min-block-size: ${euiTheme.size.l}; + } + `; +}; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx index 86d8394eb7a7c..0668c41bc8318 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filter_popover.tsx @@ -6,13 +6,12 @@ */ import React, { useState } from 'react'; -import { euiFontSize, EuiPopover, EuiSpacer, euiTextBreakWord, UseEuiTheme } from '@elastic/eui'; +import { EuiPopover, EuiSpacer } from '@elastic/eui'; import type { Query } from '@kbn/es-query'; // Need to keep it separate to make it work Jest mocks in dimension_panel tests // import { QueryInput } from '../../../../shared_components/query_input'; import { isQueryValid, QueryInput } from '@kbn/visualization-ui-components'; import { useKibana } from '@kbn/kibana-react-plugin/public'; -import { css } from '@emotion/react'; import { LENS_APP_NAME } from '../../../../../../common/constants'; import { IndexPattern } from '../../../../../types'; import { FilterValue, defaultLabel } from '.'; @@ -101,12 +100,3 @@ export const FilterPopover = ({ ); }; - -export const draggablePopoverButtonStyles = (euiThemeContext: UseEuiTheme) => { - return css` - ${euiTextBreakWord()}; - ${euiFontSize(euiThemeContext, 's')}; - min-height: ${euiThemeContext.euiTheme.size.xl}; - width: 100%; - `; -}; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx index bcc31ca6fc4c6..95206a55c5d02 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx @@ -23,9 +23,10 @@ import { IndexPattern } from '../../../../../types'; import { updateColumnParam } from '../../layer_helpers'; import type { OperationDefinition } from '..'; import type { BaseIndexPatternColumn } from '../column_types'; -import { draggablePopoverButtonStyles, FilterPopover } from './filter_popover'; +import { FilterPopover } from './filter_popover'; import { TermsIndexPatternColumn } from '../terms'; import { isColumnOfType } from '../helpers'; +import {draggablePopoverButtonStyles} from '../styles'; const generateId = htmlIdGenerator(); const OPERATION_NAME = 'filters'; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx index 9f22403ec9d76..82ae7d28aa211 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx @@ -831,7 +831,7 @@ export function FormulaEditor({
              - + {isFullscreen ? ( {errorCount || warningCount ? ( - + { @@ -136,7 +136,7 @@ export const RangePopover = ({ { diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/styles.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/styles.tsx new file mode 100644 index 0000000000000..22c27f3f603e0 --- /dev/null +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/styles.tsx @@ -0,0 +1,20 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + + +import { euiFontSize, euiTextBreakWord, UseEuiTheme } from '@elastic/eui'; +import { css } from '@emotion/react'; + +export const draggablePopoverButtonStyles = (euiThemeContext: UseEuiTheme) => { + return css` + ${euiTextBreakWord()}; + ${euiFontSize(euiThemeContext, 's')}; + min-height: ${euiThemeContext.euiTheme.size.xl}; + width: 100%; + `; +}; + diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx index b26927ff61d8e..0c5145d77592a 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx @@ -89,7 +89,7 @@ export function FrameLayout(props: FrameLayoutProps) { `} >
              Date: Tue, 11 Mar 2025 15:17:08 +0000 Subject: [PATCH 34/37] [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' --- .../form_based/dimension_panel/shared_styles.tsx | 7 +++++++ .../form_based/operations/definitions/filters/filters.tsx | 2 +- .../operations/definitions/ranges/advanced_editor.tsx | 6 +++--- .../form_based/operations/definitions/styles.tsx | 2 -- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/shared_styles.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/shared_styles.tsx index 2aed07b17e5cb..345dfef84a821 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/shared_styles.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/shared_styles.tsx @@ -1,3 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + import { UseEuiTheme } from '@elastic/eui'; import { css } from '@emotion/react'; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx index 95206a55c5d02..0b6579ede6b5a 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/filters/filters.tsx @@ -26,7 +26,7 @@ import type { BaseIndexPatternColumn } from '../column_types'; import { FilterPopover } from './filter_popover'; import { TermsIndexPatternColumn } from '../terms'; import { isColumnOfType } from '../helpers'; -import {draggablePopoverButtonStyles} from '../styles'; +import { draggablePopoverButtonStyles } from '../styles'; const generateId = htmlIdGenerator(); const OPERATION_NAME = 'filters'; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx index c3beaafd593b4..837a7fc6f1f6f 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/ranges/advanced_editor.tsx @@ -33,7 +33,7 @@ import { RangeTypeLens, isValidRange } from './ranges'; import { FROM_PLACEHOLDER, TO_PLACEHOLDER, TYPING_DEBOUNCE_TIME } from './constants'; import { LabelInput } from '../shared_components'; import { isValidNumber } from '../helpers'; -import {draggablePopoverButtonStyles} from '../styles'; +import { draggablePopoverButtonStyles } from '../styles'; const generateId = htmlIdGenerator(); @@ -103,7 +103,7 @@ export const RangePopover = ({ { @@ -136,7 +136,7 @@ export const RangePopover = ({ { diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/styles.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/styles.tsx index 22c27f3f603e0..0473e58ae5a7d 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/styles.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/styles.tsx @@ -5,7 +5,6 @@ * 2.0. */ - import { euiFontSize, euiTextBreakWord, UseEuiTheme } from '@elastic/eui'; import { css } from '@emotion/react'; @@ -17,4 +16,3 @@ export const draggablePopoverButtonStyles = (euiThemeContext: UseEuiTheme) => { width: 100%; `; }; - From b32a300d19218b98a277923633e7a2c4e44d5a6d Mon Sep 17 00:00:00 2001 From: mbondyra Date: Wed, 12 Mar 2025 13:37:09 +0100 Subject: [PATCH 35/37] add type --- .../form_based/dimension_panel/dimension_editor.tsx | 2 +- .../dimension_panel/dimensions_editor_helpers.tsx | 8 +++++++- .../lens/public/datasources/form_based/help_popover.tsx | 2 +- .../definitions/formula/editor/formula_editor.tsx | 2 +- .../editor_frame_service/editor_frame/frame_layout.tsx | 2 +- .../editor_frame/suggestion_panel.tsx | 2 +- .../editor_frame/workspace_panel/message_list.tsx | 2 +- .../editor_frame/workspace_panel/workspace_panel.tsx | 2 +- .../shared_components/dataview_picker/toolbar_button.tsx | 2 +- .../lens/public/shared_components/flyout_container.tsx | 2 +- .../shared_components/setting_with_sibling_flyout.tsx | 2 +- .../shared/lens/public/visualizations/xy/add_layer.tsx | 2 +- 12 files changed, 18 insertions(+), 12 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx index ea55e93b74602..cf8302c889356 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimension_editor.tsx @@ -24,7 +24,7 @@ import { EuiPanel, EuiBasicTable, EuiButtonIcon, - UseEuiTheme, + type UseEuiTheme, } from '@elastic/eui'; import ReactDOM from 'react-dom'; import { NameInput } from '@kbn/visualization-ui-components'; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx index 545f703663b24..a45fd2e6a6e67 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/dimension_panel/dimensions_editor_helpers.tsx @@ -14,7 +14,13 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; -import { EuiCallOut, EuiButtonGroup, EuiFormRow, UseEuiTheme, useEuiTheme } from '@elastic/eui'; +import { + EuiCallOut, + EuiButtonGroup, + EuiFormRow, + type UseEuiTheme, + useEuiTheme, +} from '@elastic/eui'; import { css } from '@emotion/react'; import { nonNullable } from '../../../utils'; import { diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.tsx index d30eb5433b1d6..c2b4b18739412 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/help_popover.tsx @@ -16,7 +16,7 @@ import { EuiWrappingPopoverProps, EuiPopoverTitle, EuiText, - UseEuiTheme, + type UseEuiTheme, useEuiTheme, } from '@elastic/eui'; import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx index 82ae7d28aa211..d6175ad3e6e55 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx @@ -25,7 +25,7 @@ import { EuiToolTip, EuiSpacer, useEuiTheme, - UseEuiTheme, + type UseEuiTheme, } from '@elastic/eui'; import useUnmount from 'react-use/lib/useUnmount'; import { monaco } from '@kbn/monaco'; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx index 0c5145d77592a..97931af2f3bbb 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx @@ -14,7 +14,7 @@ import { EuiPageBody, useEuiTheme, euiBreakpoint, - UseEuiTheme, + type UseEuiTheme, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { css } from '@emotion/react'; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx index c4a9fef1dfb81..d07d1240f3488 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.tsx @@ -20,7 +20,7 @@ import { EuiAccordion, EuiText, EuiNotificationBadge, - UseEuiTheme, + type UseEuiTheme, useEuiTheme, euiFocusRing, useEuiFontSize, diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/message_list.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/message_list.tsx index 6d578b1e9f23b..7c6158ef7c72e 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/message_list.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/message_list.tsx @@ -14,7 +14,7 @@ import { EuiToolTip, EuiFlexGroup, EuiFlexItem, - UseEuiTheme, + type UseEuiTheme, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { css, SerializedStyles } from '@emotion/react'; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx index 28ebd861d4c25..0bc62563c4ad7 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx @@ -20,7 +20,7 @@ import { transparentize, useEuiTheme, EuiSpacer, - UseEuiTheme, + type UseEuiTheme, } from '@elastic/eui'; import type { CoreStart } from '@kbn/core/public'; import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/toolbar_button.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/toolbar_button.tsx index 8b5d15ea7cf4e..36406441cc72d 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/toolbar_button.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/dataview_picker/toolbar_button.tsx @@ -11,7 +11,7 @@ import { EuiButton, PropsOf, EuiButtonProps, - UseEuiTheme, + type UseEuiTheme, euiFontSize, useEuiTheme, } from '@elastic/eui'; diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx index ae0dab8f2e410..f8973d650f04d 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/flyout_container.tsx @@ -16,7 +16,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiFocusTrap, - UseEuiTheme, + type UseEuiTheme, euiBreakpoint, useEuiTheme, } from '@elastic/eui'; diff --git a/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx b/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx index a8034de718753..68f070a426064 100644 --- a/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx +++ b/x-pack/platform/plugins/shared/lens/public/shared_components/setting_with_sibling_flyout.tsx @@ -18,7 +18,7 @@ import { EuiFocusTrap, EuiOutsideClickDetector, EuiPortal, - UseEuiTheme, + type UseEuiTheme, useEuiTheme, } from '@elastic/eui'; import { css } from '@emotion/react'; diff --git a/x-pack/platform/plugins/shared/lens/public/visualizations/xy/add_layer.tsx b/x-pack/platform/plugins/shared/lens/public/visualizations/xy/add_layer.tsx index f83acc6448776..c032be5511558 100644 --- a/x-pack/platform/plugins/shared/lens/public/visualizations/xy/add_layer.tsx +++ b/x-pack/platform/plugins/shared/lens/public/visualizations/xy/add_layer.tsx @@ -15,7 +15,7 @@ import { EuiFlexGroup, IconType, transparentize, - UseEuiTheme, + type UseEuiTheme, useEuiTheme, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; From b5a23e8c425ae5ed0c5354f72be27bec2621db61 Mon Sep 17 00:00:00 2001 From: mbondyra Date: Wed, 12 Mar 2025 13:45:27 +0100 Subject: [PATCH 36/37] types --- .../formula/editor/formula_editor.tsx | 5 +--- .../inline_editing/flyout.styles.ts | 27 ------------------- .../react_embeddable/inline_editing/mount.tsx | 21 ++++++++++++++- 3 files changed, 21 insertions(+), 32 deletions(-) delete mode 100644 x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/flyout.styles.ts diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx index d6175ad3e6e55..d20d7bc610589 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx @@ -814,10 +814,7 @@ export function FormulaEditor({ /> {!text ? ( -
              +
              {i18n.translate('xpack.lens.formulaPlaceholderText', { defaultMessage: 'Type a formula by combining functions with math, like:', diff --git a/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/flyout.styles.ts b/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/flyout.styles.ts deleted file mode 100644 index 45322e7cf9038..0000000000000 --- a/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/flyout.styles.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { UseEuiTheme } from '@elastic/eui'; - -// styles needed to display extra drop targets that are outside of the config panel main area while also allowing to scroll vertically -export const inlineFlyoutStyles = ({ euiTheme }: UseEuiTheme) => ` - clip-path: polygon(-100% 0, 100% 0, 100% 100%, -100% 100%); - max-inline-size: 640px; - min-inline-size: 256px; - background:${euiTheme.colors.backgroundBaseSubdued}; - @include euiBreakpoint('xs', 's', 'm') { - clip-path: none; - } - .kbnOverlayMountWrapper { - padding-left: 400px; - margin-left: -400px; - pointer-events: none; - .euiFlyoutFooter { - pointer-events: auto; - } - } -`; diff --git a/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/mount.tsx b/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/mount.tsx index f5b42310ac57d..d0618b5877168 100644 --- a/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/mount.tsx +++ b/x-pack/platform/plugins/shared/lens/public/react_embeddable/inline_editing/mount.tsx @@ -10,7 +10,7 @@ import { TracksOverlays } from '@kbn/presentation-containers'; import { toMountPoint } from '@kbn/react-kibana-mount'; import React from 'react'; import ReactDOM from 'react-dom'; -import { inlineFlyoutStyles } from './flyout.styles'; +import { type UseEuiTheme } from '@elastic/eui'; /** * Shared logic to mount the inline config panel @@ -62,3 +62,22 @@ export function mountInlineEditPanel( } } } + +// styles needed to display extra drop targets that are outside of the config panel main area while also allowing to scroll vertically +const inlineFlyoutStyles = ({ euiTheme }: UseEuiTheme) => ` + clip-path: polygon(-100% 0, 100% 0, 100% 100%, -100% 100%); + max-inline-size: 640px; + min-inline-size: 256px; + background:${euiTheme.colors.backgroundBaseSubdued}; + @include euiBreakpoint('xs', 's', 'm') { + clip-path: none; + } + .kbnOverlayMountWrapper { + padding-left: 400px; + margin-left: -400px; + pointer-events: none; + .euiFlyoutFooter { + pointer-events: auto; + } + } +`; From dfeefcdb5eed554955b78664d978cc8d1bb3663d Mon Sep 17 00:00:00 2001 From: mbondyra Date: Wed, 12 Mar 2025 14:31:17 +0100 Subject: [PATCH 37/37] cr --- .../definitions/formula/editor/formula_editor.tsx | 11 ++++------- .../editor_frame/frame_layout.tsx | 13 ++++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx index d20d7bc610589..e548a45d3a1b5 100644 --- a/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx +++ b/x-pack/platform/plugins/shared/lens/public/datasources/form_based/operations/definitions/formula/editor/formula_editor.tsx @@ -921,8 +921,7 @@ export function FormulaEditor({ {warnings.map(({ message, severity }, index) => (
              css` - + .lnsFormula__warningText { - margin-top: ${euiTheme.size.s}; - border-top: ${euiTheme.border.thin}; - padding-top: ${euiTheme.size.s}; - } + margin-top: ${euiTheme.size.s}; + border-top: ${euiTheme.border.thin}; + padding-top: ${euiTheme.size.s}; `, editorHelpLink: ({ euiTheme }: UseEuiTheme) => css` align-items: center; diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx index 97931af2f3bbb..e5c023b818869 100644 --- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx +++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/frame_layout.tsx @@ -93,13 +93,12 @@ export function FrameLayout(props: FrameLayoutProps) { aria-labelledby="dataPanelId" css={[ sidebarStyles(euiThemeContext), - css` - ${isFullscreen && - ` - // Hide the datapanel in fullscreen mode. Using display: none does trigger - // a rerender when the container becomes visible again, maybe pushing offscreen is better - display: none;`} - `, + isFullscreen && + css` + // Hide the datapanel in fullscreen mode. Using display: none does trigger + // a rerender when the container becomes visible again, maybe pushing offscreen is better + display: none; + `, ]} >