From 8772e75ef5cd79a7ddab7cc63886d9d8323c3136 Mon Sep 17 00:00:00 2001 From: ppisljar Date: Wed, 4 Dec 2024 07:24:46 +0100 Subject: [PATCH] fix based on review --- .../components/dimension_editor.tsx | 67 ++++++++++--------- .../datasources/text_based/to_expression.ts | 11 +-- .../public/datasources/text_based/utils.ts | 2 +- 3 files changed, 42 insertions(+), 38 deletions(-) diff --git a/x-pack/plugins/lens/public/datasources/text_based/components/dimension_editor.tsx b/x-pack/plugins/lens/public/datasources/text_based/components/dimension_editor.tsx index 6465aaf57021d..bfaf056f6089d 100644 --- a/x-pack/plugins/lens/public/datasources/text_based/components/dimension_editor.tsx +++ b/x-pack/plugins/lens/public/datasources/text_based/components/dimension_editor.tsx @@ -174,41 +174,42 @@ export function TextBasedDimensionEditor(props: TextBasedDimensionEditorProps) { {props.dataSectionExtra} )} - {!isFullscreen && ( + {!isFullscreen && selectedField && (
- {selectedField && ( - -

- {i18n.translate('xpack.lens.indexPattern.dimensionEditor.headingAppearance', { - defaultMessage: 'Appearance', - })} -

-
- )} - <> - {selectedField && ( - { - updateLayer(updateColumnLabel({ layer: state.layers[layerId], columnId, value })); - }} - /> - )} + +

+ {i18n.translate('xpack.lens.indexPattern.dimensionEditor.headingAppearance', { + defaultMessage: 'Appearance', + })} +

+
- {selectedField && selectedField.meta?.type === 'number' ? ( - - ) : null} - + { + updateLayer( + updateColumnLabel({ + layer: state.layers[layerId], + columnId, + value, + }) + ); + }} + /> + + {selectedField.meta?.type === 'number' ? ( + + ) : null}
)} diff --git a/x-pack/plugins/lens/public/datasources/text_based/to_expression.ts b/x-pack/plugins/lens/public/datasources/text_based/to_expression.ts index 196b1033e81cc..04e690de01726 100644 --- a/x-pack/plugins/lens/public/datasources/text_based/to_expression.ts +++ b/x-pack/plugins/lens/public/datasources/text_based/to_expression.ts @@ -9,7 +9,13 @@ import { i18n } from '@kbn/i18n'; import { Ast } from '@kbn/interpreter'; import { textBasedQueryStateToExpressionAst } from '@kbn/data-plugin/common'; import { ExpressionAstFunction } from '@kbn/expressions-plugin/common'; -import { TextBasedPrivateState, TextBasedLayer, IndexPatternRef } from './types'; +import { ValueFormatConfig } from '../form_based/operations/definitions/column_types'; +import { + TextBasedPrivateState, + TextBasedLayer, + IndexPatternRef, + TextBasedLayerColumn, +} from './types'; import type { OriginalColumn } from '../../../common/types'; function getExpressionForLayer( @@ -25,7 +31,6 @@ function getExpressionForLayer( layer.columns.forEach((col) => { if (idMapper[col.fieldName]) { idMapper[col.fieldName].push({ - // ...col, id: col.columnId, label: col.customLabel ? col.label : col.fieldName, } as OriginalColumn); @@ -34,7 +39,6 @@ function getExpressionForLayer( ...idMapper, [col.fieldName]: [ { - // ...col, id: col.columnId, label: col.customLabel ? col.label : col.fieldName, } as OriginalColumn, @@ -47,7 +51,6 @@ function getExpressionForLayer( const formatterOverrides: ExpressionAstFunction[] = layer.columns .filter((col) => col.params?.format) .map((col) => { - // TODO: improve the type handling here const format = col.params!.format!; const base: ExpressionAstFunction = { diff --git a/x-pack/plugins/lens/public/datasources/text_based/utils.ts b/x-pack/plugins/lens/public/datasources/text_based/utils.ts index a85cc1a6d3c7e..ec8b1cc7645e9 100644 --- a/x-pack/plugins/lens/public/datasources/text_based/utils.ts +++ b/x-pack/plugins/lens/public/datasources/text_based/utils.ts @@ -202,7 +202,7 @@ export function updateColumnLabel({ { ...currentColumn, label: value, - customLabel: true, + customLabel: !!value, }, ...layer.columns.slice(currentColumnIndex + 1), ],