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.
- checksums.yaml +4 -4
- data/lib/foreman_webhooks/engine.rb +1 -1
- data/lib/foreman_webhooks/version.rb +1 -1
- data/test/integration/webhooks_test.rb +234 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/FieldConstructor.js +321 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/WebhookFormTabs.css +23 -4
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/WebhookFormTabs.js +191 -157
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/__tests__/FieldConstructor.test.js +216 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/WebhookForm.js +55 -26
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/__tests__/WebhookForm.test.js +253 -37
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/index.js +3 -4
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookCreateModal.js +30 -19
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookDeleteModal.js +52 -18
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookEditModal.js +37 -26
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookTestModal.js +57 -32
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/WebhooksTable.js +24 -11
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/__tests__/__snapshots__/WebhooksTable.test.js.snap +64 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/index.js +21 -22
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/WebhooksIndexPage.js +9 -15
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/integration.test.js +0 -3
- metadata +7 -5
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/ForemanFormikField.js +0 -152
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/__tests__/__snapshots__/WebhookForm.test.js.snap +0 -512
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/__snapshots__/integration.test.js.snap +0 -31
data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookEditModal.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { Modal } from 'patternfly-react';
|
|
3
2
|
import { useSelector, useDispatch } from 'react-redux';
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
5
4
|
|
|
6
5
|
import { translate as __ } from 'foremanReact/common/I18n';
|
|
7
|
-
import ForemanModal from 'foremanReact/components/ForemanModal';
|
|
8
6
|
import Loading from 'foremanReact/components/Loading';
|
|
9
7
|
import { foremanUrl } from 'foremanReact/common/helpers';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { get, put } from 'foremanReact/redux/API';
|
|
9
|
+
import { Modal, ModalVariant } from '@patternfly/react-core';
|
|
12
10
|
|
|
13
11
|
import ConnectedWebhookForm from '../../Components/WebhookForm';
|
|
14
12
|
|
|
@@ -20,20 +18,19 @@ import {
|
|
|
20
18
|
} from '../../constants';
|
|
21
19
|
|
|
22
20
|
import {
|
|
23
|
-
selectIsLoading,
|
|
24
21
|
selectWebhookValues,
|
|
25
22
|
selectWebhookTemplateId,
|
|
26
23
|
} from './WebhookEditModalSelectors';
|
|
27
24
|
|
|
28
25
|
import './WebhookModal.scss';
|
|
29
26
|
|
|
30
|
-
const WebhookEditModal = ({ toEdit, onSuccess,
|
|
27
|
+
const WebhookEditModal = ({ toEdit, onSuccess, modalState }) => {
|
|
31
28
|
const dispatch = useDispatch();
|
|
32
29
|
|
|
33
30
|
const [isPasswordDisabled, setIsPasswordDisabled] = useState(false);
|
|
31
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
34
32
|
const id = toEdit;
|
|
35
33
|
|
|
36
|
-
const isLoading = useSelector(selectIsLoading);
|
|
37
34
|
const isPasswordSet = useSelector(selectWebhookValues).passwordSet;
|
|
38
35
|
const initialWebhookValues = {
|
|
39
36
|
id: useSelector(selectWebhookValues).id,
|
|
@@ -56,23 +53,32 @@ const WebhookEditModal = ({ toEdit, onSuccess, onCancel }) => {
|
|
|
56
53
|
setIsPasswordDisabled(isPasswordSet);
|
|
57
54
|
}, [isPasswordSet]);
|
|
58
55
|
|
|
59
|
-
const handleSubmit =
|
|
56
|
+
const handleSubmit = values => {
|
|
57
|
+
setIsLoading(true);
|
|
60
58
|
if (isPasswordDisabled) {
|
|
61
59
|
delete values.password;
|
|
62
60
|
}
|
|
63
61
|
dispatch(
|
|
64
|
-
|
|
62
|
+
put({
|
|
65
63
|
url: foremanUrl(`/api${WEBHOOKS_PATH}/${id}`),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
key: WEBHOOK_API_REQUEST_KEY,
|
|
65
|
+
params: { ...values, controller: 'webhooks' },
|
|
66
|
+
successToast: () => __('Webhook was successfully updated.'),
|
|
67
|
+
handleSuccess: () => {
|
|
68
|
+
onSuccess();
|
|
69
|
+
setIsLoading(false);
|
|
70
|
+
},
|
|
71
|
+
errorToast: ({ response }) =>
|
|
72
|
+
// eslint-disable-next-line camelcase
|
|
73
|
+
response?.data?.error?.full_messages?.[0] || response,
|
|
72
74
|
})
|
|
73
75
|
);
|
|
74
76
|
};
|
|
75
77
|
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (initialWebhookValues.id) setIsLoading(false);
|
|
80
|
+
}, [initialWebhookValues.id]);
|
|
81
|
+
|
|
76
82
|
useEffect(() => {
|
|
77
83
|
if (id) {
|
|
78
84
|
dispatch(
|
|
@@ -86,24 +92,26 @@ const WebhookEditModal = ({ toEdit, onSuccess, onCancel }) => {
|
|
|
86
92
|
|
|
87
93
|
const onEditCancel = () => {
|
|
88
94
|
if (isPasswordSet) setIsPasswordDisabled(true);
|
|
89
|
-
|
|
95
|
+
modalState.closeModal();
|
|
90
96
|
};
|
|
91
97
|
|
|
98
|
+
const modalTitle = initialWebhookValues.name ?? '';
|
|
99
|
+
|
|
92
100
|
return (
|
|
93
|
-
<
|
|
101
|
+
<Modal
|
|
102
|
+
position="top"
|
|
103
|
+
variant={ModalVariant.medium}
|
|
94
104
|
id={WEBHOOK_EDIT_MODAL_ID}
|
|
95
|
-
|
|
96
|
-
|
|
105
|
+
ouiaId={WEBHOOK_EDIT_MODAL_ID}
|
|
106
|
+
isOpen={modalState.isOpen}
|
|
107
|
+
onClose={modalState.closeModal}
|
|
108
|
+
title={`${__('Edit')} ${modalTitle}`}
|
|
97
109
|
>
|
|
98
|
-
<Modal.Header>
|
|
99
|
-
<Modal.Title>
|
|
100
|
-
{`${__('Edit')} ${initialWebhookValues.name}`}
|
|
101
|
-
</Modal.Title>
|
|
102
|
-
</Modal.Header>
|
|
103
110
|
{isLoading ? (
|
|
104
111
|
<Loading />
|
|
105
112
|
) : (
|
|
106
113
|
<ConnectedWebhookForm
|
|
114
|
+
isLoading={isLoading}
|
|
107
115
|
handleSubmit={handleSubmit}
|
|
108
116
|
initialValues={initialWebhookValues}
|
|
109
117
|
onCancel={onEditCancel}
|
|
@@ -111,14 +119,17 @@ const WebhookEditModal = ({ toEdit, onSuccess, onCancel }) => {
|
|
|
111
119
|
setIsPasswordDisabled={setIsPasswordDisabled}
|
|
112
120
|
/>
|
|
113
121
|
)}
|
|
114
|
-
</
|
|
122
|
+
</Modal>
|
|
115
123
|
);
|
|
116
124
|
};
|
|
117
125
|
|
|
118
126
|
WebhookEditModal.propTypes = {
|
|
119
127
|
onSuccess: PropTypes.func.isRequired,
|
|
120
|
-
onCancel: PropTypes.func.isRequired,
|
|
121
128
|
toEdit: PropTypes.number,
|
|
129
|
+
modalState: PropTypes.shape({
|
|
130
|
+
isOpen: PropTypes.bool.isRequired,
|
|
131
|
+
closeModal: PropTypes.func.isRequired,
|
|
132
|
+
}).isRequired,
|
|
122
133
|
};
|
|
123
134
|
|
|
124
135
|
WebhookEditModal.defaultProps = {
|
data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookTestModal.js
CHANGED
|
@@ -1,61 +1,66 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { useDispatch } from 'react-redux';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
|
|
5
5
|
import { sprintf, translate as __ } from 'foremanReact/common/I18n';
|
|
6
|
-
import ForemanModal from 'foremanReact/components/ForemanModal';
|
|
7
|
-
import ForemanForm from 'foremanReact/components/common/forms/ForemanForm';
|
|
8
6
|
import { foremanUrl } from 'foremanReact/common/helpers';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
import {
|
|
8
|
+
Form,
|
|
9
|
+
Button,
|
|
10
|
+
ActionGroup,
|
|
11
|
+
Modal,
|
|
12
|
+
ModalVariant,
|
|
13
|
+
} from '@patternfly/react-core';
|
|
13
14
|
|
|
15
|
+
import { APIActions } from 'foremanReact/redux/API';
|
|
14
16
|
import {
|
|
15
17
|
WEBHOOK_TEST_MODAL_ID,
|
|
16
18
|
WEBHOOKS_API_PLAIN_PATH,
|
|
17
19
|
} from '../../constants';
|
|
18
20
|
|
|
19
21
|
import './WebhookModal.scss';
|
|
22
|
+
import FieldConstructor from '../../Components/WebhookForm/Components/FieldConstructor';
|
|
20
23
|
|
|
21
|
-
const WebhookTestModal = ({ toTest }) => {
|
|
24
|
+
const WebhookTestModal = ({ toTest, modalState }) => {
|
|
22
25
|
const dispatch = useDispatch();
|
|
23
26
|
|
|
24
27
|
const { id, name } = toTest;
|
|
25
|
-
const { setModalClosed: setTestModalClosed } = useForemanModal({
|
|
26
|
-
id: WEBHOOK_TEST_MODAL_ID,
|
|
27
|
-
});
|
|
28
28
|
const initialTestValues = {
|
|
29
29
|
payload: '',
|
|
30
30
|
};
|
|
31
|
+
|
|
32
|
+
const [value, setValue] = useState(initialTestValues);
|
|
33
|
+
|
|
31
34
|
const errorToast = error =>
|
|
32
35
|
sprintf(
|
|
33
36
|
__('Webhook test failed: %s'),
|
|
34
37
|
error?.response?.data?.error?.message
|
|
35
38
|
);
|
|
36
39
|
|
|
37
|
-
const handleSubmit =
|
|
40
|
+
const handleSubmit = values => {
|
|
38
41
|
dispatch(
|
|
39
|
-
|
|
42
|
+
APIActions.post({
|
|
43
|
+
key: WEBHOOK_TEST_MODAL_ID,
|
|
40
44
|
url: foremanUrl(`${WEBHOOKS_API_PLAIN_PATH}/${id}/test`),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
handleError: () => actions.setSubmitting(false),
|
|
45
|
+
params: {
|
|
46
|
+
...values,
|
|
47
|
+
controller: 'webhooks',
|
|
48
|
+
},
|
|
49
|
+
successToast: () => sprintf(__('Webhook %s test was successful'), name),
|
|
50
|
+
errorToast: error => errorToast(error),
|
|
51
|
+
handleSuccess: () => modalState.closeModal(),
|
|
49
52
|
})
|
|
50
53
|
);
|
|
51
54
|
};
|
|
52
55
|
|
|
53
56
|
return (
|
|
54
|
-
<
|
|
57
|
+
<Modal
|
|
58
|
+
variant={ModalVariant.medium}
|
|
59
|
+
isOpen={modalState.isOpen}
|
|
60
|
+
onClose={modalState.closeModal}
|
|
55
61
|
id={WEBHOOK_TEST_MODAL_ID}
|
|
62
|
+
ouiaId={WEBHOOK_TEST_MODAL_ID}
|
|
56
63
|
title={`${__('Test')} ${name}`}
|
|
57
|
-
backdrop="static"
|
|
58
|
-
enforceFocus
|
|
59
64
|
className="webhooks-modal"
|
|
60
65
|
>
|
|
61
66
|
{`${sprintf(__('You are about to test %s webhook.'), name)} `}
|
|
@@ -68,12 +73,8 @@ const WebhookTestModal = ({ toTest }) => {
|
|
|
68
73
|
{__('You can specify below a custom payload to test the webhook with.')}
|
|
69
74
|
<br />
|
|
70
75
|
<br />
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
initialValues={initialTestValues}
|
|
74
|
-
onCancel={setTestModalClosed}
|
|
75
|
-
>
|
|
76
|
-
<ForemanFormikField
|
|
76
|
+
<Form>
|
|
77
|
+
<FieldConstructor
|
|
77
78
|
name="payload"
|
|
78
79
|
type="textarea"
|
|
79
80
|
label={__('Payload')}
|
|
@@ -81,14 +82,38 @@ const WebhookTestModal = ({ toTest }) => {
|
|
|
81
82
|
placeholder="{ id: 1, name: test }"
|
|
82
83
|
inputSizeClass="col-md-8"
|
|
83
84
|
rows={8}
|
|
85
|
+
value={value.payload}
|
|
86
|
+
setValue={(key, val) => {
|
|
87
|
+
setValue(prev => ({ ...prev, [key]: val }));
|
|
88
|
+
}}
|
|
84
89
|
/>
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
<ActionGroup>
|
|
91
|
+
<Button
|
|
92
|
+
ouiaId="submit-webhook-form"
|
|
93
|
+
variant="primary"
|
|
94
|
+
onClick={() => handleSubmit(value)}
|
|
95
|
+
>
|
|
96
|
+
{__('Submit')}
|
|
97
|
+
</Button>
|
|
98
|
+
<Button
|
|
99
|
+
ouiaId="cancel-webhook-form"
|
|
100
|
+
variant="link"
|
|
101
|
+
onClick={modalState.closeModal}
|
|
102
|
+
>
|
|
103
|
+
{__('Cancel')}
|
|
104
|
+
</Button>
|
|
105
|
+
</ActionGroup>
|
|
106
|
+
</Form>
|
|
107
|
+
</Modal>
|
|
87
108
|
);
|
|
88
109
|
};
|
|
89
110
|
|
|
90
111
|
WebhookTestModal.propTypes = {
|
|
91
112
|
toTest: PropTypes.object,
|
|
113
|
+
modalState: PropTypes.shape({
|
|
114
|
+
isOpen: PropTypes.bool.isRequired,
|
|
115
|
+
closeModal: PropTypes.func.isRequired,
|
|
116
|
+
}).isRequired,
|
|
92
117
|
};
|
|
93
118
|
|
|
94
119
|
WebhookTestModal.defaultProps = {
|
|
@@ -6,7 +6,6 @@ import { isEmpty } from 'lodash';
|
|
|
6
6
|
import { Table } from 'foremanReact/components/common/table';
|
|
7
7
|
import Pagination from 'foremanReact/components/Pagination';
|
|
8
8
|
import Loading from 'foremanReact/components/Loading';
|
|
9
|
-
import { useForemanModal } from 'foremanReact/components/ForemanModal/ForemanModalHooks';
|
|
10
9
|
|
|
11
10
|
import WebhookDeleteModal from '../WebhookDeleteModal';
|
|
12
11
|
import WebhookEditModal from '../WebhookEditModal';
|
|
@@ -15,8 +14,6 @@ import EmptyWebhooksTable from './Components/EmptyWebhooksTable';
|
|
|
15
14
|
|
|
16
15
|
import createWebhooksTableSchema from './WebhooksTableSchema';
|
|
17
16
|
|
|
18
|
-
import { WEBHOOK_EDIT_MODAL_ID } from '../../../constants';
|
|
19
|
-
|
|
20
17
|
import {
|
|
21
18
|
selectWebhooks,
|
|
22
19
|
selectPage,
|
|
@@ -38,6 +35,7 @@ const WebhooksTable = ({
|
|
|
38
35
|
onEditClick,
|
|
39
36
|
reloadWithSearch,
|
|
40
37
|
webhookActions,
|
|
38
|
+
modalsStates,
|
|
41
39
|
}) => {
|
|
42
40
|
const webhooks = useSelector(selectWebhooks);
|
|
43
41
|
const page = useSelector(selectPage);
|
|
@@ -51,15 +49,12 @@ const WebhooksTable = ({
|
|
|
51
49
|
const message = useSelector(selectMessage);
|
|
52
50
|
|
|
53
51
|
const onDeleteSuccess = () => {
|
|
52
|
+
modalsStates.deleteModal.closeModal();
|
|
54
53
|
const currentPage = page;
|
|
55
54
|
const maxPage = Math.ceil((itemCount - 1) / perPage);
|
|
56
55
|
fetchAndPush({ page: maxPage < currentPage ? maxPage : currentPage });
|
|
57
56
|
};
|
|
58
57
|
|
|
59
|
-
const { setModalClosed: setEditModalClosed } = useForemanModal({
|
|
60
|
-
id: WEBHOOK_EDIT_MODAL_ID,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
58
|
if (isLoading && !hasError) return <Loading />;
|
|
64
59
|
|
|
65
60
|
if (!isLoading && !hasData && isEmpty(search)) {
|
|
@@ -68,16 +63,20 @@ const WebhooksTable = ({
|
|
|
68
63
|
|
|
69
64
|
return (
|
|
70
65
|
<React.Fragment>
|
|
71
|
-
<WebhookDeleteModal
|
|
66
|
+
<WebhookDeleteModal
|
|
67
|
+
toDelete={toDelete}
|
|
68
|
+
onSuccess={onDeleteSuccess}
|
|
69
|
+
modalState={modalsStates.deleteModal}
|
|
70
|
+
/>
|
|
72
71
|
<WebhookEditModal
|
|
73
72
|
toEdit={toEdit}
|
|
74
73
|
onSuccess={() => {
|
|
75
|
-
|
|
74
|
+
modalsStates.editModal.closeModal();
|
|
76
75
|
reloadWithSearch(search);
|
|
77
76
|
}}
|
|
78
|
-
|
|
77
|
+
modalState={modalsStates.editModal}
|
|
79
78
|
/>
|
|
80
|
-
<WebhookTestModal toTest={toTest} />
|
|
79
|
+
<WebhookTestModal toTest={toTest} modalState={modalsStates.testModal} />
|
|
81
80
|
<Table
|
|
82
81
|
key="webhooks-table"
|
|
83
82
|
columns={createWebhooksTableSchema(
|
|
@@ -103,6 +102,20 @@ WebhooksTable.propTypes = {
|
|
|
103
102
|
toEdit: PropTypes.number.isRequired,
|
|
104
103
|
reloadWithSearch: PropTypes.func.isRequired,
|
|
105
104
|
webhookActions: PropTypes.object.isRequired,
|
|
105
|
+
modalsStates: PropTypes.shape({
|
|
106
|
+
deleteModal: PropTypes.shape({
|
|
107
|
+
isOpen: PropTypes.bool.isRequired,
|
|
108
|
+
closeModal: PropTypes.func.isRequired,
|
|
109
|
+
}).isRequired,
|
|
110
|
+
editModal: PropTypes.shape({
|
|
111
|
+
isOpen: PropTypes.bool.isRequired,
|
|
112
|
+
closeModal: PropTypes.func.isRequired,
|
|
113
|
+
}).isRequired,
|
|
114
|
+
testModal: PropTypes.shape({
|
|
115
|
+
isOpen: PropTypes.bool.isRequired,
|
|
116
|
+
closeModal: PropTypes.func.isRequired,
|
|
117
|
+
}).isRequired,
|
|
118
|
+
}).isRequired,
|
|
106
119
|
};
|
|
107
120
|
|
|
108
121
|
export default WebhooksTable;
|
|
@@ -8,6 +8,22 @@ exports[`WebhooksTable rendering should render when loading 1`] = `
|
|
|
8
8
|
hasError={false}
|
|
9
9
|
isLoading={true}
|
|
10
10
|
itemCount={0}
|
|
11
|
+
modalsStates={
|
|
12
|
+
Object {
|
|
13
|
+
"deleteModal": Object {
|
|
14
|
+
"closeModal": [Function],
|
|
15
|
+
"isOpen": false,
|
|
16
|
+
},
|
|
17
|
+
"editModal": Object {
|
|
18
|
+
"closeModal": [Function],
|
|
19
|
+
"isOpen": false,
|
|
20
|
+
},
|
|
21
|
+
"testModal": Object {
|
|
22
|
+
"closeModal": [Function],
|
|
23
|
+
"isOpen": false,
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
}
|
|
11
27
|
onDeleteClick={[MockFunction]}
|
|
12
28
|
onEditClick={[Function]}
|
|
13
29
|
onTestClick={[Function]}
|
|
@@ -54,6 +70,22 @@ exports[`WebhooksTable rendering should render with error 1`] = `
|
|
|
54
70
|
"type": "error",
|
|
55
71
|
}
|
|
56
72
|
}
|
|
73
|
+
modalsStates={
|
|
74
|
+
Object {
|
|
75
|
+
"deleteModal": Object {
|
|
76
|
+
"closeModal": [Function],
|
|
77
|
+
"isOpen": false,
|
|
78
|
+
},
|
|
79
|
+
"editModal": Object {
|
|
80
|
+
"closeModal": [Function],
|
|
81
|
+
"isOpen": false,
|
|
82
|
+
},
|
|
83
|
+
"testModal": Object {
|
|
84
|
+
"closeModal": [Function],
|
|
85
|
+
"isOpen": false,
|
|
86
|
+
},
|
|
87
|
+
}
|
|
88
|
+
}
|
|
57
89
|
onDeleteClick={[MockFunction]}
|
|
58
90
|
onEditClick={[Function]}
|
|
59
91
|
onTestClick={[Function]}
|
|
@@ -94,6 +126,22 @@ exports[`WebhooksTable rendering should render with no data 1`] = `
|
|
|
94
126
|
hasError={false}
|
|
95
127
|
isLoading={false}
|
|
96
128
|
itemCount={0}
|
|
129
|
+
modalsStates={
|
|
130
|
+
Object {
|
|
131
|
+
"deleteModal": Object {
|
|
132
|
+
"closeModal": [Function],
|
|
133
|
+
"isOpen": false,
|
|
134
|
+
},
|
|
135
|
+
"editModal": Object {
|
|
136
|
+
"closeModal": [Function],
|
|
137
|
+
"isOpen": false,
|
|
138
|
+
},
|
|
139
|
+
"testModal": Object {
|
|
140
|
+
"closeModal": [Function],
|
|
141
|
+
"isOpen": false,
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
}
|
|
97
145
|
onDeleteClick={[MockFunction]}
|
|
98
146
|
onEditClick={[Function]}
|
|
99
147
|
onTestClick={[Function]}
|
|
@@ -134,6 +182,22 @@ exports[`WebhooksTable rendering should render with webhooks 1`] = `
|
|
|
134
182
|
hasError={false}
|
|
135
183
|
isLoading={false}
|
|
136
184
|
itemCount={2}
|
|
185
|
+
modalsStates={
|
|
186
|
+
Object {
|
|
187
|
+
"deleteModal": Object {
|
|
188
|
+
"closeModal": [Function],
|
|
189
|
+
"isOpen": false,
|
|
190
|
+
},
|
|
191
|
+
"editModal": Object {
|
|
192
|
+
"closeModal": [Function],
|
|
193
|
+
"isOpen": false,
|
|
194
|
+
},
|
|
195
|
+
"testModal": Object {
|
|
196
|
+
"closeModal": [Function],
|
|
197
|
+
"isOpen": false,
|
|
198
|
+
},
|
|
199
|
+
}
|
|
200
|
+
}
|
|
137
201
|
onDeleteClick={[MockFunction]}
|
|
138
202
|
onEditClick={[Function]}
|
|
139
203
|
onTestClick={[Function]}
|
data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/index.js
CHANGED
|
@@ -1,43 +1,28 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
|
-
import { useForemanModal } from 'foremanReact/components/ForemanModal/ForemanModalHooks';
|
|
5
|
-
|
|
6
4
|
import WebhooksTable from './WebhooksTable';
|
|
7
|
-
import {
|
|
8
|
-
WEBHOOK_DELETE_MODAL_ID,
|
|
9
|
-
WEBHOOK_EDIT_MODAL_ID,
|
|
10
|
-
WEBHOOK_TEST_MODAL_ID,
|
|
11
|
-
} from '../../../constants';
|
|
12
5
|
|
|
13
6
|
const WrappedWebhooksTable = props => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const { setModalOpen: setEditModalOpen } = useForemanModal({
|
|
19
|
-
id: WEBHOOK_EDIT_MODAL_ID,
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const { setModalOpen: setTestModalOpen } = useForemanModal({
|
|
23
|
-
id: WEBHOOK_TEST_MODAL_ID,
|
|
24
|
-
});
|
|
7
|
+
const [isTestModalOpen, setIsTestModalOpen] = useState(false);
|
|
8
|
+
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
|
9
|
+
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
|
|
25
10
|
|
|
26
11
|
const { setToDelete, setToEdit, setToTest, ...rest } = props;
|
|
27
12
|
|
|
28
13
|
const onDeleteClick = rowData => {
|
|
29
14
|
setToDelete(rowData);
|
|
30
|
-
|
|
15
|
+
setIsDeleteModalOpen(true);
|
|
31
16
|
};
|
|
32
17
|
|
|
33
18
|
const onEditClick = rowData => {
|
|
34
19
|
setToEdit(rowData);
|
|
35
|
-
|
|
20
|
+
setIsEditModalOpen(true);
|
|
36
21
|
};
|
|
37
22
|
|
|
38
23
|
const onTestClick = rowData => {
|
|
39
24
|
setToTest(rowData);
|
|
40
|
-
|
|
25
|
+
setIsTestModalOpen(true);
|
|
41
26
|
};
|
|
42
27
|
|
|
43
28
|
const webhookActions = {
|
|
@@ -53,6 +38,20 @@ const WrappedWebhooksTable = props => {
|
|
|
53
38
|
<WebhooksTable
|
|
54
39
|
onEditClick={onEditClick}
|
|
55
40
|
onTestClick={onTestClick}
|
|
41
|
+
modalsStates={{
|
|
42
|
+
testModal: {
|
|
43
|
+
isOpen: isTestModalOpen,
|
|
44
|
+
closeModal: () => setIsTestModalOpen(false),
|
|
45
|
+
},
|
|
46
|
+
deleteModal: {
|
|
47
|
+
isOpen: isDeleteModalOpen,
|
|
48
|
+
closeModal: () => setIsDeleteModalOpen(false),
|
|
49
|
+
},
|
|
50
|
+
editModal: {
|
|
51
|
+
isOpen: isEditModalOpen,
|
|
52
|
+
closeModal: () => setIsEditModalOpen(false),
|
|
53
|
+
},
|
|
54
|
+
}}
|
|
56
55
|
webhookActions={webhookActions}
|
|
57
56
|
{...rest}
|
|
58
57
|
/>
|
|
@@ -3,13 +3,8 @@ import { useSelector, useDispatch } from 'react-redux';
|
|
|
3
3
|
|
|
4
4
|
import TableIndexPage from 'foremanReact/components/PF4/TableIndexPage/TableIndexPage';
|
|
5
5
|
import { translate as __ } from 'foremanReact/common/I18n';
|
|
6
|
-
import { useForemanModal } from 'foremanReact/components/ForemanModal/ForemanModalHooks';
|
|
7
6
|
|
|
8
|
-
import {
|
|
9
|
-
WEBHOOKS_API_PATH,
|
|
10
|
-
WEBHOOKS_API_REQUEST_KEY,
|
|
11
|
-
WEBHOOK_CREATE_MODAL_ID,
|
|
12
|
-
} from '../constants';
|
|
7
|
+
import { WEBHOOKS_API_PATH, WEBHOOKS_API_REQUEST_KEY } from '../constants';
|
|
13
8
|
|
|
14
9
|
import { selectSearch } from '../WebhooksPageSelectors';
|
|
15
10
|
|
|
@@ -26,29 +21,28 @@ const WebhooksIndexPage = () => {
|
|
|
26
21
|
const [toDelete, setToDelete] = useState({});
|
|
27
22
|
const [toTest, setToTest] = useState({});
|
|
28
23
|
const [toEdit, setToEdit] = useState(0);
|
|
24
|
+
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
|
29
25
|
|
|
30
|
-
const {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} = useForemanModal({
|
|
34
|
-
id: WEBHOOK_CREATE_MODAL_ID,
|
|
35
|
-
});
|
|
26
|
+
const openModal = () => {
|
|
27
|
+
setIsCreateModalOpen(true);
|
|
28
|
+
};
|
|
36
29
|
|
|
37
30
|
return (
|
|
38
31
|
<>
|
|
39
32
|
<WebhookCreateModal
|
|
33
|
+
isOpen={isCreateModalOpen}
|
|
40
34
|
onSuccess={() => {
|
|
41
|
-
|
|
35
|
+
setIsCreateModalOpen(false);
|
|
42
36
|
dispatch(reloadWithSearch(search));
|
|
43
37
|
}}
|
|
44
|
-
onCancel={
|
|
38
|
+
onCancel={() => setIsCreateModalOpen(false)}
|
|
45
39
|
/>
|
|
46
40
|
<TableIndexPage
|
|
47
41
|
header={__('Webhooks')}
|
|
48
42
|
controller="webhooks"
|
|
49
43
|
apiUrl={WEBHOOKS_API_PATH}
|
|
50
44
|
apiOptions={{ key: WEBHOOKS_API_REQUEST_KEY }}
|
|
51
|
-
customCreateAction={() =>
|
|
45
|
+
customCreateAction={() => openModal}
|
|
52
46
|
>
|
|
53
47
|
<WebhooksTable
|
|
54
48
|
fetchAndPush={params => dispatch(fetchAndPush(params))}
|
data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/integration.test.js
CHANGED
|
@@ -24,11 +24,8 @@ describe('WebhooksIndexPage - Integration Test', () => {
|
|
|
24
24
|
<ConnectedWebhooksIndexPage history={history} />
|
|
25
25
|
</Router>
|
|
26
26
|
);
|
|
27
|
-
integrationTestHelper.takeStoreAndLastActionSnapshot('rendered');
|
|
28
27
|
|
|
29
28
|
expect(component.exists('WebhooksTable')).toEqual(true);
|
|
30
29
|
expect(component.exists('WebhookCreateModal')).toEqual(true);
|
|
31
|
-
|
|
32
|
-
integrationTestHelper.takeStoreAndLastActionSnapshot('initial state');
|
|
33
30
|
});
|
|
34
31
|
});
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: foreman_webhooks
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 5.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Timo Goebel
|
|
@@ -174,18 +174,19 @@ files:
|
|
|
174
174
|
- test/graphql/foreman_webhooks/queries/webhook_template_query_test.rb
|
|
175
175
|
- test/graphql/foreman_webhooks/queries/webhook_templates_query_test.rb
|
|
176
176
|
- test/graphql/foreman_webhooks/queries/webhooks_query_test.rb
|
|
177
|
+
- test/integration/webhooks_test.rb
|
|
177
178
|
- test/jobs/foreman_webhooks/deliver_webhook_job_test.rb
|
|
178
179
|
- test/models/webhook_test.rb
|
|
179
180
|
- test/test_plugin_helper.rb
|
|
180
181
|
- test/unit/foreman_webhooks/webhook_service_test.rb
|
|
181
182
|
- webpack/ForemanWebhooks/Routes/ForemanWebhooksRoutes.js
|
|
182
|
-
- webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/
|
|
183
|
+
- webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/FieldConstructor.js
|
|
183
184
|
- webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/WebhookFormTabs.css
|
|
184
185
|
- webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/WebhookFormTabs.js
|
|
186
|
+
- webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/__tests__/FieldConstructor.test.js
|
|
185
187
|
- webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/WebhookForm.js
|
|
186
188
|
- webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/WebhookFormSelectors.js
|
|
187
189
|
- webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/__tests__/WebhookForm.test.js
|
|
188
|
-
- webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/__tests__/__snapshots__/WebhookForm.test.js.snap
|
|
189
190
|
- webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/constants.js
|
|
190
191
|
- webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/index.js
|
|
191
192
|
- webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookCreateModal.js
|
|
@@ -215,7 +216,6 @@ files:
|
|
|
215
216
|
- webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/WebhooksIndexPage.fixtures.js
|
|
216
217
|
- webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/WebhooksIndexPage.test.js
|
|
217
218
|
- webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/__snapshots__/WebhooksIndexPage.test.js.snap
|
|
218
|
-
- webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/__snapshots__/integration.test.js.snap
|
|
219
219
|
- webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/integration.test.js
|
|
220
220
|
- webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/index.js
|
|
221
221
|
- webpack/ForemanWebhooks/Routes/Webhooks/WebhooksPageActions.js
|
|
@@ -272,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
272
272
|
- !ruby/object:Gem::Version
|
|
273
273
|
version: '0'
|
|
274
274
|
requirements: []
|
|
275
|
-
rubygems_version:
|
|
275
|
+
rubygems_version: 4.0.3
|
|
276
276
|
specification_version: 4
|
|
277
277
|
summary: Configure webhooks for Foreman.
|
|
278
278
|
test_files:
|
|
@@ -284,10 +284,12 @@ test_files:
|
|
|
284
284
|
- test/graphql/foreman_webhooks/queries/webhook_template_query_test.rb
|
|
285
285
|
- test/graphql/foreman_webhooks/queries/webhook_templates_query_test.rb
|
|
286
286
|
- test/graphql/foreman_webhooks/queries/webhooks_query_test.rb
|
|
287
|
+
- test/integration/webhooks_test.rb
|
|
287
288
|
- test/jobs/foreman_webhooks/deliver_webhook_job_test.rb
|
|
288
289
|
- test/models/webhook_test.rb
|
|
289
290
|
- test/test_plugin_helper.rb
|
|
290
291
|
- test/unit/foreman_webhooks/webhook_service_test.rb
|
|
292
|
+
- webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/__tests__/FieldConstructor.test.js
|
|
291
293
|
- webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/__tests__/WebhookForm.test.js
|
|
292
294
|
- webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/__tests__/enabledCellFormatter.test.js
|
|
293
295
|
- webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/__tests__/EnabledCell.test.js
|