|
@@ -1,13 +1,20 @@
|
|
|
import {BaseButtonProps, Button} from 'sentry/components/button';
|
|
|
+import HookOrDefault from 'sentry/components/hookOrDefault';
|
|
|
import {IconPause, IconPlay} from 'sentry/icons';
|
|
|
import {t} from 'sentry/locale';
|
|
|
+import {ObjectStatus} from 'sentry/types';
|
|
|
import {Monitor} from 'sentry/views/monitors/types';
|
|
|
|
|
|
-interface StatusToggleButtonProps extends BaseButtonProps {
|
|
|
+interface StatusToggleButtonProps extends Omit<BaseButtonProps, 'onClick'> {
|
|
|
monitor: Monitor;
|
|
|
+ onToggleStatus: (status: ObjectStatus) => void;
|
|
|
}
|
|
|
|
|
|
-function StatusToggleButton({monitor, ...props}: StatusToggleButtonProps) {
|
|
|
+function SimpleStatusToggle({
|
|
|
+ monitor,
|
|
|
+ onToggleStatus,
|
|
|
+ ...props
|
|
|
+}: StatusToggleButtonProps) {
|
|
|
const {status} = monitor;
|
|
|
const isDisabeld = status === 'disabled';
|
|
|
|
|
@@ -17,7 +24,20 @@ function StatusToggleButton({monitor, ...props}: StatusToggleButtonProps) {
|
|
|
? t('Reactive this monitor')
|
|
|
: t('Disable this monitor and discard incoming check-ins');
|
|
|
|
|
|
- return <Button icon={<Icon />} aria-label={label} title={label} {...props} />;
|
|
|
+ return (
|
|
|
+ <Button
|
|
|
+ icon={<Icon />}
|
|
|
+ aria-label={label}
|
|
|
+ title={label}
|
|
|
+ onClick={() => onToggleStatus(isDisabeld ? 'active' : 'disabled')}
|
|
|
+ {...props}
|
|
|
+ />
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
-export {StatusToggleButton};
|
|
|
+const StatusToggleButton = HookOrDefault({
|
|
|
+ hookName: 'component:monitor-status-toggle',
|
|
|
+ defaultComponent: SimpleStatusToggle,
|
|
|
+});
|
|
|
+
|
|
|
+export {StatusToggleButton, StatusToggleButtonProps};
|