kibana/packages/kbn-cell-actions
Sergi Massaneda 09de0d4531
[CellActions] Support for empty value in addToTimeline action (#149527)
part of: https://github.com/elastic/kibana/issues/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 <42973632+kibanamachine@users.noreply.github.com>
2023-01-27 05:14:32 -07:00
..
.storybook [Security Solution] [CellActions] Move to a package (#149057) 2023-01-19 11:52:10 +01:00
src [CellActions] Support for empty value in addToTimeline action (#149527) 2023-01-27 05:14:32 -07:00
index.ts [Security Solution] [CellActions] Move to a package (#149057) 2023-01-19 11:52:10 +01:00
jest.config.js [Security Solution] [CellActions] Move to a package (#149057) 2023-01-19 11:52:10 +01:00
kibana.jsonc [Security Solution] [CellActions] Move to a package (#149057) 2023-01-19 11:52:10 +01:00
package.json [Security Solution] [CellActions] Move to a package (#149057) 2023-01-19 11:52:10 +01:00
README.md [Security Solution] [CellActions] Move to a package (#149057) 2023-01-19 11:52:10 +01:00
tsconfig.json [Security Solution] [CellActions] Move to a package (#149057) 2023-01-19 11:52:10 +01:00

This package provides a uniform interface for displaying UI actions for a cell. For the CellActions component to work, it must be wrapped by CellActionsProvider. Ideally, the wrapper should stay on the top of the rendering tree.

Example:

<CellActionsProvider getTriggerCompatibleActions={uiActions.getTriggerCompatibleActions}>
    [...]
    <CellActions mode={CellActionsMode.HOVER} triggerId={MY_TRIGGER_ID} config={{ field: 'fieldName', value: 'fieldValue', fieldType: 'text' }}>
        Hover me
    </CellActions>
</CellActionsProvider>

CellActions component will display all compatible actions registered for the trigger id.