diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_status_dropdown.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_status_dropdown.test.tsx
index 7873583131fdd..ad642738dfbba 100644
--- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_status_dropdown.test.tsx
+++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_status_dropdown.test.tsx
@@ -22,6 +22,7 @@ describe('RuleStatusDropdown', () => {
enableRule,
snoozeRule,
unsnoozeRule,
+ isEditable: true,
previousSnoozeInterval: null,
item: {
id: '1',
@@ -115,4 +116,19 @@ describe('RuleStatusDropdown', () => {
'Disabled'
);
});
+
+ test('renders read-only status control when isEditable is false', () => {
+ const wrapper = mountWithIntl(
+
+ );
+ expect(wrapper.find('[data-test-subj="statusDropdownReadonly"]').first().props().children).toBe(
+ 'Enabled'
+ );
+ });
});
diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_status_dropdown.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_status_dropdown.tsx
index 38867b5d2fe6b..72e4acc2e64fe 100644
--- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_status_dropdown.tsx
+++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rule_status_dropdown.tsx
@@ -43,6 +43,7 @@ export interface ComponentOpts {
disableRule: () => Promise;
snoozeRule: (snoozeEndTime: string | -1, interval: string | null) => Promise;
unsnoozeRule: () => Promise;
+ isEditable: boolean;
previousSnoozeInterval: string | null;
}
@@ -60,6 +61,7 @@ export const RuleStatusDropdown: React.FunctionComponent = ({
enableRule,
snoozeRule,
unsnoozeRule,
+ isEditable,
previousSnoozeInterval,
}: ComponentOpts) => {
const [isEnabled, setIsEnabled] = useState(item.enabled);
@@ -124,11 +126,17 @@ export const RuleStatusDropdown: React.FunctionComponent = ({
) : null;
- const badge = (
+ const nonEditableBadge = (
+
+ {badgeMessage}
+
+ );
+
+ const editableBadge = (
= ({
gutterSize="s"
>
-
-
-
+ {isEditable ? (
+
+
+
+ ) : (
+ nonEditableBadge
+ )}
{remainingSnoozeTime}
diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx
index ba379046828b7..9d56462670b67 100644
--- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx
+++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx
@@ -360,6 +360,7 @@ export const RulesList: React.FunctionComponent = () => {
unsnoozeRule={async () => await unsnoozeRule({ http, id: item.id })}
item={item}
onRuleChanged={() => loadRulesData()}
+ isEditable={item.isEditable && isRuleTypeEditableInContext(item.ruleTypeId)}
previousSnoozeInterval={previousSnoozeInterval}
/>
);