-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathWebhooksIndexPage.js
68 lines (57 loc) · 1.93 KB
/
WebhooksIndexPage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import React, { useState } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import TableIndexPage from 'foremanReact/components/PF4/TableIndexPage/TableIndexPage';
import { translate as __ } from 'foremanReact/common/I18n';
import { useForemanModal } from 'foremanReact/components/ForemanModal/ForemanModalHooks';
import {
WEBHOOKS_API_PATH,
WEBHOOKS_API_REQUEST_KEY,
WEBHOOK_CREATE_MODAL_ID,
} from '../constants';
import { selectSearch } from '../WebhooksPageSelectors';
import WebhooksTable from './Components/WebhooksTable';
import WebhookCreateModal from './Components/WebhookCreateModal';
import { reloadWithSearch, fetchAndPush } from '../WebhooksPageActions';
const WebhooksIndexPage = () => {
const dispatch = useDispatch();
const search = useSelector(selectSearch);
const [toDelete, setToDelete] = useState({});
const [toTest, setToTest] = useState({});
const [toEdit, setToEdit] = useState(0);
const {
setModalOpen: setCreateModalOpen,
setModalClosed: setCreateModalClosed,
} = useForemanModal({
id: WEBHOOK_CREATE_MODAL_ID,
});
return (
<>
<WebhookCreateModal
onSuccess={() => {
setCreateModalClosed();
dispatch(reloadWithSearch(search));
}}
onCancel={setCreateModalClosed}
/>
<TableIndexPage
header={__('Webhooks')}
controller="webhooks"
apiUrl={WEBHOOKS_API_PATH}
apiOptions={{ key: WEBHOOKS_API_REQUEST_KEY }}
customCreateAction={() => setCreateModalOpen}
>
<WebhooksTable
fetchAndPush={params => dispatch(fetchAndPush(params))}
toDelete={toDelete}
setToDelete={setToDelete}
toEdit={toEdit}
setToEdit={setToEdit}
toTest={toTest}
setToTest={setToTest}
reloadWithSearch={query => dispatch(reloadWithSearch(query))}
/>
</TableIndexPage>
</>
);
};
export default WebhooksIndexPage;