From 2f470d3431abccc6cbe80eae0d92a5a2a99ec2f5 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 5 Nov 2024 08:00:57 +1100 Subject: [PATCH] [8.x] [ResponseOps][New Rule Form] Fix new rule form issues with basic license (#198036) (#198842) # Backport This will backport the following commits from `main` to `8.x`: - [[ResponseOps][New Rule Form] Fix new rule form issues with basic license (#198036)](https://github.com/elastic/kibana/pull/198036) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Janki Salvi <117571355+js-jankisalvi@users.noreply.github.com> --- .../components/rule_type_list.test.tsx | 4 ++ .../components/rule_type_list.tsx | 58 +++++++++++++------ .../components/rules_list_table.tsx | 1 + 3 files changed, 45 insertions(+), 18 deletions(-) diff --git a/packages/kbn-alerts-ui-shared/src/rule_type_modal/components/rule_type_list.test.tsx b/packages/kbn-alerts-ui-shared/src/rule_type_modal/components/rule_type_list.test.tsx index 175d90924586c..7003b06875659 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_type_modal/components/rule_type_list.test.tsx +++ b/packages/kbn-alerts-ui-shared/src/rule_type_modal/components/rule_type_list.test.tsx @@ -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'; @@ -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(); }); }); diff --git a/packages/kbn-alerts-ui-shared/src/rule_type_modal/components/rule_type_list.tsx b/packages/kbn-alerts-ui-shared/src/rule_type_modal/components/rule_type_list.tsx index 4e21e428f3c5c..91710dbdfade5 100644 --- a/packages/kbn-alerts-ui-shared/src/rule_type_modal/components/rule_type_list.tsx +++ b/packages/kbn-alerts-ui-shared/src/rule_type_modal/components/rule_type_list.tsx @@ -20,6 +20,7 @@ import { EuiEmptyPrompt, EuiButton, useEuiTheme, + EuiToolTip, } from '@elastic/eui'; import { omit } from 'lodash'; import { PRODUCER_DISPLAY_NAMES } from '../../common/i18n'; @@ -86,6 +87,28 @@ export const RuleTypeList: React.FC = ({ const onClickAll = useCallback(() => onFilterByProducer(null), [onFilterByProducer]); + const ruleCard = (rule: RuleTypeWithDescription) => ( + onSelectRuleType(rule.id)} + description={rule.description} + style={{ marginRight: '8px', flexGrow: 0 }} + data-test-subj={`${rule.id}-SelectOption`} + isDisabled={!rule.enabledInLicense} + > + + {producerToDisplayName(rule.producer)} + + + ); + return ( = ({ )} {ruleTypesList.map((rule) => ( - onSelectRuleType(rule.id)} - description={rule.description} - style={{ marginRight: '8px', flexGrow: 0 }} - data-test-subj={`${rule.id}-SelectOption`} - isDisabled={rule.enabledInLicense === false} - > - - {producerToDisplayName(rule.producer)} - - + <>{ruleCard(rule)} + + )} ))} diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list_table.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list_table.tsx index ee3ee18152e47..88f22f9687ea6 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list_table.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list_table.tsx @@ -750,6 +750,7 @@ export const RulesListTable = (props: RulesListTableProps) => { 'xpack.triggersActionsUI.sections.rulesList.rulesListTable.columns.editAriaLabel', { defaultMessage: 'Edit' } )} + disabled={!rule.enabledInLicense} /> ) : null}