From 825ff08b0ce1db63ac3c623d8aadc2e1f816db0a Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Wed, 12 Jul 2023 13:54:39 -0700 Subject: [PATCH] Feature/prerelease code cleanup (#589) (#594) * refactor naming Signed-off-by: Eric Wei * refactor vis workspace Signed-off-by: Eric Wei * config panel refactoring Signed-off-by: Eric Wei * refactor workspace Signed-off-by: Eric Wei --------- Signed-off-by: Eric Wei (cherry picked from commit 0a803dc69b67262e8b58ffb56fc9ad5c8e473469) Co-authored-by: Eric Wei --- .../config_panel/config_panel.tsx | 29 +------------------ .../config_panel/config_panel_footer.tsx | 15 ++-------- .../shared_components/empty_placeholder.scss | 2 +- .../shared_components/empty_placeholder.tsx | 2 +- .../visualizations/shared_components/index.ts | 2 +- .../vis_canvass_placeholder.tsx | 8 ++--- .../workspace_panel/workspace_panel.scss | 6 ++-- .../workspace_panel/workspace_panel.tsx | 8 ++--- .../__snapshots__/gauge.test.tsx.snap | 4 +-- .../__snapshots__/metrics.test.tsx.snap | 4 +-- .../visualizations/visualization.tsx | 4 +-- 11 files changed, 22 insertions(+), 62 deletions(-) diff --git a/public/components/event_analytics/explorer/visualizations/config_panel/config_panel.tsx b/public/components/event_analytics/explorer/visualizations/config_panel/config_panel.tsx index bb3ed71c2..765386ff6 100644 --- a/public/components/event_analytics/explorer/visualizations/config_panel/config_panel.tsx +++ b/public/components/event_analytics/explorer/visualizations/config_panel/config_panel.tsx @@ -13,31 +13,12 @@ import { } from '@elastic/eui'; import hjson from 'hjson'; import { find } from 'lodash'; -import Mustache from 'mustache'; import { ENABLED_VIS_TYPES } from '../../../../../../common/constants/shared'; import { getVisTypeData } from '../../../../visualizations/charts/helpers/viz_types'; import { TabContext } from '../../../hooks'; import { reset as resetVisualizationConfig } from '../../../redux/slices/viualization_config_slice'; import { getDefaultSpec } from '../visualization_specs/default_spec'; -const CONFIG_LAYOUT_TEMPLATE = ` -{ - "layout": {}, - "config": { - "scrollZoom": {{config.scrollZoom}}, - "editable": {{config.editable}}, - "staticPlot": {{config.staticPlot}}, - "displayModeBar": {{config.displayModeBar}}, - "responsive": {{config.responsive}}, - "doubleClickDelay": {{config.doubleClickDelay}} - } -} -`; - -const HJSON_PARSE_OPTIONS = { - keepWsc: true, -}; - const HJSON_STRINGIFY_OPTIONS = { keepWsc: true, condense: 0, @@ -81,14 +62,6 @@ export const ConfigPanel = ({ visualizations, setCurVisId, callback }: any) => { } }, [userConfigs, curVisId]); - const getParsedLayoutConfig = useCallback( - (hjsonConfig) => - JSON.parse( - Mustache.render(CONFIG_LAYOUT_TEMPLATE, hjson.parse(hjsonConfig, HJSON_PARSE_OPTIONS)) - ), - [] - ); - const handleConfigUpdate = useCallback( (updatedConfigs) => { try { @@ -194,7 +167,7 @@ export const ConfigPanel = ({ visualizations, setCurVisId, callback }: any) => { return (
- +    {label}
diff --git a/public/components/event_analytics/explorer/visualizations/config_panel/config_panel_footer.tsx b/public/components/event_analytics/explorer/visualizations/config_panel/config_panel_footer.tsx index 75093f465..8ad45a357 100644 --- a/public/components/event_analytics/explorer/visualizations/config_panel/config_panel_footer.tsx +++ b/public/components/event_analytics/explorer/visualizations/config_panel/config_panel_footer.tsx @@ -4,20 +4,9 @@ */ import React from 'react'; -import { - EuiFlexGroup, - EuiFlexItem, - EuiButton, - EuiButtonEmpty, - EuiToolTip, -} from '@elastic/eui'; +import { EuiFlexGroup, EuiFlexItem, EuiButtonEmpty } from '@elastic/eui'; -export const DefaultEditorControls = ({ - isInvalid, - isDirty, - onConfigUpdate, - onConfigDiscard, -}: any) => { +export const DefaultEditorControls = ({ isDirty, onConfigDiscard }: any) => { return (
diff --git a/public/components/event_analytics/explorer/visualizations/shared_components/empty_placeholder.scss b/public/components/event_analytics/explorer/visualizations/shared_components/empty_placeholder.scss index be379ecec..39c6f080c 100644 --- a/public/components/event_analytics/explorer/visualizations/shared_components/empty_placeholder.scss +++ b/public/components/event_analytics/explorer/visualizations/shared_components/empty_placeholder.scss @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ - .lnsChart__empty { + .visWorkspaceNoData { display: flex; justify-content: center; align-items: center; diff --git a/public/components/event_analytics/explorer/visualizations/shared_components/empty_placeholder.tsx b/public/components/event_analytics/explorer/visualizations/shared_components/empty_placeholder.tsx index 397672821..f2bb0bf0b 100644 --- a/public/components/event_analytics/explorer/visualizations/shared_components/empty_placeholder.tsx +++ b/public/components/event_analytics/explorer/visualizations/shared_components/empty_placeholder.tsx @@ -10,7 +10,7 @@ import { FormattedMessage } from '@osd/i18n/react'; export const EmptyPlaceholder = (props: { icon: string }) => ( <> ( +export const VisWorkspaceDefault = (props: { message: string; icon: string }) => ( <> -

- { props.message } -

+

{props.message}

); diff --git a/public/components/event_analytics/explorer/visualizations/workspace_panel/workspace_panel.scss b/public/components/event_analytics/explorer/visualizations/workspace_panel/workspace_panel.scss index 820236aa1..4e2c30ae3 100644 --- a/public/components/event_analytics/explorer/visualizations/workspace_panel/workspace_panel.scss +++ b/public/components/event_analytics/explorer/visualizations/workspace_panel/workspace_panel.scss @@ -7,13 +7,13 @@ background-color: transparent; } -.ws__visCanvas { +.ws__workspace_visPanel { grid-gap: 12px; padding: 12px; - .ws__visCanvasControl { + .workspace_visPanel { height: 40px; width: 140px; - .ws__visCanvasFlexitem { + .ws__workspace_visPanelFlexitem { display: block; } } diff --git a/public/components/event_analytics/explorer/visualizations/workspace_panel/workspace_panel.tsx b/public/components/event_analytics/explorer/visualizations/workspace_panel/workspace_panel.tsx index a5fdd3f00..091c7ba9b 100644 --- a/public/components/event_analytics/explorer/visualizations/workspace_panel/workspace_panel.tsx +++ b/public/components/event_analytics/explorer/visualizations/workspace_panel/workspace_panel.tsx @@ -25,10 +25,10 @@ export function WorkspacePanel({ visualizations }: IWorkSpacePanel) { }, [visualizations]); return ( -
- +
+ diff --git a/public/components/visualizations/charts/__tests__/__snapshots__/gauge.test.tsx.snap b/public/components/visualizations/charts/__tests__/__snapshots__/gauge.test.tsx.snap index c866bda72..b4e6654b9 100644 --- a/public/components/visualizations/charts/__tests__/__snapshots__/gauge.test.tsx.snap +++ b/public/components/visualizations/charts/__tests__/__snapshots__/gauge.test.tsx.snap @@ -392,14 +392,14 @@ exports[`Gauge component Renders gauge component 1`] = ` icon="visGauge" >
) : ( - + )} );