Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lens] Reference line renaming + other small fixes #113811

Merged
merged 87 commits into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from 86 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
d7f6363
:bug: Add padding to the tick label to fit threshold markers
dej611 Sep 23, 2021
6f59341
:bug: Better icon detection
dej611 Sep 23, 2021
a5c5c09
:bug: Fix edge cases with no title or labels
dej611 Sep 23, 2021
e705e0f
:camera_flash: Update snapshots
dej611 Sep 23, 2021
a61c78b
Merge branch 'master' into fix/112793
kibanamachine Sep 27, 2021
82dba7b
:sparkles: Make threshold fit into view automatically
dej611 Sep 28, 2021
f3616a3
:bug: do not compute axis threshold extends if no threshold is present
dej611 Sep 28, 2021
e78cd2b
:white_check_mark: One more fix for 0-based extends and tests
dej611 Sep 28, 2021
33845bb
Merge branch 'master' into fix/112793
kibanamachine Sep 28, 2021
5a5270a
:sparkles: Add icon placement flag
dej611 Sep 28, 2021
6cfad94
:sparkles: Sync padding computation with marker positioning
dej611 Sep 29, 2021
6485fa7
Merge branch 'master' into fix/112793
kibanamachine Sep 29, 2021
45040f0
:sparkles: compute the default threshold based on data bounds
dej611 Sep 29, 2021
9d8cb7e
:bug: fix duplicate suggestion issue + missing over time
dej611 Sep 29, 2021
4b33f6c
Merge branch 'master' into fix/112795
kibanamachine Sep 29, 2021
1b2d56c
Merge branch 'master' into fix/112788
kibanamachine Sep 30, 2021
b0d5b4e
Merge branch 'master' into fix/112795
kibanamachine Sep 30, 2021
af96b0a
:ok_hand: Make disabled when no icon is selected
dej611 Sep 30, 2021
5a9ee3b
Merge branch 'master' into fix/112793
kibanamachine Sep 30, 2021
8eedc11
:sparkles: First text on marker implementation
dej611 Sep 30, 2021
44a70a4
:bug: Fix some edge cases with auto positioning
dej611 Sep 30, 2021
fbb372c
Merge branch 'fix/112793' of github.com:dej611/kibana into fix/112793
dej611 Sep 30, 2021
21c60b7
Merge branch 'fix/112793' into fix/112921
dej611 Sep 30, 2021
5b4374c
Update x-pack/plugins/lens/public/xy_visualization/xy_config_panel/th…
dej611 Sep 30, 2021
20cecf4
:bug: Fix minor details
dej611 Sep 30, 2021
c5b4e73
Merge branch 'fix/112793' into fix/112921
dej611 Sep 30, 2021
f8bb856
:lipstick: Small tweak
dej611 Sep 30, 2021
82a83aa
Merge remote-tracking branch 'upstream/master' into fix/112793
dej611 Sep 30, 2021
43a3a7f
Merge branch 'fix/112793' into fix/112921
dej611 Sep 30, 2021
ac46286
Merge remote-tracking branch 'upstream/master' into fix/112793
dej611 Oct 1, 2021
849e25c
Merge branch 'fix/112793' into fix/112921
dej611 Oct 1, 2021
11e2372
Merge remote-tracking branch 'upstream/master' into fix/112793
dej611 Oct 1, 2021
3fd11f5
Merge branch 'fix/112793' into fix/112921
dej611 Oct 1, 2021
32af982
:sparkles: Reduce the padding if no icon is shown on the axis
dej611 Oct 1, 2021
7b9a5f2
:bug: Fix color fallback for different type of layers
dej611 Oct 1, 2021
7188aa7
:white_check_mark: Fix broken unit tests
dej611 Oct 1, 2021
4e893bd
:bug: Fix multi layer types issue
dej611 Oct 1, 2021
6ee7a50
Merge branch 'master' into fix/112797
kibanamachine Oct 1, 2021
0153c43
:white_check_mark: Fix test
dej611 Oct 4, 2021
2b51824
Merge branch 'fix/112797' of github.com:dej611/kibana into fix/112797
dej611 Oct 4, 2021
6e22381
Merge branch 'master' into fix/113632
kibanamachine Oct 4, 2021
86f76a2
Merge branch 'master' into fix/112788
kibanamachine Oct 4, 2021
681a62e
Merge remote-tracking branch 'upstream/master' into fix/112921
dej611 Oct 4, 2021
14e8d7c
:white_check_mark: Fix other test
dej611 Oct 4, 2021
0739e7b
Merge branch 'master' into fix/112795
kibanamachine Oct 4, 2021
e1b8022
Merge branch 'fix/113632' into fix/thresholds-demo
dej611 Oct 4, 2021
2c7b6a2
Merge remote-tracking branch 'upstream/master' into fix/112921
dej611 Oct 4, 2021
be9e9d2
Merge branch 'fix/112797' into fix/thresholds-demo
dej611 Oct 4, 2021
83ae103
Merge branch 'fix/112795' into fix/thresholds-demo
dej611 Oct 4, 2021
a011671
Merge remote-tracking branch 'upstream/master' into fix/thresholds-demo
dej611 Oct 4, 2021
510c93f
Merge branch 'master' into fix/112797
kibanamachine Oct 4, 2021
4dfd901
:lipstick: Fix vertical text centering
dej611 Oct 4, 2021
3606d8a
:sparkles: Rename to reference lines + few fixes
dej611 Oct 4, 2021
8a6abb2
:rotating_light: Fix linting issue
dej611 Oct 4, 2021
f654e67
Merge remote-tracking branch 'upstream/master' into fix/113406
dej611 Oct 4, 2021
0083c09
:bug: Fix issue
dej611 Oct 4, 2021
93fdec2
Merge branch 'master' into fix/112921
kibanamachine Oct 5, 2021
25dea95
Merge branch 'master' into fix/112797
kibanamachine Oct 5, 2021
07233fa
:bug: Fix computation bug for the initial static value
dej611 Oct 5, 2021
390266d
:white_check_mark: Add new suite of test for static value computation
dej611 Oct 6, 2021
3bc9b3b
:lipstick: Reorder panel inputs
dej611 Oct 6, 2021
7f3dc80
Merge remote-tracking branch 'upstream/master' into fix/113406
dej611 Oct 6, 2021
8a16fc8
Merge branch 'master' into fix/112921
kibanamachine Oct 7, 2021
2d285fc
:lipstick: Move styling to sass
dej611 Oct 7, 2021
8cc45cf
Merge branch 'master' into fix/112797
kibanamachine Oct 7, 2021
4933841
Merge branch 'master' into fix/112797
kibanamachine Oct 7, 2021
ae94760
Merge branch 'master' into fix/112921
kibanamachine Oct 7, 2021
ecae4cd
Merge branch 'master' into fix/112921
kibanamachine Oct 7, 2021
017171a
Merge branch 'fix/112797' into fix/113406
dej611 Oct 7, 2021
c8d4977
Merge branch 'fix/112921' into fix/113406
dej611 Oct 7, 2021
6711de3
:memo: Keeping up with the renaming
dej611 Oct 7, 2021
7e580dc
:white_check_mark: Fix functional tests after renaming
dej611 Oct 7, 2021
650c27e
Merge branch 'master' into fix/113406
kibanamachine Oct 11, 2021
22a6ed6
Merge remote-tracking branch 'upstream/master' into fix/113406
dej611 Oct 11, 2021
3b51e00
:bug: Fix duplicate arg from conflict resolution
dej611 Oct 11, 2021
7c6d6b8
Merge branch 'fix/113406' of github.com:dej611/kibana into fix/113406
dej611 Oct 11, 2021
c921d8b
Merge branch 'master' into fix/113406
kibanamachine Oct 12, 2021
deb6185
Merge branch 'master' into fix/113406
kibanamachine Oct 13, 2021
8b0ec6e
Merge remote-tracking branch 'upstream/master' into fix/113406
dej611 Oct 14, 2021
0c9888f
:ok_hand: Integrate some follow up feedback
dej611 Oct 14, 2021
c5de0d2
Merge branch 'fix/113406' of github.com:dej611/kibana into fix/113406
dej611 Oct 14, 2021
fb8604e
Merge branch 'master' into fix/113406
kibanamachine Oct 14, 2021
9479213
:memo: Fix typo
dej611 Oct 15, 2021
5b818ff
:ok_hand: Integrate feedback
dej611 Oct 15, 2021
8f62aab
:bug: Fix the quick functions transition bug
dej611 Oct 15, 2021
974db2e
Merge branch 'fix/113406' of github.com:dej611/kibana into fix/113406
dej611 Oct 15, 2021
d6d004b
:bug: Fix label issue when updating value
dej611 Oct 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion x-pack/plugins/lens/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export const NOT_INTERNATIONALIZED_PRODUCT_NAME = 'Lens Visualizations';
export const BASE_API_URL = '/api/lens';
export const LENS_EDIT_BY_VALUE = 'edit_by_value';

export const layerTypes: Record<string, LayerType> = { DATA: 'data', THRESHOLD: 'threshold' };
export const layerTypes: Record<string, LayerType> = {
DATA: 'data',
REFERENCELINE: 'referenceLine',
};

export function getBasePath() {
return `#/`;
Expand Down
10 changes: 5 additions & 5 deletions x-pack/plugins/lens/common/expressions/xy_chart/axis_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,24 +173,24 @@ export const yAxisConfig: ExpressionFunctionDefinition<
lineStyle: {
types: ['string'],
options: ['solid', 'dotted', 'dashed'],
help: 'The style of the threshold line',
help: 'The style of the reference line',
},
lineWidth: {
types: ['number'],
help: 'The width of the threshold line',
help: 'The width of the reference line',
},
icon: {
types: ['string'],
help: 'An optional icon used for threshold lines',
help: 'An optional icon used for reference lines',
},
iconPosition: {
types: ['string'],
options: ['auto', 'above', 'below', 'left', 'right'],
help: 'The placement of the icon for the threshold line',
help: 'The placement of the icon for the reference line',
},
textVisibility: {
types: ['boolean'],
help: 'Visibility of the label on the threshold line',
help: 'Visibility of the label on the reference line',
},
fill: {
types: ['string'],
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/lens/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ export interface CustomPaletteParams {

export type RequiredPaletteParamTypes = Required<CustomPaletteParams>;

export type LayerType = 'data' | 'threshold';
export type LayerType = 'data' | 'referenceLine';
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import React from 'react';
import { EuiIconProps } from '@elastic/eui';

export const LensIconChartBarThreshold = ({
export const LensIconChartBarReferenceLine = ({
title,
titleId,
...props
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ describe('ConfigPanel', () => {
instance.update();
act(() => {
instance
.find(`[data-test-subj="lnsLayerAddButton-${layerTypes.THRESHOLD}"]`)
.find(`[data-test-subj="lnsLayerAddButton-${layerTypes.REFERENCELINE}"]`)
.first()
.simulate('click');
});
Expand All @@ -301,8 +301,8 @@ describe('ConfigPanel', () => {
props.activeVisualization.getSupportedLayers = jest.fn(() => [
{ type: layerTypes.DATA, label: 'Data Layer' },
{
type: layerTypes.THRESHOLD,
label: 'Threshold layer',
type: layerTypes.REFERENCELINE,
label: 'Reference layer',
},
]);
datasourceMap.testDatasource.initializeDimension = jest.fn();
Expand Down Expand Up @@ -331,8 +331,8 @@ describe('ConfigPanel', () => {
],
},
{
type: layerTypes.THRESHOLD,
label: 'Threshold layer',
type: layerTypes.REFERENCELINE,
label: 'Reference layer',
},
]);
datasourceMap.testDatasource.initializeDimension = jest.fn();
Expand All @@ -349,8 +349,8 @@ describe('ConfigPanel', () => {
props.activeVisualization.getSupportedLayers = jest.fn(() => [
{ type: layerTypes.DATA, label: 'Data Layer' },
{
type: layerTypes.THRESHOLD,
label: 'Threshold layer',
type: layerTypes.REFERENCELINE,
label: 'Reference layer',
initialDimensions: [
{
groupId: 'testGroup',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,24 @@ export function DimensionEditor(props: DimensionEditorProps) {
const addStaticValueColumn = (prevLayer = props.state.layers[props.layerId]) => {
if (selectedColumn?.operationType !== staticValueOperationName) {
trackUiEvent(`indexpattern_dimension_operation_static_value`);
return insertOrReplaceColumn({
const layer = insertOrReplaceColumn({
layer: prevLayer,
indexPattern: currentIndexPattern,
columnId,
op: staticValueOperationName,
visualizationGroups: dimensionGroups,
});
const value = props.activeData?.[layerId]?.rows[0]?.[columnId];
// replace the default value with the one from the active data
if (value != null) {
return updateColumnParam({
layer,
columnId,
paramName: 'value',
value: props.activeData?.[layerId]?.rows[0]?.[columnId],
});
}
return layer;
}
return prevLayer;
};
Expand All @@ -173,7 +184,18 @@ export function DimensionEditor(props: DimensionEditorProps) {
if (temporaryStaticValue) {
setTemporaryState('none');
}
return setStateWrapper(setter, { forceRender: true });
if (typeof setter === 'function') {
return setState(
(prevState) => {
const layer = setter(addStaticValueColumn(prevState.layers[layerId]));
return mergeLayer({ state: prevState, layerId, newLayer: layer });
},
{
isDimensionComplete: true,
forceRender: true,
}
);
}
};

const ParamEditor = getParamEditor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1206,11 +1206,11 @@ describe('IndexPattern Data Source suggestions', () => {
const modifiedState: IndexPatternPrivateState = {
...initialState,
layers: {
thresholdLayer: {
referenceLineLayer: {
indexPatternId: '1',
columnOrder: ['threshold'],
columnOrder: ['referenceLine'],
columns: {
threshold: {
referenceLine: {
dataType: 'number',
isBucketed: false,
label: 'Static Value: 0',
Expand Down Expand Up @@ -1251,10 +1251,10 @@ describe('IndexPattern Data Source suggestions', () => {
modifiedState,
'1',
documentField,
(layerId) => layerId !== 'thresholdLayer'
(layerId) => layerId !== 'referenceLineLayer'
)
);
// should ignore the threshold layer
// should ignore the referenceLine layer
expect(suggestions).toContainEqual(
expect.objectContaining({
table: expect.objectContaining({
Expand Down Expand Up @@ -1704,7 +1704,7 @@ describe('IndexPattern Data Source suggestions', () => {
);
});

it('adds date histogram over default time field for tables without time dimension and a threshold', async () => {
it('adds date histogram over default time field for tables without time dimension and a referenceLine', async () => {
const initialState = testInitialState();
const state: IndexPatternPrivateState = {
...initialState,
Expand Down Expand Up @@ -1738,11 +1738,11 @@ describe('IndexPattern Data Source suggestions', () => {
},
},
},
threshold: {
referenceLine: {
indexPatternId: '2',
columnOrder: ['thresholda'],
columnOrder: ['referenceLineA'],
columns: {
thresholda: {
referenceLineA: {
label: 'My Op',
customLabel: true,
dataType: 'number',
Expand All @@ -1758,7 +1758,7 @@ describe('IndexPattern Data Source suggestions', () => {

expect(
getSuggestionSubset(
getDatasourceSuggestionsFromCurrentState(state, (layerId) => layerId !== 'threshold')
getDatasourceSuggestionsFromCurrentState(state, (layerId) => layerId !== 'referenceLine')
)
).toContainEqual(
expect.objectContaining({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('utils', () => {

describe('checkForDataLayerType', () => {
it('should return an error if the layer is of the wrong type', () => {
expect(checkForDataLayerType(layerTypes.THRESHOLD, 'Operation')).toEqual([
expect(checkForDataLayerType(layerTypes.REFERENCELINE, 'Operation')).toEqual([
'Operation is disabled for this type of layer.',
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const buildLabelFunction =
};

export function checkForDataLayerType(layerType: LayerType, name: string) {
if (layerType === layerTypes.THRESHOLD) {
if (layerType === layerTypes.REFERENCELINE) {
return [
i18n.translate('xpack.lens.indexPattern.calculations.layerDataType', {
defaultMessage: '{name} is disabled for this type of layer.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ describe('static_value', () => {
};
});

function getLayerWithStaticValue(newValue: string): IndexPatternLayer {
function getLayerWithStaticValue(newValue: string | null | undefined): IndexPatternLayer {
return {
...layer,
columns: {
...layer.columns,
col2: {
...layer.columns.col2,
label: `Static value: ${newValue}`,
label: `Static value: ${newValue ?? String(newValue)}`,
params: {
value: newValue,
},
Expand Down Expand Up @@ -155,8 +155,9 @@ describe('static_value', () => {
).toBeUndefined();
});

it('should return error for invalid values', () => {
for (const value of ['NaN', 'Infinity', 'string']) {
it.each(['NaN', 'Infinity', 'string'])(
'should return error for invalid values: %s',
(value) => {
expect(
staticValueOperation.getErrorMessage!(
getLayerWithStaticValue(value),
Expand All @@ -165,6 +166,16 @@ describe('static_value', () => {
)
).toEqual(expect.arrayContaining([expect.stringMatching('is not a valid number')]));
}
);

it.each([null, undefined])('should return no error for: %s', (value) => {
expect(
staticValueOperation.getErrorMessage!(
getLayerWithStaticValue(value),
'col2',
createMockedIndexPattern()
)
).toBe(undefined);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const staticValueOperation: OperationDefinition<
getErrorMessage(layer, columnId) {
const column = layer.columns[columnId] as StaticValueIndexPatternColumn;

return !isValidNumber(column.params.value)
return column.params.value != null && !isValidNumber(column.params.value)
? [
i18n.translate('xpack.lens.indexPattern.staticValueError', {
defaultMessage: 'The static value of {value} is not a valid number',
Expand Down Expand Up @@ -176,10 +176,7 @@ export const staticValueOperation: OperationDefinition<

// Pick the data from the current activeData (to be used when the current operation is not static_value)
const activeDataValue =
activeData &&
activeData[layerId] &&
activeData[layerId]?.rows?.length === 1 &&
activeData[layerId].rows[0][columnId];
activeData?.[layerId]?.rows?.length === 1 && activeData[layerId].rows[0][columnId];

const fallbackValue =
currentColumn?.operationType !== 'static_value' && activeDataValue != null
Expand All @@ -206,7 +203,7 @@ export const staticValueOperation: OperationDefinition<
<div className="lnsIndexPatternDimensionEditor__section lnsIndexPatternDimensionEditor__section--padded lnsIndexPatternDimensionEditor__section--shaded">
<EuiFormLabel>
{i18n.translate('xpack.lens.indexPattern.staticValue.label', {
defaultMessage: 'Threshold value',
defaultMessage: 'Reference line value',
})}
</EuiFormLabel>
<EuiSpacer size="s" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface LayerColorConfig {
layerType: LayerType;
}

export const defaultThresholdColor = euiLightVars.euiColorDarkShade;
export const defaultReferenceLineColor = euiLightVars.euiColorDarkShade;

export type ColorAssignments = Record<
string,
Expand Down Expand Up @@ -117,11 +117,11 @@ export function getAccessorColorConfig(
triggerIcon: 'disabled',
};
}
if (layer.layerType === layerTypes.THRESHOLD) {
if (layer.layerType === layerTypes.REFERENCELINE) {
return {
columnId: accessor as string,
triggerIcon: 'color',
color: currentYConfig?.color || defaultThresholdColor,
color: currentYConfig?.color || defaultReferenceLineColor,
};
}
const columnToLabel = getColumnToLabelMap(layer, frame.datasourceLayers[layer.layerId]);
Expand Down
Loading