Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a link to documentation in the alerts and actions management UI #81909

Merged
merged 4 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions x-pack/plugins/triggers_actions_ui/public/application/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import {
} from 'kibana/public';
import { Section, routeToAlertDetails } from './constants';
import { AppContextProvider } from './app_context';
import { ActionTypeModel, AlertTypeModel } from '../types';
import { TypeRegistry } from './type_registry';
import { ActionTypeRegistryContract, AlertTypeRegistryContract } from '../types';
import { ChartsPluginStart } from '../../../../../src/plugins/charts/public';
import { DataPublicPluginStart } from '../../../../../src/plugins/data/public';
import { PluginStartContract as AlertingStart } from '../../../alerts/public';
Expand All @@ -42,8 +41,8 @@ export interface AppDeps {
uiSettings: IUiSettingsClient;
setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void;
capabilities: ApplicationStart['capabilities'];
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
alertTypeRegistry: TypeRegistry<AlertTypeModel>;
actionTypeRegistry: ActionTypeRegistryContract;
alertTypeRegistry: AlertTypeRegistryContract;
history: ScopedHistory;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@

import React, { createContext, useContext } from 'react';
import { HttpSetup, ApplicationStart, DocLinksStart, ToastsSetup } from 'kibana/public';
import { ActionTypeModel, ActionConnector } from '../../types';
import { TypeRegistry } from '../type_registry';
import { ActionTypeRegistryContract, ActionConnector } from '../../types';

export interface ActionsConnectorsContextValue {
http: HttpSetup;
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
actionTypeRegistry: ActionTypeRegistryContract;
toastNotifications: ToastsSetup;
capabilities: ApplicationStart['capabilities'];
reloadConnectors?: () => Promise<ActionConnector[] | void>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ import {
DataPublicPluginStartUi,
IndexPatternsContract,
} from 'src/plugins/data/public';
import { TypeRegistry } from '../type_registry';
import { AlertTypeModel, ActionTypeModel } from '../../types';
import { AlertTypeRegistryContract, ActionTypeRegistryContract } from '../../types';

export interface AlertsContextValue<MetaData = Record<string, any>> {
reloadAlerts?: () => Promise<void>;
http: HttpSetup;
alertTypeRegistry: TypeRegistry<AlertTypeModel>;
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
alertTypeRegistry: AlertTypeRegistryContract;
actionTypeRegistry: ActionTypeRegistryContract;
toastNotifications: ToastsStart;
uiSettings?: IUiSettingsClient;
charts?: ChartsPluginSetup;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import * as React from 'react';
import { RouteComponentProps, Router } from 'react-router-dom';
import { createMemoryHistory, createLocation } from 'history';
import { mountWithIntl } from 'test_utils/enzyme_helpers';

import TriggersActionsUIHome, { MatchParams } from './home';
import { AppContextProvider } from './app_context';
import { getMockedAppDependencies } from './test_utils';

describe('home', () => {
it('renders the documentation link', async () => {
const deps = await getMockedAppDependencies();

const props: RouteComponentProps<MatchParams> = {
history: createMemoryHistory(),
location: createLocation('/'),
match: {
isExact: true,
path: `/alerts`,
url: '',
params: {
section: 'alerts',
},
},
};
const wrapper = mountWithIntl(
<Router history={deps.history}>
<AppContextProvider appDeps={deps}>
<TriggersActionsUIHome {...props} />
</AppContextProvider>
</Router>
);
const documentationLink = wrapper.find('[data-test-subj="documentationLink"]');
expect(documentationLink.exists()).toBeTruthy();
expect(documentationLink.first().prop('href')).toEqual(
'https://www.elastic.co/guide/en/kibana/mocked-test-branch/managing-alerts-and-actions.html'
);
});
});
46 changes: 30 additions & 16 deletions x-pack/plugins/triggers_actions_ui/public/application/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import { FormattedMessage } from '@kbn/i18n/react';
import {
EuiPageBody,
EuiPageContent,
EuiPageContentHeader,
EuiPageContentHeaderSection,
EuiSpacer,
EuiTab,
EuiTabs,
EuiTitle,
EuiText,
EuiButtonEmpty,
EuiFlexGroup,
EuiFlexItem,
} from '@elastic/eui';

import { Section, routeToConnectors, routeToAlerts } from './constants';
Expand All @@ -30,7 +31,7 @@ import { AlertsList } from './sections/alerts_list/components/alerts_list';
import { HealthCheck } from './components/health_check';
import { HealthContextProvider } from './context/health_context';

interface MatchParams {
export interface MatchParams {
section: Section;
}

Expand Down Expand Up @@ -80,27 +81,40 @@ export const TriggersActionsUIHome: React.FunctionComponent<RouteComponentProps<
return (
<EuiPageBody>
<EuiPageContent>
<EuiPageContentHeader>
<EuiPageContentHeaderSection>
<EuiTitle size="m">
<EuiTitle size="m">
<EuiFlexGroup>
<EuiFlexItem>
<h1 data-test-subj="appTitle">
<FormattedMessage
id="xpack.triggersActionsUI.home.appTitle"
defaultMessage="Alerts and Actions"
/>
</h1>
</EuiTitle>
<EuiSpacer size="s" />
<EuiText>
<p>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/managing-alerts-and-actions.html`}
target="_blank"
iconType="help"
data-test-subj="documentationLink"
>
<FormattedMessage
id="xpack.triggersActionsUI.home.sectionDescription"
defaultMessage="Detect conditions using alerts, and take actions using connectors."
id="xpack.triggersActionsUI.home.alertsAndActionsDocsLinkText"
defaultMessage="Documentation"
/>
</p>
</EuiText>
</EuiPageContentHeaderSection>
</EuiPageContentHeader>
</EuiButtonEmpty>
</EuiFlexItem>
</EuiFlexGroup>
</EuiTitle>
<EuiSpacer size="s" />
<EuiText>
<p>
<FormattedMessage
id="xpack.triggersActionsUI.home.sectionDescription"
defaultMessage="Detect conditions using alerts, and take actions using connectors."
/>
</p>
</EuiText>

<EuiTabs>
{tabs.map((tab) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('action_connector_form', () => {
] = await mocks.getStartServices();
deps = {
http: mocks.http,
actionTypeRegistry: actionTypeRegistry as any,
actionTypeRegistry,
docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' },
capabilities,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import { ReducerAction } from './connector_reducer';
import {
ActionConnector,
IErrorObject,
ActionTypeModel,
ActionTypeRegistryContract,
UserConfiguredActionConnector,
} from '../../../types';
import { TypeRegistry } from '../../type_registry';
import { hasSaveActionsCapability } from '../../lib/capabilities';

export function validateBaseProperties(actionObject: ActionConnector) {
Expand Down Expand Up @@ -61,7 +60,7 @@ interface ActionConnectorProps<
};
errors: IErrorObject;
http: HttpSetup;
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
actionTypeRegistry: ActionTypeRegistryContract;
docLinks: DocLinksStart;
capabilities: ApplicationStart['capabilities'];
consumer?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe('action_form', () => {
},
},
setHasActionsWithBrokenConnector: jest.fn(),
actionTypeRegistry: actionTypeRegistry as any,
actionTypeRegistry,
docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' },
};
actionTypeRegistry.list.mockReturnValue([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { loadActionTypes, loadAllActions as loadConnectors } from '../../lib/act
import {
IErrorObject,
ActionTypeModel,
ActionTypeRegistryContract,
AlertAction,
ActionTypeIndex,
ActionConnector,
Expand All @@ -42,7 +43,6 @@ import {
} from '../../../types';
import { SectionLoading } from '../../components/section_loading';
import { ConnectorAddModal } from './connector_add_modal';
import { TypeRegistry } from '../../type_registry';
import { actionTypeCompare } from '../../lib/action_type_compare';
import { checkActionFormActionTypeEnabled } from '../../lib/check_action_type_enabled';
import { VIEW_LICENSE_OPTIONS_LINK } from '../../../common/constants';
Expand All @@ -55,7 +55,7 @@ interface ActionAccordionFormProps {
setAlertProperty: (actions: AlertAction[]) => void;
setActionParamsProperty: (key: string, value: any, index: number) => void;
http: HttpSetup;
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
actionTypeRegistry: ActionTypeRegistryContract;
toastNotifications: ToastsSetup;
docLinks: DocLinksStart;
actionTypes?: ActionType[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('connector_add_flyout', () => {
show: true,
},
},
actionTypeRegistry: actionTypeRegistry as any,
actionTypeRegistry,
docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' },
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('connector_add_flyout', () => {
show: true,
},
},
actionTypeRegistry: actionTypeRegistry as any,
actionTypeRegistry,
docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' },
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('connector_add_modal', () => {
delete: true,
},
},
actionTypeRegistry: actionTypeRegistry as any,
actionTypeRegistry,
docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' },
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,24 @@ import { EuiOverlayMask } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { HttpSetup, ToastsApi, ApplicationStart, DocLinksStart } from 'kibana/public';
import { ActionConnectorForm, validateBaseProperties } from './action_connector_form';
import { ActionType, ActionConnector, IErrorObject, ActionTypeModel } from '../../../types';
import { connectorReducer } from './connector_reducer';
import { createActionConnector } from '../../lib/action_connector_api';
import { TypeRegistry } from '../../type_registry';
import './connector_add_modal.scss';
import { hasSaveActionsCapability } from '../../lib/capabilities';
import {
ActionType,
ActionConnector,
IErrorObject,
ActionTypeRegistryContract,
} from '../../../types';

interface ConnectorAddModalProps {
actionType: ActionType;
addModalVisible: boolean;
setAddModalVisibility: React.Dispatch<React.SetStateAction<boolean>>;
postSaveEventHandler?: (savedAction: ActionConnector) => void;
http: HttpSetup;
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
actionTypeRegistry: ActionTypeRegistryContract;
toastNotifications: Pick<
ToastsApi,
'get$' | 'add' | 'remove' | 'addSuccess' | 'addWarning' | 'addDanger' | 'addError'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('connector_edit_flyout', () => {
show: true,
},
},
actionTypeRegistry: actionTypeRegistry as any,
actionTypeRegistry,
alertTypeRegistry: {} as any,
docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' },
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('actions_connectors_list component empty', () => {
},
history: scopedHistoryMock.create(),
setBreadcrumbs: jest.fn(),
actionTypeRegistry: actionTypeRegistry as any,
actionTypeRegistry,
alertTypeRegistry: {} as any,
};
actionTypeRegistry.has.mockReturnValue(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ describe('alert_add', () => {
uiSettings: mocks.uiSettings,
dataPlugin: dataPluginMock.createStartContract(),
charts: chartPluginMock.createStartContract(),
actionTypeRegistry: actionTypeRegistry as any,
alertTypeRegistry: alertTypeRegistry as any,
actionTypeRegistry,
alertTypeRegistry,
docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' },
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ describe('alert_edit', () => {
toastNotifications: mockedCoreSetup.notifications.toasts,
http: mockedCoreSetup.http,
uiSettings: mockedCoreSetup.uiSettings,
actionTypeRegistry: actionTypeRegistry as any,
alertTypeRegistry: alertTypeRegistry as any,
actionTypeRegistry,
alertTypeRegistry,
docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' },
capabilities,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ describe('alert_form', () => {
toastNotifications: mocks.notifications.toasts,
http: mocks.http,
uiSettings: mocks.uiSettings,
actionTypeRegistry: actionTypeRegistry as any,
alertTypeRegistry: alertTypeRegistry as any,
actionTypeRegistry,
alertTypeRegistry,
docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' },
capabilities,
};
Expand Down Expand Up @@ -231,8 +231,8 @@ describe('alert_form', () => {
toastNotifications: mocks.notifications.toasts,
http: mocks.http,
uiSettings: mocks.uiSettings,
actionTypeRegistry: actionTypeRegistry as any,
alertTypeRegistry: alertTypeRegistry as any,
actionTypeRegistry,
alertTypeRegistry,
docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' },
capabilities,
};
Expand Down Expand Up @@ -332,8 +332,8 @@ describe('alert_form', () => {
toastNotifications: mockes.notifications.toasts,
http: mockes.http,
uiSettings: mockes.uiSettings,
actionTypeRegistry: actionTypeRegistry as any,
alertTypeRegistry: alertTypeRegistry as any,
actionTypeRegistry,
alertTypeRegistry,
};
alertTypeRegistry.list.mockReturnValue([alertType]);
alertTypeRegistry.get.mockReturnValue(alertType);
Expand Down
Loading