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

[CellActions] Support for empty value in addToTimeline action #149527

Merged
merged 8 commits into from
Jan 27, 2023

Conversation

semd
Copy link
Contributor

@semd semd commented Jan 25, 2023

part of: #145666

Summary

This PR contains changes in the dataProvider function for the addToTimeline action:

  • add support for empty values excluding the field, to make it consistent with the legacy implementation.
  • id changes removing the "draggable" word.
  • extracted getIdForField function to reduce the main function complexity (linter warning appeared)

This PR also introduces the CellAction type for action creation:

  • isCompatible method parameters uses the new CellActionCompatibilityContext type instead of CellActionExecutionContext, it omits the field.value and the references values, they are not needed to check the compatibility and, in some situations, it is not possible to pass them.
  • use CellAction type in all SecuritySolution action creators
  • action creators now return plain objects instead of using createAction (deprecated) function.
  • all actions now check fieldHasCellActions(field.name) in the inCompatible function, to keep the consistency with legacy code.
  • useLoadAction hooks now integrate the error control, components don't need to check the error anymore.

@semd semd added release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting Security Solution Threat Hunting Team Team:Threat Hunting:Explore labels Jan 25, 2023
@semd semd self-assigned this Jan 25, 2023
@semd
Copy link
Contributor Author

semd commented Jan 26, 2023

@elasticmachine merge upstream

packages/kbn-cell-actions/src/hooks/use_load_actions.ts Outdated Show resolved Hide resolved
getIconType: (): string => COPY_TO_CLIPBOARD_ICON,
getDisplayName: () => COPY_TO_CLIPBOARD,
getDisplayNameTooltip: () => COPY_TO_CLIPBOARD,
isCompatible: async ({ field }) => fieldHasCellActions(field.name),
Copy link
Member

Choose a reason for hiding this comment

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

Note: Adding fieldHasCellActions on a generic action like this makes it hard to reuse in other applications.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right, good point.
But different solutions may have different criteria to show it, the same for Filter In/Out actions. We want these actions to not be displayed with those fields on all Security pages.
When we make these actions generic we'll have to have this in mind. We could have a factory and allow overriding the isCompatible function (and other props) when they are created and attached to the trigger, or just add an isVisible function to the action factory.
We can discuss it more deeply with @YulNaumenko

Copy link
Member

@machadoum machadoum left a comment

Choose a reason for hiding this comment

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

Good job! 👏 👏

I tested it locally and everything seems to be working.

@semd semd marked this pull request as ready for review January 26, 2023 13:46
@semd semd requested review from a team as code owners January 26, 2023 13:46
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-threat-hunting (Team:Threat Hunting)

@semd semd enabled auto-merge (squash) January 26, 2023 14:32
@semd
Copy link
Contributor Author

semd commented Jan 26, 2023

@elasticmachine merge upstream

@semd
Copy link
Contributor Author

semd commented Jan 27, 2023

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Security Solution Tests #3 / Timelines Creates a timeline by clicking untitled timeline from bottom bar can be added notes

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/cell-actions 12 14 +2

Async chunks

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

id before after diff
securitySolution 12.8MB 12.8MB -358.0B
Unknown metric groups

API count

id before after diff
@kbn/cell-actions 15 20 +5

History

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

cc @semd

@semd semd merged commit 09de0d4 into elastic:main Jan 27, 2023
@kibanamachine kibanamachine added v8.7.0 backport:skip This commit does not require backporting labels Jan 27, 2023
kqualters-elastic pushed a commit to kqualters-elastic/kibana that referenced this pull request Feb 6, 2023
…c#149527)

part of: elastic#145666

## Summary

This PR contains changes in the `dataProvider` function for the
addToTimeline action:

- add support for empty values excluding the field, to make it
consistent with the legacy implementation.
- id changes removing the "draggable" word.
- extracted `getIdForField` function to reduce the main function
complexity (linter warning appeared)

This PR also introduces the `CellAction` type for action creation:

- `isCompatible` method parameters uses the new
`CellActionCompatibilityContext` type instead of
`CellActionExecutionContext`, it omits the `field.value` and the
references values, they are not needed to check the compatibility and,
in some situations, it is not possible to pass them.
- use CellAction type in all SecuritySolution action creators
- action creators now return plain objects instead of using
`createAction` (deprecated) function.
- all actions now check `fieldHasCellActions(field.name)` in the
`inCompatible` function, to keep the consistency with legacy code.
- `useLoadAction` hooks now integrate the error control, components
don't need to check the `error` anymore.

Co-authored-by: Kibana Machine <[email protected]>
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 release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting:Explore Team:Threat Hunting Security Solution Threat Hunting Team v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants