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

[Security Solution] Default Risk score slide bar values are overlaid on Rule Creation page #161793

Merged
merged 6 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -567,27 +567,38 @@ const CreateRulePageComponent: React.FC = () => {
() => (
<>
<EuiHorizontalRule margin="m" />
<div
style={{
display: activeStep === RuleStep.aboutRule ? undefined : 'none',
}}
>
<StepAboutRule
ruleType={defineStepData.ruleType}
machineLearningJobId={defineStepData.machineLearningJobId}
index={defineStepData.index}
dataViewId={defineStepData.dataViewId}
timestampOverride={aboutStepData.timestampOverride}
isLoading={isCreateRuleLoading || loading}
form={aboutStepForm}
/>

<NextStep
dataTestSubj="about-continue"
onClick={aboutRuleNextStep}
isDisabled={isCreateRuleLoading}
/>
</div>
{
// TODO: https://github.com/elastic/kibana/issues/161456
// The About step page contains EuiRnage component which does not work properly within memoized parents.
// In this case we memoize the StepAboutRule and initially this component is offscreen since the Define step page is default.
// The About step page is not displayed due to `style.display ='none'` and this breaks EuiRange.
// EUI team suggested not to memoize EuiRange/EuiDualRange: https://github.com/elastic/eui/issues/6846
// Related ticket: https://github.com/elastic/kibana/issues/160561
// NOTE: We should remove this workaround once EUI team fixed EuiRange.
activeStep !== RuleStep.aboutRule ? null : (
Copy link
Contributor

Choose a reason for hiding this comment

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

We need the StepAboutRule component to remain in the DOM even when it's not the active step, otherwise the formData gets cleared. Perhaps triggering an extra re-render at some point while the component is setting up could be a workaround for the risk score track issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah ok, that's why probably so many tests are broken :-) Will check what we can do to re-render action step after it appeared.

<div
style={{
display: activeStep === RuleStep.aboutRule ? undefined : 'none',
}}
>
<StepAboutRule
ruleType={defineStepData.ruleType}
machineLearningJobId={defineStepData.machineLearningJobId}
index={defineStepData.index}
dataViewId={defineStepData.dataViewId}
timestampOverride={aboutStepData.timestampOverride}
isLoading={isCreateRuleLoading || loading}
form={aboutStepForm}
/>

<NextStep
dataTestSubj="about-continue"
onClick={aboutRuleNextStep}
isDisabled={isCreateRuleLoading}
/>
</div>
)
}
{memoAboutStepReadOnly}
</>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,31 +257,39 @@ const EditRulePageComponent: FC<{ rule: Rule }> = ({ rule }) => {
id: RuleStep.aboutRule,
name: ruleI18n.ABOUT,
disabled: rule?.immutable,
content: (
<div
style={{
display: activeStep === RuleStep.aboutRule ? undefined : 'none',
}}
>
<EuiSpacer />
<StepPanel loading={loading} title={ruleI18n.ABOUT}>
{aboutStepData != null && defineStepData != null && (
<StepAboutRule
isLoading={isLoading}
isUpdateView
ruleType={defineStepData.ruleType}
machineLearningJobId={defineStepData.machineLearningJobId}
index={defineStepData.index}
dataViewId={defineStepData.dataViewId}
timestampOverride={aboutStepData.timestampOverride}
form={aboutStepForm}
key="aboutStep"
/>
)}
content:
// TODO: https://github.com/elastic/kibana/issues/161456
// The About step page contains EuiRnage component which does not work properly within memoized parents.
// In this case we memoize the StepAboutRule and initially this component is offscreen since the Define step page is default.
// The About step page is not displayed due to `style.display ='none'` and this breaks EuiRange.
// EUI team suggested not to memoize EuiRange/EuiDualRange: https://github.com/elastic/eui/issues/6846
// Related ticket: https://github.com/elastic/kibana/issues/160561
// NOTE: We should remove this workaround once EUI team fixed EuiRange.
activeStep !== RuleStep.aboutRule ? null : (
<div
style={{
display: activeStep === RuleStep.aboutRule ? undefined : 'none',
}}
>
<EuiSpacer />
</StepPanel>
</div>
),
<StepPanel loading={loading} title={ruleI18n.ABOUT}>
{aboutStepData != null && defineStepData != null && (
<StepAboutRule
isLoading={isLoading}
isUpdateView
ruleType={defineStepData.ruleType}
machineLearningJobId={defineStepData.machineLearningJobId}
index={defineStepData.index}
dataViewId={defineStepData.dataViewId}
timestampOverride={aboutStepData.timestampOverride}
form={aboutStepForm}
key="aboutStep"
/>
)}
<EuiSpacer />
</StepPanel>
</div>
),
},
{
'data-test-subj': 'edit-rule-schedule-tab',
Expand Down