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] Retain column config #90048

Merged
merged 60 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 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
00b7ab6
Merge remote-tracking branch 'upstream/master' into lens/hidden-column
flash1293 Jan 29, 2021
a17d9d5
Merge remote-tracking branch 'upstream/master' into lens/hidden-column
flash1293 Feb 1, 2021
064794b
fix bug
flash1293 Feb 1, 2021
db3ab50
Merge remote-tracking branch 'upstream/master' into lens/hidden-column
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
7a4befb
Merge branch 'master' into lens/hidden-column
kibanamachine Feb 4, 2021
a193204
review comments
flash1293 Feb 4, 2021
ac84d9e
Merge branch 'lens/hidden-column' into lens/retain-column-config
flash1293 Feb 4, 2021
dfd4e7d
review comments
flash1293 Feb 4, 2021
7847e86
simplify
flash1293 Feb 4, 2021
cc23316
Merge branch 'lens/hidden-column' into lens/retain-column-config
flash1293 Feb 4, 2021
ba6d4aa
Merge remote-tracking branch 'upstream/master' into lens/retain-colum…
flash1293 Feb 4, 2021
cb2bd07
Merge remote-tracking branch 'upstream/master' into lens/retain-colum…
flash1293 Feb 5, 2021
2540446
also make sure sorting is persisted
flash1293 Feb 5, 2021
fc40914
Merge branch 'master' into lens/retain-column-config
kibanamachine Feb 8, 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
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,40 @@ describe('Datatable Visualization', () => {
expect(suggestions.length).toBeGreaterThan(0);
});

it('should retain width and hidden config from existing state', () => {
const suggestions = datatableVisualization.getSuggestions({
state: {
layerId: 'first',
columns: [
{ columnId: 'col1', width: 123 },
{ columnId: 'col2', hidden: true },
],
sorting: {
columnId: 'col1',
direction: 'asc',
},
},
table: {
isMultiRow: true,
layerId: 'first',
changeType: 'initial',
columns: [numCol('col1'), strCol('col2'), strCol('col3')],
},
keptLayerIds: [],
});

expect(suggestions.length).toBeGreaterThan(0);
expect(suggestions[0].state.columns).toEqual([
{ columnId: 'col1', width: 123 },
{ columnId: 'col2', hidden: true },
{ columnId: 'col3' },
]);
expect(suggestions[0].state.sorting).toEqual({
columnId: 'col1',
direction: 'asc',
});
});

it('should not make suggestions when the table is unchanged', () => {
const suggestions = datatableVisualization.getSuggestions({
state: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ export const datatableVisualization: Visualization<DatatableVisualizationState>
) {
return [];
}
const oldColumnSettings: Record<string, ColumnState> = {};
if (state) {
state.columns.forEach((column) => {
oldColumnSettings[column.columnId] = column;
});
}
const title =
table.changeType === 'unchanged'
? i18n.translate('xpack.lens.datatable.suggestionLabel', {
Expand Down Expand Up @@ -126,8 +132,12 @@ export const datatableVisualization: Visualization<DatatableVisualizationState>
// table with >= 10 columns will have a score of 0.4, fewer columns reduce score
score: (Math.min(table.columns.length, 10) / 10) * 0.4,
state: {
...(state || {}),
layerId: table.layerId,
columns: table.columns.map((col) => ({ columnId: col.columnId })),
columns: table.columns.map((col) => ({
...(oldColumnSettings[col.columnId] || {}),
columnId: col.columnId,
})),
},
previewIcon: LensIconChartDatatable,
// tables are hidden from suggestion bar, but used for drag & drop and chart switching
Expand Down