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

[Discover][UnifiedDataTable] Enable drag&drop for grid columns #197832

Merged
merged 23 commits into from
Nov 6, 2024

Conversation

jughosta
Copy link
Contributor

@jughosta jughosta commented Oct 25, 2024

Summary

Eui now supports reordering of grid columns by dra&drop elastic/eui#8015
The PR enables this functionality for UnifiedDataTable.

Nov-01-2024 10-21-49

Checklist

@jughosta jughosta added release_note:enhancement Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) labels Oct 25, 2024
@jughosta jughosta self-assigned this Oct 25, 2024
@@ -41,13 +41,17 @@
}

.euiDataGridHeaderCell {
align-items: start;
align-items: center;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To align with the "graggable" state of the header column which is in a portal and we can't override it there.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can keep the original styles and have this work for dragging by adding this to our EuiDataGridColumn defs:

displayHeaderCellProps: { className: `unifiedDataTable__headerCell` }

Then we can remove these nested styles including euiDataGridHeaderCell__popover and euiDataGridHeaderCell__draggableIcon, and use a single global style:

.euiDataGridHeaderCell.unifiedDataTable__headerCell {
  align-items: start;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great idea, thanks! Updated via 7946301

@jughosta jughosta marked this pull request as ready for review October 28, 2024 15:32
@jughosta jughosta requested review from a team as code owners October 28, 2024 15:32
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

Looking good to me overall! Just a small suggestion around some styling.

It works well, although the delay when reordering is a bit annoying. But that exists in the EUI docs too for the most part, so not really something we can address on the Discover side. Interestingly there's less of a delay when using the keyboard and it feels smoother, maybe since there's no animation.

Comment on lines 105 to 122
const headerDraggableColumns = await this.find.allByCssSelector(
'[data-test-subj="euiDataGridHeaderDroppable"] > div'
);
// searching for a common parent of the field column header and its resizer
const fieldHeader: WebElementWrapper | null | undefined = (
await Promise.all(
headerDraggableColumns.map(async (column) => {
const hasFieldColumn =
(await column.findAllByCssSelector(`[data-gridcell-column-id="${field}"]`)).length > 0;
return hasFieldColumn ? column : null;
})
)
).find(Boolean);
const resizer = await fieldHeader?.findByTestSubject('dataGridColumnResizer');

if (!fieldHeader || !resizer) {
throw new Error(`Unable to find column resizer for field ${field}`);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow, maybe we should ask EUI for a test subj on the draggable wrappers as a followup 😅

@@ -41,13 +41,17 @@
}

.euiDataGridHeaderCell {
align-items: start;
align-items: center;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can keep the original styles and have this work for dragging by adding this to our EuiDataGridColumn defs:

displayHeaderCellProps: { className: `unifiedDataTable__headerCell` }

Then we can remove these nested styles including euiDataGridHeaderCell__popover and euiDataGridHeaderCell__draggableIcon, and use a single global style:

.euiDataGridHeaderCell.unifiedDataTable__headerCell {
  align-items: start;
}

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

And with the latest styling changes, this LGTM 👍 Thanks, it's so much nicer reordering columns this way vs the popover!

align-items: start;

.euiDataGridHeaderCell__draggableIcon {
padding-block: 2px // to align with a token height
Copy link
Contributor

Choose a reason for hiding this comment

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

nit :)
This could be...

padding-block: $euiSizeXS / 2;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated via 7967c37, thanks!

Copy link
Contributor

@ryankeairns ryankeairns left a comment

Choose a reason for hiding this comment

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

Approving with a small nit to use an EUI variable in place of the 2px

Excited for the feature :)

Copy link
Contributor

@logeekal logeekal left a comment

Choose a reason for hiding this comment

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

Thanks for making this change opt-in 🙏 . I have desk tested it and table is working fine.

@jughosta , @davismcphee, I would suggest that these tickets should take into account ( during estimation ) the compatibility of consumers of unified data table ( in this case security solution ) otherwise, it increases tech debt for us since there are multiple features as of now which are opt-in such as this one and couple of previous deprecations of externalControlColumns.

@davismcphee
Copy link
Contributor

Thanks @logeekal for working through this with us.

@jughosta , @davismcphee, I would suggest that these tickets should take into account ( during estimation ) the compatibility of consumers of unified data table ( in this case security solution ) otherwise, it increases tech debt for us since there are multiple features as of now which are opt-in such as this one and couple of previous deprecations of externalControlColumns.

You might need to expand on this point a bit because I'm not sure I understand. Some features we intentionally make opt-in, like the document comparison feature, since we can't be sure all consumers would want it enabled by default. Other features, like this one, would ideally be enabled by default since they should be appropriate for all consumers, but we're making it opt-in for now since it happens to have a bug when used in Timeline (and I appreciate you checking btw since I did forget to check Timeline originally).

For deprecations like externalControlColumns, we are maintaining the deprecated APIs until consumers are able to get off them, and have created a followup issue for the Timeline work: #189294. Sometimes we're able to address these directly in consumers' code during the initial PR if the work is straightforward, but in other cases we're unfamiliar with the code and it would be more feasible for consuming teams to address it when they can prioritize. Do you feel there is something more here we could be doing?

@logeekal
Copy link
Contributor

logeekal commented Nov 6, 2024

@davismcphee , @jughosta ,

Firstly, I just want to make it clear that please do not consider this discussion as a blocker to this PR. I think we can safely merge it from investigations team perspective.

Some features we intentionally make opt-in, like the document comparison feature, since we can't be sure all consumers would want it enabled by default.

100% agree with the above point.

Other features, like this one, would ideally be enabled by default since they should be appropriate for all consumers, but we're making it opt-in for now since it happens to have a bug when used in Timeline (and I appreciate you checking btw since I did forget to check Timeline originally).

Yes, my opinion was mainly regarding these kind of features and it is just an opinion so feel free to disagree. I was mainly referring to keeping consumer's code either up-to-date for opt-in features or identification of bug ( reason why code cannot be updated ) should be part of the change of the shared code. An example for the same is that you were able to find out the issue with EUI and EuiDataGrid in a modal. Thank you for that by the way 👏 👏 . I looked into it yesterday whole day and could not have guessed it was a modal issue.

Do you feel there is something more here we could be doing?

My statement was not just for your team. It is applicable to us as well when we are making a change in a shared component such as unified-data-table or anything else.

Sometimes we're able to address these directly in consumers' code during the initial PR if the work is straightforward, but in other cases we're unfamiliar with the code and it would be more feasible for consuming teams to address it when they can prioritize.

I appreciate that unfamilar code can be time taking and I think we should be able to put in some time to take a look if nothing breaks. I was mainly concerned about 2 things and may be it was a pre-cautionary comment.

  1. If a change is a deprecation, if possible, the consuming could should be updated. But i also agree with you that if change is big for consumers, it should be left of them.
  2. If a change is opt-in, testing that opting-in does not break consumer's code ( like discover and security solution ) should also be part of ticket. And case-by-case basis we can decide whether it is worth doing now to later as a separate work.

Sometimes we're able to address these directly in consumers' code during the initial PR if the work is straightforward

I think this statement really captures the essence of what I was saying and i think we are on the same page. When making that comment, I mainly had deprecations and this particular change ( which breaks security solution when opted in ) in mind. Both of these are now tech-debt for us and somehow lose priority ( I know that is our problem ) and I was feeling that cumulatively, we can be behind a lot of functionality.

@jughosta jughosta enabled auto-merge (squash) November 6, 2024 11:03
@kertal
Copy link
Member

kertal commented Nov 6, 2024

Other features, like this one, would ideally be enabled by default since they should be appropriate for all consumers, but we're making it opt-in for now since it happens to have a bug when used in Timeline (and I appreciate you checking btw since I did forget to check Timeline originally).

Yes, my opinion was mainly regarding these kind of features and it is just an opinion so feel free to disagree. I was mainly referring to keeping consumer's code either up-to-date for opt-in features or identification of bug ( reason why code cannot be updated ) should be part of the change of the shared code. An example for the same is that you were able to find out the issue with EUI and EuiDataGrid in a modal. Thank you for that by the way 👏 👏 . I looked into it yesterday whole day and could not have guessed it was a modal issue.

I do disagree. This kind of bug is not foreseeable, it can't be estimated. iI's a small change code wise, adapting a behavior in the EuiDataGrid that should be the default, and is long requested. So IMO having a code review from CodeOwners should have been sufficient, similar to other smaller changes we added to the table. Also we can't test all consuming apps. The modal problem is unfortunate, but such things happen in software engineering. 🙏 thx for catching it.

@logeekal Ideally this should have been caught by functional testing, because also moving left and right in the "old" way didn't work with this PR initially. What would be actionable to prevent something like this, would maybe to implement more essential functional tests of the table in the security timeline, and think about a way if we could deduplicate code longer down the road.

here's an example of the discover coverage:

await dataGrid.clickMoveColumnLeft('agent');

On the other hand, there's OneDiscover, and this should won't surface in a modal, right, so it would benefit already by functional coverage of the table.

@jughosta jughosta merged commit 436405f into elastic:main Nov 6, 2024
27 checks passed
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
cloudSecurityPosture 509.1KB 509.3KB +188.0B
discover 809.2KB 809.4KB +212.0B
esqlDataGrid 153.5KB 153.7KB +188.0B
securitySolution 21.0MB 21.0MB +940.0B
slo 856.3KB 856.4KB +189.0B
total +1.7KB
Unknown metric groups

API count

id before after diff
@kbn/unified-data-table 183 184 +1

History

cc @jughosta

@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11703101653

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 6, 2024
…ic#197832)

- Closes elastic#195769

## Summary

Eui now supports reordering of grid columns by dra&drop
elastic/eui#8015
The PR enables this functionality for UnifiedDataTable.

![Nov-01-2024
10-21-49](https://github.com/user-attachments/assets/bc47507c-7b9e-44c2-88d7-5f48f37924cb)

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

(cherry picked from commit 436405f)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Nov 6, 2024
…mns (#197832) (#199111)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Discover][UnifiedDataTable] Enable drag&drop for grid columns
(#197832)](#197832)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Julia
Rechkunova","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-06T12:00:49Z","message":"[Discover][UnifiedDataTable]
Enable drag&drop for grid columns (#197832)\n\n- Closes
https://github.com/elastic/kibana/issues/195769\r\n\r\n##
Summary\r\n\r\nEui now supports reordering of grid columns by
dra&drop\r\nhttps://github.com/elastic/eui/pull/8015\r\nThe PR enables
this functionality for
UnifiedDataTable.\r\n\r\n![Nov-01-2024\r\n10-21-49](https://github.com/user-attachments/assets/bc47507c-7b9e-44c2-88d7-5f48f37924cb)\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"436405fefbbd834a68df93d8179a5b377e84b614","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","Feature:Discover","v9.0.0","Team:DataDiscovery","backport:prev-minor","Feature:UnifiedDataTable"],"title":"[Discover][UnifiedDataTable]
Enable drag&drop for grid
columns","number":197832,"url":"https://github.com/elastic/kibana/pull/197832","mergeCommit":{"message":"[Discover][UnifiedDataTable]
Enable drag&drop for grid columns (#197832)\n\n- Closes
https://github.com/elastic/kibana/issues/195769\r\n\r\n##
Summary\r\n\r\nEui now supports reordering of grid columns by
dra&drop\r\nhttps://github.com/elastic/eui/pull/8015\r\nThe PR enables
this functionality for
UnifiedDataTable.\r\n\r\n![Nov-01-2024\r\n10-21-49](https://github.com/user-attachments/assets/bc47507c-7b9e-44c2-88d7-5f48f37924cb)\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"436405fefbbd834a68df93d8179a5b377e84b614"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197832","number":197832,"mergeCommit":{"message":"[Discover][UnifiedDataTable]
Enable drag&drop for grid columns (#197832)\n\n- Closes
https://github.com/elastic/kibana/issues/195769\r\n\r\n##
Summary\r\n\r\nEui now supports reordering of grid columns by
dra&drop\r\nhttps://github.com/elastic/eui/pull/8015\r\nThe PR enables
this functionality for
UnifiedDataTable.\r\n\r\n![Nov-01-2024\r\n10-21-49](https://github.com/user-attachments/assets/bc47507c-7b9e-44c2-88d7-5f48f37924cb)\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"436405fefbbd834a68df93d8179a5b377e84b614"}}]}]
BACKPORT-->

Co-authored-by: Julia Rechkunova <[email protected]>
mgadewoll pushed a commit to mgadewoll/kibana that referenced this pull request Nov 7, 2024
…ic#197832)

- Closes elastic#195769

## Summary

Eui now supports reordering of grid columns by dra&drop
elastic/eui#8015
The PR enables this functionality for UnifiedDataTable.

![Nov-01-2024
10-21-49](https://github.com/user-attachments/assets/bc47507c-7b9e-44c2-88d7-5f48f37924cb)


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
florent-leborgne added a commit that referenced this pull request Nov 25, 2024
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 25, 2024
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 25, 2024
kibanamachine added a commit that referenced this pull request Nov 25, 2024
…201571) (#201601)

# Backport

This will backport the following commits from `main` to `8.17`:
- [[Docs] Document ability to drag and drop columns in Discover
(#201571)](#201571)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"florent-leborgne","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-25T14:09:07Z","message":"[Docs]
Document ability to drag and drop columns in Discover (#201571)\n\nThis
PR adds docs related to\r\nhttps://github.com//pull/197832
for Discover\r\n\r\nRel:
https://github.com/elastic/platform-docs-team/issues/562","sha":"fcf319e7c447f3fe5057461a33d4a814ebc6a2c8","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Docs","release_note:skip","v9.0.0","docs","backport:version","v8.17.0","v8.18.0"],"title":"[Docs]
Document ability to drag and drop columns in
Discover","number":201571,"url":"https://github.com/elastic/kibana/pull/201571","mergeCommit":{"message":"[Docs]
Document ability to drag and drop columns in Discover (#201571)\n\nThis
PR adds docs related to\r\nhttps://github.com//pull/197832
for Discover\r\n\r\nRel:
https://github.com/elastic/platform-docs-team/issues/562","sha":"fcf319e7c447f3fe5057461a33d4a814ebc6a2c8"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201571","number":201571,"mergeCommit":{"message":"[Docs]
Document ability to drag and drop columns in Discover (#201571)\n\nThis
PR adds docs related to\r\nhttps://github.com//pull/197832
for Discover\r\n\r\nRel:
https://github.com/elastic/platform-docs-team/issues/562","sha":"fcf319e7c447f3fe5057461a33d4a814ebc6a2c8"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: florent-leborgne <[email protected]>
kibanamachine added a commit that referenced this pull request Nov 25, 2024
…201571) (#201602)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Docs] Document ability to drag and drop columns in Discover
(#201571)](#201571)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"florent-leborgne","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-25T14:09:07Z","message":"[Docs]
Document ability to drag and drop columns in Discover (#201571)\n\nThis
PR adds docs related to\r\nhttps://github.com//pull/197832
for Discover\r\n\r\nRel:
https://github.com/elastic/platform-docs-team/issues/562","sha":"fcf319e7c447f3fe5057461a33d4a814ebc6a2c8","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Docs","release_note:skip","v9.0.0","docs","backport:version","v8.17.0","v8.18.0"],"title":"[Docs]
Document ability to drag and drop columns in
Discover","number":201571,"url":"https://github.com/elastic/kibana/pull/201571","mergeCommit":{"message":"[Docs]
Document ability to drag and drop columns in Discover (#201571)\n\nThis
PR adds docs related to\r\nhttps://github.com//pull/197832
for Discover\r\n\r\nRel:
https://github.com/elastic/platform-docs-team/issues/562","sha":"fcf319e7c447f3fe5057461a33d4a814ebc6a2c8"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201571","number":201571,"mergeCommit":{"message":"[Docs]
Document ability to drag and drop columns in Discover (#201571)\n\nThis
PR adds docs related to\r\nhttps://github.com//pull/197832
for Discover\r\n\r\nRel:
https://github.com/elastic/platform-docs-team/issues/562","sha":"fcf319e7c447f3fe5057461a33d4a814ebc6a2c8"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: florent-leborgne <[email protected]>
paulinashakirova pushed a commit to paulinashakirova/kibana that referenced this pull request Nov 26, 2024
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Discover Discover Application Feature:UnifiedDataTable release_note:enhancement Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[OneDiscover] Enable columns sorting by draggable column header
7 participants