Skip to content

Commit

Permalink
fix based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar committed Dec 4, 2024
1 parent f531765 commit 8772e75
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,41 +174,42 @@ export function TextBasedDimensionEditor(props: TextBasedDimensionEditorProps) {
{props.dataSectionExtra}
</div>
)}
{!isFullscreen && (
{!isFullscreen && selectedField && (
<div className="lnsIndexPatternDimensionEditor--padded lnsIndexPatternDimensionEditor--collapseNext">
{selectedField && (
<EuiText
size="s"
css={css`
margin-bottom: ${euiTheme.size.base};
`}
>
<h4>
{i18n.translate('xpack.lens.indexPattern.dimensionEditor.headingAppearance', {
defaultMessage: 'Appearance',
})}
</h4>
</EuiText>
)}
<>
{selectedField && (
<NameInput
value={selectedField.label || ''}
defaultValue={''}
onChange={(value) => {
updateLayer(updateColumnLabel({ layer: state.layers[layerId], columnId, value }));
}}
/>
)}
<EuiText
size="s"
css={css`
margin-bottom: ${euiTheme.size.base};
`}
>
<h4>
{i18n.translate('xpack.lens.indexPattern.dimensionEditor.headingAppearance', {
defaultMessage: 'Appearance',
})}
</h4>
</EuiText>

{selectedField && selectedField.meta?.type === 'number' ? (
<FormatSelector
selectedColumn={selectedField}
onChange={onFormatChange}
docLinks={props.core.docLinks}
/>
) : null}
</>
<NameInput
value={selectedField.label || ''}
defaultValue={''}
onChange={(value) => {
updateLayer(
updateColumnLabel({
layer: state.layers[layerId],
columnId,
value,
})
);
}}
/>

{selectedField.meta?.type === 'number' ? (
<FormatSelector
selectedColumn={selectedField}
onChange={onFormatChange}
docLinks={props.core.docLinks}
/>
) : null}
</div>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
Expand All @@ -34,7 +39,6 @@ function getExpressionForLayer(
...idMapper,
[col.fieldName]: [
{
// ...col,
id: col.columnId,
label: col.customLabel ? col.label : col.fieldName,
} as OriginalColumn,
Expand All @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/lens/public/datasources/text_based/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export function updateColumnLabel({
{
...currentColumn,
label: value,
customLabel: true,
customLabel: !!value,
},
...layer.columns.slice(currentColumnIndex + 1),
],
Expand Down

0 comments on commit 8772e75

Please sign in to comment.