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] Get rid of rule description's fade in/out effect #150998

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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',
Expand Down Expand Up @@ -99,15 +79,20 @@ const StepAboutRuleToggleDetailsComponent: React.FC<StepPanelProps> = ({
}, [stepDataDetails]);

return (
<MyPanel hasBorder>
<EuiPanel
hasBorder
css={css`
position: 'relative';
`}
>
{loading && (
<>
<EuiProgress size="xs" color="accent" position="absolute" />
<HeaderSection title={i18n.ABOUT_TEXT} />
</>
)}
{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 && (
Expand All @@ -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"
Expand All @@ -145,7 +130,7 @@ const StepAboutRuleToggleDetailsComponent: React.FC<StepPanelProps> = ({
isLoading={false}
defaultValues={stepData}
/>
</AboutContent>
</div>
)}
</EuiResizeObserver>
)}
Expand All @@ -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>
Expand All @@ -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>
);
}
Original file line number Diff line number Diff line change
@@ -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%;
`;