foreman_webhooks 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/api/v2/webhooks_controller.rb +7 -1
- data/app/controllers/concerns/foreman_webhooks/controller/parameters/webhook.rb +1 -0
- data/app/controllers/webhooks_controller.rb +1 -24
- data/app/services/foreman_webhooks/webhook_service.rb +1 -1
- data/app/views/foreman_webhooks/webhook_templates/remote_execution_-_host_job.erb +0 -1
- data/config/routes.rb +6 -2
- data/lib/foreman_webhooks/engine.rb +2 -2
- data/lib/foreman_webhooks/version.rb +1 -1
- data/package.json +6 -6
- data/webpack/ForemanWebhooks/Routes/ForemanWebhooksRoutes.js +2 -2
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/ForemanFormikField.js +117 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/WebhookFormTabs.css +7 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/WebhookFormTabs.js +163 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/WebhookForm.js +69 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/WebhookFormSelectors.js +58 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/__tests__/WebhookForm.test.js +51 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/__tests__/__snapshots__/WebhookForm.test.js.snap +510 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/constants.js +9 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/index.js +73 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/EmptyWebhooksIndexPage/index.js +63 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookCreateModal.js +69 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookDeleteModal.js +1 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookEditModal.js +107 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookEditModalSelectors.js +22 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookModal.scss +6 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/index.js +1 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/nameToEditFormatter.js +19 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/NameToEditCell.js +35 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/WebhooksTable.js +31 -14
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/WebhooksTableSchema.js +12 -4
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/__tests__/WebhooksTable.test.js +13 -4
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/__tests__/__snapshots__/WebhooksTable.test.js.snap +62 -19
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/index.js +27 -5
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/WebhooksIndexPage.js +61 -32
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/WebhooksIndexPage.fixtures.js +36 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/WebhooksIndexPage.test.js +3 -1
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/__snapshots__/WebhooksIndexPage.test.js.snap +18 -60
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/__snapshots__/integration.test.js.snap +43 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/integration.test.js +34 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksPageActions.js +3 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/constants.js +11 -1
- data/webpack/__mocks__/foremanReact/Root/Context/ForemanContext.js +1 -0
- data/webpack/__mocks__/foremanReact/common/HOC.js +26 -1
- data/webpack/__mocks__/foremanReact/common/urlHelpers.js +7 -0
- data/webpack/__mocks__/foremanReact/components/ForemanModal/index.js +6 -1
- data/webpack/__mocks__/foremanReact/components/Loading/Loading.js +2 -0
- data/webpack/__mocks__/foremanReact/components/Loading/index.js +3 -0
- data/webpack/__mocks__/foremanReact/components/Pagination/PaginationWrapper.js +3 -1
- data/webpack/__mocks__/foremanReact/components/common/forms/ForemanForm.js +9 -0
- data/webpack/__mocks__/foremanReact/components/common/forms/FormField.js +3 -0
- data/webpack/__mocks__/foremanReact/components/common/table.js +21 -0
- data/webpack/__mocks__/foremanReact/history.js +3 -0
- data/webpack/__mocks__/foremanReact/redux/actions/common/forms.js +1 -0
- data/webpack/test_setup.js +15 -0
- metadata +30 -7
- data/app/views/webhooks/_form.html.erb +0 -38
- data/app/views/webhooks/_templates.html.erb +0 -5
- data/app/views/webhooks/edit.html.erb +0 -3
- data/app/views/webhooks/new.html.erb +0 -3
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/EmptyWebhooksTable/index.js +0 -29
@@ -0,0 +1,69 @@
|
|
1
|
+
import React, { useState } from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import * as Yup from 'yup';
|
4
|
+
|
5
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
6
|
+
import ForemanForm from 'foremanReact/components/common/forms/ForemanForm';
|
7
|
+
|
8
|
+
import WebhookFormTabs from './Components/WebhookFormTabs';
|
9
|
+
|
10
|
+
import { HTTP_METHODS, WEBHOOK_ITEM } from './constants';
|
11
|
+
|
12
|
+
const webhookFormSchema = Yup.object().shape({
|
13
|
+
name: Yup.string().required(__('is required')),
|
14
|
+
target_url: Yup.string().required(__('is required')),
|
15
|
+
http_method: Yup.string().required(__('is required')),
|
16
|
+
event: Yup.string().required(__('is required')),
|
17
|
+
webhook_template_id: Yup.string().required(__('is required')),
|
18
|
+
});
|
19
|
+
|
20
|
+
const WebhookForm = ({
|
21
|
+
onCancel,
|
22
|
+
handleSubmit,
|
23
|
+
initialValues,
|
24
|
+
templates,
|
25
|
+
availableEvents,
|
26
|
+
isTemplatesLoading,
|
27
|
+
isEventsLoading,
|
28
|
+
}) => {
|
29
|
+
const webhookTemplates = templates.map(t => ({ value: t.id, label: t.name }));
|
30
|
+
|
31
|
+
const [activeTab, setActiveTab] = useState(0);
|
32
|
+
const handleTabClick = (event, tabIndex) => {
|
33
|
+
event.preventDefault();
|
34
|
+
setActiveTab(tabIndex);
|
35
|
+
};
|
36
|
+
|
37
|
+
return (
|
38
|
+
<ForemanForm
|
39
|
+
onSubmit={handleSubmit}
|
40
|
+
initialValues={initialValues}
|
41
|
+
validationSchema={webhookFormSchema}
|
42
|
+
onCancel={onCancel}
|
43
|
+
enableReinitialize
|
44
|
+
item={WEBHOOK_ITEM}
|
45
|
+
>
|
46
|
+
<WebhookFormTabs
|
47
|
+
activeTab={activeTab}
|
48
|
+
handleTabClick={handleTabClick}
|
49
|
+
webhookTemplates={webhookTemplates}
|
50
|
+
httpMethods={HTTP_METHODS}
|
51
|
+
availableEvents={availableEvents}
|
52
|
+
isEventsLoading={isEventsLoading}
|
53
|
+
isTemplatesLoading={isTemplatesLoading}
|
54
|
+
/>
|
55
|
+
</ForemanForm>
|
56
|
+
);
|
57
|
+
};
|
58
|
+
|
59
|
+
WebhookForm.propTypes = {
|
60
|
+
onCancel: PropTypes.func.isRequired,
|
61
|
+
handleSubmit: PropTypes.func.isRequired,
|
62
|
+
initialValues: PropTypes.object.isRequired,
|
63
|
+
templates: PropTypes.array.isRequired,
|
64
|
+
availableEvents: PropTypes.array.isRequired,
|
65
|
+
isEventsLoading: PropTypes.bool.isRequired,
|
66
|
+
isTemplatesLoading: PropTypes.bool.isRequired,
|
67
|
+
};
|
68
|
+
|
69
|
+
export default WebhookForm;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { STATUS } from 'foremanReact/constants';
|
2
|
+
import { deepPropsToCamelCase } from 'foremanReact/common/helpers';
|
3
|
+
import {
|
4
|
+
selectAPIStatus,
|
5
|
+
selectAPIResponse,
|
6
|
+
} from 'foremanReact/redux/API/APISelectors';
|
7
|
+
|
8
|
+
import {
|
9
|
+
WEBHOOK_TEMPLATES_API_REQUEST_KEY,
|
10
|
+
WEBHOOK_EVENTS_API_REQUEST_KEY,
|
11
|
+
} from '../../constants';
|
12
|
+
|
13
|
+
// Webhook templates selectors
|
14
|
+
const selectWebhookFormTemplatesResponse = state =>
|
15
|
+
deepPropsToCamelCase(
|
16
|
+
selectAPIResponse(state, WEBHOOK_TEMPLATES_API_REQUEST_KEY)
|
17
|
+
);
|
18
|
+
|
19
|
+
const selectWebhookFormTemplatesStatus = state =>
|
20
|
+
selectAPIStatus(state, WEBHOOK_TEMPLATES_API_REQUEST_KEY);
|
21
|
+
|
22
|
+
export const selectTemplatesHasError = state =>
|
23
|
+
selectWebhookFormTemplatesStatus(state) === STATUS.ERROR;
|
24
|
+
|
25
|
+
export const selectTemplatesIsLoading = state => {
|
26
|
+
const status = selectWebhookFormTemplatesStatus(state);
|
27
|
+
return !status || status === STATUS.PENDING;
|
28
|
+
};
|
29
|
+
|
30
|
+
export const selectWebhookTemplates = state => {
|
31
|
+
if (selectTemplatesHasError(state) || selectTemplatesIsLoading(state))
|
32
|
+
return [];
|
33
|
+
|
34
|
+
return selectWebhookFormTemplatesResponse(state).results;
|
35
|
+
};
|
36
|
+
|
37
|
+
// Webhook events selectors
|
38
|
+
const selectWebhookFormEventsResponse = state =>
|
39
|
+
deepPropsToCamelCase(
|
40
|
+
selectAPIResponse(state, WEBHOOK_EVENTS_API_REQUEST_KEY)
|
41
|
+
);
|
42
|
+
|
43
|
+
const selectWebhookFormEventsStatus = state =>
|
44
|
+
selectAPIStatus(state, WEBHOOK_EVENTS_API_REQUEST_KEY);
|
45
|
+
|
46
|
+
export const selectEventsHasError = state =>
|
47
|
+
selectWebhookFormEventsStatus(state) === STATUS.ERROR;
|
48
|
+
|
49
|
+
export const selectEventsIsLoading = state => {
|
50
|
+
const status = selectWebhookFormEventsStatus(state);
|
51
|
+
return !status || status === STATUS.PENDING;
|
52
|
+
};
|
53
|
+
|
54
|
+
export const selectWebhookEvents = state => {
|
55
|
+
if (selectEventsHasError(state) || selectEventsIsLoading(state)) return [];
|
56
|
+
|
57
|
+
return selectWebhookFormEventsResponse(state);
|
58
|
+
};
|
data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/__tests__/WebhookForm.test.js
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
2
|
+
|
3
|
+
import WebhookForm from '../WebhookForm';
|
4
|
+
|
5
|
+
const props = {
|
6
|
+
handleSubmit: jest.fn(),
|
7
|
+
onCancel: jest.fn(),
|
8
|
+
onSuccess: jest.fn(),
|
9
|
+
templates: [
|
10
|
+
{ id: 204, name: 'default template' },
|
11
|
+
{ id: 205, name: 'default template clone' },
|
12
|
+
],
|
13
|
+
availableEvents: ['host_created'],
|
14
|
+
isEventsLoading: false,
|
15
|
+
isTemplatesLoading: false,
|
16
|
+
};
|
17
|
+
|
18
|
+
const fixtures = {
|
19
|
+
'should render for new page': {
|
20
|
+
...props,
|
21
|
+
initialValues: {
|
22
|
+
http_method: 'POST',
|
23
|
+
enabled: true,
|
24
|
+
verify_ssl: true,
|
25
|
+
http_content_type: 'application/json',
|
26
|
+
event: 'host_created.event.foreman',
|
27
|
+
},
|
28
|
+
},
|
29
|
+
'should render for edit page': {
|
30
|
+
...props,
|
31
|
+
initialValues: {
|
32
|
+
id: 54,
|
33
|
+
http_method: 'PUT',
|
34
|
+
enabled: true,
|
35
|
+
verify_ssl: true,
|
36
|
+
http_content_type: 'application/json',
|
37
|
+
event: 'host_created.event.foreman',
|
38
|
+
name: 'first webhook',
|
39
|
+
target_url: 'https://foreman.example.com',
|
40
|
+
user: undefined,
|
41
|
+
password: undefined,
|
42
|
+
webhook_template_id: 204,
|
43
|
+
ssl_ca_certs: undefined,
|
44
|
+
},
|
45
|
+
},
|
46
|
+
};
|
47
|
+
|
48
|
+
describe('WebhookForm', () => {
|
49
|
+
describe('rendering', () =>
|
50
|
+
testComponentSnapshotsWithFixtures(WebhookForm, fixtures));
|
51
|
+
});
|
@@ -0,0 +1,510 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`WebhookForm rendering should render for edit page 1`] = `
|
4
|
+
<ForemanForm
|
5
|
+
enableReinitialize={true}
|
6
|
+
initialValues={
|
7
|
+
Object {
|
8
|
+
"enabled": true,
|
9
|
+
"event": "host_created.event.foreman",
|
10
|
+
"http_content_type": "application/json",
|
11
|
+
"http_method": "PUT",
|
12
|
+
"id": 54,
|
13
|
+
"name": "first webhook",
|
14
|
+
"password": undefined,
|
15
|
+
"ssl_ca_certs": undefined,
|
16
|
+
"target_url": "https://foreman.example.com",
|
17
|
+
"user": undefined,
|
18
|
+
"verify_ssl": true,
|
19
|
+
"webhook_template_id": 204,
|
20
|
+
}
|
21
|
+
}
|
22
|
+
item="Webhook"
|
23
|
+
onCancel={[MockFunction]}
|
24
|
+
onSubmit={[MockFunction]}
|
25
|
+
validationSchema={
|
26
|
+
ObjectSchema {
|
27
|
+
"_blacklist": RefSet {
|
28
|
+
"list": Array [],
|
29
|
+
"refs": Array [],
|
30
|
+
},
|
31
|
+
"_conditions": Array [],
|
32
|
+
"_defaultDefault": [Function],
|
33
|
+
"_deps": Array [],
|
34
|
+
"_excludedEdges": Array [],
|
35
|
+
"_exclusive": Object {},
|
36
|
+
"_mutate": undefined,
|
37
|
+
"_nodes": Array [
|
38
|
+
"webhook_template_id",
|
39
|
+
"event",
|
40
|
+
"http_method",
|
41
|
+
"target_url",
|
42
|
+
"name",
|
43
|
+
],
|
44
|
+
"_options": Object {
|
45
|
+
"abortEarly": true,
|
46
|
+
"recursive": true,
|
47
|
+
},
|
48
|
+
"_type": "object",
|
49
|
+
"_typeError": [Function],
|
50
|
+
"_whitelist": RefSet {
|
51
|
+
"list": Array [],
|
52
|
+
"refs": Array [],
|
53
|
+
},
|
54
|
+
"fields": Object {
|
55
|
+
"event": StringSchema {
|
56
|
+
"_blacklist": RefSet {
|
57
|
+
"list": Array [],
|
58
|
+
"refs": Array [],
|
59
|
+
},
|
60
|
+
"_conditions": Array [],
|
61
|
+
"_deps": Array [],
|
62
|
+
"_exclusive": Object {
|
63
|
+
"required": true,
|
64
|
+
},
|
65
|
+
"_mutate": undefined,
|
66
|
+
"_options": Object {
|
67
|
+
"abortEarly": true,
|
68
|
+
"recursive": true,
|
69
|
+
},
|
70
|
+
"_type": "string",
|
71
|
+
"_typeError": [Function],
|
72
|
+
"_whitelist": RefSet {
|
73
|
+
"list": Array [],
|
74
|
+
"refs": Array [],
|
75
|
+
},
|
76
|
+
"tests": Array [
|
77
|
+
[Function],
|
78
|
+
],
|
79
|
+
"transforms": Array [
|
80
|
+
[Function],
|
81
|
+
],
|
82
|
+
"type": "string",
|
83
|
+
},
|
84
|
+
"http_method": StringSchema {
|
85
|
+
"_blacklist": RefSet {
|
86
|
+
"list": Array [],
|
87
|
+
"refs": Array [],
|
88
|
+
},
|
89
|
+
"_conditions": Array [],
|
90
|
+
"_deps": Array [],
|
91
|
+
"_exclusive": Object {
|
92
|
+
"required": true,
|
93
|
+
},
|
94
|
+
"_mutate": undefined,
|
95
|
+
"_options": Object {
|
96
|
+
"abortEarly": true,
|
97
|
+
"recursive": true,
|
98
|
+
},
|
99
|
+
"_type": "string",
|
100
|
+
"_typeError": [Function],
|
101
|
+
"_whitelist": RefSet {
|
102
|
+
"list": Array [],
|
103
|
+
"refs": Array [],
|
104
|
+
},
|
105
|
+
"tests": Array [
|
106
|
+
[Function],
|
107
|
+
],
|
108
|
+
"transforms": Array [
|
109
|
+
[Function],
|
110
|
+
],
|
111
|
+
"type": "string",
|
112
|
+
},
|
113
|
+
"name": StringSchema {
|
114
|
+
"_blacklist": RefSet {
|
115
|
+
"list": Array [],
|
116
|
+
"refs": Array [],
|
117
|
+
},
|
118
|
+
"_conditions": Array [],
|
119
|
+
"_deps": Array [],
|
120
|
+
"_exclusive": Object {
|
121
|
+
"required": true,
|
122
|
+
},
|
123
|
+
"_mutate": undefined,
|
124
|
+
"_options": Object {
|
125
|
+
"abortEarly": true,
|
126
|
+
"recursive": true,
|
127
|
+
},
|
128
|
+
"_type": "string",
|
129
|
+
"_typeError": [Function],
|
130
|
+
"_whitelist": RefSet {
|
131
|
+
"list": Array [],
|
132
|
+
"refs": Array [],
|
133
|
+
},
|
134
|
+
"tests": Array [
|
135
|
+
[Function],
|
136
|
+
],
|
137
|
+
"transforms": Array [
|
138
|
+
[Function],
|
139
|
+
],
|
140
|
+
"type": "string",
|
141
|
+
},
|
142
|
+
"target_url": StringSchema {
|
143
|
+
"_blacklist": RefSet {
|
144
|
+
"list": Array [],
|
145
|
+
"refs": Array [],
|
146
|
+
},
|
147
|
+
"_conditions": Array [],
|
148
|
+
"_deps": Array [],
|
149
|
+
"_exclusive": Object {
|
150
|
+
"required": true,
|
151
|
+
},
|
152
|
+
"_mutate": undefined,
|
153
|
+
"_options": Object {
|
154
|
+
"abortEarly": true,
|
155
|
+
"recursive": true,
|
156
|
+
},
|
157
|
+
"_type": "string",
|
158
|
+
"_typeError": [Function],
|
159
|
+
"_whitelist": RefSet {
|
160
|
+
"list": Array [],
|
161
|
+
"refs": Array [],
|
162
|
+
},
|
163
|
+
"tests": Array [
|
164
|
+
[Function],
|
165
|
+
],
|
166
|
+
"transforms": Array [
|
167
|
+
[Function],
|
168
|
+
],
|
169
|
+
"type": "string",
|
170
|
+
},
|
171
|
+
"webhook_template_id": StringSchema {
|
172
|
+
"_blacklist": RefSet {
|
173
|
+
"list": Array [],
|
174
|
+
"refs": Array [],
|
175
|
+
},
|
176
|
+
"_conditions": Array [],
|
177
|
+
"_deps": Array [],
|
178
|
+
"_exclusive": Object {
|
179
|
+
"required": true,
|
180
|
+
},
|
181
|
+
"_mutate": undefined,
|
182
|
+
"_options": Object {
|
183
|
+
"abortEarly": true,
|
184
|
+
"recursive": true,
|
185
|
+
},
|
186
|
+
"_type": "string",
|
187
|
+
"_typeError": [Function],
|
188
|
+
"_whitelist": RefSet {
|
189
|
+
"list": Array [],
|
190
|
+
"refs": Array [],
|
191
|
+
},
|
192
|
+
"tests": Array [
|
193
|
+
[Function],
|
194
|
+
],
|
195
|
+
"transforms": Array [
|
196
|
+
[Function],
|
197
|
+
],
|
198
|
+
"type": "string",
|
199
|
+
},
|
200
|
+
},
|
201
|
+
"tests": Array [],
|
202
|
+
"transforms": Array [
|
203
|
+
[Function],
|
204
|
+
],
|
205
|
+
"type": "object",
|
206
|
+
}
|
207
|
+
}
|
208
|
+
>
|
209
|
+
<WebhookFormTabs
|
210
|
+
activeTab={0}
|
211
|
+
availableEvents={
|
212
|
+
Array [
|
213
|
+
"host_created",
|
214
|
+
]
|
215
|
+
}
|
216
|
+
disabled={false}
|
217
|
+
formProps={Object {}}
|
218
|
+
handleTabClick={[Function]}
|
219
|
+
httpMethods={
|
220
|
+
Array [
|
221
|
+
Object {
|
222
|
+
"label": "POST",
|
223
|
+
"value": "POST",
|
224
|
+
},
|
225
|
+
Object {
|
226
|
+
"label": "GET",
|
227
|
+
"value": "GET",
|
228
|
+
},
|
229
|
+
Object {
|
230
|
+
"label": "PUT",
|
231
|
+
"value": "PUT",
|
232
|
+
},
|
233
|
+
Object {
|
234
|
+
"label": "DELETE",
|
235
|
+
"value": "DELETE",
|
236
|
+
},
|
237
|
+
Object {
|
238
|
+
"label": "PATCH",
|
239
|
+
"value": "PATCH",
|
240
|
+
},
|
241
|
+
]
|
242
|
+
}
|
243
|
+
isEventsLoading={false}
|
244
|
+
isTemplatesLoading={false}
|
245
|
+
webhookTemplates={
|
246
|
+
Array [
|
247
|
+
Object {
|
248
|
+
"label": "default template",
|
249
|
+
"value": 204,
|
250
|
+
},
|
251
|
+
Object {
|
252
|
+
"label": "default template clone",
|
253
|
+
"value": 205,
|
254
|
+
},
|
255
|
+
]
|
256
|
+
}
|
257
|
+
/>
|
258
|
+
</ForemanForm>
|
259
|
+
`;
|
260
|
+
|
261
|
+
exports[`WebhookForm rendering should render for new page 1`] = `
|
262
|
+
<ForemanForm
|
263
|
+
enableReinitialize={true}
|
264
|
+
initialValues={
|
265
|
+
Object {
|
266
|
+
"enabled": true,
|
267
|
+
"event": "host_created.event.foreman",
|
268
|
+
"http_content_type": "application/json",
|
269
|
+
"http_method": "POST",
|
270
|
+
"verify_ssl": true,
|
271
|
+
}
|
272
|
+
}
|
273
|
+
item="Webhook"
|
274
|
+
onCancel={[MockFunction]}
|
275
|
+
onSubmit={[MockFunction]}
|
276
|
+
validationSchema={
|
277
|
+
ObjectSchema {
|
278
|
+
"_blacklist": RefSet {
|
279
|
+
"list": Array [],
|
280
|
+
"refs": Array [],
|
281
|
+
},
|
282
|
+
"_conditions": Array [],
|
283
|
+
"_defaultDefault": [Function],
|
284
|
+
"_deps": Array [],
|
285
|
+
"_excludedEdges": Array [],
|
286
|
+
"_exclusive": Object {},
|
287
|
+
"_mutate": undefined,
|
288
|
+
"_nodes": Array [
|
289
|
+
"webhook_template_id",
|
290
|
+
"event",
|
291
|
+
"http_method",
|
292
|
+
"target_url",
|
293
|
+
"name",
|
294
|
+
],
|
295
|
+
"_options": Object {
|
296
|
+
"abortEarly": true,
|
297
|
+
"recursive": true,
|
298
|
+
},
|
299
|
+
"_type": "object",
|
300
|
+
"_typeError": [Function],
|
301
|
+
"_whitelist": RefSet {
|
302
|
+
"list": Array [],
|
303
|
+
"refs": Array [],
|
304
|
+
},
|
305
|
+
"fields": Object {
|
306
|
+
"event": StringSchema {
|
307
|
+
"_blacklist": RefSet {
|
308
|
+
"list": Array [],
|
309
|
+
"refs": Array [],
|
310
|
+
},
|
311
|
+
"_conditions": Array [],
|
312
|
+
"_deps": Array [],
|
313
|
+
"_exclusive": Object {
|
314
|
+
"required": true,
|
315
|
+
},
|
316
|
+
"_mutate": undefined,
|
317
|
+
"_options": Object {
|
318
|
+
"abortEarly": true,
|
319
|
+
"recursive": true,
|
320
|
+
},
|
321
|
+
"_type": "string",
|
322
|
+
"_typeError": [Function],
|
323
|
+
"_whitelist": RefSet {
|
324
|
+
"list": Array [],
|
325
|
+
"refs": Array [],
|
326
|
+
},
|
327
|
+
"tests": Array [
|
328
|
+
[Function],
|
329
|
+
],
|
330
|
+
"transforms": Array [
|
331
|
+
[Function],
|
332
|
+
],
|
333
|
+
"type": "string",
|
334
|
+
},
|
335
|
+
"http_method": StringSchema {
|
336
|
+
"_blacklist": RefSet {
|
337
|
+
"list": Array [],
|
338
|
+
"refs": Array [],
|
339
|
+
},
|
340
|
+
"_conditions": Array [],
|
341
|
+
"_deps": Array [],
|
342
|
+
"_exclusive": Object {
|
343
|
+
"required": true,
|
344
|
+
},
|
345
|
+
"_mutate": undefined,
|
346
|
+
"_options": Object {
|
347
|
+
"abortEarly": true,
|
348
|
+
"recursive": true,
|
349
|
+
},
|
350
|
+
"_type": "string",
|
351
|
+
"_typeError": [Function],
|
352
|
+
"_whitelist": RefSet {
|
353
|
+
"list": Array [],
|
354
|
+
"refs": Array [],
|
355
|
+
},
|
356
|
+
"tests": Array [
|
357
|
+
[Function],
|
358
|
+
],
|
359
|
+
"transforms": Array [
|
360
|
+
[Function],
|
361
|
+
],
|
362
|
+
"type": "string",
|
363
|
+
},
|
364
|
+
"name": StringSchema {
|
365
|
+
"_blacklist": RefSet {
|
366
|
+
"list": Array [],
|
367
|
+
"refs": Array [],
|
368
|
+
},
|
369
|
+
"_conditions": Array [],
|
370
|
+
"_deps": Array [],
|
371
|
+
"_exclusive": Object {
|
372
|
+
"required": true,
|
373
|
+
},
|
374
|
+
"_mutate": undefined,
|
375
|
+
"_options": Object {
|
376
|
+
"abortEarly": true,
|
377
|
+
"recursive": true,
|
378
|
+
},
|
379
|
+
"_type": "string",
|
380
|
+
"_typeError": [Function],
|
381
|
+
"_whitelist": RefSet {
|
382
|
+
"list": Array [],
|
383
|
+
"refs": Array [],
|
384
|
+
},
|
385
|
+
"tests": Array [
|
386
|
+
[Function],
|
387
|
+
],
|
388
|
+
"transforms": Array [
|
389
|
+
[Function],
|
390
|
+
],
|
391
|
+
"type": "string",
|
392
|
+
},
|
393
|
+
"target_url": StringSchema {
|
394
|
+
"_blacklist": RefSet {
|
395
|
+
"list": Array [],
|
396
|
+
"refs": Array [],
|
397
|
+
},
|
398
|
+
"_conditions": Array [],
|
399
|
+
"_deps": Array [],
|
400
|
+
"_exclusive": Object {
|
401
|
+
"required": true,
|
402
|
+
},
|
403
|
+
"_mutate": undefined,
|
404
|
+
"_options": Object {
|
405
|
+
"abortEarly": true,
|
406
|
+
"recursive": true,
|
407
|
+
},
|
408
|
+
"_type": "string",
|
409
|
+
"_typeError": [Function],
|
410
|
+
"_whitelist": RefSet {
|
411
|
+
"list": Array [],
|
412
|
+
"refs": Array [],
|
413
|
+
},
|
414
|
+
"tests": Array [
|
415
|
+
[Function],
|
416
|
+
],
|
417
|
+
"transforms": Array [
|
418
|
+
[Function],
|
419
|
+
],
|
420
|
+
"type": "string",
|
421
|
+
},
|
422
|
+
"webhook_template_id": StringSchema {
|
423
|
+
"_blacklist": RefSet {
|
424
|
+
"list": Array [],
|
425
|
+
"refs": Array [],
|
426
|
+
},
|
427
|
+
"_conditions": Array [],
|
428
|
+
"_deps": Array [],
|
429
|
+
"_exclusive": Object {
|
430
|
+
"required": true,
|
431
|
+
},
|
432
|
+
"_mutate": undefined,
|
433
|
+
"_options": Object {
|
434
|
+
"abortEarly": true,
|
435
|
+
"recursive": true,
|
436
|
+
},
|
437
|
+
"_type": "string",
|
438
|
+
"_typeError": [Function],
|
439
|
+
"_whitelist": RefSet {
|
440
|
+
"list": Array [],
|
441
|
+
"refs": Array [],
|
442
|
+
},
|
443
|
+
"tests": Array [
|
444
|
+
[Function],
|
445
|
+
],
|
446
|
+
"transforms": Array [
|
447
|
+
[Function],
|
448
|
+
],
|
449
|
+
"type": "string",
|
450
|
+
},
|
451
|
+
},
|
452
|
+
"tests": Array [],
|
453
|
+
"transforms": Array [
|
454
|
+
[Function],
|
455
|
+
],
|
456
|
+
"type": "object",
|
457
|
+
}
|
458
|
+
}
|
459
|
+
>
|
460
|
+
<WebhookFormTabs
|
461
|
+
activeTab={0}
|
462
|
+
availableEvents={
|
463
|
+
Array [
|
464
|
+
"host_created",
|
465
|
+
]
|
466
|
+
}
|
467
|
+
disabled={false}
|
468
|
+
formProps={Object {}}
|
469
|
+
handleTabClick={[Function]}
|
470
|
+
httpMethods={
|
471
|
+
Array [
|
472
|
+
Object {
|
473
|
+
"label": "POST",
|
474
|
+
"value": "POST",
|
475
|
+
},
|
476
|
+
Object {
|
477
|
+
"label": "GET",
|
478
|
+
"value": "GET",
|
479
|
+
},
|
480
|
+
Object {
|
481
|
+
"label": "PUT",
|
482
|
+
"value": "PUT",
|
483
|
+
},
|
484
|
+
Object {
|
485
|
+
"label": "DELETE",
|
486
|
+
"value": "DELETE",
|
487
|
+
},
|
488
|
+
Object {
|
489
|
+
"label": "PATCH",
|
490
|
+
"value": "PATCH",
|
491
|
+
},
|
492
|
+
]
|
493
|
+
}
|
494
|
+
isEventsLoading={false}
|
495
|
+
isTemplatesLoading={false}
|
496
|
+
webhookTemplates={
|
497
|
+
Array [
|
498
|
+
Object {
|
499
|
+
"label": "default template",
|
500
|
+
"value": 204,
|
501
|
+
},
|
502
|
+
Object {
|
503
|
+
"label": "default template clone",
|
504
|
+
"value": 205,
|
505
|
+
},
|
506
|
+
]
|
507
|
+
}
|
508
|
+
/>
|
509
|
+
</ForemanForm>
|
510
|
+
`;
|