-
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]Expandable flyout - Replace rule sections with new components #169029
[Security Solution]Expandable flyout - Replace rule sections with new components #169029
Conversation
810efa5
to
c221cb4
Compare
c221cb4
to
0eda0cc
Compare
Pinging @elastic/security-threat-hunting (Team:Threat Hunting) |
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 something bothers me with this approach but I'm not sure what is exactly...
Maybe it's the fact that we're lacking documentation of the props, so it's unclear what the itemRenderer does exactly. Unless I look at the component's implementation, I wouldn't be able to tell that the itemRender overrides the default render.
Maybe it's the fact that ultimately the default renderer and the one we're passing from our flyout component aren't that different. They both use the EuiDescriptionList
component. Yes the type
, rowGutterSize
and className
are different, but couldn't we make these props and have a single render inside the component?
Maybe it's the face that we have a default render in the component and the other ones are passed in via props. We could have no default render and have the itemRenderer
a required props instead of optional. We could even have the RuleAboutSection
render {children}
and force the parent to define how they want the list to be rendered?
Just a bunch of ideas, but I feel this can be improved, maybe with the help of the @elastic/security-detection-rule-management team?
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.
@PhilippeOberti The render prop approach aims at avoiding too many props purely for UI. I wonder if it's more bothering because it is repeated 3 times? maybe it will help description list is extracted and reused..
But ultimately, all we wanted is to show rule details in a smaller font and more compressed. I don't have strong preference on either approach. I'll defer to @elastic/security-detection-rule-management / @nikitaindik on their preference?
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.
First of all, thanks for doing this refactoring work! ❤️ It brings us one step closer to decoupling rule view components from rule creation components. Once we also refactor the remaining bits of the creation page, we can remove a lot of tangled code. And that's great!
As for passing the itemRenderer
, I think the most straightforward way would be to just expand the props of section components with EuiDescriptionList
props. Since the only difference between default rendering and custom rendering are props passed to EuiDescriptionList
.
It can look like this:
<RuleDefinitionSection
rule={castRuleAsRuleResponse(rule)}
type="row"
className={panelViewStyle}
rowGutterSize="s"
/>
And then this the section component code:
export interface RuleDefinitionSectionProps
extends React.ComponentProps<typeof EuiDescriptionList> { // allow EuiDescriptionList props
rule: Partial<RuleResponse>;
isInteractive?: boolean;
dataTestSubj?: string;
}
export const RuleDefinitionSection = ({
rule,
isInteractive = false,
dataTestSubj,
...descriptionListProps
}: RuleDefinitionSectionProps) => {
/* ... */
return (
<div data-test-subj={dataTestSubj}>
<EuiDescriptionList
{...descriptionListProps}
type={descriptionListProps.type ?? 'column'} // Set defaults here to avoid changing existing usage of section components
rowGutterSize={descriptionListProps.rowGutterSize ?? 'm'} // Or pass these manually in all places where sections are used (not a lot of places yet)
listItems={definitionSectionListItems}
columnWidths={DESCRIPTION_LIST_COLUMN_WIDTHS}
/>
</div>
);
};
Passing the itemRenderer
is also a fine way IMO, and we might need it in the future, but for now I think just adding the props would suffice.
What do you folks think?
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.
yup thanks for your input @nikitaindik, I like this approach the best!
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
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.
Approved
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.
thanks for making the change @christineweng, tested and code LGTM! :)
This PR updates rule preview panel in the document expandable flyout:
itemRenderer
to allow custom render of the description listisPanelView
props from the rule detail read only components. It was added to accommodate the preview styling ([Security Solution] Expandable flyout - Rule preview contents #163027)No UI change from this PR
How to test
Show rule summary
to expand the rule preview panel