Skip to content

Commit

Permalink
[8.8] [Security Solution] Fix a broken header on small screens (#156525
Browse files Browse the repository at this point in the history
…) (#156650)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[Security Solution] Fix a broken header on small screens
(#156525)](#156525)

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

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

<!--BACKPORT [{"author":{"name":"Maxim
Palenov","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-05-04T08:19:36Z","message":"[Security
Solution] Fix a broken header on small screens
(#156525)\n\n**Resolves:**
https://github.com/elastic/kibana/issues/155596\r\n\r\n##
Summary\r\n\r\nIt fixes a broken header on small screen after adding
rule snooze badge component.
\r\n\r\n*Before:*\r\n\r\n![image](https://user-images.githubusercontent.com/3775283/235914975-d30c75c4-f4fe-4887-86d1-417787e16521.png)\r\n![image](https://user-images.githubusercontent.com/3775283/235915062-b079fac0-0fef-447a-b2e5-d571f6862441.png)\r\n![image](https://user-images.githubusercontent.com/3775283/235915165-d34cb157-ecf1-4074-9a08-48c4dfa3605d.png)\r\n\r\n*After:*\r\n\r\n![image](https://user-images.githubusercontent.com/3775283/235915333-ca658f3a-8dfe-47d4-90ec-8bc629566d5c.png)\r\n![image](https://user-images.githubusercontent.com/3775283/235915401-31a7ff25-933e-4c8e-938d-323433e85d66.png)\r\n![image](https://user-images.githubusercontent.com/3775283/235915479-fc56dd64-e113-4535-b268-f3dacdd6f4a4.png)\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios\r\n- [x] Any UI
touched in this PR does not create any new axe failures (run axe in
browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] This renders correctly on smaller devices using a responsive layout.
(You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)","sha":"0a9bbe7c1fd32765116f508b9d01879ba58482fb","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:Detections
and Resp","Team: SecuritySolution","Team:Detection
Rules","backport:prev-minor","v8.8.0","v8.9.0"],"number":156525,"url":"https://github.com/elastic/kibana/pull/156525","mergeCommit":{"message":"[Security
Solution] Fix a broken header on small screens
(#156525)\n\n**Resolves:**
https://github.com/elastic/kibana/issues/155596\r\n\r\n##
Summary\r\n\r\nIt fixes a broken header on small screen after adding
rule snooze badge component.
\r\n\r\n*Before:*\r\n\r\n![image](https://user-images.githubusercontent.com/3775283/235914975-d30c75c4-f4fe-4887-86d1-417787e16521.png)\r\n![image](https://user-images.githubusercontent.com/3775283/235915062-b079fac0-0fef-447a-b2e5-d571f6862441.png)\r\n![image](https://user-images.githubusercontent.com/3775283/235915165-d34cb157-ecf1-4074-9a08-48c4dfa3605d.png)\r\n\r\n*After:*\r\n\r\n![image](https://user-images.githubusercontent.com/3775283/235915333-ca658f3a-8dfe-47d4-90ec-8bc629566d5c.png)\r\n![image](https://user-images.githubusercontent.com/3775283/235915401-31a7ff25-933e-4c8e-938d-323433e85d66.png)\r\n![image](https://user-images.githubusercontent.com/3775283/235915479-fc56dd64-e113-4535-b268-f3dacdd6f4a4.png)\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios\r\n- [x] Any UI
touched in this PR does not create any new axe failures (run axe in
browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] This renders correctly on smaller devices using a responsive layout.
(You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)","sha":"0a9bbe7c1fd32765116f508b9d01879ba58482fb"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/156525","number":156525,"mergeCommit":{"message":"[Security
Solution] Fix a broken header on small screens
(#156525)\n\n**Resolves:**
https://github.com/elastic/kibana/issues/155596\r\n\r\n##
Summary\r\n\r\nIt fixes a broken header on small screen after adding
rule snooze badge component.
\r\n\r\n*Before:*\r\n\r\n![image](https://user-images.githubusercontent.com/3775283/235914975-d30c75c4-f4fe-4887-86d1-417787e16521.png)\r\n![image](https://user-images.githubusercontent.com/3775283/235915062-b079fac0-0fef-447a-b2e5-d571f6862441.png)\r\n![image](https://user-images.githubusercontent.com/3775283/235915165-d34cb157-ecf1-4074-9a08-48c4dfa3605d.png)\r\n\r\n*After:*\r\n\r\n![image](https://user-images.githubusercontent.com/3775283/235915333-ca658f3a-8dfe-47d4-90ec-8bc629566d5c.png)\r\n![image](https://user-images.githubusercontent.com/3775283/235915401-31a7ff25-933e-4c8e-938d-323433e85d66.png)\r\n![image](https://user-images.githubusercontent.com/3775283/235915479-fc56dd64-e113-4535-b268-f3dacdd6f4a4.png)\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios\r\n- [x] Any UI
touched in this PR does not create any new axe failures (run axe in
browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[x] This renders correctly on smaller devices using a responsive layout.
(You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)","sha":"0a9bbe7c1fd32765116f508b9d01879ba58482fb"}}]}]
BACKPORT-->

Co-authored-by: Maxim Palenov <[email protected]>
  • Loading branch information
kibanamachine and maximpn authored May 4, 2023
1 parent 499b5e9 commit 15c0b0a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 30 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@
* 2.0.
*/

import { EuiProgress, EuiPageHeader, EuiPageHeaderSection, EuiSpacer } from '@elastic/eui';
import {
EuiProgress,
EuiPageHeader,
EuiPageHeaderSection,
EuiSpacer,
useEuiTheme,
} from '@elastic/eui';
import React from 'react';
import styled, { css } from 'styled-components';
import { css } from '@emotion/react';
import styled, { css as styleCss } from 'styled-components';

import type { LinkIconProps } from '../link_icon';
import { LinkIcon } from '../link_icon';
Expand All @@ -23,19 +30,10 @@ interface HeaderProps {
isLoading?: boolean;
}

const Header = styled.header.attrs({
className: 'securitySolutionHeaderPage',
})<HeaderProps>`
${({ border, theme }) => css`
margin-bottom: ${theme.eui.euiSizeL};
`}
`;
Header.displayName = 'Header';

const LinkBack = styled.div.attrs({
className: 'securitySolutionHeaderPage__linkBack',
})`
${({ theme }) => css`
${({ theme }) => styleCss`
font-size: ${theme.eui.euiFontSizeXS};
line-height: ${theme.eui.euiLineHeight};
margin-bottom: ${theme.eui.euiSizeS};
Expand All @@ -51,6 +49,18 @@ const HeaderSection = styled(EuiPageHeaderSection)`
`;
HeaderSection.displayName = 'HeaderSection';

function Divider(): JSX.Element {
const { euiTheme } = useEuiTheme();

return (
<div
css={css`
border-bottom: ${euiTheme.border.thin};
`}
/>
);
}

interface BackOptions {
pageId: SecurityPageName;
text: LinkIconProps['children'];
Expand Down Expand Up @@ -110,15 +120,19 @@ const HeaderPageComponent: React.FC<HeaderPageProps> = ({
titleNode,
}) => (
<>
<EuiPageHeader alignItems="center" bottomBorder={border} rightSideItems={rightSideItems}>
<EuiPageHeader alignItems="center" rightSideItems={rightSideItems}>
<HeaderSection>
{backOptions && <HeaderLinkBack backOptions={backOptions} />}
{!backOptions && backComponent && <>{backComponent}</>}

{titleNode || <Title title={title} badgeOptions={badgeOptions} />}

{subtitle && <Subtitle data-test-subj="header-page-subtitle" items={subtitle} />}
{subtitle2 && <Subtitle data-test-subj="header-page-subtitle-2" items={subtitle2} />}
{subtitle && (
<>
<EuiSpacer size="s" />
<Subtitle data-test-subj="header-page-subtitle" items={subtitle} />
</>
)}
{border && isLoading && <EuiProgress size="xs" color="accent" />}
</HeaderSection>

Expand All @@ -128,6 +142,18 @@ const HeaderPageComponent: React.FC<HeaderPageProps> = ({
</EuiPageHeaderSection>
)}
</EuiPageHeader>
{subtitle2 && (
<>
<EuiSpacer size="xs" />
<Subtitle data-test-subj="header-page-subtitle-2" items={subtitle2} />
</>
)}
{border && (
<>
<EuiSpacer size="m" />
<Divider />
</>
)}
{/* Manually add a 'padding-bottom' to header */}
<EuiSpacer size="l" />
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import styled, { css } from 'styled-components';

const Wrapper = styled.div`
${({ theme }) => css`
margin-top: ${theme.eui.euiSizeS};
.siemSubtitle__item {
color: ${theme.eui.euiTextSubduedColor};
font-size: ${theme.eui.euiFontSizeXS};
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 15c0b0a

Please sign in to comment.