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] Cell actions extension #190754

Merged
merged 21 commits into from
Sep 11, 2024

Conversation

davismcphee
Copy link
Contributor

@davismcphee davismcphee commented Aug 20, 2024

Summary

This PR adds a new cell actions extension to Discover using the kbn-cell-actions framework which Unified Data Table already supports, allowing profiles to register additional cell actions within the data grid:
cell_actions

The extension point supports the following:

  • Cell actions can be registered at the root or data source level.
  • Supports an isCompatible method, allowing cell actions to be shown for all cells in a column or conditionally based on the column field, etc.
  • Cell actions have access to a context object including the current field, value, dataSource, dataView, query, filters, and timeRange.

Note that currently cell actions do not have access to the entire record, only the current cell value. We can support this as a followup if needed, but it will require an enhancement to kbn-cell-actions.

Testing

  • Add discover.experimental.enabledProfiles: ['example-root-profile', 'example-data-source-profile', 'example-document-profile'] to kibana.dev.yml and start Kibana.
  • Ingest the Discover context awareness example data using the following command: node scripts/es_archiver --kibana-url=http://elastic:changeme@localhost:5601 --es-url=http://elastic:changeme@localhost:9200 load test/functional/fixtures/es_archiver/discover/context_awareness.
  • Navigate to Discover and create a my-example-logs data view or target the index in an ES|QL query.
  • Confirm that the example cell actions appear in expanded cell popover menus and are functional.

Resolves #186576.

Checklist

For maintainers

@davismcphee davismcphee added Team:DataDiscovery Discover App Team (Document Explorer, Saved Search, Surrounding documents, Graph) Project:OneDiscover Enrich Discover with contextual awareness / Merge with Logs Explorer labels Aug 20, 2024
@davismcphee davismcphee self-assigned this Aug 20, 2024
@davismcphee
Copy link
Contributor Author

/ci

@davismcphee davismcphee force-pushed the discover-cell-actions-extension branch from 68000ef to 82ecafc Compare August 20, 2024 22:27
@davismcphee
Copy link
Contributor Author

/ci

@davismcphee davismcphee force-pushed the discover-cell-actions-extension branch from e901ed7 to ffebaab Compare September 1, 2024 01:43
@davismcphee
Copy link
Contributor Author

/ci

@davismcphee davismcphee force-pushed the discover-cell-actions-extension branch from ffebaab to b16eccd Compare September 5, 2024 20:12
@davismcphee
Copy link
Contributor Author

/ci

@davismcphee
Copy link
Contributor Author

/ci

@davismcphee davismcphee added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting labels Sep 6, 2024
Copy link
Contributor Author

@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.

I think I may still have to investigate the page load bundle increase (we'll see what CI says), but otherwise this should be good to review now.

Comment on lines +154 to +157
// Security Solution overrides our cell actions -- this is a temporary workaroud to keep
// things working as they do currently until we can migrate their actions to One Discover
const isInSecuritySolution =
useObservable(discoverServices.application.currentAppId$) === 'securitySolutionUI';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@elastic/security-threat-hunting-investigations I wanted to build this extension point on top of kbn-cell-actions since Unified Data Table already supports it, rather than introducing an alternative approach. Unfortunately this conflicts with the saved search embeddable cell action overrides currently active within the Security Solution UI.

So I needed a way to disable the cell actions extension point when it would conflict with the overrides and couldn't figure out another way other than this. I'm open to ideas for a cleaner approach, but my thinking is that this won't be needed eventually anyway since ideally we'll migrate the current Security actions to a context aware Discover profile instead.

@davismcphee davismcphee marked this pull request as ready for review September 6, 2024 04:35
@davismcphee davismcphee requested a review from a team as a code owner September 6, 2024 04:35
@davismcphee davismcphee requested a review from a team as a code owner September 6, 2024 04:35
@elasticmachine
Copy link
Contributor

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

@davismcphee
Copy link
Contributor Author

/ci

Copy link
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

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

Looks great!

The additional cell actions don't appear on Surrounding Documents page. Is it expected?

@@ -264,6 +272,21 @@ function DiscoverDocumentsComponent({
[documentState.esqlQueryColumns]
);

const { filters } = useQuerySubscriber({ data: services.data });
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we rather take filters via useAppStateSelector hook above as we do for query?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd prefer to do something like that, but unfortunately the app state filters don't include the pinned filters.

Copy link
Contributor Author

@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.

The additional cell actions don't appear on Surrounding Documents page. Is it expected?

Nope not expected, I just missed it, thanks! Updated to support surrounding docs here: 2d66307

@@ -264,6 +272,21 @@ function DiscoverDocumentsComponent({
[documentState.esqlQueryColumns]
);

const { filters } = useQuerySubscriber({ data: services.data });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd prefer to do something like that, but unfortunately the app state filters don't include the pinned filters.

Copy link
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #45 / serverless observability UI Observability Logs Explorer DataSourceSelector with installed integrations and uncategorized data streams "after all" hook in "with installed integrations and uncategorized data streams"
  • [job] [logs] FTR Configs #45 / serverless observability UI Observability Logs Explorer DataSourceSelector with installed integrations and uncategorized data streams "before all" hook in "with installed integrations and uncategorized data streams"

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
discover 973 988 +15

Async chunks

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

id before after diff
cloudSecurityPosture 495.8KB 496.0KB +185.0B
discover 797.2KB 807.9KB +10.7KB
esqlDataGrid 152.6KB 152.8KB +195.0B
securitySolution 19.7MB 19.7MB +975.0B
slo 852.1KB 852.3KB +183.0B
total +12.2KB

Page load bundle

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

id before after diff
discover 47.9KB 47.2KB -744.0B
Unknown metric groups

API count

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

History

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

cc @davismcphee

@davismcphee davismcphee merged commit 034625a into elastic:main Sep 11, 2024
46 of 48 checks passed
@davismcphee davismcphee deleted the discover-cell-actions-extension branch September 11, 2024 00:24
gergoabraham pushed a commit to gergoabraham/kibana that referenced this pull request Sep 13, 2024
## Summary

This PR adds a new cell actions extension to Discover using the
[`kbn-cell-actions`](packages/kbn-cell-actions) framework which Unified
Data Table already supports, allowing profiles to register additional
cell actions within the data grid:
<img width="2168" alt="cell_actions"
src="https://github.com/user-attachments/assets/f01a97be-d90f-4284-9cbf-4a2e1a5dd78c">

The extension point supports the following:
- Cell actions can be registered at the root or data source level.
- Supports an `isCompatible` method, allowing cell actions to be shown
for all cells in a column or conditionally based on the column field,
etc.
- Cell actions have access to a `context` object including the current
`field`, `value`, `dataSource`, `dataView`, `query`, `filters`, and
`timeRange`.


**Note that currently cell actions do not have access to the entire
record, only the current cell value. We can support this as a followup
if needed, but it will require an enhancement to `kbn-cell-actions`.**

## Testing
- Add `discover.experimental.enabledProfiles: ['example-root-profile',
'example-data-source-profile', 'example-document-profile']` to
`kibana.dev.yml` and start Kibana.
- Ingest the Discover context awareness example data using the following
command: `node scripts/es_archiver
--kibana-url=http://elastic:changeme@localhost:5601
--es-url=http://elastic:changeme@localhost:9200 load
test/functional/fixtures/es_archiver/discover/context_awareness`.
- Navigate to Discover and create a `my-example-logs` data view or
target the index in an ES|QL query.
- Confirm that the example cell actions appear in expanded cell popover
menus and are functional.

Resolves elastic#186576.

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [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
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
markov00 pushed a commit to markov00/kibana that referenced this pull request Sep 18, 2024
## Summary

This PR adds a new cell actions extension to Discover using the
[`kbn-cell-actions`](packages/kbn-cell-actions) framework which Unified
Data Table already supports, allowing profiles to register additional
cell actions within the data grid:
<img width="2168" alt="cell_actions"
src="https://github.com/user-attachments/assets/f01a97be-d90f-4284-9cbf-4a2e1a5dd78c">

The extension point supports the following:
- Cell actions can be registered at the root or data source level.
- Supports an `isCompatible` method, allowing cell actions to be shown
for all cells in a column or conditionally based on the column field,
etc.
- Cell actions have access to a `context` object including the current
`field`, `value`, `dataSource`, `dataView`, `query`, `filters`, and
`timeRange`.


**Note that currently cell actions do not have access to the entire
record, only the current cell value. We can support this as a followup
if needed, but it will require an enhancement to `kbn-cell-actions`.**

## Testing
- Add `discover.experimental.enabledProfiles: ['example-root-profile',
'example-data-source-profile', 'example-document-profile']` to
`kibana.dev.yml` and start Kibana.
- Ingest the Discover context awareness example data using the following
command: `node scripts/es_archiver
--kibana-url=http://elastic:changeme@localhost:5601
--es-url=http://elastic:changeme@localhost:9200 load
test/functional/fixtures/es_archiver/discover/context_awareness`.
- Navigate to Discover and create a `my-example-logs` data view or
target the index in an ES|QL query.
- Confirm that the example cell actions appear in expanded cell popover
menus and are functional.

Resolves elastic#186576.

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [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
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Project:OneDiscover Enrich Discover with contextual awareness / Merge with Logs Explorer release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover App Team (Document Explorer, Saved Search, Surrounding documents, Graph) v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[OneDiscover][Extension] DataTable Cell Actions
5 participants