foreman_webhooks 4.0.1 → 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 (74) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/foreman_webhooks/locale/ca/foreman_webhooks.js +1 -1
  3. data/app/assets/javascripts/foreman_webhooks/locale/cs_CZ/foreman_webhooks.js +1 -1
  4. data/app/assets/javascripts/foreman_webhooks/locale/de/foreman_webhooks.js +1 -1
  5. data/app/assets/javascripts/foreman_webhooks/locale/en/foreman_webhooks.js +6 -6
  6. data/app/assets/javascripts/foreman_webhooks/locale/en_GB/foreman_webhooks.js +11 -11
  7. data/app/assets/javascripts/foreman_webhooks/locale/es/foreman_webhooks.js +1 -1
  8. data/app/assets/javascripts/foreman_webhooks/locale/fr/foreman_webhooks.js +74 -74
  9. data/app/assets/javascripts/foreman_webhooks/locale/it/foreman_webhooks.js +1 -1
  10. data/app/assets/javascripts/foreman_webhooks/locale/ja/foreman_webhooks.js +75 -75
  11. data/app/assets/javascripts/foreman_webhooks/locale/ka/foreman_webhooks.js +9 -9
  12. data/app/assets/javascripts/foreman_webhooks/locale/ko/foreman_webhooks.js +80 -80
  13. data/app/assets/javascripts/foreman_webhooks/locale/pl/foreman_webhooks.js +1 -1
  14. data/app/assets/javascripts/foreman_webhooks/locale/pt_BR/foreman_webhooks.js +1 -1
  15. data/app/assets/javascripts/foreman_webhooks/locale/ru/foreman_webhooks.js +1 -1
  16. data/app/assets/javascripts/foreman_webhooks/locale/zh_CN/foreman_webhooks.js +78 -78
  17. data/app/assets/javascripts/foreman_webhooks/locale/zh_TW/foreman_webhooks.js +1 -1
  18. data/lib/foreman_webhooks/engine.rb +1 -1
  19. data/lib/foreman_webhooks/version.rb +1 -1
  20. data/locale/ca/LC_MESSAGES/foreman_webhooks.mo +0 -0
  21. data/locale/ca/foreman_webhooks.po +1 -1
  22. data/locale/cs_CZ/LC_MESSAGES/foreman_webhooks.mo +0 -0
  23. data/locale/cs_CZ/foreman_webhooks.po +1 -1
  24. data/locale/de/LC_MESSAGES/foreman_webhooks.mo +0 -0
  25. data/locale/de/foreman_webhooks.po +1 -1
  26. data/locale/en/LC_MESSAGES/foreman_webhooks.mo +0 -0
  27. data/locale/en/foreman_webhooks.po +9 -9
  28. data/locale/en_GB/LC_MESSAGES/foreman_webhooks.mo +0 -0
  29. data/locale/en_GB/foreman_webhooks.po +12 -12
  30. data/locale/es/LC_MESSAGES/foreman_webhooks.mo +0 -0
  31. data/locale/es/foreman_webhooks.po +1 -1
  32. data/locale/fr/LC_MESSAGES/foreman_webhooks.mo +0 -0
  33. data/locale/fr/foreman_webhooks.po +77 -74
  34. data/locale/it/LC_MESSAGES/foreman_webhooks.mo +0 -0
  35. data/locale/it/foreman_webhooks.po +2 -2
  36. data/locale/ja/LC_MESSAGES/foreman_webhooks.mo +0 -0
  37. data/locale/ja/foreman_webhooks.po +77 -75
  38. data/locale/ka/LC_MESSAGES/foreman_webhooks.mo +0 -0
  39. data/locale/ka/foreman_webhooks.po +9 -9
  40. data/locale/ko/LC_MESSAGES/foreman_webhooks.mo +0 -0
  41. data/locale/ko/foreman_webhooks.po +82 -81
  42. data/locale/pl/LC_MESSAGES/foreman_webhooks.mo +0 -0
  43. data/locale/pl/foreman_webhooks.po +1 -1
  44. data/locale/pt_BR/LC_MESSAGES/foreman_webhooks.mo +0 -0
  45. data/locale/pt_BR/foreman_webhooks.po +1 -1
  46. data/locale/ru/LC_MESSAGES/foreman_webhooks.mo +0 -0
  47. data/locale/ru/foreman_webhooks.po +1 -1
  48. data/locale/zh_CN/LC_MESSAGES/foreman_webhooks.mo +0 -0
  49. data/locale/zh_CN/foreman_webhooks.po +80 -78
  50. data/locale/zh_TW/LC_MESSAGES/foreman_webhooks.mo +0 -0
  51. data/locale/zh_TW/foreman_webhooks.po +1 -1
  52. data/test/integration/webhooks_test.rb +234 -0
  53. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/FieldConstructor.js +321 -0
  54. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/WebhookFormTabs.css +23 -4
  55. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/WebhookFormTabs.js +191 -149
  56. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/__tests__/FieldConstructor.test.js +216 -0
  57. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/WebhookForm.js +55 -26
  58. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/__tests__/WebhookForm.test.js +253 -37
  59. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/index.js +3 -4
  60. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookCreateModal.js +30 -19
  61. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookDeleteModal.js +52 -18
  62. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookEditModal.js +37 -26
  63. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookTestModal.js +57 -32
  64. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/NameToEditCell.js +8 -1
  65. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/__tests__/__snapshots__/EnabledCell.test.js.snap +2 -14
  66. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/WebhooksTable.js +24 -11
  67. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/__tests__/__snapshots__/WebhooksTable.test.js.snap +64 -0
  68. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/index.js +21 -22
  69. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/WebhooksIndexPage.js +9 -15
  70. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/integration.test.js +0 -3
  71. metadata +8 -9
  72. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/ForemanFormikField.js +0 -152
  73. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/__tests__/__snapshots__/WebhookForm.test.js.snap +0 -512
  74. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/__snapshots__/integration.test.js.snap +0 -31
@@ -0,0 +1,321 @@
1
+ /* eslint-disable max-lines */
2
+ import React, { useEffect, useState } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import AutocompleteInput from 'foremanReact/components/common/AutocompleteInput/AutocompleteInput';
5
+ import { translate as __ } from 'foremanReact/common/I18n';
6
+ import {
7
+ ExclamationCircleIcon,
8
+ HelpIcon,
9
+ PencilAltIcon,
10
+ } from '@patternfly/react-icons';
11
+ import {
12
+ TextInput,
13
+ Checkbox,
14
+ Button,
15
+ FormHelperText,
16
+ HelperText,
17
+ HelperTextItem,
18
+ Icon,
19
+ TextArea,
20
+ FormGroup,
21
+ Popover,
22
+ Grid,
23
+ GridItem,
24
+ } from '@patternfly/react-core';
25
+
26
+ const FormField = ({
27
+ name,
28
+ type,
29
+ required,
30
+ options,
31
+ isLoading,
32
+ validated,
33
+ value,
34
+ disabled,
35
+ setValue,
36
+ placeholder,
37
+ errMsg,
38
+ fieldId,
39
+ ...props
40
+ }) => {
41
+ const [fieldValidated, setFieldValidated] = useState('default');
42
+ const [firstLoad, setFirstLoad] = useState(true);
43
+ const [isDisabled, setIsDisabled] = useState(disabled);
44
+
45
+ const requiredValidate = () => {
46
+ if (firstLoad || !required) return;
47
+ if (!value || value === '' || validated === 'error')
48
+ setFieldValidated('error');
49
+ else setFieldValidated('success');
50
+ };
51
+
52
+ const localHandler = (_event, newValue) => {
53
+ setValue(name, newValue);
54
+ };
55
+
56
+ useEffect(() => {
57
+ setFirstLoad(false);
58
+ }, []);
59
+
60
+ useEffect(() => {
61
+ setIsDisabled(disabled);
62
+ }, [disabled]);
63
+
64
+ useEffect(() => {
65
+ requiredValidate();
66
+ // eslint-disable-next-line react-hooks/exhaustive-deps
67
+ }, [value]);
68
+
69
+ if (type === 'checkbox') {
70
+ return (
71
+ <>
72
+ <Checkbox
73
+ ouiaId={name}
74
+ id={fieldId ?? `id-${name}`}
75
+ isChecked={value || false}
76
+ onChange={(_, newValue) => {
77
+ setValue(name, newValue);
78
+ }}
79
+ isDisabled={isLoading || isDisabled}
80
+ isRequired={required}
81
+ type={type}
82
+ validated={fieldValidated}
83
+ />
84
+ <ValidationComponent localValidated={fieldValidated} errMsg={errMsg} />
85
+ </>
86
+ );
87
+ } else if (type === 'textarea') {
88
+ return (
89
+ <>
90
+ <TextArea
91
+ rows={6}
92
+ name={name}
93
+ id={fieldId ?? `id-${name}`}
94
+ value={value ?? ''}
95
+ onChange={(_, newValue) => setValue(name, newValue)}
96
+ isRequired={required}
97
+ isDisabled={isLoading || isDisabled}
98
+ type={type}
99
+ validated={fieldValidated}
100
+ placeholder={placeholder}
101
+ />
102
+ <ValidationComponent localValidated={fieldValidated} errMsg={errMsg} />
103
+ </>
104
+ );
105
+ } else if (options.length !== 0) {
106
+ return (
107
+ <>
108
+ <AutocompleteInput
109
+ options={options}
110
+ selected={value ?? ''}
111
+ onSelect={newValue => setValue(name, newValue)}
112
+ onChange={() => requiredValidate()}
113
+ name={name}
114
+ placeholder={placeholder}
115
+ validationStatus={fieldValidated}
116
+ validationMsg={errMsg}
117
+ fieldId={fieldId}
118
+ />
119
+ </>
120
+ );
121
+ }
122
+ return (
123
+ <>
124
+ {name === 'password' && (isDisabled || disabled) ? (
125
+ <Grid hasGutter={false}>
126
+ <GridItem span={11}>
127
+ <TextInput
128
+ name={name}
129
+ value={value ?? ''}
130
+ id={fieldId ?? `id-${name}`}
131
+ onChange={localHandler}
132
+ isDisabled={isLoading || isDisabled}
133
+ isRequired={required}
134
+ type={type}
135
+ validated={fieldValidated}
136
+ placeholder={placeholder}
137
+ onBlur={requiredValidate}
138
+ autoComplete="off"
139
+ />
140
+ </GridItem>
141
+ <GridItem span={1}>
142
+ <Button
143
+ ouiaId={`reset-${name}`}
144
+ onClick={() => setIsDisabled(false)}
145
+ variant="control"
146
+ icon={<PencilAltIcon />}
147
+ />
148
+ </GridItem>
149
+ </Grid>
150
+ ) : (
151
+ <TextInput
152
+ name={name}
153
+ value={value ?? ''}
154
+ id={fieldId ?? `id-${name}`}
155
+ onChange={localHandler}
156
+ isDisabled={isLoading || isDisabled}
157
+ isRequired={required}
158
+ type={type}
159
+ validated={fieldValidated}
160
+ placeholder={placeholder}
161
+ onBlur={requiredValidate}
162
+ autoComplete={type === 'password' ? 'new-password' : null}
163
+ />
164
+ )}
165
+
166
+ <ValidationComponent localValidated={fieldValidated} errMsg={errMsg} />
167
+ </>
168
+ );
169
+ };
170
+
171
+ const ValidationComponent = ({ localValidated, errMsg }) => (
172
+ <>
173
+ {localValidated === 'error' && (
174
+ <FormHelperText>
175
+ <HelperText>
176
+ <HelperTextItem
177
+ icon={
178
+ <Icon>
179
+ <ExclamationCircleIcon />
180
+ </Icon>
181
+ }
182
+ variant={localValidated}
183
+ >
184
+ {errMsg ?? __('Field is required')}
185
+ </HelperTextItem>
186
+ </HelperText>
187
+ </FormHelperText>
188
+ )}
189
+ </>
190
+ );
191
+
192
+ const FieldConstructor = ({
193
+ label,
194
+ value,
195
+ required,
196
+ labelHelp,
197
+ fieldId,
198
+ name,
199
+ ...props
200
+ }) => (
201
+ <FormGroup
202
+ isInline
203
+ fieldId={fieldId ?? `id-${name}`}
204
+ label={label}
205
+ isRequired={required}
206
+ labelIcon={
207
+ labelHelp ? (
208
+ <Popover
209
+ bodyContent={
210
+ typeof labelHelp === 'string' ? (
211
+ <div dangerouslySetInnerHTML={{ __html: labelHelp }} />
212
+ ) : (
213
+ labelHelp
214
+ )
215
+ }
216
+ >
217
+ <Button
218
+ ouiaId={`label-${label}`}
219
+ type="button"
220
+ variant="plain"
221
+ onClick={e => e.preventDefault()}
222
+ >
223
+ <Icon>
224
+ <HelpIcon />
225
+ </Icon>
226
+ </Button>
227
+ </Popover>
228
+ ) : (
229
+ ''
230
+ )
231
+ }
232
+ >
233
+ <FormField
234
+ value={value}
235
+ required={required}
236
+ name={name}
237
+ {...props}
238
+ fieldId={fieldId}
239
+ />
240
+ </FormGroup>
241
+ );
242
+
243
+ FieldConstructor.propTypes = {
244
+ label: PropTypes.string.isRequired,
245
+ required: PropTypes.bool,
246
+ labelHelp: PropTypes.oneOfType([
247
+ PropTypes.string,
248
+ PropTypes.object,
249
+ PropTypes.node,
250
+ ]),
251
+ setValue: PropTypes.func.isRequired,
252
+ name: PropTypes.string.isRequired,
253
+ disabled: PropTypes.bool,
254
+ value: PropTypes.oneOfType([
255
+ PropTypes.string,
256
+ PropTypes.object,
257
+ PropTypes.bool,
258
+ PropTypes.number,
259
+ ]),
260
+ fieldId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
261
+ };
262
+
263
+ FieldConstructor.defaultProps = {
264
+ labelHelp: undefined,
265
+ required: false,
266
+ disabled: false,
267
+ value: '',
268
+ fieldId: undefined,
269
+ };
270
+
271
+ FormField.propTypes = {
272
+ disabled: PropTypes.bool,
273
+ setValue: PropTypes.func.isRequired,
274
+ name: PropTypes.string.isRequired,
275
+ type: PropTypes.string.isRequired,
276
+ label: PropTypes.string,
277
+ required: PropTypes.bool,
278
+ allowClear: PropTypes.bool,
279
+ options: PropTypes.arrayOf(
280
+ PropTypes.shape({
281
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
282
+ .isRequired,
283
+ label: PropTypes.string.isRequired,
284
+ })
285
+ ),
286
+ isLoading: PropTypes.bool,
287
+ validated: PropTypes.string,
288
+ placeholder: PropTypes.string,
289
+ errMsg: PropTypes.string,
290
+ value: PropTypes.oneOfType([
291
+ PropTypes.bool,
292
+ PropTypes.string,
293
+ PropTypes.number,
294
+ ]),
295
+ fieldId: PropTypes.string,
296
+ };
297
+
298
+ FormField.defaultProps = {
299
+ label: '',
300
+ errMsg: null,
301
+ placeholder: '',
302
+ validated: 'default',
303
+ required: false,
304
+ allowClear: false,
305
+ options: [],
306
+ isLoading: false,
307
+ disabled: false,
308
+ value: '',
309
+ fieldId: undefined,
310
+ };
311
+
312
+ ValidationComponent.propTypes = {
313
+ localValidated: PropTypes.string.isRequired,
314
+ errMsg: PropTypes.string,
315
+ };
316
+
317
+ ValidationComponent.defaultProps = {
318
+ errMsg: null,
319
+ };
320
+
321
+ export default FieldConstructor;
@@ -1,7 +1,26 @@
1
- .webhook-form-tab-content {
2
- padding-top: 3em;
3
- }
4
-
5
1
  .webhook-form-tab:focus {
6
2
  outline: none;
7
3
  }
4
+
5
+ .pf-v5-c-form.pf-m-horizontal .webhook-form-tab {
6
+ .webhook-form-tab-content .pf-v5-c-form__group{
7
+ margin-top: var(--pf-v5-c-form--GridGap);
8
+ grid-template-columns: calc(var(--pf-v5-c-form--m-horizontal__group-label--md--GridColumnWidth) + 3rem) var(--pf-v5-c-form--m-horizontal__group-control--md--GridColumnWidth);
9
+ }
10
+
11
+ .autocomplete-input-wrapper {
12
+ width: 100%;
13
+ }
14
+
15
+ .pf-v5-c-form__group-control {
16
+ align-content: space-evenly;
17
+ }
18
+
19
+ .pf-v5-c-form__group-label {
20
+ text-wrap: nowrap;
21
+ }
22
+ }
23
+ #select-typeahead-listbox {
24
+ max-height: 400px;
25
+ overflow: auto;
26
+ }