forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Alerting UI] Added visual indicator when enable switched click is pr…
…ocessed on the server side. (elastic#107272) * [Alerting UI] Added visual indicator when enable switched click is processed on the server side. * fixed rule details * fixed functional tests * fixed unit tests * fixed due to comments * fixed due to comments
- Loading branch information
1 parent
d77bcc3
commit 32a7e1b
Showing
5 changed files
with
229 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...ers_actions_ui/public/application/sections/alert_details/components/rule_muted_switch.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { useState } from 'react'; | ||
import { EuiSwitch, EuiLoadingSpinner } from '@elastic/eui'; | ||
|
||
import { AlertInstanceListItem } from './alert_instances'; | ||
|
||
interface ComponentOpts { | ||
alertInstance: AlertInstanceListItem; | ||
onMuteAction: (instance: AlertInstanceListItem) => Promise<void>; | ||
disabled: boolean; | ||
} | ||
|
||
export const RuleMutedSwitch: React.FunctionComponent<ComponentOpts> = ({ | ||
alertInstance, | ||
onMuteAction, | ||
disabled, | ||
}: ComponentOpts) => { | ||
const [isMuted, setIsMuted] = useState<boolean>(alertInstance?.isMuted); | ||
const [isUpdating, setIsUpdating] = useState<boolean>(false); | ||
|
||
return isUpdating ? ( | ||
<EuiLoadingSpinner size="m" /> | ||
) : ( | ||
<EuiSwitch | ||
name="mute" | ||
disabled={disabled} | ||
compressed={true} | ||
checked={isMuted} | ||
onChange={async () => { | ||
setIsUpdating(true); | ||
await onMuteAction(alertInstance); | ||
setIsMuted(!isMuted); | ||
setIsUpdating(false); | ||
}} | ||
data-test-subj={`muteAlertInstanceButton_${alertInstance.instance}`} | ||
showLabel={false} | ||
label="mute" | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters