-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Security Solution] Add CellActions (alpha version) component to ui_actions plugin #147434
[Security Solution] Add CellActions (alpha version) component to ui_actions plugin #147434
Conversation
Pinging @elastic/security-threat-hunting (Team:Threat Hunting) |
Pinging @elastic/security-solution (Team: SecuritySolution) |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
}) => { | ||
const actionProps = useMemo( | ||
() => ({ | ||
iconType: action.getIconType(actionContext) as IconType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it make sense to update the Action
type to make getIconType
return IconType
instead of string | undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using IconType
instead of string
makes sense to me. I think it is a string
because EuiContextMenuItemIcon
expects a string
instead of IconType
. So updating it might lead to cascading changes that could grow big.
Tagging @Dosant and @vadimkibana to collect their input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to think about this. That would mean ui_actions
plugin service layer would have a dependency on EUI, which maybe is fine, maybe not desirable.
src/plugins/ui_actions/public/cell_actions/components/cell_actions.tsx
Outdated
Show resolved
Hide resolved
src/plugins/ui_actions/public/cell_actions/components/cell_actions.tsx
Outdated
Show resolved
Hide resolved
src/plugins/ui_actions/public/cell_actions/components/extra_actions_popover.tsx
Outdated
Show resolved
Hide resolved
src/plugins/ui_actions/public/cell_actions/components/extra_actions_popover.tsx
Outdated
Show resolved
Hide resolved
src/plugins/ui_actions/public/cell_actions/components/hover_actions_popover.tsx
Outdated
Show resolved
Hide resolved
src/plugins/ui_actions/public/cell_actions/components/inline_actions.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few nits. Tested in storybook and works as expected. Nicely done! LGTM
e6c6a8d
to
0d443a0
Compare
src/plugins/ui_actions/public/cell_actions/components/hover_actions_popover.tsx
Outdated
Show resolved
Hide resolved
src/plugins/ui_actions/public/cell_actions/components/cell_actions.tsx
Outdated
Show resolved
Hide resolved
export const CellActions: React.FC<CellActionsProps> = ({ | ||
field, | ||
triggerId, | ||
children, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose for the children
property? Trying to find the description in CellActionsProps
.
Probably we just should name it different, something like triggeringElement
or so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The children
property will be used for rendering the field content. CellActions
wraps the cell content and provides extra functionality.
The children
property is required for the hovering mode. CellActions
wraps the children and displays a popover on hover.
Here is an example:
<CellActions mode={CellActionsMode.HOVER_POPOVER} triggerId={TRIGGER_ID} field={FIELD}>
Hover me
</CellActions>
For inline mode, it isn't strictly required. But if it is provided, CellActions
will display the action side-by-side with children
.
We could consider exporting two components, one for hover and one for inline actions. But, in the first interaction, I decided to keep the API as simple as possible by exporting one component (We can easily change that).
Given that hover actions need to wrap the field value to work, children
is the only property that allows the "wrapping" JSX syntax.
<WrappingComponent>
<WrappedComponent />
</WrappingComponent>
It is also built into typescript. So if a component is typed with React.FC<>
, it already has a property named children
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the components design LGTM. I have some minor questions regarding the props naming, because we should clearly explain the purpose and capabilities of each.
@PhilippeOberti thank you for the detailed feedback. This is just an early phase of the design the new cell actions functionality, which we decided to split by the smaller PRs, without the touching or impacting existing code base till the final version will be ready. The idea is to have it simple, much simpler that it is now covered by
We definitely will provide the documentation (and RFC) for the components when it will be ready for a wide usage and will do the cleanup of the existing HoverActions usage by replacing it with the CellActions component. |
…actions are alredy rendered
03ce6c5
to
cd96c5e
Compare
src/plugins/ui_actions/public/cell_actions/components/cell_actions_context.test.tsx
Show resolved
Hide resolved
src/plugins/ui_actions/public/cell_actions/components/cell_actions.tsx
Outdated
Show resolved
Hide resolved
src/plugins/ui_actions/public/cell_actions/components/cell_actions.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This component looks amazing. Thanks for taking the time to address the comments @machadoum.
I only left a couple of naming NITs, the component code overall LGTM!
Great job! 🚀
34b6b9b
to
cf8373e
Compare
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
ESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @machadoum |
Summary
Create a
CellActions
component. It hooks into a UI-Actions trigger and displays all available actions.It has two modes, Hover_Actions and Always_Visible.
You can run the storybook and take a look at the component:
yarn storybook ui_actions
or access https://ci-artifacts.kibana.dev/storybooks/pr-147434/226993c612bbe1719de6374219009bc69b0378d8/ui_actions/index.html*** This component is still not in use.
Why?
The security Solution team is creating a generic UI component to allow teams to share actions between different plugins.
Initially, only the Security solution plugin will use this component and deprecate the Security solution custom implementation. Some actions that will be shared are: "copy to clipboard", "filter in", "filter out" and "add to timeline".
How to use it:
This package provides a uniform interface for displaying UI actions for a cell.
For the
CellActions
component to work, it must be wrapped byCellActionsContextProvider
. Ideally, the wrapper should stay on the top of the rendering tree.Example:
CellActions
component will display all compatible actions registered for the trigger id.Checklist