foreman_ansible 2.3.2 → 2.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/foreman_ansible/foreman-ansible.css +4 -0
  3. data/app/controllers/ansible_variables_controller.rb +28 -6
  4. data/app/controllers/api/v2/ansible_variables_controller.rb +9 -1
  5. data/app/controllers/concerns/foreman/controller/parameters/ansible_variable.rb +2 -1
  6. data/app/controllers/ui_ansible_roles_controller.rb +14 -0
  7. data/app/helpers/foreman_ansible/ansible_roles_helper.rb +19 -1
  8. data/app/models/ansible_role.rb +1 -0
  9. data/app/models/ansible_variable.rb +8 -3
  10. data/app/services/foreman_ansible/variables_importer.rb +61 -30
  11. data/app/views/ansible_roles/welcome.html.erb +1 -1
  12. data/app/views/ansible_variables/_fields.erb +12 -5
  13. data/app/views/ansible_variables/import.html.erb +4 -1
  14. data/app/views/ansible_variables/index.html.erb +8 -3
  15. data/app/views/ansible_variables/new.html.erb +17 -0
  16. data/app/views/api/v2/ansible_variables/create.json.rabl +3 -0
  17. data/app/views/api/v2/ansible_variables/show.json.rabl +1 -1
  18. data/app/views/foreman_ansible/ansible_roles/_select_tab_content.html.erb +13 -13
  19. data/app/views/ui_ansible_roles/index.json.rabl +3 -0
  20. data/app/views/ui_ansible_roles/main.json.rabl +3 -0
  21. data/app/views/ui_ansible_roles/show.json.rabl +3 -0
  22. data/config/routes.rb +4 -2
  23. data/db/migrate/20190318094437_add_imported_attr_to_ansible_variables.rb +15 -0
  24. data/lib/foreman_ansible/register.rb +13 -2
  25. data/lib/foreman_ansible/version.rb +1 -1
  26. data/package.json +50 -9
  27. data/test/factories/ansible_variables.rb +1 -0
  28. data/test/functional/ansible_variables_controller_test.rb +10 -0
  29. data/test/functional/api/v2/ansible_variables_controller_test.rb +10 -0
  30. data/test/functional/ui_ansible_roles_controller_test.rb +14 -0
  31. data/test/unit/services/ansible_variables_importer_test.rb +20 -3
  32. data/webpack/__mocks__/foremanReact/components/Pagination/PaginationWrapper.js +2 -0
  33. data/webpack/__mocks__/foremanReact/components/common/EmptyState.js +5 -0
  34. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.js +140 -0
  35. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.scss +45 -0
  36. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherActions.js +69 -0
  37. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherConstants.js +7 -0
  38. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherHelpers.js +7 -0
  39. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherReducer.js +69 -0
  40. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherSelectors.js +68 -0
  41. data/webpack/components/AnsibleRolesSwitcher/__fixtures__/ansibleRolesData.fixtures.js +20 -0
  42. data/webpack/components/AnsibleRolesSwitcher/__fixtures__/ansibleRolesSwitcherReducer.fixtures.js +36 -0
  43. data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcher.test.js +30 -0
  44. data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherReducer.test.js +73 -0
  45. data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherSelectors.test.js +43 -0
  46. data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcher.test.js.snap +79 -0
  47. data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcherReducer.test.js.snap +399 -0
  48. data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcherSelectors.test.js.snap +60 -0
  49. data/webpack/components/AnsibleRolesSwitcher/components/AnsiblePermissionDenied.js +33 -0
  50. data/webpack/components/AnsibleRolesSwitcher/components/AnsiblePermissionDenied.test.js +9 -0
  51. data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js +56 -0
  52. data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.test.js +26 -0
  53. data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRoleActionButton.js +16 -0
  54. data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRolesSwitcherError.js +32 -0
  55. data/webpack/components/AnsibleRolesSwitcher/components/AssignedRolesList.js +67 -0
  56. data/webpack/components/AnsibleRolesSwitcher/components/AssignedRolesList.test.js +19 -0
  57. data/webpack/components/AnsibleRolesSwitcher/components/AvailableRolesList.js +52 -0
  58. data/webpack/components/AnsibleRolesSwitcher/components/AvailableRolesList.test.js +22 -0
  59. data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AnsiblePermissionDenied.test.js.snap +26 -0
  60. data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AnsibleRole.test.js.snap +108 -0
  61. data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AssignedRolesList.test.js.snap +64 -0
  62. data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AvailableRolesList.test.js.snap +54 -0
  63. data/webpack/components/AnsibleRolesSwitcher/components/withProtectedView.js +14 -0
  64. data/webpack/components/AnsibleRolesSwitcher/index.js +44 -0
  65. data/webpack/components/ReportJsonViewer.js +11 -7
  66. data/webpack/index.js +14 -1
  67. data/webpack/reducer.js +7 -0
  68. data/webpack/test_setup.js +11 -0
  69. metadata +46 -2
@@ -0,0 +1,30 @@
1
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import AnsibleRolesSwitcher from '../AnsibleRolesSwitcher';
4
+
5
+ jest.mock('foremanReact/components/Pagination/PaginationWrapper');
6
+
7
+ const noop = () => {};
8
+
9
+ const fixtures = {
10
+ 'should render': {
11
+ loading: false,
12
+ pagination: { page: 1, perPage: 12 },
13
+ itemCount: 20,
14
+ addAnsibleRole: noop,
15
+ removeAnsibleRole: noop,
16
+ getAnsibleRoles: noop,
17
+ changeAssignedPage: noop,
18
+ assignedPagination: { page: 1, perPage: 12 },
19
+ assignedRolesCount: 2,
20
+ assignedRoles: [],
21
+ unassignedRoles: [],
22
+ data: {
23
+ initialAssignedRoles: [],
24
+ },
25
+ error: { statusText: '', errorMsg: '' },
26
+ },
27
+ };
28
+
29
+ describe('AnsibleRolesSwitcher', () =>
30
+ testComponentSnapshotsWithFixtures(AnsibleRolesSwitcher, fixtures));
@@ -0,0 +1,73 @@
1
+ import { testReducerSnapshotWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import reducer, { initialState } from '../AnsibleRolesSwitcherReducer';
4
+ import { ansibleRolesLong } from '../__fixtures__/ansibleRolesData.fixtures';
5
+
6
+ import {
7
+ successPayload,
8
+ successState,
9
+ errorPayload,
10
+ } from '../__fixtures__/ansibleRolesSwitcherReducer.fixtures';
11
+
12
+ import {
13
+ ANSIBLE_ROLES_REQUEST,
14
+ ANSIBLE_ROLES_SUCCESS,
15
+ ANSIBLE_ROLES_FAILURE,
16
+ ANSIBLE_ROLES_ADD,
17
+ ANSIBLE_ROLES_REMOVE,
18
+ ANSIBLE_ROLES_ASSIGNED_PAGE_CHANGE,
19
+ } from '../AnsibleRolesSwitcherConstants';
20
+
21
+ const fixtures = {
22
+ 'should return initial state': {
23
+ state: initialState,
24
+ action: {
25
+ type: undefined,
26
+ payload: {},
27
+ },
28
+ },
29
+ 'should start loading on Ansible roles request': {
30
+ state: initialState,
31
+ action: {
32
+ type: ANSIBLE_ROLES_REQUEST,
33
+ },
34
+ },
35
+ 'should stop loading on Ansible roles success': {
36
+ state: initialState.set('loading', true),
37
+ action: {
38
+ type: ANSIBLE_ROLES_SUCCESS,
39
+ payload: successPayload,
40
+ },
41
+ },
42
+ 'should stop loading on Ansible roles error': {
43
+ state: initialState.set('loading', true),
44
+ action: {
45
+ type: ANSIBLE_ROLES_FAILURE,
46
+ payload: { error: errorPayload },
47
+ },
48
+ },
49
+ 'should add Ansible role to assigned': {
50
+ state: successState,
51
+ action: {
52
+ type: ANSIBLE_ROLES_ADD,
53
+ payload: { role: ansibleRolesLong[8] },
54
+ },
55
+ },
56
+ 'should remove Ansible role from assigned': {
57
+ state: successState,
58
+ action: {
59
+ type: ANSIBLE_ROLES_REMOVE,
60
+ payload: { role: ansibleRolesLong[5] },
61
+ },
62
+ },
63
+ 'should change pagination for assigned roles': {
64
+ state: successState,
65
+ action: {
66
+ type: ANSIBLE_ROLES_ASSIGNED_PAGE_CHANGE,
67
+ payload: { pagination: { page: 20, perPage: 5 } },
68
+ },
69
+ },
70
+ };
71
+
72
+ describe('AnsibleRolesSwitcherReducer', () =>
73
+ testReducerSnapshotWithFixtures(reducer, fixtures));
@@ -0,0 +1,43 @@
1
+ import { testSelectorsSnapshotWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import {
4
+ selectUnassignedRoles,
5
+ selectAssignedRolesPage,
6
+ } from '../AnsibleRolesSwitcherSelectors';
7
+ import {
8
+ ansibleRolesShort,
9
+ ansibleRolesLong,
10
+ } from '../__fixtures__/ansibleRolesData.fixtures';
11
+
12
+ const stateFactory = obj => ({
13
+ foremanAnsible: {
14
+ ansibleRolesSwitcher: obj,
15
+ },
16
+ });
17
+
18
+ const state1 = {
19
+ results: ansibleRolesShort,
20
+ assignedRoles: [{ id: 2 }, { id: 4 }],
21
+ };
22
+
23
+ const state2 = {
24
+ results: ansibleRolesShort,
25
+ assignedRoles: [],
26
+ };
27
+
28
+ const state3 = {
29
+ assignedRoles: ansibleRolesLong,
30
+ assignedPagination: { page: 2, perPage: 5 },
31
+ };
32
+
33
+ const fixtures = {
34
+ 'should return unassigned roles': () =>
35
+ selectUnassignedRoles(stateFactory(state1)),
36
+ 'should return all roles when no roles assigned': () =>
37
+ selectUnassignedRoles(stateFactory(state2)),
38
+ 'should return requested page': () =>
39
+ selectAssignedRolesPage(stateFactory(state3)),
40
+ };
41
+
42
+ describe('AnsibleRolesSwitcherSelectors', () =>
43
+ testSelectorsSnapshotWithFixtures(fixtures));
@@ -0,0 +1,79 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`AnsibleRolesSwitcher should render 1`] = `
4
+ <Grid
5
+ bsClass="container-fluid"
6
+ componentClass="div"
7
+ fluid={false}
8
+ id="ansibleRolesSwitcher"
9
+ >
10
+ <Row
11
+ bsClass="row"
12
+ className="row-eq-height"
13
+ componentClass="div"
14
+ >
15
+ <AnsibleRolesSwitcherError
16
+ error={
17
+ Object {
18
+ "errorMsg": "",
19
+ "statusText": "",
20
+ }
21
+ }
22
+ />
23
+ <Col
24
+ bsClass="col"
25
+ className="available-roles-container"
26
+ componentClass="div"
27
+ sm={6}
28
+ >
29
+ <div
30
+ className="available-roles-header"
31
+ >
32
+ <h2>
33
+ Available Ansible Roles
34
+ </h2>
35
+ </div>
36
+ <AvailableRolesList
37
+ itemCount={20}
38
+ loading={false}
39
+ onAddRole={[Function]}
40
+ onListingChange={[Function]}
41
+ pagination={
42
+ Object {
43
+ "page": 1,
44
+ "perPage": 12,
45
+ }
46
+ }
47
+ unassignedRoles={Array []}
48
+ />
49
+ </Col>
50
+ <Col
51
+ bsClass="col"
52
+ className="assigned-roles-container"
53
+ componentClass="div"
54
+ sm={6}
55
+ >
56
+ <div
57
+ className="assigned-roles-header"
58
+ >
59
+ <h2>
60
+ Assigned Ansible Roles
61
+ </h2>
62
+ </div>
63
+ <AssignedRolesList
64
+ assignedRoles={Array []}
65
+ itemCount={2}
66
+ onPaginationChange={[Function]}
67
+ onRemoveRole={[Function]}
68
+ pagination={
69
+ Object {
70
+ "page": 1,
71
+ "perPage": 12,
72
+ }
73
+ }
74
+ resourceName=""
75
+ />
76
+ </Col>
77
+ </Row>
78
+ </Grid>
79
+ `;
@@ -0,0 +1,399 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`AnsibleRolesSwitcherReducer should add Ansible role to assigned 1`] = `
4
+ Object {
5
+ "assignedPagination": Object {
6
+ "page": 1,
7
+ "perPage": 20,
8
+ },
9
+ "assignedRoles": Array [
10
+ Object {
11
+ "id": 4,
12
+ "inherited": true,
13
+ "name": "geerlingguy.java",
14
+ },
15
+ Object {
16
+ "id": 5,
17
+ "name": "naftulikay.golang",
18
+ },
19
+ Object {
20
+ "id": 6,
21
+ "name": "theforeman.foreman_scap_client",
22
+ },
23
+ Object {
24
+ "id": 9,
25
+ "name": "chef.chef",
26
+ },
27
+ ],
28
+ "error": Object {
29
+ "errorMsg": "",
30
+ "status": "",
31
+ "statusText": "",
32
+ },
33
+ "itemCount": 10,
34
+ "loading": false,
35
+ "pagination": Object {
36
+ "page": 1,
37
+ "perPage": 5,
38
+ },
39
+ "results": Array [
40
+ Object {
41
+ "id": 1,
42
+ "name": "sthirugn.motd",
43
+ },
44
+ Object {
45
+ "id": 2,
46
+ "name": "jtyr.ntp",
47
+ },
48
+ Object {
49
+ "id": 3,
50
+ "name": "rvm.ruby",
51
+ },
52
+ Object {
53
+ "id": 4,
54
+ "name": "geerlingguy.java",
55
+ },
56
+ Object {
57
+ "id": 5,
58
+ "name": "naftulikay.golang",
59
+ },
60
+ Object {
61
+ "id": 6,
62
+ "name": "theforeman.foreman_scap_client",
63
+ },
64
+ Object {
65
+ "id": 7,
66
+ "name": "ansible.ansible",
67
+ },
68
+ Object {
69
+ "id": 8,
70
+ "name": "puppet.puppet",
71
+ },
72
+ Object {
73
+ "id": 9,
74
+ "name": "chef.chef",
75
+ },
76
+ Object {
77
+ "id": 10,
78
+ "name": "salt.salt",
79
+ },
80
+ Object {
81
+ "id": 11,
82
+ "name": "anonymous.something",
83
+ },
84
+ ],
85
+ }
86
+ `;
87
+
88
+ exports[`AnsibleRolesSwitcherReducer should change pagination for assigned roles 1`] = `
89
+ Object {
90
+ "assignedPagination": Object {
91
+ "page": 20,
92
+ "perPage": 5,
93
+ },
94
+ "assignedRoles": Array [
95
+ Object {
96
+ "id": 4,
97
+ "inherited": true,
98
+ "name": "geerlingguy.java",
99
+ },
100
+ Object {
101
+ "id": 5,
102
+ "name": "naftulikay.golang",
103
+ },
104
+ Object {
105
+ "id": 6,
106
+ "name": "theforeman.foreman_scap_client",
107
+ },
108
+ ],
109
+ "error": Object {
110
+ "errorMsg": "",
111
+ "status": "",
112
+ "statusText": "",
113
+ },
114
+ "itemCount": 11,
115
+ "loading": false,
116
+ "pagination": Object {
117
+ "page": 1,
118
+ "perPage": 5,
119
+ },
120
+ "results": Array [
121
+ Object {
122
+ "id": 1,
123
+ "name": "sthirugn.motd",
124
+ },
125
+ Object {
126
+ "id": 2,
127
+ "name": "jtyr.ntp",
128
+ },
129
+ Object {
130
+ "id": 3,
131
+ "name": "rvm.ruby",
132
+ },
133
+ Object {
134
+ "id": 4,
135
+ "name": "geerlingguy.java",
136
+ },
137
+ Object {
138
+ "id": 5,
139
+ "name": "naftulikay.golang",
140
+ },
141
+ Object {
142
+ "id": 6,
143
+ "name": "theforeman.foreman_scap_client",
144
+ },
145
+ Object {
146
+ "id": 7,
147
+ "name": "ansible.ansible",
148
+ },
149
+ Object {
150
+ "id": 8,
151
+ "name": "puppet.puppet",
152
+ },
153
+ Object {
154
+ "id": 9,
155
+ "name": "chef.chef",
156
+ },
157
+ Object {
158
+ "id": 10,
159
+ "name": "salt.salt",
160
+ },
161
+ Object {
162
+ "id": 11,
163
+ "name": "anonymous.something",
164
+ },
165
+ ],
166
+ }
167
+ `;
168
+
169
+ exports[`AnsibleRolesSwitcherReducer should remove Ansible role from assigned 1`] = `
170
+ Object {
171
+ "assignedPagination": Object {
172
+ "page": 1,
173
+ "perPage": 20,
174
+ },
175
+ "assignedRoles": Array [
176
+ Object {
177
+ "id": 4,
178
+ "inherited": true,
179
+ "name": "geerlingguy.java",
180
+ },
181
+ Object {
182
+ "id": 5,
183
+ "name": "naftulikay.golang",
184
+ },
185
+ ],
186
+ "error": Object {
187
+ "errorMsg": "",
188
+ "status": "",
189
+ "statusText": "",
190
+ },
191
+ "itemCount": 12,
192
+ "loading": false,
193
+ "pagination": Object {
194
+ "page": 1,
195
+ "perPage": 5,
196
+ },
197
+ "results": Array [
198
+ Object {
199
+ "id": 1,
200
+ "name": "sthirugn.motd",
201
+ },
202
+ Object {
203
+ "id": 2,
204
+ "name": "jtyr.ntp",
205
+ },
206
+ Object {
207
+ "id": 3,
208
+ "name": "rvm.ruby",
209
+ },
210
+ Object {
211
+ "id": 4,
212
+ "name": "geerlingguy.java",
213
+ },
214
+ Object {
215
+ "id": 5,
216
+ "name": "naftulikay.golang",
217
+ },
218
+ Object {
219
+ "id": 6,
220
+ "name": "theforeman.foreman_scap_client",
221
+ },
222
+ Object {
223
+ "id": 7,
224
+ "name": "ansible.ansible",
225
+ },
226
+ Object {
227
+ "id": 8,
228
+ "name": "puppet.puppet",
229
+ },
230
+ Object {
231
+ "id": 9,
232
+ "name": "chef.chef",
233
+ },
234
+ Object {
235
+ "id": 10,
236
+ "name": "salt.salt",
237
+ },
238
+ Object {
239
+ "id": 11,
240
+ "name": "anonymous.something",
241
+ },
242
+ Object {
243
+ "id": 6,
244
+ "name": "theforeman.foreman_scap_client",
245
+ },
246
+ ],
247
+ }
248
+ `;
249
+
250
+ exports[`AnsibleRolesSwitcherReducer should return initial state 1`] = `
251
+ Object {
252
+ "assignedPagination": Object {
253
+ "page": 1,
254
+ "perPage": 10,
255
+ },
256
+ "assignedRoles": Array [],
257
+ "error": Object {
258
+ "errorMsg": "",
259
+ "status": "",
260
+ "statusText": "",
261
+ },
262
+ "inheritedRoleIds": Array [],
263
+ "itemCount": 0,
264
+ "loading": false,
265
+ "pagination": Object {
266
+ "page": 1,
267
+ "perPage": 10,
268
+ },
269
+ "results": Array [],
270
+ }
271
+ `;
272
+
273
+ exports[`AnsibleRolesSwitcherReducer should start loading on Ansible roles request 1`] = `
274
+ Object {
275
+ "assignedPagination": Object {
276
+ "page": 1,
277
+ "perPage": 10,
278
+ },
279
+ "assignedRoles": Array [],
280
+ "error": Object {
281
+ "errorMsg": "",
282
+ "status": "",
283
+ "statusText": "",
284
+ },
285
+ "inheritedRoleIds": Array [],
286
+ "itemCount": 0,
287
+ "loading": true,
288
+ "pagination": Object {
289
+ "page": 1,
290
+ "perPage": 10,
291
+ },
292
+ "results": Array [],
293
+ }
294
+ `;
295
+
296
+ exports[`AnsibleRolesSwitcherReducer should stop loading on Ansible roles error 1`] = `
297
+ Object {
298
+ "assignedPagination": Object {
299
+ "page": 1,
300
+ "perPage": 10,
301
+ },
302
+ "assignedRoles": Array [],
303
+ "error": Object {
304
+ "errorMsg": "Failed to fetch Ansible Roles from server.",
305
+ "statusText": "500",
306
+ },
307
+ "inheritedRoleIds": Array [],
308
+ "itemCount": 0,
309
+ "loading": false,
310
+ "pagination": Object {
311
+ "page": 1,
312
+ "perPage": 10,
313
+ },
314
+ "results": Array [],
315
+ }
316
+ `;
317
+
318
+ exports[`AnsibleRolesSwitcherReducer should stop loading on Ansible roles success 1`] = `
319
+ Object {
320
+ "assignedPagination": Object {
321
+ "page": 1,
322
+ "perPage": 10,
323
+ },
324
+ "assignedRoles": Array [
325
+ Object {
326
+ "id": 4,
327
+ "name": "geerlingguy.java",
328
+ },
329
+ Object {
330
+ "id": 5,
331
+ "name": "naftulikay.golang",
332
+ },
333
+ Object {
334
+ "id": 6,
335
+ "name": "theforeman.foreman_scap_client",
336
+ },
337
+ ],
338
+ "error": Object {
339
+ "errorMsg": "",
340
+ "status": "",
341
+ "statusText": "",
342
+ },
343
+ "inheritedRoleIds": Array [
344
+ 4,
345
+ ],
346
+ "itemCount": 11,
347
+ "loading": false,
348
+ "pagination": Object {
349
+ "page": 1,
350
+ "perPage": 5,
351
+ },
352
+ "results": Array [
353
+ Object {
354
+ "id": 1,
355
+ "name": "sthirugn.motd",
356
+ },
357
+ Object {
358
+ "id": 2,
359
+ "name": "jtyr.ntp",
360
+ },
361
+ Object {
362
+ "id": 3,
363
+ "name": "rvm.ruby",
364
+ },
365
+ Object {
366
+ "id": 4,
367
+ "name": "geerlingguy.java",
368
+ },
369
+ Object {
370
+ "id": 5,
371
+ "name": "naftulikay.golang",
372
+ },
373
+ Object {
374
+ "id": 6,
375
+ "name": "theforeman.foreman_scap_client",
376
+ },
377
+ Object {
378
+ "id": 7,
379
+ "name": "ansible.ansible",
380
+ },
381
+ Object {
382
+ "id": 8,
383
+ "name": "puppet.puppet",
384
+ },
385
+ Object {
386
+ "id": 9,
387
+ "name": "chef.chef",
388
+ },
389
+ Object {
390
+ "id": 10,
391
+ "name": "salt.salt",
392
+ },
393
+ Object {
394
+ "id": 11,
395
+ "name": "anonymous.something",
396
+ },
397
+ ],
398
+ }
399
+ `;
@@ -0,0 +1,60 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`AnsibleRolesSwitcherSelectors should return all roles when no roles assigned 1`] = `
4
+ Array [
5
+ Object {
6
+ "id": 4,
7
+ "name": "geerlingguy.java",
8
+ },
9
+ Object {
10
+ "id": 2,
11
+ "name": "jtyr.ntp",
12
+ },
13
+ Object {
14
+ "id": 3,
15
+ "name": "rvm.ruby",
16
+ },
17
+ Object {
18
+ "id": 1,
19
+ "name": "sthirugn.motd",
20
+ },
21
+ ]
22
+ `;
23
+
24
+ exports[`AnsibleRolesSwitcherSelectors should return requested page 1`] = `
25
+ Array [
26
+ Object {
27
+ "id": 5,
28
+ "name": "naftulikay.golang",
29
+ },
30
+ Object {
31
+ "id": 8,
32
+ "name": "puppet.puppet",
33
+ },
34
+ Object {
35
+ "id": 3,
36
+ "name": "rvm.ruby",
37
+ },
38
+ Object {
39
+ "id": 10,
40
+ "name": "salt.salt",
41
+ },
42
+ Object {
43
+ "id": 1,
44
+ "name": "sthirugn.motd",
45
+ },
46
+ ]
47
+ `;
48
+
49
+ exports[`AnsibleRolesSwitcherSelectors should return unassigned roles 1`] = `
50
+ Array [
51
+ Object {
52
+ "id": 3,
53
+ "name": "rvm.ruby",
54
+ },
55
+ Object {
56
+ "id": 1,
57
+ "name": "sthirugn.motd",
58
+ },
59
+ ]
60
+ `;
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { EmptyStatePattern as EmptyState } from 'foremanReact/components/common/EmptyState';
3
+
4
+ const AnsiblePermissionDenied = props => {
5
+ const description = (
6
+ <span>
7
+ {__('You are not authorized to perform this action.')}
8
+ <br />
9
+ {__(
10
+ 'Please request one of the required permissions listed below from a Foreman administrator:'
11
+ )}
12
+ <br />
13
+ </span>
14
+ );
15
+
16
+ const doc = (
17
+ <ul className="list-unstyled">
18
+ <li>view_ansible_roles</li>
19
+ </ul>
20
+ );
21
+
22
+ return (
23
+ <EmptyState
24
+ iconType="fa"
25
+ icon="lock"
26
+ header={__('Permission Denied')}
27
+ description={description}
28
+ documentation={doc}
29
+ />
30
+ );
31
+ };
32
+
33
+ export default AnsiblePermissionDenied;