Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
fkanout committed May 23, 2022
1 parent 0b3c7c7 commit ce1f4a8
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions x-pack/plugins/observability/public/pages/rule_details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,20 @@ export function RuleDetailsPage() {
/>
</EuiPanel>
);

const getRuleStatusComponent = () =>
getRuleStatusDropdown({
rule,
enableRule: async () => await enableRule({ http, id: rule.id }),
disableRule: async () => await disableRule({ http, id: rule.id }),
onRuleChanged: () => reloadRule(),
isEditable: hasEditButton,
snoozeRule: async (snoozeEndTime: string | -1) => {
await snoozeRule({ http, id: rule.id, snoozeEndTime });
},
unsnoozeRule: async () => await unsnoozeRule({ http, id: rule.id }),
});

const getNotifyText = () =>
NOTIFY_WHEN_OPTIONS.find((option) => option.value === rule?.notifyWhen)?.inputDisplay ||
rule.notifyWhen;
Expand Down Expand Up @@ -270,17 +284,7 @@ export function RuleDetailsPage() {
</EuiFlexItem>
</EuiTitle>

{getRuleStatusDropdown({
rule,
enableRule: async () => await enableRule({ http, id: rule.id }),
disableRule: async () => await disableRule({ http, id: rule.id }),
onRuleChanged: () => reloadRule(),
isEditable: hasEditButton,
snoozeRule: async (snoozeEndTime: string | -1) => {
await snoozeRule({ http, id: rule.id, snoozeEndTime });
},
unsnoozeRule: async () => await unsnoozeRule({ http, id: rule.id }),
})}
{getRuleStatusComponent()}
</EuiFlexItem>
</EuiFlexGroup>,
]
Expand Down Expand Up @@ -310,19 +314,7 @@ export function RuleDetailsPage() {
defaultMessage: 'Rule is',
})}
</ItemTitleRuleSummary>
<EuiFlexItem>
{getRuleStatusDropdown({
rule,
enableRule: async () => await enableRule({ http, id: rule.id }),
disableRule: async () => await disableRule({ http, id: rule.id }),
onRuleChanged: () => reloadRule(),
isEditable: hasEditButton,
snoozeRule: async (snoozeEndTime: string | -1) => {
await snoozeRule({ http, id: rule.id, snoozeEndTime });
},
unsnoozeRule: async () => await unsnoozeRule({ http, id: rule.id }),
})}
</EuiFlexItem>
<EuiFlexItem>{getRuleStatusComponent()}</EuiFlexItem>
</EuiFlexGroup>
<EuiHorizontalRule margin="s" />
<EuiFlexGroup>
Expand Down

0 comments on commit ce1f4a8

Please sign in to comment.