Skip to content

Commit b458b3b

Browse files
YulNaumenkosnide
andauthored
Implement UI for Create Alert form (#55232)
* Updated Alert ui model, fixed form validation and small issues * Fixed error messages and validation for action params forms * Fixed typecheck error * Moved alert add/edit common fields to alert form * Fixed type checks * Refactored alert add flyout by splitting it to the form and flyout components, added some unit tests * Refactored connector add/edit flyouts and created add connector modal * Refactored add/edit flyout tests * Fixed test * Removed orig files * Removed orig file * Added unit tests for add connector modal dialog * Action Groups idea of implementation * Removed action group tabs and set only first action group as default (temporary till design will be ready for support multiple groups) * Added missing unit tests * Changed design of the email params form * Fixed actions params forms according to latest mockups * Fixed options list for available actions connectors * Fixed modal dialog update on action delete * fixed build fail * Added functionality for action types with Message field to Add variables * Added alertReducer unit tests * Added create alert functional test * Added types for Params * Some design fixes * alerts empty prompt * Fixed failing app on save alert and added possibility to hide Change trigger button * Fixed type check issues * Added connector config types * fixed type check * Fixed merge issues * Fixed type checks * Fixed functional tests and error expression message * Fixed jest tests * Review changes Co-authored-by: [email protected] <[email protected]>
1 parent b92e8e2 commit b458b3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3160
-1661
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const App = (appDeps: AppDeps) => {
4848
);
4949
};
5050

51-
export const AppWithoutRouter = ({ sectionsRegex }: any) => {
51+
export const AppWithoutRouter = ({ sectionsRegex }: { sectionsRegex: string }) => {
5252
const { capabilities } = useAppDependencies();
5353
const canShowAlerts = hasShowAlertsCapability(capabilities);
5454
const DEFAULT_SECTION: Section = canShowAlerts ? 'alerts' : 'connectors';

x-pack/legacy/plugins/triggers_actions_ui/np_ready/public/application/components/builtin_action_types/email.test.tsx

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6-
import React from 'react';
6+
import React, { FunctionComponent } from 'react';
77
import { mountWithIntl } from 'test_utils/enzyme_helpers';
88
import { TypeRegistry } from '../../type_registry';
99
import { registerBuiltInActionTypes } from './index';
10-
import { ActionTypeModel, ActionConnector } from '../../../types';
10+
import { ActionTypeModel, ActionParamsProps } from '../../../types';
11+
import { EmailActionParams, EmailActionConnector } from './types';
1112

1213
const ACTION_TYPE_ID = '.email';
1314
let actionTypeModel: ActionTypeModel;
@@ -40,43 +41,15 @@ describe('connector validation', () => {
4041
name: 'email',
4142
config: {
4243
43-
port: '2323',
44+
port: 2323,
4445
host: 'localhost',
4546
test: 'test',
4647
},
47-
} as ActionConnector;
48+
} as EmailActionConnector;
4849

4950
expect(actionTypeModel.validateConnector(actionConnector)).toEqual({
5051
errors: {
5152
from: [],
52-
service: [],
53-
port: [],
54-
host: [],
55-
user: [],
56-
password: [],
57-
},
58-
});
59-
60-
delete actionConnector.config.test;
61-
actionConnector.config.host = 'elastic.co';
62-
actionConnector.config.port = 8080;
63-
expect(actionTypeModel.validateConnector(actionConnector)).toEqual({
64-
errors: {
65-
from: [],
66-
service: [],
67-
port: [],
68-
host: [],
69-
user: [],
70-
password: [],
71-
},
72-
});
73-
delete actionConnector.config.host;
74-
delete actionConnector.config.port;
75-
actionConnector.config.service = 'testService';
76-
expect(actionTypeModel.validateConnector(actionConnector)).toEqual({
77-
errors: {
78-
from: [],
79-
service: [],
8053
port: [],
8154
host: [],
8255
user: [],
@@ -97,12 +70,11 @@ describe('connector validation', () => {
9770
config: {
9871
9972
},
100-
} as ActionConnector;
73+
} as EmailActionConnector;
10174

10275
expect(actionTypeModel.validateConnector(actionConnector)).toEqual({
10376
errors: {
10477
from: [],
105-
service: ['Service is required.'],
10678
port: ['Port is required.'],
10779
host: ['Host is required.'],
10880
user: [],
@@ -168,14 +140,13 @@ describe('EmailActionConnectorFields renders', () => {
168140
config: {
169141
170142
},
171-
} as ActionConnector;
143+
} as EmailActionConnector;
172144
const wrapper = mountWithIntl(
173145
<ConnectorFields
174146
action={actionConnector}
175-
errors={{ from: [], service: [], port: [], host: [], user: [], password: [] }}
147+
errors={{ from: [], port: [], host: [], user: [], password: [] }}
176148
editActionConfig={() => {}}
177149
editActionSecrets={() => {}}
178-
hasErrors={false}
179150
/>
180151
);
181152
expect(wrapper.find('[data-test-subj="emailFromInput"]').length > 0).toBeTruthy();
@@ -198,19 +169,22 @@ describe('EmailParamsFields renders', () => {
198169
if (!actionTypeModel.actionParamsFields) {
199170
return;
200171
}
201-
const ParamsFields = actionTypeModel.actionParamsFields;
172+
const ParamsFields = actionTypeModel.actionParamsFields as FunctionComponent<
173+
ActionParamsProps<EmailActionParams>
174+
>;
202175
const actionParams = {
176+
cc: [],
177+
bcc: [],
203178
204179
subject: 'test',
205180
message: 'test message',
206181
};
207182
const wrapper = mountWithIntl(
208183
<ParamsFields
209-
action={actionParams}
210-
errors={{}}
184+
actionParams={actionParams}
185+
errors={{ to: [], cc: [], bcc: [], subject: [], message: [] }}
211186
editAction={() => {}}
212187
index={0}
213-
hasErrors={false}
214188
/>
215189
);
216190
expect(wrapper.find('[data-test-subj="toEmailAddressInput"]').length > 0).toBeTruthy();
@@ -220,8 +194,6 @@ describe('EmailParamsFields renders', () => {
220194
.first()
221195
.prop('selectedOptions')
222196
).toStrictEqual([{ label: '[email protected]' }]);
223-
expect(wrapper.find('[data-test-subj="ccEmailAddressInput"]').length > 0).toBeTruthy();
224-
expect(wrapper.find('[data-test-subj="bccEmailAddressInput"]').length > 0).toBeTruthy();
225197
expect(wrapper.find('[data-test-subj="emailSubjectInput"]').length > 0).toBeTruthy();
226198
expect(wrapper.find('[data-test-subj="emailMessageInput"]').length > 0).toBeTruthy();
227199
});

0 commit comments

Comments
 (0)