Skip to content

Commit

Permalink
[Session View] Close session viewer button fixes (elastic#131910)
Browse files Browse the repository at this point in the history
  • Loading branch information
opauloh authored and Bamieh committed May 16, 2022
1 parent 5f5db43 commit 04cd6d9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
*/

import React, { useMemo, useEffect, useRef, useLayoutEffect } from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule, EuiLoadingSpinner } from '@elastic/eui';
import {
EuiFlexGroup,
EuiFlexItem,
EuiHorizontalRule,
EuiLoadingSpinner,
EuiSpacer,
} from '@elastic/eui';
import { euiThemeVars } from '@kbn/ui-theme';
import { useDispatch } from 'react-redux';
import styled, { css } from 'styled-components';
Expand All @@ -30,6 +36,8 @@ import { SourcererScopeName } from '../../../common/store/sourcerer/model';
import { useSourcererDataView } from '../../../common/containers/sourcerer';
import { sourcererSelectors } from '../../../common/store';

const SESSION_VIEW_FULL_SCREEN = 'sessionViewFullScreen';

const OverlayStyle = css`
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -59,10 +67,12 @@ const StyledResolver = styled(Resolver)`
`;

const ScrollableFlexItem = styled(EuiFlexItem)`
${({ theme }) => `padding: 0 ${theme.eui.euiSizeM};
background-color: ${theme.eui.euiColorEmptyShade};`}
${({ theme }) => `background-color: ${theme.eui.euiColorEmptyShade};`}
overflow: hidden;
width: 100%;
&.${SESSION_VIEW_FULL_SCREEN} {
${({ theme }) => `padding: 0 ${theme.eui.euiSizeM}`}
}
`;

interface GraphOverlayProps {
Expand Down Expand Up @@ -158,8 +168,13 @@ const GraphOverlayComponent: React.FC<GraphOverlayProps> = ({
return (
<OverlayContainer data-test-subj="overlayContainer" ref={sessionContainerRef}>
<EuiFlexGroup alignItems="flexStart" gutterSize="none" direction="column">
<EuiHorizontalRule margin="none" />
<EuiFlexItem grow={false}>{Navigation}</EuiFlexItem>
<ScrollableFlexItem grow={2}>{SessionView}</ScrollableFlexItem>
<EuiHorizontalRule margin="none" />
<EuiSpacer size="m" />
<ScrollableFlexItem grow={2} className={fullScreen ? SESSION_VIEW_FULL_SCREEN : ''}>
{SessionView}
</ScrollableFlexItem>
</EuiFlexGroup>
</OverlayContainer>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
*/

import React, { useState, useCallback } from 'react';
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule, EuiSpacer } from '@elastic/eui';
import styled from 'styled-components';
import { TimelineId } from '../../../../../common/types/timeline';
import { useSessionViewNavigation, useSessionView } from './use_session_view';

const FlexItemWithMargin = styled(EuiFlexItem)`
const MaxWidthFlexItem = styled(EuiFlexItem)`
width: 100%;
`;
const SessionViewWrapper = styled.div`
${({ theme }) => `margin: 0 ${theme.eui.euiSizeM};`}
`;

Expand Down Expand Up @@ -59,10 +61,13 @@ const SessionTabContent: React.FC<Props> = ({ timelineId }) => {
ref={measuredRef}
data-test-subj="timeline-session-content"
>
<FlexItemWithMargin grow={false}>
<MaxWidthFlexItem grow={false}>
<EuiHorizontalRule margin="none" />
{Navigation}
{SessionView}
</FlexItemWithMargin>
<EuiHorizontalRule margin="none" />
<EuiSpacer size="m" />
<SessionViewWrapper>{SessionView}</SessionViewWrapper>
</MaxWidthFlexItem>
{shouldShowDetailsPanel && (
<>
<VerticalRule />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export const CLOSE_ANALYZER = i18n.translate(
export const CLOSE_SESSION = i18n.translate(
'xpack.securitySolution.timeline.graphOverlay.closeSessionButton',
{
defaultMessage: 'Close session',
defaultMessage: 'Close session viewer',
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe('useSessionView with active timeline and a session id and graph event i
);
const navigation = result.current.Navigation;
const renderResult = render(<TestProviders>{navigation}</TestProviders>);
expect(renderResult.getByText('Close session')).toBeTruthy();
expect(renderResult.getByText('Close session viewer')).toBeTruthy();
});

it('uses an optional height when passed', () => {
Expand Down

0 comments on commit 04cd6d9

Please sign in to comment.