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

Fix "Deleted rule" badge is not displayed if 'Rule Name' contains more that 55 words #103164

Merged
merged 1 commit into from
Jun 24, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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.

Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ const Badge = (styled(EuiBadge)`
` as unknown) as typeof EuiBadge;
Badge.displayName = 'Badge';

const HeaderSection = styled(EuiPageHeaderSection)`
// Without min-width: 0, as a flex child, it wouldn't shrink properly
// and could overflow its parent.
min-width: 0;
max-width: 100%;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this results in the Rule Details title overflow options (Activate, Edit Settings & overflow menu) being pushed off screen when the main title is truncated. This results in those options not being visible or able to be scrolled to when the title is truncated on lower viewport widths.

Perhaps we can keep this at 100% (for all other pages) and just constrain in the RuleDetails header so that the title overflow options are always visible?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified actually issue is fixed btw, so all good there 👍. Interestingly though, the emoji in the title got converted to a text emoticon after deleting the rule.

They display fine in the alerts fwiw -- so probably just in how we're parsing out the deleted title from the alert? Not big deal either way, so no need to address here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must've been on an old commit as just re-tested and not seeing this (the off-screen overflow options hidden) issue. Apologies for the confusion here! 😅

`;
HeaderSection.displayName = 'HeaderSection';

interface BackOptions {
href: LinkIconProps['href'];
text: LinkIconProps['children'];
Expand Down Expand Up @@ -105,7 +113,7 @@ const HeaderPageComponent: React.FC<HeaderPageProps> = ({
return (
<>
<EuiPageHeader alignItems="center" bottomBorder={border}>
<EuiPageHeaderSection>
<HeaderSection>
{backOptions && (
<LinkBack>
<LinkIcon
Expand All @@ -132,7 +140,7 @@ const HeaderPageComponent: React.FC<HeaderPageProps> = ({
{subtitle && <Subtitle data-test-subj="header-page-subtitle" items={subtitle} />}
{subtitle2 && <Subtitle data-test-subj="header-page-subtitle-2" items={subtitle2} />}
{border && isLoading && <EuiProgress size="xs" color="accent" />}
</EuiPageHeaderSection>
</HeaderSection>

{children && (
<EuiPageHeaderSection data-test-subj="header-page-supplements">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ const Badge = (styled(EuiBadge)`
` as unknown) as typeof EuiBadge;
Badge.displayName = 'Badge';

const Header = styled.h1`
display: flex;
align-items: center;
`;
Header.displayName = 'Header';

const TitleWrapper = styled.span`
// Without min-width: 0, as a flex child, it wouldn't shrink properly
// and could overflow its parent.
min-width: 0;
`;
TitleWrapper.displayName = 'TitleWrapper';

interface Props {
badgeOptions?: BadgeOptions;
title: TitleProp;
Expand All @@ -32,9 +45,11 @@ interface Props {

const TitleComponent: React.FC<Props> = ({ draggableArguments, title, badgeOptions }) => (
<EuiTitle size="l">
<h1 data-test-subj="header-page-title">
<Header data-test-subj="header-page-title">
{!draggableArguments ? (
<TruncatableText tooltipContent={title}>{title}</TruncatableText>
<TitleWrapper>
<TruncatableText tooltipContent={title}>{title}</TruncatableText>
</TitleWrapper>
) : (
<DefaultDraggable
data-test-subj="header-page-draggable"
Expand All @@ -53,13 +68,13 @@ const TitleComponent: React.FC<Props> = ({ draggableArguments, title, badgeOptio
tooltipPosition="bottom"
/>
) : (
<Badge color="hollow" title="">
<Badge color={badgeOptions.color || 'hollow'} title="">
{badgeOptions.text}
</Badge>
)}
</>
)}
</h1>
</Header>
</EuiTitle>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { EuiBadgeProps } from '@elastic/eui';
import type React from 'react';
export type TitleProp = string | React.ReactNode;

Expand All @@ -17,4 +18,5 @@ export interface BadgeOptions {
beta?: boolean;
text: string;
tooltip?: string;
color?: EuiBadgeProps['color'];
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
EuiTabs,
EuiToolTip,
EuiWindowEvent,
EuiBadge,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { noop } from 'lodash/fp';
Expand Down Expand Up @@ -115,6 +114,7 @@ import { NeedAdminForUpdateRulesCallOut } from '../../../../components/callouts/
import { getRuleStatusText } from '../../../../../../common/detection_engine/utils';
import { MissingPrivilegesCallOut } from '../../../../components/callouts/missing_privileges_callout';
import { useRuleWithFallback } from '../../../../containers/detection_engine/rules/use_rule_with_fallback';
import { BadgeOptions } from '../../../../../common/components/header_page/types';

/**
* Need a 100% height here to account for the graph/analyze tool, which sets no explicit height parameters, but fills the available space.
Expand Down Expand Up @@ -253,15 +253,20 @@ const RuleDetailsPageComponent = () => {
const title = useMemo(
() => (
<>
{rule?.name}{' '}
{ruleLoading ? (
<EuiLoadingSpinner size="m" />
) : (
!isExistingRule && <EuiBadge>{i18n.DELETED_RULE}</EuiBadge>
)}
{rule?.name} {ruleLoading && <EuiLoadingSpinner size="m" />}
</>
),
[rule, ruleLoading, isExistingRule]
[rule, ruleLoading]
);
const badgeOptions = useMemo<BadgeOptions | undefined>(
() =>
!ruleLoading && !isExistingRule
? {
text: i18n.DELETED_RULE,
color: 'default',
}
: undefined,
[isExistingRule, ruleLoading]
);
const subTitle = useMemo(
() =>
Expand Down Expand Up @@ -595,6 +600,7 @@ const RuleDetailsPageComponent = () => {
</>,
]}
title={title}
badgeOptions={badgeOptions}
>
<EuiFlexGroup alignItems="center">
<EuiFlexItem grow={false}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('Network Details', () => {
);
expect(
wrapper
.find('[data-test-subj="network-details-headline"] [data-test-subj="header-page-title"]')
.find('[data-test-subj="network-details-headline"] h1[data-test-subj="header-page-title"]')
.text()
).toEqual('fe80::24ce:f7ff:fede:a571');
});
Expand Down