Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed Nov 17, 2021
1 parent b4d509e commit 725545e
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import React, { useCallback } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiFieldNumber, EuiFormLabel, EuiSpacer } from '@elastic/eui';
import { OperationDefinition } from './index';
import { ReferenceBasedIndexPatternColumn } from './column_types';
import { ReferenceBasedIndexPatternColumn, GenericIndexPatternColumn } from './column_types';
import type { IndexPattern } from '../../types';
import { useDebouncedValue } from '../../../shared_components';
import { getFormatFromPreviousColumn, isColumnOfType, isValidNumber } from './helpers';
import { getFormatFromPreviousColumn, isValidNumber } from './helpers';

const defaultLabel = i18n.translate('xpack.lens.indexPattern.staticValueLabelDefault', {
defaultMessage: 'Static value',
Expand Down Expand Up @@ -46,6 +46,12 @@ export interface StaticValueIndexPatternColumn extends ReferenceBasedIndexPatter
};
}

function isStaticValueColumnLike(
col: GenericIndexPatternColumn
): col is StaticValueIndexPatternColumn {
return Boolean('params' in col && col.params && 'value' in col.params);
}

export const staticValueOperation: OperationDefinition<
StaticValueIndexPatternColumn,
'managedReference'
Expand Down Expand Up @@ -103,7 +109,7 @@ export const staticValueOperation: OperationDefinition<
buildColumn({ previousColumn, layer, indexPattern }, columnParams, operationDefinitionMap) {
const existingStaticValue =
previousColumn &&
isColumnOfType<StaticValueIndexPatternColumn>('static_value', previousColumn) &&
isStaticValueColumnLike(previousColumn) &&
isValidNumber(previousColumn.params.value)
? previousColumn.params.value
: undefined;
Expand Down

0 comments on commit 725545e

Please sign in to comment.