-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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] Expandable flyout - Rule preview contents #163027
[Security Solution] Expandable flyout - Rule preview contents #163027
Conversation
c8ef38d
to
36206d9
Compare
36206d9
to
f1da4a1
Compare
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.
Left a few comments, the major one being the isInPanelView
prop approach.
I would be fine keeping it, but I'm not a fan of props that are only there to drive the UI, especially if they are specific to a single use. In our case, it is extremely unlikely anybody else would ever need this specific behavior when reusing this component... Doing this a recipe to have later way too many props... (I understand that the columns
prop is already doing that so we're not breaking a pattern here, but also to my point that's already 2 props to drive the UI...)
A few options I can see:
- have some sort of prop that would include all css changes
- like I mentioned in the comment, maybe try to see what we can do with the
titleProps
prop? - could we pass in css changes and use them (I know it's feasible in Angular but have never done it with React)
But I believe my favorite approach would be to have our own component. If we look at the StepRuleDescriptionComponent, it's really not doing much... We don't care about the if (column==='multi') or the singleSplit sections.
Could we extract the listItems logic and build our own component?
The code duplication would be pretty small, and we wouldn't introduce a new usage-specific prop?
If you think it's too much work for not much value (which I don't deny) and if the @elastic/security-detection-rule-management team is OK with the current change, I can be convinced to merge the code as it is (after fixing the few nits)
x-pack/plugins/security_solution/public/detections/components/rules/step_define_rule/index.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/flyout/preview/components/rule_preview.tsx
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/flyout/preview/components/rule_preview.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/flyout/preview/components/rule_preview.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/flyout/preview/components/rule_preview.tsx
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/flyout/preview/components/rule_preview_title.tsx
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/flyout/preview/hooks/use_rule_switch.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/flyout/preview/hooks/use_rule_switch.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/flyout/preview/hooks/use_rule_switch.ts
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.
@christineweng these are nice changes for the rule preview 👍
Basically I agree with @PhilippeOberti regarding isInPanelView
prop. We should avoid parametrisation as it adds too much complexity. React's philosophy is composition so we need to focus on this. Obviously it will require more effort but we can address some tech debt here. Rule details page wasn't designed to share its components in a wider environment and has suboptimal structure. It's possible to refactor it a bit to make the components you need shared. Specifically we need to address the following
- Have an ability to reuse rule details page's content with customizations at some other place (refactor for that
StepRuleDescriptionComponent
to split it or have a render prop) - Make
RuleSwitch
shared without necessity to pull all the data and permission (avoid customuseRuleSwitch
appearing in different places) - Share the text (it looks like updated by, created by and enable/disabled rule texts are the same and it worth to find a way to share it via ready to use components)
I understand that it inflates the scope but I think we can find a way to address it. Feel free to reach me to discuss the above by voice if necessary.
packages/kbn-expandable-flyout/src/components/preview_section.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/detections/components/rules/description_step/index.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/flyout/preview/components/rule_preview.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/flyout/preview/components/rule_preview.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/flyout/preview/hooks/use_rule_switch.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/public/detections/components/rules/step_define_rule/index.tsx
Outdated
Show resolved
Hide resolved
@christineweng fyi, Rule Management team has been working on a similar task having a flyout with rule details in this PR. There is an idea to build rule details lightweight components everyone can reuse to display rule details information. The feature is targeted |
@christineweng @maximpn Hey folks! Just wanted to clarify that we (the Rules Mgmt team) can't guarantee that we will be able to properly implement the reusable components mentioned above by FF date. We are doing our best to squeeze this refactoring in, but please don't count on us to have it fully ready by FF. |
@maximpn thank you so much for the feedback!
|
712ae7e
to
0a1c401
Compare
ab8fa09
to
ae63e2b
Compare
x-pack/plugins/security_solution/public/detections/components/rules/rule_info/index.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 an idea, but it the CreatedBy
and UpdatedBy
components were taking a single prop rule: Rule | null
it would simplify the way devs use it, and they wouldn't have to check if the rule is null when using the component, like you do now (for example rule?.updated_by
). That logic would be embedded in your component, which is a slightly nicer developer experience...
I'm not strongly attached to this though, and for the sake of time (mainly updating tests) I'm ok keeping what you have!
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.
LGTM, thanks for making all the changes! I left a few more small nits, I'll leave it to you to implement them or not!
One last request: would you mind writing a ticket on our expandable flyout board to log the tech debt (to better share hooks and components)?
@PhilippeOberti thanks! ticket created here |
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.
@christineweng thank you for addressing my comments 🙏 special thanks for CreatedBy
and UpdatedBy
components 😉
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Unknown metric groupsReferences to deprecated APIs
History
To update your PR or re-run it, just comment with: |
… components (#169029) This PR updates rule preview panel in the document expandable flyout: - Replaced rule details sections with the simplified components from #166158 - Added `itemRenderer` to allow custom render of the description list - Removed `isPanelView` props from the rule detail read only components. It was added to accommodate the preview styling (#163027) **No UI change from this PR** **How to test** - Go to alerts page and generate some alerts - Expand a row in the table, a flyout should appear - Click `Show rule summary` to expand the rule preview panel
Summary
This PR is part 2 of adding a rule preview panel to the expandable flyout. PR (#161999) adds the preview skeleton, and this PR populates the actual content related to rule details:
Expandable flyout:
created by
andupdated by
timestamps, and rule switch button~/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/index.tsx
)Rule & detections:
isPanelView
option allow rendering rule details in smaller font, so that it can fit in panel viewcreatedBy
andupdatedBy
to~/security_solution/public/detections/components/rules/rule_info
to be shared between rule details page and flyoutHow to test
xpack.securitySolution.enableExperimental: ['securityFlyoutEnabled']
to thekibana.dev.json
fileChecklist