foreman_webhooks 5.0.3 → 5.1.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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -15
  3. data/app/models/webhook.rb +1 -1
  4. data/lib/foreman_webhooks/version.rb +1 -1
  5. data/webpack/ForemanWebhooks/Routes/ForemanWebhooksRoutes.js +1 -1
  6. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookTable/Components/Formatters/__tests__/actionCellFormatter.test.js +109 -0
  7. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookTable/Components/Formatters/__tests__/enabledCellFormatter.test.js +38 -0
  8. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookTable/Components/Formatters/__tests__/nameToEditFormatter.test.js +82 -0
  9. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookTable/Components/Formatters/actionCellFormatter.js +23 -0
  10. data/webpack/ForemanWebhooks/Routes/Webhooks/{WebhooksIndexPage/Components/WebhooksTable/Components/EnabledCell.js → Components/WebhookTable/Components/Formatters/enabledCellFormatter.js} +6 -1
  11. data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookTable/Components/Formatters/nameToEditFormatter.js +33 -0
  12. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookCreateModal.js +1 -0
  13. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookDeleteModal.js +5 -1
  14. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookEditModal.js +1 -0
  15. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/WebhooksIndexPage.js +120 -16
  16. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/WebhooksIndexPage.test.js +130 -22
  17. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/integration.test.js +10 -3
  18. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/mocks/MockForemanTableIndexPage.js +37 -0
  19. data/webpack/ForemanWebhooks/Routes/Webhooks/constants.js +3 -3
  20. data/webpack/test_setup.js +3 -0
  21. metadata +18 -93
  22. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/EmptyWebhooksTable/index.js +0 -29
  23. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/__tests__/__snapshots__/enabledCellFormatter.test.js.snap +0 -7
  24. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/__tests__/enabledCellFormatter.test.js +0 -7
  25. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/actionCellFormatter.js +0 -20
  26. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/enabledCellFormatter.js +0 -6
  27. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/index.js +0 -3
  28. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/nameToEditFormatter.js +0 -19
  29. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/NameToEditCell.js +0 -42
  30. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/__tests__/EnabledCell.test.js +0 -14
  31. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/__tests__/__snapshots__/EnabledCell.test.js.snap +0 -5
  32. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/WebhooksTable.js +0 -121
  33. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/WebhooksTableSchema.js +0 -48
  34. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/__tests__/WebhooksTable.test.js +0 -64
  35. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/__tests__/__snapshots__/WebhooksTable.test.js.snap +0 -250
  36. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/index.js +0 -76
  37. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/__snapshots__/WebhooksIndexPage.test.js.snap +0 -17
  38. data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/index.js +0 -3
  39. data/webpack/__mocks__/foremanReact/Root/Context/ForemanContext.js +0 -1
  40. data/webpack/__mocks__/foremanReact/common/HOC.js +0 -30
  41. data/webpack/__mocks__/foremanReact/common/I18n.js +0 -7
  42. data/webpack/__mocks__/foremanReact/common/helpers.js +0 -7
  43. data/webpack/__mocks__/foremanReact/common/urlHelpers.js +0 -8
  44. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +0 -2
  45. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalHooks.js +0 -10
  46. data/webpack/__mocks__/foremanReact/components/ForemanModal/index.js +0 -23
  47. data/webpack/__mocks__/foremanReact/components/Layout/LayoutActions.js +0 -2
  48. data/webpack/__mocks__/foremanReact/components/Loading/Loading.js +0 -2
  49. data/webpack/__mocks__/foremanReact/components/Loading/index.js +0 -3
  50. data/webpack/__mocks__/foremanReact/components/PF4/TableIndexPage/TableIndexPage.js +0 -10
  51. data/webpack/__mocks__/foremanReact/components/Pagination/index.js +0 -4
  52. data/webpack/__mocks__/foremanReact/components/common/ActionButtons/ActionButtons.js +0 -3
  53. data/webpack/__mocks__/foremanReact/components/common/EmptyState.js +0 -5
  54. data/webpack/__mocks__/foremanReact/components/common/forms/ForemanForm.js +0 -9
  55. data/webpack/__mocks__/foremanReact/components/common/forms/FormField.js +0 -3
  56. data/webpack/__mocks__/foremanReact/components/common/table.js +0 -26
  57. data/webpack/__mocks__/foremanReact/constants.js +0 -24
  58. data/webpack/__mocks__/foremanReact/history.js +0 -3
  59. data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +0 -6
  60. data/webpack/__mocks__/foremanReact/redux/API/index.js +0 -10
  61. data/webpack/__mocks__/foremanReact/redux/actions/common/forms.js +0 -1
  62. data/webpack/__mocks__/foremanReact/redux/actions/toasts.js +0 -8
  63. data/webpack/__mocks__/foremanReact/routes/common/PageLayout/PageLayout.js +0 -10
  64. /data/webpack/ForemanWebhooks/Routes/Webhooks/{WebhooksIndexPage/Components/WebhooksTable → Components/WebhookTable}/Components/ActionButtons/ActionButton.js +0 -0
@@ -1,32 +1,140 @@
1
1
  import React from 'react';
2
- import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+ import { render, screen, fireEvent } from '@testing-library/react';
3
+ import '@testing-library/jest-dom';
3
4
  import { Provider } from 'react-redux';
4
5
  import { createStore } from 'redux';
5
6
 
7
+ import mockForemanTableIndexPage from './mocks/MockForemanTableIndexPage';
8
+
9
+ import * as selectors from '../../WebhooksPageSelectors';
6
10
  import WebhooksIndexPage from '../WebhooksIndexPage';
11
+ import {
12
+ spySelector,
13
+ webhooks as webhooksFixture,
14
+ } from './WebhooksIndexPage.fixtures';
15
+
16
+ jest.mock(
17
+ '../../Components/WebhookTable/Components/Formatters/nameToEditFormatter',
18
+ () => ({
19
+ __esModule: true,
20
+ default: () => () => null,
21
+ })
22
+ );
23
+ jest.mock(
24
+ '../../Components/WebhookTable/Components/Formatters/enabledCellFormatter',
25
+ () => ({
26
+ __esModule: true,
27
+ default: () => () => null,
28
+ })
29
+ );
30
+ jest.mock(
31
+ '../../Components/WebhookTable/Components/Formatters/actionCellFormatter',
32
+ () => ({
33
+ __esModule: true,
34
+ default: () => () => null,
35
+ })
36
+ );
37
+
38
+ jest.mock('foremanReact/components/PF4/TableIndexPage/TableIndexPage', () => ({
39
+ __esModule: true,
40
+ default: mockForemanTableIndexPage,
41
+ }));
42
+
43
+ jest.mock('../Components/WebhookCreateModal', () => ({
44
+ __esModule: true,
45
+ default: ({ isOpen, onCancel }) =>
46
+ isOpen ? (
47
+ <div data-testid="webhook-create-modal">
48
+ <button type="button" onClick={onCancel}>
49
+ Close create modal
50
+ </button>
51
+ </div>
52
+ ) : null,
53
+ }));
54
+
55
+ jest.mock('../Components/WebhookDeleteModal', () => ({
56
+ __esModule: true,
57
+ default: ({ modalState }) =>
58
+ modalState.isOpen ? (
59
+ <div data-testid="webhook-delete-modal">Delete modal</div>
60
+ ) : null,
61
+ }));
62
+
63
+ jest.mock('../Components/WebhookEditModal', () => ({
64
+ __esModule: true,
65
+ default: ({ modalState }) =>
66
+ modalState.isOpen ? (
67
+ <div data-testid="webhook-edit-modal">Edit modal</div>
68
+ ) : null,
69
+ }));
70
+
71
+ jest.mock('../Components/WebhookTestModal', () => ({
72
+ __esModule: true,
73
+ default: ({ modalState }) =>
74
+ modalState.isOpen ? (
75
+ <div data-testid="webhook-test-modal">Test modal</div>
76
+ ) : null,
77
+ }));
7
78
 
8
- const fixtures = {
9
- 'render with minimal props': {
10
- fetchAndPush: jest.fn(),
11
- reloadWithSearch: jest.fn(),
12
- handleCreateSubmit: jest.fn(),
13
- isLoading: false,
14
- hasError: false,
15
- hasData: false,
16
- itemCount: 0,
17
- canCreate: true,
18
- sort: {},
19
- webhooks: [],
20
- },
21
- };
79
+ const store = createStore((state = {}) => state);
80
+
81
+ const renderPage = () =>
82
+ render(
83
+ <Provider store={store}>
84
+ <WebhooksIndexPage />
85
+ </Provider>
86
+ );
22
87
 
23
88
  describe('WebhooksIndexPage', () => {
24
- describe('redering', () => {
25
- const webhooksPage = () => (
26
- <Provider store={createStore((state = [], action) => state)}>
27
- <WebhooksIndexPage />
28
- </Provider>
29
- );
30
- testComponentSnapshotsWithFixtures(webhooksPage, fixtures);
89
+ beforeAll(() => {
90
+ spySelector(selectors);
91
+ });
92
+
93
+ beforeEach(() => {
94
+ jest.clearAllMocks();
95
+ selectors.selectWebhooks.mockImplementation(() => []);
96
+ });
97
+
98
+ it('renders the webhooks header', () => {
99
+ renderPage();
100
+
101
+ expect(
102
+ screen.getByRole('heading', { name: 'Webhooks' })
103
+ ).toBeInTheDocument();
104
+ expect(screen.getByTestId('webhooks-table-index')).toBeInTheDocument();
105
+ });
106
+
107
+ it('renders webhook rows from the store', () => {
108
+ selectors.selectWebhooks.mockImplementation(() => webhooksFixture);
109
+
110
+ renderPage();
111
+
112
+ expect(screen.getByText('my-webhook')).toBeInTheDocument();
113
+ expect(screen.getByText('your-webhook')).toBeInTheDocument();
114
+ });
115
+
116
+ it('opens the create modal when Create new is clicked', () => {
117
+ renderPage();
118
+
119
+ expect(
120
+ screen.queryByTestId('webhook-create-modal')
121
+ ).not.toBeInTheDocument();
122
+
123
+ fireEvent.click(screen.getByRole('button', { name: 'Create new' }));
124
+
125
+ expect(screen.getByTestId('webhook-create-modal')).toBeInTheDocument();
126
+ });
127
+
128
+ it('closes the create modal when cancel is triggered', () => {
129
+ renderPage();
130
+
131
+ fireEvent.click(screen.getByRole('button', { name: 'Create new' }));
132
+ expect(screen.getByTestId('webhook-create-modal')).toBeInTheDocument();
133
+
134
+ fireEvent.click(screen.getByRole('button', { name: 'Close create modal' }));
135
+
136
+ expect(
137
+ screen.queryByTestId('webhook-create-modal')
138
+ ).not.toBeInTheDocument();
31
139
  });
32
140
  });
@@ -2,8 +2,12 @@ import React from 'react';
2
2
  import { IntegrationTestHelper } from '@theforeman/test';
3
3
  import { Router } from 'react-router-dom';
4
4
  import { createMemoryHistory } from 'history';
5
+ import {
6
+ reducers as foremanApiReducers,
7
+ APIMiddleware,
8
+ } from 'foremanReact/redux/API';
5
9
 
6
- import ConnectedWebhooksIndexPage from '../index';
10
+ import ConnectedWebhooksIndexPage from '../WebhooksIndexPage';
7
11
 
8
12
  import * as selectors from '../../WebhooksPageSelectors';
9
13
  import * as editSelectors from '../Components/WebhookEditModalSelectors';
@@ -17,7 +21,10 @@ describe('WebhooksIndexPage - Integration Test', () => {
17
21
  const history = createMemoryHistory();
18
22
  history.push({ pathname: '/webhooks', search: '' });
19
23
 
20
- const integrationTestHelper = new IntegrationTestHelper();
24
+ const integrationTestHelper = new IntegrationTestHelper(
25
+ foremanApiReducers,
26
+ [APIMiddleware]
27
+ );
21
28
 
22
29
  const component = integrationTestHelper.mount(
23
30
  <Router history={history}>
@@ -25,7 +32,7 @@ describe('WebhooksIndexPage - Integration Test', () => {
25
32
  </Router>
26
33
  );
27
34
 
28
- expect(component.exists('WebhooksTable')).toEqual(true);
35
+ expect(component.find('table[role="grid"]').exists()).toEqual(true);
29
36
  expect(component.exists('WebhookCreateModal')).toEqual(true);
30
37
  });
31
38
  });
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { useSelector } from 'react-redux';
4
+
5
+ import { selectWebhooks } from '../../../WebhooksPageSelectors';
6
+
7
+ function MockForemanTableIndexPage({ header, customCreateAction }) {
8
+ const rows = useSelector(selectWebhooks);
9
+ const onCreate = customCreateAction ? customCreateAction() : undefined;
10
+ return (
11
+ <div data-testid="webhooks-table-index">
12
+ <h1>{header}</h1>
13
+ <ul aria-label="webhook-rows">
14
+ {rows.map(row => (
15
+ <li key={row.id}>{row.name}</li>
16
+ ))}
17
+ </ul>
18
+ {onCreate ? (
19
+ <button type="button" onClick={onCreate}>
20
+ Create new
21
+ </button>
22
+ ) : null}
23
+ </div>
24
+ );
25
+ }
26
+
27
+ MockForemanTableIndexPage.propTypes = {
28
+ header: PropTypes.string,
29
+ customCreateAction: PropTypes.func,
30
+ };
31
+
32
+ MockForemanTableIndexPage.defaultProps = {
33
+ header: '',
34
+ customCreateAction: null,
35
+ };
36
+
37
+ export default MockForemanTableIndexPage;
@@ -4,13 +4,13 @@ export const WEBHOOKS_PAGE_HIDE_LOADING = 'WEBHOOKS_PAGE_HIDE_LOADING';
4
4
  export const WEBHOOKS_PAGE_SHOW_LOADING = 'WEBHOOKS_PAGE_SHOW_LOADING';
5
5
  export const WEBHOOKS_PAGE_CLEAR_ERROR = 'WEBHOOKS_PAGE_CLEAR_ERROR';
6
6
 
7
- export const WEBHOOKS_API_PATH = '/api/v2/webhooks?include_permissions=true';
7
+ export const WEBHOOKS_API_PATH = '/api/webhooks?include_permissions=true';
8
8
  export const WEBHOOKS_PATH = '/webhooks';
9
- export const WEBHOOKS_API_REQUEST_KEY = 'WEBHOOKS';
9
+ export const WEBHOOKS_API_REQUEST_KEY = 'webhooks';
10
10
 
11
11
  export const WEBHOOK_TEMPLATES_API_PATH =
12
12
  '/api/v2/webhook_templates?include_permissions=true';
13
- export const WEBHOOKS_API_PLAIN_PATH = '/api/v2/webhooks';
13
+ export const WEBHOOKS_API_PLAIN_PATH = '/api/webhooks';
14
14
  export const WEBHOOK_TEMPLATES_API_REQUEST_KEY = 'WEBHOOK_TEMPLATES';
15
15
  export const WEBHOOK_API_REQUEST_KEY = 'WEBHOOK';
16
16
  export const WEBHOOK_API_UPDATE_KEY = 'WEBHOOK_UPDATE';
@@ -1,3 +1,6 @@
1
+ // eslint-disable-next-line import/no-unresolved
2
+ import 'foremanJSTestSetup';
3
+
1
4
  jest.mock('foremanReact/history', () => ({
2
5
  history: {
3
6
  action: 'PUSH',
metadata CHANGED
@@ -1,56 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_webhooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.3
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timo Goebel
8
8
  bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
- dependencies:
12
- - !ruby/object:Gem::Dependency
13
- name: rake
14
- requirement: !ruby/object:Gem::Requirement
15
- requirements:
16
- - - ">="
17
- - !ruby/object:Gem::Version
18
- version: '0'
19
- type: :development
20
- prerelease: false
21
- version_requirements: !ruby/object:Gem::Requirement
22
- requirements:
23
- - - ">="
24
- - !ruby/object:Gem::Version
25
- version: '0'
26
- - !ruby/object:Gem::Dependency
27
- name: rdoc
28
- requirement: !ruby/object:Gem::Requirement
29
- requirements:
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :development
34
- prerelease: false
35
- version_requirements: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: '0'
40
- - !ruby/object:Gem::Dependency
41
- name: theforeman-rubocop
42
- requirement: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: 0.1.0
47
- type: :development
48
- prerelease: false
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: 0.1.0
11
+ dependencies: []
54
12
  description: Plugin for Foreman that allows to configure Webhooks.
55
13
  email:
56
14
  - mail@timogoebel.name
@@ -189,35 +147,24 @@ files:
189
147
  - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/__tests__/WebhookForm.test.js
190
148
  - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/constants.js
191
149
  - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/index.js
150
+ - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookTable/Components/ActionButtons/ActionButton.js
151
+ - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookTable/Components/Formatters/__tests__/actionCellFormatter.test.js
152
+ - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookTable/Components/Formatters/__tests__/enabledCellFormatter.test.js
153
+ - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookTable/Components/Formatters/__tests__/nameToEditFormatter.test.js
154
+ - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookTable/Components/Formatters/actionCellFormatter.js
155
+ - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookTable/Components/Formatters/enabledCellFormatter.js
156
+ - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookTable/Components/Formatters/nameToEditFormatter.js
192
157
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookCreateModal.js
193
158
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookDeleteModal.js
194
159
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookEditModal.js
195
160
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookEditModalSelectors.js
196
161
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookModal.scss
197
162
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookTestModal.js
198
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/ActionButtons/ActionButton.js
199
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/EmptyWebhooksTable/index.js
200
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/EnabledCell.js
201
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/__tests__/__snapshots__/enabledCellFormatter.test.js.snap
202
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/__tests__/enabledCellFormatter.test.js
203
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/actionCellFormatter.js
204
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/enabledCellFormatter.js
205
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/index.js
206
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/nameToEditFormatter.js
207
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/NameToEditCell.js
208
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/__tests__/EnabledCell.test.js
209
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/__tests__/__snapshots__/EnabledCell.test.js.snap
210
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/WebhooksTable.js
211
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/WebhooksTableSchema.js
212
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/__tests__/WebhooksTable.test.js
213
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/__tests__/__snapshots__/WebhooksTable.test.js.snap
214
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/index.js
215
163
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/WebhooksIndexPage.js
216
164
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/WebhooksIndexPage.fixtures.js
217
165
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/WebhooksIndexPage.test.js
218
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/__snapshots__/WebhooksIndexPage.test.js.snap
219
166
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/integration.test.js
220
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/index.js
167
+ - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/mocks/MockForemanTableIndexPage.js
221
168
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksPageActions.js
222
169
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksPageHelpers.js
223
170
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksPageSelectors.js
@@ -225,31 +172,6 @@ files:
225
172
  - webpack/ForemanWebhooks/Routes/Webhooks/__tests__/WebhooksPageSelectors.test.js
226
173
  - webpack/ForemanWebhooks/Routes/Webhooks/__tests__/__snapshots__/WebhooksPageSelectors.test.js.snap
227
174
  - webpack/ForemanWebhooks/Routes/Webhooks/constants.js
228
- - webpack/__mocks__/foremanReact/Root/Context/ForemanContext.js
229
- - webpack/__mocks__/foremanReact/common/HOC.js
230
- - webpack/__mocks__/foremanReact/common/I18n.js
231
- - webpack/__mocks__/foremanReact/common/helpers.js
232
- - webpack/__mocks__/foremanReact/common/urlHelpers.js
233
- - webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js
234
- - webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalHooks.js
235
- - webpack/__mocks__/foremanReact/components/ForemanModal/index.js
236
- - webpack/__mocks__/foremanReact/components/Layout/LayoutActions.js
237
- - webpack/__mocks__/foremanReact/components/Loading/Loading.js
238
- - webpack/__mocks__/foremanReact/components/Loading/index.js
239
- - webpack/__mocks__/foremanReact/components/PF4/TableIndexPage/TableIndexPage.js
240
- - webpack/__mocks__/foremanReact/components/Pagination/index.js
241
- - webpack/__mocks__/foremanReact/components/common/ActionButtons/ActionButtons.js
242
- - webpack/__mocks__/foremanReact/components/common/EmptyState.js
243
- - webpack/__mocks__/foremanReact/components/common/forms/ForemanForm.js
244
- - webpack/__mocks__/foremanReact/components/common/forms/FormField.js
245
- - webpack/__mocks__/foremanReact/components/common/table.js
246
- - webpack/__mocks__/foremanReact/constants.js
247
- - webpack/__mocks__/foremanReact/history.js
248
- - webpack/__mocks__/foremanReact/redux/API/APISelectors.js
249
- - webpack/__mocks__/foremanReact/redux/API/index.js
250
- - webpack/__mocks__/foremanReact/redux/actions/common/forms.js
251
- - webpack/__mocks__/foremanReact/redux/actions/toasts.js
252
- - webpack/__mocks__/foremanReact/routes/common/PageLayout/PageLayout.js
253
175
  - webpack/index.js
254
176
  - webpack/routes_index.js
255
177
  - webpack/test_setup.js
@@ -265,14 +187,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
265
187
  requirements:
266
188
  - - ">="
267
189
  - !ruby/object:Gem::Version
268
- version: 2.7.0
190
+ version: '3.0'
191
+ - - "<"
192
+ - !ruby/object:Gem::Version
193
+ version: '4'
269
194
  required_rubygems_version: !ruby/object:Gem::Requirement
270
195
  requirements:
271
196
  - - ">="
272
197
  - !ruby/object:Gem::Version
273
198
  version: '0'
274
199
  requirements: []
275
- rubygems_version: 4.0.6
200
+ rubygems_version: 4.0.10
276
201
  specification_version: 4
277
202
  summary: Configure webhooks for Foreman.
278
203
  test_files:
@@ -291,9 +216,9 @@ test_files:
291
216
  - test/unit/foreman_webhooks/webhook_service_test.rb
292
217
  - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/__tests__/FieldConstructor.test.js
293
218
  - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/__tests__/WebhookForm.test.js
294
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/__tests__/enabledCellFormatter.test.js
295
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/__tests__/EnabledCell.test.js
296
- - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/__tests__/WebhooksTable.test.js
219
+ - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookTable/Components/Formatters/__tests__/actionCellFormatter.test.js
220
+ - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookTable/Components/Formatters/__tests__/enabledCellFormatter.test.js
221
+ - webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookTable/Components/Formatters/__tests__/nameToEditFormatter.test.js
297
222
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/WebhooksIndexPage.fixtures.js
298
223
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/WebhooksIndexPage.test.js
299
224
  - webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/integration.test.js
@@ -1,29 +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
- 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,7 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`enabledCellFormatter render 1`] = `
4
- <EnabledCell
5
- condition={true}
6
- />
7
- `;
@@ -1,7 +0,0 @@
1
- import { enabledCellFormatter } from '../index';
2
-
3
- describe('enabledCellFormatter', () => {
4
- it('render', () => {
5
- expect(enabledCellFormatter()(true)).toMatchSnapshot();
6
- });
7
- });
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import { cellFormatter } from 'foremanReact/components/common/table';
3
- import { ActionButton } from '../ActionButtons/ActionButton';
4
-
5
- const actionCellFormatter = webhookActions => (
6
- _,
7
- { rowData: { id, name, canEdit, canDelete } }
8
- ) =>
9
- cellFormatter(
10
- canEdit && (
11
- <ActionButton
12
- canDelete={canDelete}
13
- id={id}
14
- name={name}
15
- webhookActions={webhookActions}
16
- />
17
- )
18
- );
19
-
20
- export default actionCellFormatter;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import EnabledCell from '../EnabledCell';
3
-
4
- const enabledCellFormatter = () => value => <EnabledCell condition={value} />;
5
-
6
- export default enabledCellFormatter;
@@ -1,3 +0,0 @@
1
- export { default as enabledCellFormatter } from './enabledCellFormatter';
2
- export { default as nameToEditFormatter } from './nameToEditFormatter';
3
- export { default as actionCellFormatter } from './actionCellFormatter';
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
- import NameToEditCell from '../NameToEditCell';
3
-
4
- const nameToEditFormatter = (controllerPluralize, onClick) => (
5
- value,
6
- { rowData: { canEdit, id, name } }
7
- ) => (
8
- <NameToEditCell
9
- active={canEdit}
10
- id={id}
11
- name={encodeURI(name)}
12
- controller={controllerPluralize}
13
- onClick={onClick}
14
- >
15
- {value}
16
- </NameToEditCell>
17
- );
18
-
19
- export default nameToEditFormatter;
@@ -1,42 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { Button } from '@patternfly/react-core';
4
-
5
- const NameToEditCell = ({ active, id, name, controller, onClick, children }) =>
6
- active ? (
7
- <Button
8
- ouiaId="name-edit-active-button"
9
- variant="link"
10
- isInline
11
- component="span"
12
- onClick={() => onClick(id)}
13
- >
14
- {children}
15
- </Button>
16
- ) : (
17
- <Button
18
- ouiaId="name-edit-disabled-button"
19
- variant="link"
20
- isInline
21
- isDisabled
22
- component="span"
23
- >
24
- {children}
25
- </Button>
26
- );
27
-
28
- NameToEditCell.propTypes = {
29
- active: PropTypes.bool,
30
- id: PropTypes.number.isRequired,
31
- name: PropTypes.string.isRequired,
32
- controller: PropTypes.string.isRequired,
33
- onClick: PropTypes.func.isRequired,
34
- children: PropTypes.node,
35
- };
36
-
37
- NameToEditCell.defaultProps = {
38
- active: false,
39
- children: null,
40
- };
41
-
42
- export default NameToEditCell;
@@ -1,14 +0,0 @@
1
- import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
- import EnabledCell from '../EnabledCell';
3
-
4
- const fixtures = {
5
- 'should render blank cell': {
6
- condition: false,
7
- },
8
- 'should render marked cell': {
9
- condition: true,
10
- },
11
- };
12
-
13
- describe('EnabledCell', () =>
14
- testComponentSnapshotsWithFixtures(EnabledCell, fixtures));
@@ -1,5 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`EnabledCell should render blank cell 1`] = `<BanIcon />`;
4
-
5
- exports[`EnabledCell should render marked cell 1`] = `<CheckIcon />`;