foreman_webhooks 4.0.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/lib/foreman_webhooks/engine.rb +1 -1
  3. data/lib/foreman_webhooks/version.rb +1 -1
  4. data/test/integration/webhooks_test.rb +234 -0
  5. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/FieldConstructor.js +321 -0
  6. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/WebhookFormTabs.css +23 -4
  7. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/WebhookFormTabs.js +191 -157
  8. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/__tests__/FieldConstructor.test.js +216 -0
  9. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/WebhookForm.js +55 -26
  10. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/__tests__/WebhookForm.test.js +253 -37
  11. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/index.js +3 -4
  12. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookCreateModal.js +30 -19
  13. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookDeleteModal.js +52 -18
  14. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookEditModal.js +37 -26
  15. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookTestModal.js +57 -32
  16. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/WebhooksTable.js +24 -11
  17. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/__tests__/__snapshots__/WebhooksTable.test.js.snap +64 -0
  18. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/index.js +21 -22
  19. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/WebhooksIndexPage.js +9 -15
  20. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/integration.test.js +0 -3
  21. metadata +7 -5
  22. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/ForemanFormikField.js +0 -152
  23. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/__tests__/__snapshots__/WebhookForm.test.js.snap +0 -512
  24. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/__snapshots__/integration.test.js.snap +0 -31
@@ -1,152 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { Field as FormikField } from 'formik';
4
- import { Spinner } from '@patternfly/react-core';
5
- import { TypeAheadSelect } from 'patternfly-react';
6
- import { filter } from 'lodash';
7
-
8
- import { translate as __ } from 'foremanReact/common/I18n';
9
-
10
- import FormField from 'foremanReact/components/common/forms/FormField';
11
-
12
- const ForemanFormikField = ({
13
- name,
14
- type,
15
- required,
16
- label,
17
- labelHelp,
18
- inputSizeClass,
19
- labelSizeClass,
20
- rows,
21
- placeholder,
22
- options,
23
- isLoading,
24
- disabled,
25
- setDisabled,
26
- }) => (
27
- <FormikField name={name}>
28
- {({
29
- field, // { name, value, onChange, onBlur }
30
- form: { touched, errors, setFieldValue, setFieldTouched }, // also values, setXXXX, handleXXXX, dirty, isValid, status, etc.
31
- }) => {
32
- const defaultSelection = (fieldValue, initialOptions) => {
33
- if (!fieldValue) return [];
34
-
35
- return filter(initialOptions, o => o.value === fieldValue);
36
- };
37
- const passwordInput = (
38
- <input
39
- {...field}
40
- placeholder={disabled ? '********' : ''}
41
- type={type}
42
- disabled={disabled}
43
- className="form-control"
44
- />
45
- );
46
- let content = null;
47
- switch (type) {
48
- case 'textarea':
49
- content = (
50
- <textarea
51
- {...field}
52
- className="form-control"
53
- rows={rows}
54
- placeholder={placeholder}
55
- />
56
- );
57
- break;
58
- case 'select':
59
- content = isLoading ? (
60
- <Spinner size="md" aria-label="loading icon" />
61
- ) : (
62
- <TypeAheadSelect
63
- id={name}
64
- options={options}
65
- placeholder={__('Start typing to search')}
66
- selected={defaultSelection(field.value, options)}
67
- onChange={selected =>
68
- setFieldValue(field.name, selected[0]?.value)
69
- }
70
- />
71
- );
72
- break;
73
- case 'password':
74
- content = setDisabled ? (
75
- <div className="input-group">
76
- {passwordInput}
77
- <span className="input-group-btn">
78
- <button
79
- className="btn btn-default"
80
- onClick={e => {
81
- e.preventDefault();
82
- setDisabled(!disabled);
83
- }}
84
- title={__('Change the password')}
85
- >
86
- <span className="pficon pficon-edit" />
87
- </button>
88
- </span>
89
- </div>
90
- ) : (
91
- passwordInput
92
- );
93
- break;
94
- default:
95
- content = (
96
- <input
97
- {...field}
98
- type={type}
99
- checked={type === 'checkbox' ? field.value || '' : undefined}
100
- className={type === 'checkbox' ? '' : 'form-control'}
101
- />
102
- );
103
- }
104
- return (
105
- <FormField
106
- {...field}
107
- error={touched[name] ? errors[name] : undefined}
108
- type={type}
109
- inputSizeClass={inputSizeClass}
110
- labelSizeClass={labelSizeClass}
111
- required={required}
112
- label={label}
113
- labelHelp={labelHelp}
114
- options={options}
115
- >
116
- {content}
117
- </FormField>
118
- );
119
- }}
120
- </FormikField>
121
- );
122
-
123
- ForemanFormikField.propTypes = {
124
- name: PropTypes.string.isRequired,
125
- type: PropTypes.string.isRequired,
126
- required: PropTypes.bool,
127
- label: PropTypes.string.isRequired,
128
- labelHelp: PropTypes.string,
129
- inputSizeClass: PropTypes.string,
130
- labelSizeClass: PropTypes.string,
131
- rows: PropTypes.number,
132
- placeholder: PropTypes.string,
133
- options: PropTypes.array,
134
- isLoading: PropTypes.bool,
135
- disabled: PropTypes.bool,
136
- setDisabled: PropTypes.func,
137
- };
138
-
139
- ForemanFormikField.defaultProps = {
140
- required: false,
141
- labelHelp: null,
142
- inputSizeClass: 'col-md-8',
143
- labelSizeClass: 'col-md-3',
144
- rows: 1,
145
- placeholder: '',
146
- options: null,
147
- isLoading: false,
148
- disabled: false,
149
- setDisabled: undefined,
150
- };
151
-
152
- export default ForemanFormikField;
@@ -1,512 +0,0 @@
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
- isPasswordDisabled={false}
245
- isTemplatesLoading={false}
246
- webhookTemplates={
247
- Array [
248
- Object {
249
- "label": "default template",
250
- "value": 204,
251
- },
252
- Object {
253
- "label": "default template clone",
254
- "value": 205,
255
- },
256
- ]
257
- }
258
- />
259
- </ForemanForm>
260
- `;
261
-
262
- exports[`WebhookForm rendering should render for new page 1`] = `
263
- <ForemanForm
264
- enableReinitialize={true}
265
- initialValues={
266
- Object {
267
- "enabled": true,
268
- "event": "host_created.event.foreman",
269
- "http_content_type": "application/json",
270
- "http_method": "POST",
271
- "verify_ssl": true,
272
- }
273
- }
274
- item="Webhook"
275
- onCancel={[MockFunction]}
276
- onSubmit={[MockFunction]}
277
- validationSchema={
278
- ObjectSchema {
279
- "_blacklist": RefSet {
280
- "list": Array [],
281
- "refs": Array [],
282
- },
283
- "_conditions": Array [],
284
- "_defaultDefault": [Function],
285
- "_deps": Array [],
286
- "_excludedEdges": Array [],
287
- "_exclusive": Object {},
288
- "_mutate": undefined,
289
- "_nodes": Array [
290
- "webhook_template_id",
291
- "event",
292
- "http_method",
293
- "target_url",
294
- "name",
295
- ],
296
- "_options": Object {
297
- "abortEarly": true,
298
- "recursive": true,
299
- },
300
- "_type": "object",
301
- "_typeError": [Function],
302
- "_whitelist": RefSet {
303
- "list": Array [],
304
- "refs": Array [],
305
- },
306
- "fields": Object {
307
- "event": StringSchema {
308
- "_blacklist": RefSet {
309
- "list": Array [],
310
- "refs": Array [],
311
- },
312
- "_conditions": Array [],
313
- "_deps": Array [],
314
- "_exclusive": Object {
315
- "required": true,
316
- },
317
- "_mutate": undefined,
318
- "_options": Object {
319
- "abortEarly": true,
320
- "recursive": true,
321
- },
322
- "_type": "string",
323
- "_typeError": [Function],
324
- "_whitelist": RefSet {
325
- "list": Array [],
326
- "refs": Array [],
327
- },
328
- "tests": Array [
329
- [Function],
330
- ],
331
- "transforms": Array [
332
- [Function],
333
- ],
334
- "type": "string",
335
- },
336
- "http_method": StringSchema {
337
- "_blacklist": RefSet {
338
- "list": Array [],
339
- "refs": Array [],
340
- },
341
- "_conditions": Array [],
342
- "_deps": Array [],
343
- "_exclusive": Object {
344
- "required": true,
345
- },
346
- "_mutate": undefined,
347
- "_options": Object {
348
- "abortEarly": true,
349
- "recursive": true,
350
- },
351
- "_type": "string",
352
- "_typeError": [Function],
353
- "_whitelist": RefSet {
354
- "list": Array [],
355
- "refs": Array [],
356
- },
357
- "tests": Array [
358
- [Function],
359
- ],
360
- "transforms": Array [
361
- [Function],
362
- ],
363
- "type": "string",
364
- },
365
- "name": StringSchema {
366
- "_blacklist": RefSet {
367
- "list": Array [],
368
- "refs": Array [],
369
- },
370
- "_conditions": Array [],
371
- "_deps": Array [],
372
- "_exclusive": Object {
373
- "required": true,
374
- },
375
- "_mutate": undefined,
376
- "_options": Object {
377
- "abortEarly": true,
378
- "recursive": true,
379
- },
380
- "_type": "string",
381
- "_typeError": [Function],
382
- "_whitelist": RefSet {
383
- "list": Array [],
384
- "refs": Array [],
385
- },
386
- "tests": Array [
387
- [Function],
388
- ],
389
- "transforms": Array [
390
- [Function],
391
- ],
392
- "type": "string",
393
- },
394
- "target_url": StringSchema {
395
- "_blacklist": RefSet {
396
- "list": Array [],
397
- "refs": Array [],
398
- },
399
- "_conditions": Array [],
400
- "_deps": Array [],
401
- "_exclusive": Object {
402
- "required": true,
403
- },
404
- "_mutate": undefined,
405
- "_options": Object {
406
- "abortEarly": true,
407
- "recursive": true,
408
- },
409
- "_type": "string",
410
- "_typeError": [Function],
411
- "_whitelist": RefSet {
412
- "list": Array [],
413
- "refs": Array [],
414
- },
415
- "tests": Array [
416
- [Function],
417
- ],
418
- "transforms": Array [
419
- [Function],
420
- ],
421
- "type": "string",
422
- },
423
- "webhook_template_id": StringSchema {
424
- "_blacklist": RefSet {
425
- "list": Array [],
426
- "refs": Array [],
427
- },
428
- "_conditions": Array [],
429
- "_deps": Array [],
430
- "_exclusive": Object {
431
- "required": true,
432
- },
433
- "_mutate": undefined,
434
- "_options": Object {
435
- "abortEarly": true,
436
- "recursive": true,
437
- },
438
- "_type": "string",
439
- "_typeError": [Function],
440
- "_whitelist": RefSet {
441
- "list": Array [],
442
- "refs": Array [],
443
- },
444
- "tests": Array [
445
- [Function],
446
- ],
447
- "transforms": Array [
448
- [Function],
449
- ],
450
- "type": "string",
451
- },
452
- },
453
- "tests": Array [],
454
- "transforms": Array [
455
- [Function],
456
- ],
457
- "type": "object",
458
- }
459
- }
460
- >
461
- <WebhookFormTabs
462
- activeTab={0}
463
- availableEvents={
464
- Array [
465
- "host_created",
466
- ]
467
- }
468
- disabled={false}
469
- formProps={Object {}}
470
- handleTabClick={[Function]}
471
- httpMethods={
472
- Array [
473
- Object {
474
- "label": "POST",
475
- "value": "POST",
476
- },
477
- Object {
478
- "label": "GET",
479
- "value": "GET",
480
- },
481
- Object {
482
- "label": "PUT",
483
- "value": "PUT",
484
- },
485
- Object {
486
- "label": "DELETE",
487
- "value": "DELETE",
488
- },
489
- Object {
490
- "label": "PATCH",
491
- "value": "PATCH",
492
- },
493
- ]
494
- }
495
- isEventsLoading={false}
496
- isPasswordDisabled={false}
497
- isTemplatesLoading={false}
498
- webhookTemplates={
499
- Array [
500
- Object {
501
- "label": "default template",
502
- "value": 204,
503
- },
504
- Object {
505
- "label": "default template clone",
506
- "value": 205,
507
- },
508
- ]
509
- }
510
- />
511
- </ForemanForm>
512
- `;
@@ -1,31 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`WebhooksIndexPage - Integration Test should flow: initial state 1`] = `
4
- Object {
5
- "action": Array [
6
- Array [
7
- Object {
8
- "key": "WEBHOOK_EVENTS",
9
- "type": "get-some-type",
10
- "url": "",
11
- },
12
- ],
13
- ],
14
- "state": Object {},
15
- }
16
- `;
17
-
18
- exports[`WebhooksIndexPage - Integration Test should flow: rendered 1`] = `
19
- Object {
20
- "action": Array [
21
- Array [
22
- Object {
23
- "key": "WEBHOOK_EVENTS",
24
- "type": "get-some-type",
25
- "url": "",
26
- },
27
- ],
28
- ],
29
- "state": Object {},
30
- }
31
- `;