Skip to content

Commit

Permalink
Merge branch 'main' into serverless/poc/navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
clintandrewhall authored Mar 14, 2023
2 parents 8f969b4 + b24cdb1 commit 3985e3d
Show file tree
Hide file tree
Showing 16 changed files with 128 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function AlertsPopover({
updateDataViewList(metadata.adHocDataViewList);
};

return triggersActionsUi?.getAddAlertFlyout({
return triggersActionsUi?.getAddRuleFlyout({
metadata: discoverMetadata,
consumer: 'discover',
onClose: (_, metadata) => {
Expand Down
28 changes: 11 additions & 17 deletions x-pack/examples/alerting_example/public/components/create_alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,21 @@
* 2.0.
*/

import React, { useMemo, useState, useCallback } from 'react';
import React, { 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,
triggersActionsUi: { getAddRuleFlyout: AddRuleFlyout },
}: Pick<AlertingExampleComponentParams, 'triggersActionsUi'>) => {
const [alertFlyoutVisible, setAlertFlyoutVisibility] = useState<boolean>(false);
const [ruleFlyoutVisible, setRuleFlyoutVisibility] = 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]
() => setRuleFlyoutVisibility(false),
[setRuleFlyoutVisibility]
);

return (
Expand All @@ -39,10 +29,14 @@ export const CreateAlert = ({
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)}
onClick={() => setRuleFlyoutVisibility(true)}
/>
</EuiFlexItem>
<EuiFlexItem>{alertFlyoutVisible && AddAlertFlyout}</EuiFlexItem>
<EuiFlexItem>
{ruleFlyoutVisible ? (
<AddRuleFlyout consumer={ALERTING_EXAMPLE_APP_ID} onClose={onCloseAlertFlyout} />
) : null}
</EuiFlexItem>
</EuiFlexGroup>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function AlertingFlyout(props: Props) {
const addAlertFlyout = useMemo(
() =>
ruleType &&
services.triggersActionsUi.getAddAlertFlyout({
services.triggersActionsUi.getAddRuleFlyout({
consumer: APM_SERVER_FEATURE_ID,
onClose: onCloseAddFlyout,
ruleTypeId: ruleType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const AlertFlyout = ({ options, nodeType, filter, visible, setVisible }:
const AddAlertFlyout = useMemo(
() =>
triggersActionsUI &&
triggersActionsUI.getAddAlertFlyout({
triggersActionsUI.getAddRuleFlyout({
consumer: 'infrastructure',
onClose: onCloseFlyout,
canChangeTrigger: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const AlertFlyout = (props: Props) => {
const AddAlertFlyout = useMemo(
() =>
triggersActionsUI &&
triggersActionsUI.getAddAlertFlyout({
triggersActionsUI.getAddRuleFlyout({
consumer: 'logs',
onClose: onCloseFlyout,
canChangeTrigger: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const AlertFlyout = ({ metric, nodeType, visible, setVisible }: Props) =>
const AddAlertFlyout = useMemo(
() =>
triggersActionsUI &&
triggersActionsUI.getAddAlertFlyout({
triggersActionsUI.getAddRuleFlyout({
consumer: 'infrastructure',
onClose: onCloseFlyout,
canChangeTrigger: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const AlertFlyout = (props: Props) => {
const AddAlertFlyout = useMemo(
() =>
triggersActionsUI &&
triggersActionsUI.getAddAlertFlyout({
triggersActionsUI.getAddRuleFlyout({
consumer: 'infrastructure',
onClose: onCloseFlyout,
canChangeTrigger: false,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/ml/public/alerting/ml_alerting_flyout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const MlAnomalyAlertFlyout: FC<MlAnomalyAlertFlyoutProps> = ({
});
}

return triggersActionsUi.getAddAlertFlyout({
return triggersActionsUi.getAddRuleFlyout({
...commonProps,
consumer: PLUGIN_ID,
canChangeTrigger: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ const embeddableStartMock = {
const triggersActionsUiStartMock = {
createStart() {
return {
getAddAlertFlyout: jest.fn(() => (
<div data-test-subj="add-alerts-flyout">mocked component</div>
)),
getAlertsSearchBar: jest.fn(() => (
<div data-test-subj="alerts-search-bar">mocked component</div>
)),
getAlertsStateTable: jest.fn(() => (
<div data-test-subj="alerts-state-table">mocked component</div>
)),
getAddRuleFlyout: jest.fn(() => <div data-test-subj="add-rule-flyout">mocked component</div>),
getEditAlertFlyout: jest.fn(() => (
<div data-test-subj="edit-alert-flyout">mocked component</div>
)),
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/observability/public/pages/rules/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function RulesPage() {
http,
docLinks,
triggersActionsUi: {
getAddAlertFlyout: AddAlertFlyout,
getAddRuleFlyout: AddRuleFlyout,
getRulesList: RuleList,
getRulesSettingsLink: RulesSettingsLink,
},
Expand Down Expand Up @@ -121,7 +121,7 @@ function RulesPage() {
</EuiFlexGroup>

{addRuleFlyoutVisibility && (
<AddAlertFlyout
<AddRuleFlyout
consumer={ALERTS_FEATURE_ID}
filteredRuleTypes={filteredRuleTypes}
onClose={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const UptimeAlertsFlyoutWrapperComponent = ({
);
const AddAlertFlyout = useMemo(
() =>
triggersActionsUi.getAddAlertFlyout({
triggersActionsUi.getAddRuleFlyout({
consumer: 'uptime',
onClose: onCloseAlertFlyout,
ruleTypeId: alertTypeId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const TransformAlertFlyout: FC<TransformAlertFlyoutProps> = ({
});
}

return triggersActionsUi.getAddAlertFlyout({
return triggersActionsUi.getAddRuleFlyout({
...commonProps,
consumer: 'stackAlerts',
canChangeTrigger: false,
Expand Down
Loading

0 comments on commit 3985e3d

Please sign in to comment.