mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 11:05:39 -04:00
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
/*
|
|
* 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, { useMemo, useState, useCallback } from 'react';
|
|
|
|
import { EuiIcon, EuiFlexItem, EuiCard, EuiFlexGroup } from '@elastic/eui';
|
|
|
|
import { AlertingExampleComponentParams } from '../application';
|
|
import { ALERTING_EXAMPLE_APP_ID } from '../../common/constants';
|
|
|
|
export const CreateAlert = ({
|
|
triggersActionsUi,
|
|
}: Pick<AlertingExampleComponentParams, 'triggersActionsUi'>) => {
|
|
const [alertFlyoutVisible, setAlertFlyoutVisibility] = useState<boolean>(false);
|
|
|
|
const onCloseAlertFlyout = useCallback(
|
|
() => setAlertFlyoutVisibility(false),
|
|
[setAlertFlyoutVisibility]
|
|
);
|
|
|
|
const AddAlertFlyout = useMemo(
|
|
() =>
|
|
triggersActionsUi.getAddAlertFlyout({
|
|
consumer: ALERTING_EXAMPLE_APP_ID,
|
|
onClose: onCloseAlertFlyout,
|
|
}),
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
[onCloseAlertFlyout]
|
|
);
|
|
|
|
return (
|
|
<EuiFlexGroup>
|
|
<EuiFlexItem grow={false}>
|
|
<EuiCard
|
|
icon={<EuiIcon size="xxl" type={`bell`} />}
|
|
title={`Create Rule`}
|
|
description="Create a new Rule based on one of our example Rule Types ."
|
|
onClick={() => setAlertFlyoutVisibility(true)}
|
|
/>
|
|
</EuiFlexItem>
|
|
<EuiFlexItem>{alertFlyoutVisible && AddAlertFlyout}</EuiFlexItem>
|
|
</EuiFlexGroup>
|
|
);
|
|
};
|