Skip to content

Commit

Permalink
[SECURITY_SOLUTION][ENDPOINT] Fix Policy Details Name to ensure it tr…
Browse files Browse the repository at this point in the history
…uncates the value when its too long (#71526)

* Fix title not truncated on policy details
  • Loading branch information
paul-tavares authored Jul 13, 2020
1 parent b217cb3 commit 9e99f73
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 13 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 @@ -17,6 +17,7 @@ import {
EuiTab,
EuiTabs,
EuiTitle,
EuiTitleProps,
} from '@elastic/eui';
import React, { memo, MouseEventHandler, ReactNode, useMemo } from 'react';
import styled from 'styled-components';
Expand Down Expand Up @@ -45,6 +46,9 @@ const StyledEuiPage = styled(EuiPage)`
.endpoint-navTabs {
margin-left: ${(props) => props.theme.eui.euiSizeM};
}
.endpoint-header-leftSection {
overflow: hidden;
}
`;

const isStringOrNumber = /(string|number)/;
Expand All @@ -54,13 +58,15 @@ const isStringOrNumber = /(string|number)/;
* Can be used when wanting to customize the `headerLeft` value but still use the standard
* title component
*/
export const PageViewHeaderTitle = memo<{ children: ReactNode }>(({ children }) => {
return (
<EuiTitle size="l">
<h1 data-test-subj="pageViewHeaderLeftTitle">{children}</h1>
</EuiTitle>
);
});
export const PageViewHeaderTitle = memo<Omit<EuiTitleProps, 'children'> & { children: ReactNode }>(
({ children, size = 'l', ...otherProps }) => {
return (
<EuiTitle {...otherProps} size={size}>
<h1 data-test-subj="pageViewHeaderLeftTitle">{children}</h1>
</EuiTitle>
);
}
);

PageViewHeaderTitle.displayName = 'PageViewHeaderTitle';

Expand Down Expand Up @@ -135,7 +141,10 @@ export const PageView = memo<PageViewProps>(
<EuiPageBody>
{(headerLeft || headerRight) && (
<EuiPageHeader className="endpoint-header">
<EuiPageHeaderSection data-test-subj="pageViewHeaderLeft">
<EuiPageHeaderSection
className="endpoint-header-leftSection"
data-test-subj="pageViewHeaderLeft"
>
{isStringOrNumber.test(typeof headerLeft) ? (
<PageViewHeaderTitle>{headerLeft}</PageViewHeaderTitle>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const PolicyDetails = React.memo(() => {
defaultMessage="Back to policy list"
/>
</EuiButtonEmpty>
<PageViewHeaderTitle>{policyItem.name}</PageViewHeaderTitle>
<PageViewHeaderTitle className="eui-textTruncate">{policyItem.name}</PageViewHeaderTitle>
</div>
);

Expand Down

0 comments on commit 9e99f73

Please sign in to comment.