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] Hide column in table #88680

Merged
merged 53 commits into from
Feb 4, 2021
Merged

Conversation

flash1293
Copy link
Contributor

@flash1293 flash1293 commented Jan 19, 2021

Fixes #85140

This PR allows to hide a column in lens data table. There's an action in the cell popover as well as a switch in the dimension editor:
Screenshot 2021-02-03 at 14 21 13
Screenshot 2021-02-03 at 14 21 08

This PR also restructures the data table shape a little on all levels to make it easier to work with (especially considering the fact we will add many more settings to individual columns)

New state and expression shape

The old state looked like this:

{
  layers: Array<{
    columnIds: string[];
    columnWidth: ColumnWidthState[];
    layerId: string;
  }>;
  sorting?: SortingState;
}

As we are going to add many more config settings to specific columns, this PR changes the state to this easier to manager shape:

{
  layerId: string;
  columns: Array<ColumnState>;
  sorting?: SortingState;
}

interface ColumnState {
  columnId: string;
  width?: number;
  hidden?: boolean;
  // to be continued
}

This is also reflected on the expression layer, the new layout looks like this:

lens_datatable column={lens_datatable_column columnId="a" width=300} column={lens_datatable_column columnId="b"} ...

Functional tests

I slightly restructured functional tests by starting a separate "table" test file, moving some things over from the very crowded "smokescreen" test file, extending it with a test for hiding the column.

@flash1293 flash1293 added release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Lens v7.12.0 8.0.0 labels Jan 19, 2021
@flash1293
Copy link
Contributor Author

flash1293 commented Feb 1, 2021

Thanks for the review everyone. I think all of the reported problems were caused by this pretty basic mistake:

+                hidden: !column.hidden,
-                hidden: !!column.hidden,

The edit action didn't actually toggle the hidden flag... It should be fixed now

I'd suggest to make the last visible column visibility disabled. I cannot see no use for it, at least in a single visualization configuration. Maybe in a dashboard could have "some sense" with some sort of filters, but that's a different flow.

I see the reasoning, but I don't think we should do this, because it unnecessarily restricts the user (e.g. if they only want to have a single visible column and switch from col1 to col2, now they first have to make col2 visible, then hide col1 because the switch will be disabled if they would do it the other way around). I think it makes sense to disable settings if they can't be applied to the visualization or would cause some harm, but that doesn't apply in this case IMHO.

@flash1293
Copy link
Contributor Author

flash1293 commented Feb 1, 2021

Toggling the column visibility from the dropdown menu triggers a waterfall of RangerError for max call stack size in the console

I saw this behavior before, AFAIK it's a bug of the EUI data grid. I will check with the most recent update whether it still persists.

Edit: Tested this and it's still happening. I will investigate this separately, but I'm not sure whether we can fix it from the Kibana side.

@flash1293
Copy link
Contributor Author

@dej611 @wylieconlon I added an indicator for the dimension trigger and moved the flag into the dimension editor.

With the indicator I think a separate popover is not really justified and the consistency of where functionalities are shown is more important.

@flash1293 flash1293 requested a review from dej611 February 3, 2021 13:24
Copy link
Contributor

@dej611 dej611 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "hidden" icon is not shown for Metrics:

Screenshot 2021-02-03 at 19 47 00

I may also suggest to use the same eyeClosed icon for the column dropdown menu for consistency.

Screenshot 2021-02-03 at 19 48 14

I am not fully convinced about the ability to hide all columns and show a blank canvas: perhaps at least one column has to be shown? Not a blocker, but it would be nice to have it sorted.

Copy link
Contributor

@wylieconlon wylieconlon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested again in FF and the new UI seems to have no issues with syncing. LGTM!

@flash1293
Copy link
Contributor Author

@elasticmachine merge upstream

@flash1293
Copy link
Contributor Author

@dej611

The "hidden" icon is not shown for Metrics:

Thanks, fixed

I am not fully convinced about the ability to hide all columns and show a blank canvas: perhaps at least one column has to be shown? Not a blocker, but it would be nice to have it sorted.

I don't really see when it would be relevant, but I don't have a strong opinion on it either - added the logic to disable the last visible column switch.

Copy link
Contributor

@dej611 dej611 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the panel toggle component is disabled for the last column:

Screenshot 2021-02-04 at 11 06 07

You can still have a blank table passing thru the column dropdown Hide:

Screenshot 2021-02-04 at 11 06 30

As said, it's not a blocker, either way is fine as long as it's consistent.

Also the Reset width action in the column dropdown is always enabled. If clicked nothing happens.

Edit: nvm, I guess the dropdown arrow icon is too close to the border and my click has been captured as "resize" action rather than "open" action on the icon. I've tried few times and if I click on the right side of the icon that issue does not happen 👍

@flash1293
Copy link
Contributor Author

@dej611 Fixed that as well and also added the same icon as you mentioned above.

@flash1293 flash1293 requested a review from dej611 February 4, 2021 10:23
Copy link
Contributor

@dej611 dej611 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tested on Chrome and FF. 👍

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
lens 478 479 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
lens 873.7KB 876.2KB +2.5KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
lens 34.3KB 34.3KB -100.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@flash1293 flash1293 merged commit 1741cef into elastic:master Feb 4, 2021
flash1293 added a commit to flash1293/kibana that referenced this pull request Feb 4, 2021
gmmorris added a commit to gmmorris/kibana that referenced this pull request Feb 4, 2021
* master: (244 commits)
  [maps] Top hits per entity--change to title to use recent, minor edits (elastic#89254)
  [DOCS] Update installation details (elastic#90354)
  RFC for automatically generated typescript API documentation for every plugins public services, types, and functionality (elastic#86704)
  Elastic Maps Server config is `host` not `hostname` (elastic#90234)
  Use doc link services in index pattern management (elastic#89937)
  [Fleet] Managed Agent Policy (elastic#88688)
  [Workplace Search] Fix Source Settings bug  (elastic#90242)
  [Enterprise Search] Refactor MockRouter test helper to not store payload (elastic#90206)
  Use doc link service in more Stack Monitoring pages (elastic#89050)
  [App Search] Relevance Tuning logic - actions and selectors only, no listeners (elastic#89313)
  Remove UI filters from UI (elastic#89793)
  Use newfeed.service config for all newsfeeds (elastic#90252)
  skip flaky suite (elastic#85086)
  Add readme to geo containment alert covering test alert setup (elastic#89625)
  [APM] Enabling yesterday option when 24 hours is selected (elastic#90017)
  Test user for maps tests under import geoJSON tests (elastic#86015)
  [Lens] Hide column in table (elastic#88680)
  [Security Solution][Detections] Reduce detection engine reliance on _source (elastic#89371)
  [Discover] Minor cleanup (elastic#90260)
  [Search Session][Management] Rename "cancel" button and delete "Reload" button (elastic#90015)
  ...
flash1293 added a commit that referenced this pull request Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Lens release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.12.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] Allow hiding of columns in table
5 participants