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] Transpose columns #89748

Merged
merged 105 commits into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
e3dcee1
migrate data table visualization to data grid
flash1293 Jan 4, 2021
a752f4d
memoize as good as possible
flash1293 Jan 4, 2021
84c2a9d
improve visuals
flash1293 Jan 4, 2021
60ceeba
Merge remote-tracking branch 'upstream/master' into lens/eui-data-grid
flash1293 Jan 5, 2021
234891d
clean up and fix tests
flash1293 Jan 5, 2021
f298b4d
:truck: Refactor table codebase in modules
dej611 Jan 12, 2021
ffe5fd2
Merge remote-tracking branch 'upstream/master' into lens/eui-data-grid
dej611 Jan 12, 2021
c233e3b
:truck: Move table component tests to its own folder
dej611 Jan 12, 2021
9318950
:bug: Fix deep check for table column header
dej611 Jan 12, 2021
79836ae
:label: Fix type check
dej611 Jan 12, 2021
3181b88
:globe_with_meridians: Fix locatization tokens
dej611 Jan 12, 2021
16b0d90
:bug: Fix functional tests
dej611 Jan 13, 2021
eb72077
:globe_with_meridians: Fix unused translation
dej611 Jan 13, 2021
07dc9a0
:camera_flash: Fix snapshot tests
dej611 Jan 13, 2021
5c0fecf
Merge branch 'master' into lens/eui-data-grid
kibanamachine Jan 14, 2021
1c9ce68
:white_check_mark: Add more functional tests for Lens table
dej611 Jan 14, 2021
38fdf2a
Merge branch 'lens/eui-data-grid' of github.com:dej611/kibana into le…
dej611 Jan 14, 2021
acc4f92
:sparkles: Add resize reset + add more unit tests
dej611 Jan 18, 2021
bc4f37a
Merge branch 'master' into lens/eui-data-grid
kibanamachine Jan 18, 2021
0637948
:lipstick: Make header sticky
dej611 Jan 18, 2021
ceea3cf
Merge branch 'lens/eui-data-grid' of github.com:dej611/kibana into le…
dej611 Jan 18, 2021
f6fc9a3
:camera_flash: Updated snapshots for sticky header fix
dej611 Jan 18, 2021
f27aafe
Merge branch 'master' into lens/eui-data-grid
kibanamachine Jan 19, 2021
3f02cd7
add column toggle functionality
flash1293 Jan 19, 2021
a993045
Merge branch 'master' into lens/eui-data-grid
kibanamachine Jan 20, 2021
e4e6761
Merge branch 'master' into lens/hidden-column
kibanamachine Jan 20, 2021
2f39d62
Merge branch 'master' into lens/eui-data-grid
kibanamachine Jan 21, 2021
ff69cc7
Merge branch 'master' into lens/eui-data-grid
kibanamachine Jan 25, 2021
07967ed
:lipstick: Some css classes clean up
dej611 Jan 25, 2021
0fed673
:lipstick: Make truncate work by the datagrid component
dej611 Jan 25, 2021
4eef909
Merge remote-tracking branch 'dej611/lens/eui-data-grid' into lens/hi…
flash1293 Jan 25, 2021
5a458d9
Merge branch 'lens/hidden-column' of github.com:flash1293/kibana into…
flash1293 Jan 25, 2021
9c6f5cf
Merge branch 'master' into lens/eui-data-grid
kibanamachine Jan 26, 2021
90e810b
refactoring
flash1293 Jan 26, 2021
8fc5c07
Merge remote-tracking branch 'dej611/lens/eui-data-grid' into lens/hi…
flash1293 Jan 26, 2021
e821ca6
add tests and clean up
flash1293 Jan 26, 2021
83e3e85
Merge branch 'master' into lens/eui-data-grid
kibanamachine Jan 26, 2021
fc4b39d
Merge remote-tracking branch 'dej611/lens/eui-data-grid' into lens/hi…
flash1293 Jan 26, 2021
82d7e9f
fix migrations
flash1293 Jan 26, 2021
4e1052f
Merge branch 'master' into lens/eui-data-grid
kibanamachine Jan 27, 2021
c7240ab
Merge remote-tracking branch 'dej611/lens/eui-data-grid' into lens/hi…
flash1293 Jan 27, 2021
c25be23
Bump EUI to v31.4.0
chandlerprall Jan 28, 2021
00b7ab6
Merge remote-tracking branch 'upstream/master' into lens/hidden-column
flash1293 Jan 29, 2021
754ce1d
make nested groups possible
flash1293 Jan 29, 2021
5021c07
Merge branch 'master' into eui-31-4-0
kibanamachine Feb 1, 2021
687bd60
fix datagrid functional tests
flash1293 Feb 1, 2021
e8efcc8
fix Lens unit tests
flash1293 Feb 1, 2021
a17d9d5
Merge remote-tracking branch 'upstream/master' into lens/hidden-column
flash1293 Feb 1, 2021
064794b
fix bug
flash1293 Feb 1, 2021
90347e1
Merge branch 'eui-31-4-0' into lens/hidden-column
flash1293 Feb 1, 2021
db88277
Merge remote-tracking branch 'upstream/master' into lens/hidden-column
flash1293 Feb 2, 2021
91886d5
Merge branch 'lens/hidden-column' into lens/transpose-columns
flash1293 Feb 2, 2021
0db8606
fix problems
flash1293 Feb 2, 2021
db3ab50
Merge remote-tracking branch 'upstream/master' into lens/hidden-column
flash1293 Feb 2, 2021
9e5de86
fix problems
flash1293 Feb 2, 2021
f852c8a
implement missing pieces
flash1293 Feb 2, 2021
2768a32
fix multi transpose case
flash1293 Feb 2, 2021
cfc5332
fix column config retention
flash1293 Feb 2, 2021
46ec8ac
Merge remote-tracking branch 'upstream/master' into lens/hidden-column
flash1293 Feb 3, 2021
0ec8926
Merge remote-tracking branch 'upstream/master' into lens/hidden-column
flash1293 Feb 3, 2021
4ebca5f
move hidden flag to dimension editor
flash1293 Feb 3, 2021
b2ba6b9
fix i18n
flash1293 Feb 3, 2021
173287f
Merge branch 'lens/hidden-column' into lens/transpose-columns
flash1293 Feb 3, 2021
9ed25cc
Merge branch 'lens/retain-column-config' into lens/transpose-columns
flash1293 Feb 3, 2021
44996d4
fix some bugs
flash1293 Feb 3, 2021
7a4befb
Merge branch 'master' into lens/hidden-column
kibanamachine Feb 4, 2021
a193204
review comments
flash1293 Feb 4, 2021
f4208ea
Merge branch 'lens/hidden-column' into lens/transpose-columns
flash1293 Feb 4, 2021
dfd4e7d
review comments
flash1293 Feb 4, 2021
7847e86
simplify
flash1293 Feb 4, 2021
5c89868
Merge branch 'lens/hidden-column' into lens/transpose-columns
flash1293 Feb 4, 2021
996990d
Merge remote-tracking branch 'upstream/master' into lens/transpose-co…
flash1293 Feb 4, 2021
dfea904
Merge remote-tracking branch 'upstream/master' into lens/transpose-co…
flash1293 Feb 5, 2021
d5612af
fix some stuff and clean up
flash1293 Feb 5, 2021
3560157
Merge remote-tracking branch 'upstream/master' into lens/transpose-co…
flash1293 Feb 8, 2021
08ac279
Merge remote-tracking branch 'upstream/master' into lens/transpose-co…
flash1293 Feb 15, 2021
e2118d9
fix some edge cases and add tests
flash1293 Feb 15, 2021
044bcc4
Merge remote-tracking branch 'upstream/master' into lens/transpose-co…
flash1293 Feb 16, 2021
71fdb01
fix types
flash1293 Feb 16, 2021
d9d1507
fix i18n
flash1293 Feb 16, 2021
1fe3d7a
fix functional tests
flash1293 Feb 16, 2021
ef7147b
Merge remote-tracking branch 'upstream/master' into lens/transpose-co…
flash1293 Feb 18, 2021
cfabcc5
fix auto alignment detection for transposed columns
flash1293 Feb 18, 2021
584a4ab
Merge branch 'master' into lens/transpose-columns
kibanamachine Feb 19, 2021
3132240
Merge remote-tracking branch 'upstream/master' into lens/transpose-co…
flash1293 Feb 22, 2021
4d49951
fix type problems
flash1293 Feb 22, 2021
e63c907
Merge branch 'master' into lens/transpose-columns
kibanamachine Feb 24, 2021
56de640
Merge remote-tracking branch 'upstream/master' into lens/transpose-co…
flash1293 Mar 1, 2021
f992d91
Merge branch 'lens/transpose-columns' of github.com:flash1293/kibana …
flash1293 Mar 1, 2021
4e6ac3f
hide hide action for transposed metrics
flash1293 Mar 1, 2021
1edab2c
fix functional test
flash1293 Mar 1, 2021
6be7c03
do not show dimension editor flag for transposed column
flash1293 Mar 1, 2021
685eaba
Merge branch 'master' into lens/transpose-columns
kibanamachine Mar 2, 2021
9419ad8
Merge branch 'master' into lens/transpose-columns
kibanamachine Mar 4, 2021
29c3d55
fix docs
flash1293 Mar 4, 2021
3b209bd
Merge remote-tracking branch 'upstream/master' into lens/transpose-co…
flash1293 Mar 5, 2021
757fb4a
review comments
flash1293 Mar 8, 2021
d341703
Merge remote-tracking branch 'upstream/master' into lens/transpose-co…
flash1293 Mar 8, 2021
b085c48
add lens api docs
flash1293 Mar 8, 2021
a801abc
fix docs
flash1293 Mar 8, 2021
9fde78a
add separator to functional tests
flash1293 Mar 8, 2021
2f5790e
Merge branch 'master' into lens/transpose-columns
kibanamachine Mar 9, 2021
9dd1c7e
Improve wording
flash1293 Mar 10, 2021
5f75a51
Merge branch 'master' into lens/transpose-columns
kibanamachine Mar 10, 2021
f1b1e1a
Merge branch 'master' into lens/transpose-columns
kibanamachine Mar 11, 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
8 changes: 4 additions & 4 deletions api_docs/lens.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"description": [],
"source": {
"path": "x-pack/plugins/lens/public/datatable_visualization/visualization.tsx",
"lineNumber": 35
"lineNumber": 43
},
"signature": [
{
Expand All @@ -128,7 +128,7 @@
"description": [],
"source": {
"path": "x-pack/plugins/lens/public/datatable_visualization/visualization.tsx",
"lineNumber": 36
"lineNumber": 44
}
},
{
Expand All @@ -139,7 +139,7 @@
"description": [],
"source": {
"path": "x-pack/plugins/lens/public/datatable_visualization/visualization.tsx",
"lineNumber": 37
"lineNumber": 45
},
"signature": [
{
Expand All @@ -155,7 +155,7 @@
],
"source": {
"path": "x-pack/plugins/lens/public/datatable_visualization/visualization.tsx",
"lineNumber": 34
"lineNumber": 42
},
"initialIsOpen": false
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiDataGridColumn, EuiDataGridColumnCellActionProps } from '@elastic/eui';
import type { Datatable, DatatableColumnMeta } from 'src/plugins/expressions';
import {
EuiDataGridColumn,
EuiDataGridColumnCellActionProps,
EuiListGroupItemProps,
} from '@elastic/eui';
import type { Datatable, DatatableColumn, DatatableColumnMeta } from 'src/plugins/expressions';
import type { FormatFactory } from '../../types';
import { ColumnConfig } from './table_basic';

Expand All @@ -22,6 +26,10 @@ export const createGridColumns = (
rowIndex: number,
negate?: boolean
) => void,
handleTransposedColumnClick: (
bucketValues: Array<{ originalBucketColumn: DatatableColumn; value: unknown }>,
negate?: boolean
) => void,
isReadOnly: boolean,
columnConfig: ColumnConfig,
visibleColumns: string[],
Expand Down Expand Up @@ -135,9 +143,63 @@ export const createGridColumns = (
]
: undefined;

const column = columnConfig.columns.find(({ columnId }) => columnId === field);
const initialWidth = column?.width;
const isHidden = column?.hidden;
const columnArgs = columnConfig.columns.find(({ columnId }) => columnId === field);
const isTransposed = Boolean(columnArgs?.originalColumnId);
const initialWidth = columnArgs?.width;
const isHidden = columnArgs?.hidden;
const originalColumnId = columnArgs?.originalColumnId;

const additionalActions: EuiListGroupItemProps[] = [];

if (!isReadOnly) {
additionalActions.push({
color: 'text',
size: 'xs',
onClick: () => onColumnResize({ columnId: originalColumnId || field, width: undefined }),
iconType: 'empty',
label: i18n.translate('xpack.lens.table.resize.reset', {
defaultMessage: 'Reset width',
}),
'data-test-subj': 'lensDatatableResetWidth',
isDisabled: initialWidth == null,
});
if (!isTransposed) {
additionalActions.push({
color: 'text',
size: 'xs',
onClick: () => onColumnHide({ columnId: originalColumnId || field }),
iconType: 'eyeClosed',
label: i18n.translate('xpack.lens.table.hide.hideLabel', {
defaultMessage: 'Hide',
}),
'data-test-subj': 'lensDatatableHide',
isDisabled: !isHidden && visibleColumns.length <= 1,
});
} else if (columnArgs?.bucketValues) {
const bucketValues = columnArgs?.bucketValues;
additionalActions.push({
color: 'text',
size: 'xs',
onClick: () => handleTransposedColumnClick(bucketValues, false),
iconType: 'plusInCircle',
label: i18n.translate('xpack.lens.table.columnFilter.filterForValueText', {
defaultMessage: 'Filter for column',
}),
'data-test-subj': 'lensDatatableHide',
});

additionalActions.push({
color: 'text',
size: 'xs',
onClick: () => handleTransposedColumnClick(bucketValues, true),
iconType: 'minusInCircle',
label: i18n.translate('xpack.lens.table.columnFilter.filterOutValueText', {
defaultMessage: 'Filter out column',
}),
'data-test-subj': 'lensDatatableHide',
});
}
}

const columnDefinition: EuiDataGridColumn = {
id: field,
Expand All @@ -162,32 +224,7 @@ export const createGridColumns = (
defaultMessage: 'Sort descending',
}),
},
additional: isReadOnly
? undefined
: [
{
color: 'text',
size: 'xs',
onClick: () => onColumnResize({ columnId: field, width: undefined }),
iconType: 'empty',
label: i18n.translate('xpack.lens.table.resize.reset', {
defaultMessage: 'Reset width',
}),
'data-test-subj': 'lensDatatableResetWidth',
isDisabled: initialWidth == null,
},
{
color: 'text',
size: 'xs',
onClick: () => onColumnHide({ columnId: field }),
iconType: 'eyeClosed',
label: i18n.translate('xpack.lens.table.hide.hideLabel', {
defaultMessage: 'Hide',
}),
'data-test-subj': 'lensDatatableHide',
isDisabled: !isHidden && visibleColumns.length <= 1,
},
],
additional: additionalActions,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { i18n } from '@kbn/i18n';
import { EuiFormRow, EuiSwitch, EuiButtonGroup, htmlIdGenerator } from '@elastic/eui';
import { VisualizationDimensionEditorProps } from '../../types';
import { DatatableVisualizationState } from '../visualization';
import { getOriginalId } from '../transpose_helpers';

const idPrefix = htmlIdGenerator()();

Expand All @@ -20,13 +21,15 @@ export function TableDimensionEditor(
const column = state.columns.find(({ columnId }) => accessor === columnId);

if (!column) return null;
if (column.isTransposed) return null;

// either read config state or use same logic as chart itself
const currentAlignment =
column?.alignment ||
(frame.activeData &&
frame.activeData[state.layerId].columns.find((col) => col.id === accessor)?.meta.type ===
'number'
frame.activeData[state.layerId].columns.find(
(col) => col.id === accessor || getOriginalId(col.id) === accessor
)?.meta.type === 'number'
? 'right'
: 'left');

Expand Down Expand Up @@ -89,39 +92,41 @@ export function TableDimensionEditor(
}}
/>
</EuiFormRow>
<EuiFormRow
label={i18n.translate('xpack.lens.table.columnVisibilityLabel', {
defaultMessage: 'Column hidden in table',
})}
display="columnCompressedSwitch"
>
<EuiSwitch
compressed
{!column.isTransposed && (
<EuiFormRow
label={i18n.translate('xpack.lens.table.columnVisibilityLabel', {
defaultMessage: 'Column hidden in table',
defaultMessage: 'Hide column',
})}
showLabel={false}
data-test-subj="lns-table-column-hidden"
checked={Boolean(column?.hidden)}
disabled={!column.hidden && visibleColumnsCount <= 1}
onChange={() => {
const newState = {
...state,
columns: state.columns.map((currentColumn) => {
if (currentColumn.columnId === accessor) {
return {
...currentColumn,
hidden: !column.hidden,
};
} else {
return currentColumn;
}
}),
};
setState(newState);
}}
/>
</EuiFormRow>
display="columnCompressedSwitch"
>
<EuiSwitch
compressed
label={i18n.translate('xpack.lens.table.columnVisibilityLabel', {
defaultMessage: 'Hide column',
})}
showLabel={false}
data-test-subj="lns-table-column-hidden"
checked={Boolean(column?.hidden)}
disabled={!column.hidden && visibleColumnsCount <= 1}
onChange={() => {
const newState = {
...state,
columns: state.columns.map((currentColumn) => {
if (currentColumn.columnId === accessor) {
return {
...currentColumn,
hidden: !column.hidden,
};
} else {
return currentColumn;
}
}),
};
setState(newState);
}}
/>
</EuiFormRow>
)}
</>
);
}
Loading