From dfd4e7d28a9604c3b082edf1615e418e384c3a9b Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Thu, 4 Feb 2021 11:20:51 +0100 Subject: [PATCH] review comments --- .../__snapshots__/table_basic.test.tsx.snap | 18 ++++++++++++------ .../components/columns.tsx | 9 +++++++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/__snapshots__/table_basic.test.tsx.snap b/x-pack/plugins/lens/public/datatable_visualization/components/__snapshots__/table_basic.test.tsx.snap index 24ced995cdaef..d69af298018e7 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/__snapshots__/table_basic.test.tsx.snap +++ b/x-pack/plugins/lens/public/datatable_visualization/components/__snapshots__/table_basic.test.tsx.snap @@ -96,7 +96,8 @@ exports[`DatatableComponent it renders actions column when there are row actions Object { "color": "text", "data-test-subj": "lensDatatableHide", - "iconType": "empty", + "iconType": "eyeClosed", + "isDisabled": false, "label": "Hide", "onClick": [Function], "size": "xs", @@ -132,7 +133,8 @@ exports[`DatatableComponent it renders actions column when there are row actions Object { "color": "text", "data-test-subj": "lensDatatableHide", - "iconType": "empty", + "iconType": "eyeClosed", + "isDisabled": false, "label": "Hide", "onClick": [Function], "size": "xs", @@ -168,7 +170,8 @@ exports[`DatatableComponent it renders actions column when there are row actions Object { "color": "text", "data-test-subj": "lensDatatableHide", - "iconType": "empty", + "iconType": "eyeClosed", + "isDisabled": false, "label": "Hide", "onClick": [Function], "size": "xs", @@ -315,7 +318,8 @@ exports[`DatatableComponent it renders the title and value 1`] = ` Object { "color": "text", "data-test-subj": "lensDatatableHide", - "iconType": "empty", + "iconType": "eyeClosed", + "isDisabled": false, "label": "Hide", "onClick": [Function], "size": "xs", @@ -351,7 +355,8 @@ exports[`DatatableComponent it renders the title and value 1`] = ` Object { "color": "text", "data-test-subj": "lensDatatableHide", - "iconType": "empty", + "iconType": "eyeClosed", + "isDisabled": false, "label": "Hide", "onClick": [Function], "size": "xs", @@ -387,7 +392,8 @@ exports[`DatatableComponent it renders the title and value 1`] = ` Object { "color": "text", "data-test-subj": "lensDatatableHide", - "iconType": "empty", + "iconType": "eyeClosed", + "isDisabled": false, "label": "Hide", "onClick": [Function], "size": "xs", diff --git a/x-pack/plugins/lens/public/datatable_visualization/components/columns.tsx b/x-pack/plugins/lens/public/datatable_visualization/components/columns.tsx index 76779b4856b92..7255b2c4be7d9 100644 --- a/x-pack/plugins/lens/public/datatable_visualization/components/columns.tsx +++ b/x-pack/plugins/lens/public/datatable_visualization/components/columns.tsx @@ -50,6 +50,8 @@ export const createGridColumns = ( return { rowValue, contentsIsDefined, cellContent }; }; + const visibleColumnsCount = columnConfig.columns.filter((c) => !c.hidden).length; + return visibleColumns.map((field) => { const filterable = bucketLookup.has(field); const { name, index: colIndex } = columnsReverseLookup[field]; @@ -135,7 +137,9 @@ export const createGridColumns = ( ] : undefined; - const initialWidth = columnConfig.columns.find(({ columnId }) => columnId === field)?.width; + const column = columnConfig.columns.find(({ columnId }) => columnId === field); + const initialWidth = column?.width; + const isHidden = column?.hidden; const columnDefinition: EuiDataGridColumn = { id: field, @@ -178,11 +182,12 @@ export const createGridColumns = ( color: 'text', size: 'xs', onClick: () => onColumnHide({ columnId: field }), - iconType: 'empty', + iconType: 'eyeClosed', label: i18n.translate('xpack.lens.table.hide.hideLabel', { defaultMessage: 'Hide', }), 'data-test-subj': 'lensDatatableHide', + isDisabled: !isHidden && visibleColumnsCount <= 1, }, ], },