[8.7] [Security Solution] Get rid of rule description's fade in/out effect (#150998) (#151683)

# Backport

This will backport the following commits from `main` to `8.7`:
- [[Security Solution] Get rid of rule description's fade in/out effect
(#150998)](https://github.com/elastic/kibana/pull/150998)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Maxim
Palenov","email":"maxim.palenov@elastic.co"},"sourceCommit":{"committedDate":"2023-02-21T10:48:03Z","message":"[Security
Solution] Get rid of rule description's fade in/out effect
(#150998)\n\n**Addresses:**
https://github.com/elastic/kibana/issues/150997\r\n\r\n##
Summary\r\n\r\nIt removed rule details description's fade in and out
effect which was added by scrolling EUI
styles.\r\n\r\n*Before:*\r\n\r\n![Screenshot 2023-02-13 at 13 30
02](https://user-images.githubusercontent.com/3775283/218459498-28dd50ce-94eb-427f-865c-279f611b4049.png)\r\n\r\n![Screenshot
2023-02-13 at 13 30
11](https://user-images.githubusercontent.com/3775283/218459532-56072024-8e8b-4ee1-89be-ffece60d31a7.png)\r\n\r\n*After:*\r\n\r\n![Screenshot
2023-02-13 at 13 27
49](https://user-images.githubusercontent.com/3775283/218459699-8da6f5c3-e05d-4c9f-8122-392f3bfd6846.png)\r\n\r\n![Screenshot
2023-02-13 at 13 28
00](https://user-images.githubusercontent.com/3775283/218459735-1c522e19-573f-47c4-9490-5828373ac5ac.png)","sha":"de97462358fb859590693b1cca43c20b23f30c20","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Detections
and Resp","Team: SecuritySolution","Team:Detection Rules","Feature:Rule
Details","backport:prev-minor","v8.7.0","v8.8.0"],"number":150998,"url":"https://github.com/elastic/kibana/pull/150998","mergeCommit":{"message":"[Security
Solution] Get rid of rule description's fade in/out effect
(#150998)\n\n**Addresses:**
https://github.com/elastic/kibana/issues/150997\r\n\r\n##
Summary\r\n\r\nIt removed rule details description's fade in and out
effect which was added by scrolling EUI
styles.\r\n\r\n*Before:*\r\n\r\n![Screenshot 2023-02-13 at 13 30
02](https://user-images.githubusercontent.com/3775283/218459498-28dd50ce-94eb-427f-865c-279f611b4049.png)\r\n\r\n![Screenshot
2023-02-13 at 13 30
11](https://user-images.githubusercontent.com/3775283/218459532-56072024-8e8b-4ee1-89be-ffece60d31a7.png)\r\n\r\n*After:*\r\n\r\n![Screenshot
2023-02-13 at 13 27
49](https://user-images.githubusercontent.com/3775283/218459699-8da6f5c3-e05d-4c9f-8122-392f3bfd6846.png)\r\n\r\n![Screenshot
2023-02-13 at 13 28
00](https://user-images.githubusercontent.com/3775283/218459735-1c522e19-573f-47c4-9490-5828373ac5ac.png)","sha":"de97462358fb859590693b1cca43c20b23f30c20"}},"sourceBranch":"main","suggestedTargetBranches":["8.7"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/150998","number":150998,"mergeCommit":{"message":"[Security
Solution] Get rid of rule description's fade in/out effect
(#150998)\n\n**Addresses:**
https://github.com/elastic/kibana/issues/150997\r\n\r\n##
Summary\r\n\r\nIt removed rule details description's fade in and out
effect which was added by scrolling EUI
styles.\r\n\r\n*Before:*\r\n\r\n![Screenshot 2023-02-13 at 13 30
02](https://user-images.githubusercontent.com/3775283/218459498-28dd50ce-94eb-427f-865c-279f611b4049.png)\r\n\r\n![Screenshot
2023-02-13 at 13 30
11](https://user-images.githubusercontent.com/3775283/218459532-56072024-8e8b-4ee1-89be-ffece60d31a7.png)\r\n\r\n*After:*\r\n\r\n![Screenshot
2023-02-13 at 13 27
49](https://user-images.githubusercontent.com/3775283/218459699-8da6f5c3-e05d-4c9f-8122-392f3bfd6846.png)\r\n\r\n![Screenshot
2023-02-13 at 13 28
00](https://user-images.githubusercontent.com/3775283/218459735-1c522e19-573f-47c4-9490-5828373ac5ac.png)","sha":"de97462358fb859590693b1cca43c20b23f30c20"}}]}]
BACKPORT-->

Co-authored-by: Maxim Palenov <maxim.palenov@elastic.co>
This commit is contained in:
Kibana Machine 2023-02-21 07:29:37 -05:00 committed by GitHub
parent a6b8d62bdb
commit afa799b6ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 74 additions and 38 deletions

View file

@ -17,9 +17,10 @@ import {
EuiResizeObserver,
} from '@elastic/eui';
import { isEmpty } from 'lodash';
import type { PropsWithChildren } from 'react';
import React, { memo, useCallback, useMemo, useState } from 'react';
import styled from 'styled-components';
import { css } from '@emotion/react';
import { HeaderSection } from '../../../../common/components/header_section';
import { MarkdownRenderer } from '../../../../common/components/markdown_editor';
import type {
@ -28,28 +29,7 @@ import type {
} from '../../../pages/detection_engine/rules/types';
import * as i18n from './translations';
import { StepAboutRule } from '../step_about_rule';
const MyPanel = styled(EuiPanel)`
position: relative;
`;
const FlexGroupFullHeight = styled(EuiFlexGroup)`
height: 100%;
`;
const VerticalOverflowContainer = styled.div((props: { maxHeight: number }) => ({
'max-height': `${props.maxHeight}px`,
'overflow-y': 'hidden',
'word-break': 'break-word',
}));
const VerticalOverflowContent = styled.div((props: { maxHeight: number }) => ({
'max-height': `${props.maxHeight}px`,
}));
const AboutContent = styled.div`
height: 100%;
`;
import { fullHeight } from './styles';
const detailsOption: EuiButtonGroupOptionProps = {
id: 'details',
@ -99,7 +79,12 @@ const StepAboutRuleToggleDetailsComponent: React.FC<StepPanelProps> = ({
}, [stepDataDetails]);
return (
<MyPanel hasBorder>
<EuiPanel
hasBorder
css={css`
position: 'relative';
`}
>
{loading && (
<>
<EuiProgress size="xs" color="accent" position="absolute" />
@ -107,7 +92,7 @@ const StepAboutRuleToggleDetailsComponent: React.FC<StepPanelProps> = ({
</>
)}
{stepData != null && stepDataDetails != null && (
<FlexGroupFullHeight gutterSize="xs" direction="column">
<EuiFlexGroup gutterSize="xs" direction="column" css={fullHeight}>
<EuiFlexItem grow={false} key="header">
<HeaderSection title={i18n.ABOUT_TEXT}>
{toggleOptions.length > 0 && (
@ -127,9 +112,9 @@ const StepAboutRuleToggleDetailsComponent: React.FC<StepPanelProps> = ({
{selectedToggleOption === 'details' && (
<EuiResizeObserver data-test-subj="stepAboutDetailsContent" onResize={onResize}>
{(resizeRef) => (
<AboutContent ref={resizeRef}>
<div ref={resizeRef} css={fullHeight}>
<VerticalOverflowContainer maxHeight={120}>
<VerticalOverflowContent maxHeight={120} className="eui-yScrollWithShadows">
<VerticalOverflowContent maxHeight={120}>
<EuiText
size="s"
data-test-subj="stepAboutRuleDetailsToggleDescriptionText"
@ -145,7 +130,7 @@ const StepAboutRuleToggleDetailsComponent: React.FC<StepPanelProps> = ({
isLoading={false}
defaultValues={stepData}
/>
</AboutContent>
</div>
)}
</EuiResizeObserver>
)}
@ -154,10 +139,7 @@ const StepAboutRuleToggleDetailsComponent: React.FC<StepPanelProps> = ({
data-test-subj="stepAboutDetailsNoteContent"
maxHeight={aboutPanelHeight}
>
<VerticalOverflowContent
maxHeight={aboutPanelHeight}
className="eui-yScrollWithShadows"
>
<VerticalOverflowContent maxHeight={aboutPanelHeight}>
<MarkdownRenderer>{stepDataDetails.note}</MarkdownRenderer>
</VerticalOverflowContent>
</VerticalOverflowContainer>
@ -167,19 +149,61 @@ const StepAboutRuleToggleDetailsComponent: React.FC<StepPanelProps> = ({
data-test-subj="stepAboutDetailsSetupContent"
maxHeight={aboutPanelHeight}
>
<VerticalOverflowContent
maxHeight={aboutPanelHeight}
className="eui-yScrollWithShadows"
>
<VerticalOverflowContent maxHeight={aboutPanelHeight}>
<MarkdownRenderer>{stepDataDetails.setup}</MarkdownRenderer>
</VerticalOverflowContent>
</VerticalOverflowContainer>
)}
</EuiFlexItem>
</FlexGroupFullHeight>
</EuiFlexGroup>
)}
</MyPanel>
</EuiPanel>
);
};
export const StepAboutRuleToggleDetails = memo(StepAboutRuleToggleDetailsComponent);
interface VerticalOverflowContainerProps {
maxHeight: number;
'data-test-subj'?: string;
}
function VerticalOverflowContainer({
maxHeight,
'data-test-subj': dataTestSubject,
children,
}: PropsWithChildren<VerticalOverflowContainerProps>): JSX.Element {
return (
<div
css={css`
max-height: ${maxHeight};
overflow-y: 'hidden';
word-break: 'break-word';
`}
data-test-subj={dataTestSubject}
>
{children}
</div>
);
}
interface VerticalOverflowContentProps {
maxHeight: number;
}
function VerticalOverflowContent({
maxHeight,
children,
}: PropsWithChildren<VerticalOverflowContentProps>): JSX.Element {
return (
<div
className="eui-yScroll"
css={css`
max-height: ${maxHeight};
`}
>
{children}
</div>
);
}

View file

@ -0,0 +1,12 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { css } from '@emotion/react';
export const fullHeight = css`
height: 100%;
`;