Skip to content

Commit f167934

Browse files
committed
Add a link to documentation in the alerts and actions management UI (elastic#81909)
* Add a link to documentation in the alerts and actions management UI * Update label * Remove usage of any on registries # Conflicts: # x-pack/plugins/triggers_actions_ui/public/application/context/alerts_context.tsx
1 parent d168d37 commit f167934

File tree

20 files changed

+158
-58
lines changed

20 files changed

+158
-58
lines changed

x-pack/plugins/triggers_actions_ui/public/application/app.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import {
1818
} from 'kibana/public';
1919
import { Section, routeToAlertDetails } from './constants';
2020
import { AppContextProvider } from './app_context';
21-
import { ActionTypeModel, AlertTypeModel } from '../types';
22-
import { TypeRegistry } from './type_registry';
21+
import { ActionTypeRegistryContract, AlertTypeRegistryContract } from '../types';
2322
import { ChartsPluginStart } from '../../../../../src/plugins/charts/public';
2423
import { DataPublicPluginStart } from '../../../../../src/plugins/data/public';
2524
import { PluginStartContract as AlertingStart } from '../../../alerts/public';
@@ -42,8 +41,8 @@ export interface AppDeps {
4241
uiSettings: IUiSettingsClient;
4342
setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void;
4443
capabilities: ApplicationStart['capabilities'];
45-
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
46-
alertTypeRegistry: TypeRegistry<AlertTypeModel>;
44+
actionTypeRegistry: ActionTypeRegistryContract;
45+
alertTypeRegistry: AlertTypeRegistryContract;
4746
history: ScopedHistory;
4847
}
4948

x-pack/plugins/triggers_actions_ui/public/application/context/actions_connectors_context.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66

77
import React, { createContext, useContext } from 'react';
88
import { HttpSetup, ApplicationStart, DocLinksStart, ToastsSetup } from 'kibana/public';
9-
import { ActionTypeModel, ActionConnector } from '../../types';
10-
import { TypeRegistry } from '../type_registry';
9+
import { ActionTypeRegistryContract, ActionConnector } from '../../types';
1110

1211
export interface ActionsConnectorsContextValue {
1312
http: HttpSetup;
14-
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
13+
actionTypeRegistry: ActionTypeRegistryContract;
1514
toastNotifications: ToastsSetup;
1615
capabilities: ApplicationStart['capabilities'];
1716
reloadConnectors?: () => Promise<ActionConnector[] | void>;

x-pack/plugins/triggers_actions_ui/public/application/context/alerts_context.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ import {
1515
import { ChartsPluginSetup } from 'src/plugins/charts/public';
1616
import { FieldFormatsRegistry } from 'src/plugins/data/common/field_formats';
1717
import { DataPublicPluginStartUi, IndexPatternsContract } from 'src/plugins/data/public';
18-
import { TypeRegistry } from '../type_registry';
19-
import { AlertTypeModel, ActionTypeModel } from '../../types';
18+
import { AlertTypeRegistryContract, ActionTypeRegistryContract } from '../../types';
2019

2120
export interface AlertsContextValue<MetaData = Record<string, any>> {
2221
reloadAlerts?: () => Promise<void>;
2322
http: HttpSetup;
24-
alertTypeRegistry: TypeRegistry<AlertTypeModel>;
25-
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
23+
alertTypeRegistry: AlertTypeRegistryContract;
24+
actionTypeRegistry: ActionTypeRegistryContract;
2625
toastNotifications: ToastsStart;
2726
uiSettings?: IUiSettingsClient;
2827
charts?: ChartsPluginSetup;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import * as React from 'react';
8+
import { RouteComponentProps, Router } from 'react-router-dom';
9+
import { createMemoryHistory, createLocation } from 'history';
10+
import { mountWithIntl } from 'test_utils/enzyme_helpers';
11+
12+
import TriggersActionsUIHome, { MatchParams } from './home';
13+
import { AppContextProvider } from './app_context';
14+
import { getMockedAppDependencies } from './test_utils';
15+
16+
describe('home', () => {
17+
it('renders the documentation link', async () => {
18+
const deps = await getMockedAppDependencies();
19+
20+
const props: RouteComponentProps<MatchParams> = {
21+
history: createMemoryHistory(),
22+
location: createLocation('/'),
23+
match: {
24+
isExact: true,
25+
path: `/alerts`,
26+
url: '',
27+
params: {
28+
section: 'alerts',
29+
},
30+
},
31+
};
32+
const wrapper = mountWithIntl(
33+
<Router history={deps.history}>
34+
<AppContextProvider appDeps={deps}>
35+
<TriggersActionsUIHome {...props} />
36+
</AppContextProvider>
37+
</Router>
38+
);
39+
const documentationLink = wrapper.find('[data-test-subj="documentationLink"]');
40+
expect(documentationLink.exists()).toBeTruthy();
41+
expect(documentationLink.first().prop('href')).toEqual(
42+
'https://www.elastic.co/guide/en/kibana/mocked-test-branch/managing-alerts-and-actions.html'
43+
);
44+
});
45+
});

x-pack/plugins/triggers_actions_ui/public/application/home.tsx

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import { FormattedMessage } from '@kbn/i18n/react';
1010
import {
1111
EuiPageBody,
1212
EuiPageContent,
13-
EuiPageContentHeader,
14-
EuiPageContentHeaderSection,
1513
EuiSpacer,
1614
EuiTab,
1715
EuiTabs,
1816
EuiTitle,
1917
EuiText,
18+
EuiButtonEmpty,
19+
EuiFlexGroup,
20+
EuiFlexItem,
2021
} from '@elastic/eui';
2122

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

33-
interface MatchParams {
34+
export interface MatchParams {
3435
section: Section;
3536
}
3637

@@ -80,27 +81,40 @@ export const TriggersActionsUIHome: React.FunctionComponent<RouteComponentProps<
8081
return (
8182
<EuiPageBody>
8283
<EuiPageContent>
83-
<EuiPageContentHeader>
84-
<EuiPageContentHeaderSection>
85-
<EuiTitle size="m">
84+
<EuiTitle size="m">
85+
<EuiFlexGroup>
86+
<EuiFlexItem>
8687
<h1 data-test-subj="appTitle">
8788
<FormattedMessage
8889
id="xpack.triggersActionsUI.home.appTitle"
8990
defaultMessage="Alerts and Actions"
9091
/>
9192
</h1>
92-
</EuiTitle>
93-
<EuiSpacer size="s" />
94-
<EuiText>
95-
<p>
93+
</EuiFlexItem>
94+
<EuiFlexItem grow={false}>
95+
<EuiButtonEmpty
96+
href={`${docLinks.ELASTIC_WEBSITE_URL}guide/en/kibana/${docLinks.DOC_LINK_VERSION}/managing-alerts-and-actions.html`}
97+
target="_blank"
98+
iconType="help"
99+
data-test-subj="documentationLink"
100+
>
96101
<FormattedMessage
97-
id="xpack.triggersActionsUI.home.sectionDescription"
98-
defaultMessage="Detect conditions using alerts, and take actions using connectors."
102+
id="xpack.triggersActionsUI.home.alertsAndActionsDocsLinkText"
103+
defaultMessage="Documentation"
99104
/>
100-
</p>
101-
</EuiText>
102-
</EuiPageContentHeaderSection>
103-
</EuiPageContentHeader>
105+
</EuiButtonEmpty>
106+
</EuiFlexItem>
107+
</EuiFlexGroup>
108+
</EuiTitle>
109+
<EuiSpacer size="s" />
110+
<EuiText>
111+
<p>
112+
<FormattedMessage
113+
id="xpack.triggersActionsUI.home.sectionDescription"
114+
defaultMessage="Detect conditions using alerts, and take actions using connectors."
115+
/>
116+
</p>
117+
</EuiText>
104118

105119
<EuiTabs>
106120
{tabs.map((tab) => (

x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_connector_form.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('action_connector_form', () => {
2222
] = await mocks.getStartServices();
2323
deps = {
2424
http: mocks.http,
25-
actionTypeRegistry: actionTypeRegistry as any,
25+
actionTypeRegistry,
2626
docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' },
2727
capabilities,
2828
};

x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_connector_form.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ import { ReducerAction } from './connector_reducer';
2424
import {
2525
ActionConnector,
2626
IErrorObject,
27-
ActionTypeModel,
27+
ActionTypeRegistryContract,
2828
UserConfiguredActionConnector,
2929
} from '../../../types';
30-
import { TypeRegistry } from '../../type_registry';
3130
import { hasSaveActionsCapability } from '../../lib/capabilities';
3231

3332
export function validateBaseProperties(actionObject: ActionConnector) {
@@ -61,7 +60,7 @@ interface ActionConnectorProps<
6160
};
6261
errors: IErrorObject;
6362
http: HttpSetup;
64-
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
63+
actionTypeRegistry: ActionTypeRegistryContract;
6564
docLinks: DocLinksStart;
6665
capabilities: ApplicationStart['capabilities'];
6766
consumer?: string;

x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ describe('action_form', () => {
178178
},
179179
},
180180
setHasActionsWithBrokenConnector: jest.fn(),
181-
actionTypeRegistry: actionTypeRegistry as any,
181+
actionTypeRegistry,
182182
docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' },
183183
};
184184
actionTypeRegistry.list.mockReturnValue([

x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { loadActionTypes, loadAllActions as loadConnectors } from '../../lib/act
3434
import {
3535
IErrorObject,
3636
ActionTypeModel,
37+
ActionTypeRegistryContract,
3738
AlertAction,
3839
ActionTypeIndex,
3940
ActionConnector,
@@ -42,7 +43,6 @@ import {
4243
} from '../../../types';
4344
import { SectionLoading } from '../../components/section_loading';
4445
import { ConnectorAddModal } from './connector_add_modal';
45-
import { TypeRegistry } from '../../type_registry';
4646
import { actionTypeCompare } from '../../lib/action_type_compare';
4747
import { checkActionFormActionTypeEnabled } from '../../lib/check_action_type_enabled';
4848
import { VIEW_LICENSE_OPTIONS_LINK } from '../../../common/constants';
@@ -55,7 +55,7 @@ interface ActionAccordionFormProps {
5555
setAlertProperty: (actions: AlertAction[]) => void;
5656
setActionParamsProperty: (key: string, value: any, index: number) => void;
5757
http: HttpSetup;
58-
actionTypeRegistry: TypeRegistry<ActionTypeModel>;
58+
actionTypeRegistry: ActionTypeRegistryContract;
5959
toastNotifications: ToastsSetup;
6060
docLinks: DocLinksStart;
6161
actionTypes?: ActionType[];

x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_menu.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('connector_add_flyout', () => {
3333
show: true,
3434
},
3535
},
36-
actionTypeRegistry: actionTypeRegistry as any,
36+
actionTypeRegistry,
3737
docLinks: { ELASTIC_WEBSITE_URL: '', DOC_LINK_VERSION: '' },
3838
};
3939
});

0 commit comments

Comments
 (0)