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

[8.x] [ResponseOps][New Rule Form] Fix new rule form issues with basic license (#198036) #198842

Merged
merged 1 commit into from
Nov 4, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import React from 'react';
import { render, screen, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { RuleTypeList } from './rule_type_list';
import { RuleTypeWithDescription } from '../types';

Expand Down Expand Up @@ -93,5 +94,8 @@ describe('RuleTypeList', () => {
expect(secondRuleInList).not.toBeDisabled();
const thirdRuleInList = within(ruleListEl[2]).getByRole('button', { name: 'Rule Type 2' });
expect(thirdRuleInList).toBeDisabled();

await userEvent.hover(ruleListEl[2]);
expect(await screen.findByText('This rule requires a platinum license.')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
EuiEmptyPrompt,
EuiButton,
useEuiTheme,
EuiToolTip,
} from '@elastic/eui';
import { omit } from 'lodash';
import { PRODUCER_DISPLAY_NAMES } from '../../common/i18n';
Expand Down Expand Up @@ -86,6 +87,28 @@ export const RuleTypeList: React.FC<RuleTypeListProps> = ({

const onClickAll = useCallback(() => onFilterByProducer(null), [onFilterByProducer]);

const ruleCard = (rule: RuleTypeWithDescription) => (
<EuiCard
titleSize="xs"
textAlign="left"
hasBorder
title={rule.name}
onClick={() => onSelectRuleType(rule.id)}
description={rule.description}
style={{ marginRight: '8px', flexGrow: 0 }}
data-test-subj={`${rule.id}-SelectOption`}
isDisabled={!rule.enabledInLicense}
>
<EuiText
color="subdued"
size="xs"
style={{ textTransform: 'uppercase', fontWeight: euiTheme.font.weight.bold }}
>
{producerToDisplayName(rule.producer)}
</EuiText>
</EuiCard>
);

return (
<EuiFlexGroup
style={{
Expand Down Expand Up @@ -151,25 +174,24 @@ export const RuleTypeList: React.FC<RuleTypeListProps> = ({
)}
{ruleTypesList.map((rule) => (
<React.Fragment key={rule.id}>
<EuiCard
titleSize="xs"
textAlign="left"
hasBorder
title={rule.name}
onClick={() => onSelectRuleType(rule.id)}
description={rule.description}
style={{ marginRight: '8px', flexGrow: 0 }}
data-test-subj={`${rule.id}-SelectOption`}
isDisabled={rule.enabledInLicense === false}
>
<EuiText
color="subdued"
size="xs"
style={{ textTransform: 'uppercase', fontWeight: euiTheme.font.weight.bold }}
{rule.enabledInLicense ? (
ruleCard(rule)
) : (
<EuiToolTip
position="top"
content={i18n.translate(
'alertsUIShared.components.ruleTypeModal.minimumRequiredLicenseMessage',
{
defaultMessage: 'This rule requires a {minimumLicenseRequired} license.',
values: {
minimumLicenseRequired: rule.minimumLicenseRequired,
},
}
)}
>
{producerToDisplayName(rule.producer)}
</EuiText>
</EuiCard>
<>{ruleCard(rule)} </>
</EuiToolTip>
)}
<EuiSpacer size="s" />
</React.Fragment>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ export const RulesListTable = (props: RulesListTableProps) => {
'xpack.triggersActionsUI.sections.rulesList.rulesListTable.columns.editAriaLabel',
{ defaultMessage: 'Edit' }
)}
disabled={!rule.enabledInLicense}
/>
</EuiFlexItem>
) : null}
Expand Down