foreman_webhooks 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1334f49eb8f7f4e7459b9be38c441530ded5f9bf3c9ec4e3b81486d10790966f
4
- data.tar.gz: 17d3ed3b1aada4e91b227a59c2f0aaed8530bf9ff574cb9356373c7b45a27508
3
+ metadata.gz: 5382cbf96f38f9ab42cef651aaf8eb1e602d2c651352c370138b911e7cd10901
4
+ data.tar.gz: 5e32f69db8731876e51af931c9d3b174c9dcae62ae3ebdb11b186d70b5fff384
5
5
  SHA512:
6
- metadata.gz: a49b1de24a65d38bec45c490ef8d88e7a04fbc682b990f09832f6de36450557bbccf9a306de1bd0c6032f594ca7e45512de4b3cdf3872c74e59e1b7b119abfe5
7
- data.tar.gz: 107303f91d79b0590ac2d304adc0a36bf6f616bde6d7c6427744a5b71f2a9e696a61776e497433cb5a4db46dc6774464934c4256245a09e32ef4d96e1e018510
6
+ metadata.gz: fc5314756061144ef29988e98b7344c25b2df0e13b3cb122a965d071c18c5fdb9e46badc061b50f2e79b76e33ebf95e8d9c54671bac1dd0e46b334e070a9048a
7
+ data.tar.gz: f9e3824a1b66dfdd988eeb9b3bbbd922d9e9b460bb7922a0139130a47cf7074ed958449c82e97941b7492328b361f2296026168b41ee85d492689ae691620012
@@ -79,7 +79,10 @@ class Webhook < ApplicationRecord
79
79
 
80
80
  def ca_certs_store
81
81
  store = OpenSSL::X509::Store.new
82
- return store if ssl_ca_certs.blank?
82
+ if ssl_ca_certs.blank?
83
+ store.set_default_paths
84
+ return store
85
+ end
83
86
 
84
87
  ssl_ca_certs.split(/(?=-----BEGIN)/).each do |cert|
85
88
  store.add_cert(OpenSSL::X509::Certificate.new(cert))
@@ -15,7 +15,7 @@ module ForemanWebhooks
15
15
 
16
16
  initializer 'foreman_webhooks.register_plugin', before: :finisher_hook do |_app|
17
17
  Foreman::Plugin.register :foreman_webhooks do
18
- requires_foreman '>= 3.2'
18
+ requires_foreman '>= 3.3'
19
19
 
20
20
  apipie_documented_controllers ["#{ForemanWebhooks::Engine.root}/app/controllers/api/v2/*.rb"]
21
21
  ApipieDSL.configuration.sections += ['webhooks']
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanWebhooks
4
- VERSION = '3.0.3'
4
+ VERSION = '3.0.4'
5
5
  end
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { translate as __ } from 'foremanReact/common/I18n';
4
+ import DefaultEmptyState from 'foremanReact/components/common/EmptyState';
5
+
6
+ const EmptyWebhooksTable = ({ message: { type, text } }) => (
7
+ <DefaultEmptyState
8
+ icon={type === 'error' ? 'error-circle-o' : 'add-circle-o'}
9
+ header={type === 'error' ? __('Error') : __('No Results')}
10
+ description={text}
11
+ documentation={null}
12
+ />
13
+ );
14
+
15
+ EmptyWebhooksTable.propTypes = {
16
+ message: PropTypes.shape({
17
+ type: PropTypes.oneOf(['empty', 'error']),
18
+ text: PropTypes.string,
19
+ }),
20
+ };
21
+
22
+ EmptyWebhooksTable.defaultProps = {
23
+ message: {
24
+ type: 'empty',
25
+ text: __('Try to create a new webhook'),
26
+ },
27
+ };
28
+
29
+ export default EmptyWebhooksTable;
@@ -1,33 +1,56 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
+ import { useSelector } from 'react-redux';
4
+ import { isEmpty } from 'lodash';
3
5
 
4
6
  import { Table } from 'foremanReact/components/common/table';
5
7
  import Pagination from 'foremanReact/components/Pagination';
8
+ import Loading from 'foremanReact/components/Loading';
6
9
  import { useForemanModal } from 'foremanReact/components/ForemanModal/ForemanModalHooks';
7
10
 
8
11
  import WebhookDeleteModal from '../WebhookDeleteModal';
9
12
  import WebhookEditModal from '../WebhookEditModal';
13
+ import EmptyWebhooksTable from './Components/EmptyWebhooksTable';
10
14
 
11
15
  import createWebhooksTableSchema from './WebhooksTableSchema';
12
16
 
13
17
  import { WEBHOOK_EDIT_MODAL_ID } from '../../../constants';
14
18
 
19
+ import {
20
+ selectWebhooks,
21
+ selectPage,
22
+ selectPerPage,
23
+ selectSearch,
24
+ selectSort,
25
+ selectHasData,
26
+ selectHasError,
27
+ selectIsLoading,
28
+ selectSubtotal,
29
+ selectMessage,
30
+ } from '../../../WebhooksPageSelectors';
31
+
15
32
  const WebhooksTable = ({
16
33
  fetchAndPush,
17
- itemCount,
18
- results,
19
- sort,
20
- pagination,
21
34
  toDelete,
22
35
  onDeleteClick,
23
36
  toEdit,
24
37
  onEditClick,
25
38
  reloadWithSearch,
26
- search,
27
39
  }) => {
40
+ const webhooks = useSelector(selectWebhooks);
41
+ const page = useSelector(selectPage);
42
+ const perPage = useSelector(selectPerPage);
43
+ const search = useSelector(selectSearch);
44
+ const sort = useSelector(selectSort);
45
+ const isLoading = useSelector(selectIsLoading);
46
+ const hasData = useSelector(selectHasData);
47
+ const hasError = useSelector(selectHasError);
48
+ const itemCount = useSelector(selectSubtotal);
49
+ const message = useSelector(selectMessage);
50
+
28
51
  const onDeleteSuccess = () => {
29
- const currentPage = pagination.page;
30
- const maxPage = Math.ceil((itemCount - 1) / pagination.perPage);
52
+ const currentPage = page;
53
+ const maxPage = Math.ceil((itemCount - 1) / perPage);
31
54
  fetchAndPush({ page: maxPage < currentPage ? maxPage : currentPage });
32
55
  };
33
56
 
@@ -35,6 +58,12 @@ const WebhooksTable = ({
35
58
  id: WEBHOOK_EDIT_MODAL_ID,
36
59
  });
37
60
 
61
+ if (isLoading && !hasError) return <Loading />;
62
+
63
+ if (!isLoading && !hasData && isEmpty(search)) {
64
+ return <EmptyWebhooksTable message={message} />;
65
+ }
66
+
38
67
  return (
39
68
  <React.Fragment>
40
69
  <WebhookDeleteModal toDelete={toDelete} onSuccess={onDeleteSuccess} />
@@ -55,7 +84,7 @@ const WebhooksTable = ({
55
84
  onDeleteClick,
56
85
  onEditClick
57
86
  )}
58
- rows={results}
87
+ rows={webhooks}
59
88
  id="webhooks-table"
60
89
  />
61
90
  <Pagination itemCount={itemCount} onChange={fetchAndPush} />
@@ -64,22 +93,12 @@ const WebhooksTable = ({
64
93
  };
65
94
 
66
95
  WebhooksTable.propTypes = {
67
- results: PropTypes.array.isRequired,
68
96
  fetchAndPush: PropTypes.func.isRequired,
69
97
  onDeleteClick: PropTypes.func.isRequired,
70
98
  onEditClick: PropTypes.func.isRequired,
71
- itemCount: PropTypes.number.isRequired,
72
- sort: PropTypes.object,
73
- pagination: PropTypes.object.isRequired,
74
99
  toDelete: PropTypes.object.isRequired,
75
100
  toEdit: PropTypes.number.isRequired,
76
101
  reloadWithSearch: PropTypes.func.isRequired,
77
- search: PropTypes.string,
78
- };
79
-
80
- WebhooksTable.defaultProps = {
81
- sort: { by: '', order: '' },
82
- search: '',
83
102
  };
84
103
 
85
104
  export default WebhooksTable;
@@ -1,33 +1,28 @@
1
1
  import React, { useState } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { Button } from 'patternfly-react';
2
+ import { useSelector, useDispatch } from 'react-redux';
4
3
 
4
+ import TableIndexPage from 'foremanReact/components/PF4/TableIndexPage/TableIndexPage';
5
5
  import { translate as __ } from 'foremanReact/common/I18n';
6
- import PageLayout from 'foremanReact/routes/common/PageLayout/PageLayout';
7
6
  import { useForemanModal } from 'foremanReact/components/ForemanModal/ForemanModalHooks';
8
- import { withRenderHandler } from 'foremanReact/common/HOC';
9
7
 
10
- import { WEBHOOKS_SEARCH_PROPS, WEBHOOK_CREATE_MODAL_ID } from '../constants';
8
+ import {
9
+ WEBHOOKS_API_PATH,
10
+ WEBHOOKS_API_REQUEST_KEY,
11
+ WEBHOOK_CREATE_MODAL_ID,
12
+ } from '../constants';
13
+
14
+ import { selectSearch } from '../WebhooksPageSelectors';
11
15
 
12
16
  import WebhooksTable from './Components/WebhooksTable';
13
17
  import WebhookCreateModal from './Components/WebhookCreateModal';
14
- import EmptyWebhooksIndexPage from './Components/EmptyWebhooksIndexPage';
15
18
 
16
- const WebhooksIndexPage = ({
17
- fetchAndPush,
18
- search,
19
- isLoading,
20
- hasData,
21
- webhooks,
22
- page,
23
- perPage,
24
- sort,
25
- hasError,
26
- itemCount,
27
- message,
28
- canCreate,
29
- reloadWithSearch,
30
- }) => {
19
+ import { reloadWithSearch, fetchAndPush } from '../WebhooksPageActions';
20
+
21
+ const WebhooksIndexPage = () => {
22
+ const dispatch = useDispatch();
23
+
24
+ const search = useSelector(selectSearch);
25
+
31
26
  const [toDelete, setToDelete] = useState({});
32
27
  const [toEdit, setToEdit] = useState(0);
33
28
 
@@ -38,76 +33,33 @@ const WebhooksIndexPage = ({
38
33
  id: WEBHOOK_CREATE_MODAL_ID,
39
34
  });
40
35
 
41
- const createBtn = (
42
- <Button onClick={setCreateModalOpen} bsStyle="primary">
43
- {__('Create Webhook')}
44
- </Button>
45
- );
46
-
47
36
  return (
48
37
  <>
49
38
  <WebhookCreateModal
50
39
  onSuccess={() => {
51
40
  setCreateModalClosed();
52
- reloadWithSearch(search);
41
+ dispatch(reloadWithSearch(search));
53
42
  }}
54
43
  onCancel={setCreateModalClosed}
55
44
  />
56
- <PageLayout
45
+ <TableIndexPage
57
46
  header={__('Webhooks')}
58
- searchable={!isLoading}
59
- searchProps={WEBHOOKS_SEARCH_PROPS}
60
- searchQuery={search}
61
- isLoading={isLoading && hasData}
62
- onSearch={reloadWithSearch}
63
- onBookmarkClick={reloadWithSearch}
64
- toolbarButtons={canCreate && createBtn}
47
+ controller="webhooks"
48
+ apiUrl={WEBHOOKS_API_PATH}
49
+ apiOptions={{ key: WEBHOOKS_API_REQUEST_KEY }}
50
+ customCreateAction={() => setCreateModalOpen}
65
51
  >
66
52
  <WebhooksTable
67
- results={webhooks}
68
- fetchAndPush={fetchAndPush}
69
- pagination={{ page, perPage }}
70
- itemCount={itemCount}
71
- sort={sort}
53
+ fetchAndPush={params => dispatch(fetchAndPush(params))}
72
54
  toDelete={toDelete}
73
55
  setToDelete={setToDelete}
74
- hasData={hasData}
75
- hasError={hasError}
76
- isLoading={isLoading}
77
56
  toEdit={toEdit}
78
57
  setToEdit={setToEdit}
79
- reloadWithSearch={reloadWithSearch}
58
+ reloadWithSearch={query => dispatch(reloadWithSearch(query))}
80
59
  />
81
- </PageLayout>
60
+ </TableIndexPage>
82
61
  </>
83
62
  );
84
63
  };
85
64
 
86
- WebhooksIndexPage.propTypes = {
87
- fetchAndPush: PropTypes.func.isRequired,
88
- search: PropTypes.string,
89
- isLoading: PropTypes.bool.isRequired,
90
- hasData: PropTypes.bool.isRequired,
91
- webhooks: PropTypes.array.isRequired,
92
- page: PropTypes.number,
93
- perPage: PropTypes.number,
94
- sort: PropTypes.object.isRequired,
95
- hasError: PropTypes.bool.isRequired,
96
- itemCount: PropTypes.number.isRequired,
97
- message: PropTypes.object,
98
- canCreate: PropTypes.bool.isRequired,
99
- reloadWithSearch: PropTypes.func.isRequired,
100
- };
101
-
102
- WebhooksIndexPage.defaultProps = {
103
- page: null,
104
- perPage: null,
105
- search: '',
106
- message: { type: 'empty', text: __('Try to create a new Webhook') },
107
- };
108
-
109
- export default withRenderHandler({
110
- Component: WebhooksIndexPage,
111
- EmptyComponent: EmptyWebhooksIndexPage,
112
- ErrorComponent: EmptyWebhooksIndexPage,
113
- });
65
+ export default WebhooksIndexPage;
@@ -1,4 +1,8 @@
1
+ import React from 'react';
1
2
  import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
3
+ import { Provider } from 'react-redux';
4
+ import { createStore } from 'redux';
5
+
2
6
  import WebhooksIndexPage from '../WebhooksIndexPage';
3
7
 
4
8
  const fixtures = {
@@ -17,6 +21,12 @@ const fixtures = {
17
21
  };
18
22
 
19
23
  describe('WebhooksIndexPage', () => {
20
- describe('redering', () =>
21
- testComponentSnapshotsWithFixtures(WebhooksIndexPage, fixtures));
24
+ describe('redering', () => {
25
+ const webhooksPage = () => (
26
+ <Provider store={createStore((state = [], action) => state)}>
27
+ <WebhooksIndexPage />
28
+ </Provider>
29
+ );
30
+ testComponentSnapshotsWithFixtures(webhooksPage, fixtures);
31
+ });
22
32
  });
@@ -1,25 +1,17 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`WebhooksIndexPage redering render with minimal props 1`] = `
4
- <WebhooksIndexPage
5
- canCreate={true}
6
- fetchAndPush={[MockFunction]}
7
- handleCreateSubmit={[MockFunction]}
8
- hasData={false}
9
- hasError={false}
10
- isLoading={false}
11
- itemCount={0}
12
- message={
4
+ <Provider
5
+ store={
13
6
  Object {
14
- "text": "Try to create a new Webhook",
15
- "type": "empty",
7
+ "dispatch": [Function],
8
+ "getState": [Function],
9
+ "replaceReducer": [Function],
10
+ "subscribe": [Function],
11
+ Symbol(Symbol.observable): [Function],
16
12
  }
17
13
  }
18
- page={null}
19
- perPage={null}
20
- reloadWithSearch={[MockFunction]}
21
- search=""
22
- sort={Object {}}
23
- webhooks={Array []}
24
- />
14
+ >
15
+ <WebhooksIndexPage />
16
+ </Provider>
25
17
  `;
@@ -5,15 +5,9 @@ Object {
5
5
  "action": Array [
6
6
  Array [
7
7
  Object {
8
- "key": "WEBHOOKS",
9
- "params": Object {
10
- "order": "",
11
- "page": 1,
12
- "per_page": 20,
13
- "search": "",
14
- },
8
+ "key": "WEBHOOK_EVENTS",
15
9
  "type": "get-some-type",
16
- "url": "/api/v2/webhooks?include_permissions=true",
10
+ "url": "",
17
11
  },
18
12
  ],
19
13
  ],
@@ -26,15 +20,9 @@ Object {
26
20
  "action": Array [
27
21
  Array [
28
22
  Object {
29
- "key": "WEBHOOKS",
30
- "params": Object {
31
- "order": "",
32
- "page": 1,
33
- "per_page": 20,
34
- "search": "",
35
- },
23
+ "key": "WEBHOOK_EVENTS",
36
24
  "type": "get-some-type",
37
- "url": "/api/v2/webhooks?include_permissions=true",
25
+ "url": "",
38
26
  },
39
27
  ],
40
28
  ],
@@ -1,43 +1,3 @@
1
- import { connect } from 'react-redux';
2
- import { compose, bindActionCreators } from 'redux';
3
-
4
- import { callOnMount, callOnPopState } from 'foremanReact/common/HOC';
5
-
6
1
  import WebhooksIndexPage from './WebhooksIndexPage';
7
- import * as actions from '../WebhooksPageActions';
8
-
9
- import {
10
- selectWebhooks,
11
- selectPage,
12
- selectPerPage,
13
- selectSearch,
14
- selectSort,
15
- selectHasData,
16
- selectHasError,
17
- selectIsLoading,
18
- selectSubtotal,
19
- selectMessage,
20
- selectCanCreate,
21
- } from '../WebhooksPageSelectors';
22
-
23
- const mapStateToProps = state => ({
24
- webhooks: selectWebhooks(state),
25
- page: selectPage(state),
26
- perPage: selectPerPage(state),
27
- search: selectSearch(state),
28
- sort: selectSort(state),
29
- isLoading: selectIsLoading(state),
30
- hasData: selectHasData(state),
31
- hasError: selectHasError(state),
32
- itemCount: selectSubtotal(state),
33
- message: selectMessage(state),
34
- canCreate: selectCanCreate(state),
35
- });
36
-
37
- const mapDispatchToProps = dispatch => bindActionCreators(actions, dispatch);
38
2
 
39
- export default compose(
40
- connect(mapStateToProps, mapDispatchToProps),
41
- callOnMount(({ initializeWebhooks }) => initializeWebhooks()),
42
- callOnPopState(({ fetchWebhooks }) => fetchWebhooks())
43
- )(WebhooksIndexPage);
3
+ export default WebhooksIndexPage;
@@ -1,6 +1,6 @@
1
1
  import history from 'foremanReact/history';
2
2
  import { get } from 'foremanReact/redux/API';
3
- import { stringifyParams, getParams } from 'foremanReact/common/urlHelpers';
3
+ import { stringifyParams } from 'foremanReact/common/urlHelpers';
4
4
 
5
5
  import { buildQuery } from './WebhooksPageHelpers';
6
6
  import {
@@ -9,17 +9,6 @@ import {
9
9
  WEBHOOKS_API_REQUEST_KEY,
10
10
  } from './constants';
11
11
 
12
- export const initializeWebhooks = () => dispatch => {
13
- const params = getParams();
14
- dispatch(fetchWebhooks({ per_page: params.perPage, ...params }));
15
- if (!history.action === 'POP') {
16
- history.replace({
17
- pathname: WEBHOOKS_PATH,
18
- search: stringifyParams(params),
19
- });
20
- }
21
- };
22
-
23
12
  export const fetchWebhooks = (
24
13
  /* eslint-disable-next-line camelcase */
25
14
  { page, per_page, searchQuery, sort },
@@ -1,12 +1,9 @@
1
- import { getControllerSearchProps } from 'foremanReact/constants';
2
-
3
1
  export const WEBHOOKS_PAGE_DATA_RESOLVED = 'WEBHOOKS_PAGE_DATA_RESOLVED';
4
2
  export const WEBHOOKS_PAGE_DATA_FAILED = 'WEBHOOKS_PAGE_DATA_FAILED';
5
3
  export const WEBHOOKS_PAGE_HIDE_LOADING = 'WEBHOOKS_PAGE_HIDE_LOADING';
6
4
  export const WEBHOOKS_PAGE_SHOW_LOADING = 'WEBHOOKS_PAGE_SHOW_LOADING';
7
5
  export const WEBHOOKS_PAGE_CLEAR_ERROR = 'WEBHOOKS_PAGE_CLEAR_ERROR';
8
6
 
9
- export const WEBHOOKS_SEARCH_PROPS = getControllerSearchProps('webhooks');
10
7
  export const WEBHOOKS_API_PATH = '/api/v2/webhooks?include_permissions=true';
11
8
  export const WEBHOOKS_PATH = '/webhooks';
12
9
  export const WEBHOOKS_API_REQUEST_KEY = 'WEBHOOKS';
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ const TableIndexPage = ({ children }) => <div>{children}</div>;
5
+
6
+ TableIndexPage.propTypes = {
7
+ children: PropTypes.node.isRequired,
8
+ };
9
+
10
+ export default TableIndexPage;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_webhooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timo Goebel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-03 00:00:00.000000000 Z
11
+ date: 2022-08-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Plugin for Foreman that allows to configure Webhooks.
14
14
  email:
@@ -94,12 +94,12 @@ files:
94
94
  - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/__tests__/__snapshots__/WebhookForm.test.js.snap
95
95
  - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/constants.js
96
96
  - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/index.js
97
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/EmptyWebhooksIndexPage/index.js
98
97
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookCreateModal.js
99
98
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookDeleteModal.js
100
99
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookEditModal.js
101
100
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookEditModalSelectors.js
102
101
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookModal.scss
102
+ - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/EmptyWebhooksTable/index.js
103
103
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/EnabledCell.js
104
104
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/__tests__/__snapshots__/enabledCellFormatter.test.js.snap
105
105
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/__tests__/enabledCellFormatter.test.js
@@ -139,6 +139,7 @@ files:
139
139
  - webpack/__mocks__/foremanReact/components/Layout/LayoutActions.js
140
140
  - webpack/__mocks__/foremanReact/components/Loading/Loading.js
141
141
  - webpack/__mocks__/foremanReact/components/Loading/index.js
142
+ - webpack/__mocks__/foremanReact/components/PF4/TableIndexPage/TableIndexPage.js
142
143
  - webpack/__mocks__/foremanReact/components/Pagination/index.js
143
144
  - webpack/__mocks__/foremanReact/components/common/EmptyState.js
144
145
  - webpack/__mocks__/foremanReact/components/common/forms/ForemanForm.js
@@ -192,8 +193,8 @@ test_files:
192
193
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/__tests__/enabledCellFormatter.test.js
193
194
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/__tests__/EnabledCell.test.js
194
195
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/__tests__/WebhooksTable.test.js
195
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/integration.test.js
196
196
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/WebhooksIndexPage.fixtures.js
197
197
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/WebhooksIndexPage.test.js
198
+ - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/integration.test.js
198
199
  - webpack/ForemanWebhooks/Routes/Webhooks/__tests__/WebhooksPageHelpers.test.js
199
200
  - webpack/ForemanWebhooks/Routes/Webhooks/__tests__/WebhooksPageSelectors.test.js
@@ -1,63 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { translate as __ } from 'foremanReact/common/I18n';
4
- import DefaultEmptyState from 'foremanReact/components/common/EmptyState';
5
-
6
- import { useForemanModal } from 'foremanReact/components/ForemanModal/ForemanModalHooks';
7
-
8
- import WebhookCreateModal from '../WebhookCreateModal';
9
- import { WEBHOOK_CREATE_MODAL_ID } from '../../../constants';
10
-
11
- const EmptyWebhooksIndexPage = ({
12
- search,
13
- reloadWithSearch,
14
- message: { type, text },
15
- }) => {
16
- const {
17
- setModalOpen: setCreateModalOpen,
18
- setModalClosed: setCreateModalClosed,
19
- } = useForemanModal({
20
- id: WEBHOOK_CREATE_MODAL_ID,
21
- });
22
-
23
- return (
24
- <>
25
- <WebhookCreateModal
26
- onSuccess={() => {
27
- setCreateModalClosed();
28
- reloadWithSearch(search);
29
- }}
30
- onCancel={setCreateModalClosed}
31
- />
32
- <DefaultEmptyState
33
- icon={type === 'error' ? 'error-circle-o' : 'add-circle-o'}
34
- header={type === 'error' ? __('Error') : __('No Results')}
35
- description={text}
36
- documentation={null}
37
- action={{
38
- title: __('Create Webhook'),
39
- onClick: () => setCreateModalOpen(),
40
- }}
41
- />
42
- </>
43
- );
44
- };
45
-
46
- EmptyWebhooksIndexPage.propTypes = {
47
- message: PropTypes.shape({
48
- type: PropTypes.oneOf(['empty', 'error']),
49
- text: PropTypes.string,
50
- }),
51
- search: PropTypes.string,
52
- reloadWithSearch: PropTypes.func.isRequired,
53
- };
54
-
55
- EmptyWebhooksIndexPage.defaultProps = {
56
- message: {
57
- type: 'empty',
58
- text: __('Try to create a new Webhook'),
59
- },
60
- search: '',
61
- };
62
-
63
- export default EmptyWebhooksIndexPage;