From 9341e063f472bb1b0746c23332082916fbd50605 Mon Sep 17 00:00:00 2001 From: Ryland Herrick Date: Thu, 19 Mar 2020 12:05:43 -0500 Subject: [PATCH] Prevent users from changing an existing Rule's type --- .../rules/components/select_rule_type/index.tsx | 5 ++++- .../rules/components/step_define_rule/index.tsx | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/select_rule_type/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/select_rule_type/index.tsx index b3b35699914f6b..229ccde54ecab7 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/select_rule_type/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/select_rule_type/index.tsx @@ -14,9 +14,10 @@ import { isMlRule } from '../../helpers'; interface SelectRuleTypeProps { field: FieldHook; + isReadOnly: boolean; } -export const SelectRuleType: React.FC = ({ field }) => { +export const SelectRuleType: React.FC = ({ field, isReadOnly = false }) => { const ruleType = field.value as RuleType; const setType = useCallback( (type: RuleType) => { @@ -37,6 +38,7 @@ export const SelectRuleType: React.FC = ({ field }) => { description={i18n.QUERY_TYPE_DESCRIPTION} icon={} selectable={{ + isDisabled: isReadOnly, onClick: setQuery, isSelected: !isMlRule(ruleType), }} @@ -49,6 +51,7 @@ export const SelectRuleType: React.FC = ({ field }) => { isDisabled={!license} icon={} selectable={{ + isDisabled: isReadOnly, onClick: setMl, isSelected: isMlRule(ruleType), }} diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/step_define_rule/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/step_define_rule/index.tsx index 6b1a9a828d9501..d3ef185f3786b3 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/step_define_rule/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/step_define_rule/index.tsx @@ -178,7 +178,13 @@ const StepDefineRuleComponent: FC = ({ <>
- + <>