foreman_ansible 2.3.6 → 3.0.0

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/controllers/ui_ansible_roles_controller.rb +14 -0
  3. data/app/helpers/foreman_ansible/ansible_roles_helper.rb +4 -0
  4. data/app/models/ansible_role.rb +1 -0
  5. data/app/models/foreman_ansible/ansible_provider.rb +6 -1
  6. data/app/models/setting/ansible.rb +10 -10
  7. data/app/services/foreman_ansible/inventory_creator.rb +26 -23
  8. data/app/views/foreman_ansible/ansible_roles/_select_tab_content.html.erb +13 -13
  9. data/app/views/ui_ansible_roles/index.json.rabl +3 -0
  10. data/app/views/ui_ansible_roles/main.json.rabl +3 -0
  11. data/app/views/ui_ansible_roles/show.json.rabl +3 -0
  12. data/config/routes.rb +2 -0
  13. data/db/migrate/20190328114657_remove_top_level_ansible_variables_setting.rb +6 -0
  14. data/lib/foreman_ansible/register.rb +3 -2
  15. data/lib/foreman_ansible/version.rb +1 -1
  16. data/locale/de/foreman_ansible.edit.po +90 -191
  17. data/locale/en/foreman_ansible.edit.po +90 -191
  18. data/locale/es/foreman_ansible.edit.po +90 -191
  19. data/locale/fr/foreman_ansible.edit.po +90 -191
  20. data/locale/it/foreman_ansible.edit.po +90 -191
  21. data/locale/ja/foreman_ansible.edit.po +90 -191
  22. data/locale/ko/foreman_ansible.edit.po +90 -191
  23. data/locale/pt_BR/foreman_ansible.edit.po +90 -191
  24. data/locale/ru/foreman_ansible.edit.po +90 -191
  25. data/locale/zh_CN/foreman_ansible.edit.po +90 -191
  26. data/locale/zh_TW/foreman_ansible.edit.po +90 -191
  27. data/package.json +50 -9
  28. data/test/factories/ansible_variables.rb +1 -0
  29. data/test/functional/ui_ansible_roles_controller_test.rb +14 -0
  30. data/test/unit/lib/foreman_ansible_core/playbook_runner_test.rb +11 -11
  31. data/test/unit/services/inventory_creator_test.rb +75 -24
  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 +44 -2
@@ -0,0 +1,64 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`AssignedRolesList should render 1`] = `
4
+ <div>
5
+ <ListView
6
+ className=""
7
+ >
8
+ <div
9
+ className="sticky-pagination sticky-pagination-grey"
10
+ >
11
+ <PaginationWrapper
12
+ dropdownButtonId="assigned-ansible-roles-pagination-row-dropdown"
13
+ itemCount={2}
14
+ onChange={[Function]}
15
+ pagination={
16
+ Object {
17
+ "page": 1,
18
+ "perPage": 25,
19
+ }
20
+ }
21
+ viewType="list"
22
+ />
23
+ </div>
24
+ <AnsibleRole
25
+ icon="fa fa-minus-circle"
26
+ key="1"
27
+ onClick={[Function]}
28
+ resourceName="host"
29
+ role={
30
+ Object {
31
+ "id": 1,
32
+ "name": "fake.role",
33
+ }
34
+ }
35
+ />
36
+ <AnsibleRole
37
+ icon="fa fa-minus-circle"
38
+ key="2"
39
+ onClick={[Function]}
40
+ resourceName="host"
41
+ role={
42
+ Object {
43
+ "id": 2,
44
+ "name": "test.role",
45
+ }
46
+ }
47
+ />
48
+ </ListView>
49
+ <div>
50
+ <input
51
+ key="1"
52
+ name="host[ansible_role_ids][]"
53
+ type="hidden"
54
+ value={1}
55
+ />
56
+ <input
57
+ key="2"
58
+ name="host[ansible_role_ids][]"
59
+ type="hidden"
60
+ value={2}
61
+ />
62
+ </div>
63
+ </div>
64
+ `;
@@ -0,0 +1,54 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`AvailableRolesList should render 1`] = `
4
+ <ListView
5
+ className=""
6
+ >
7
+ <div
8
+ className="sticky-pagination"
9
+ >
10
+ <PaginationWrapper
11
+ dropdownButtonId="available-ansible-roles-pagination-row-dropdown"
12
+ itemCount={2}
13
+ onChange={[Function]}
14
+ pagination={
15
+ Object {
16
+ "page": 1,
17
+ "perPage": 25,
18
+ }
19
+ }
20
+ viewType="list"
21
+ />
22
+ </div>
23
+ <LoadingState
24
+ additionalClasses=""
25
+ loading={false}
26
+ loadingText="Loading"
27
+ size="lg"
28
+ timeout={300}
29
+ >
30
+ <AnsibleRole
31
+ icon="fa fa-plus-circle"
32
+ key="1"
33
+ onClick={[Function]}
34
+ role={
35
+ Object {
36
+ "id": 1,
37
+ "name": "fake.role",
38
+ }
39
+ }
40
+ />
41
+ <AnsibleRole
42
+ icon="fa fa-plus-circle"
43
+ key="2"
44
+ onClick={[Function]}
45
+ role={
46
+ Object {
47
+ "id": 2,
48
+ "name": "test.role",
49
+ }
50
+ }
51
+ />
52
+ </LoadingState>
53
+ </ListView>
54
+ `;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+
3
+ const withProtectedView = (
4
+ ProtectedComponent,
5
+ ProtectionComponent,
6
+ protectionFn
7
+ ) => props =>
8
+ protectionFn(props) ? (
9
+ <ProtectedComponent {...props} />
10
+ ) : (
11
+ <ProtectionComponent {...props} />
12
+ );
13
+
14
+ export default withProtectedView;
@@ -0,0 +1,44 @@
1
+ import { connect } from 'react-redux';
2
+ import { bindActionCreators } from 'redux';
3
+
4
+ import AnsibleRolesSwitcher from './AnsibleRolesSwitcher';
5
+ import * as AnsibleRolesSwitcherActions from './AnsibleRolesSwitcherActions';
6
+ import AnsiblePermissionDenied from './components/AnsiblePermissionDenied';
7
+ import withProtectedView from './components/withProtectedView';
8
+ import {
9
+ selectUnassignedRoles,
10
+ selectAssignedRolesPage,
11
+ selectAssignedRoles,
12
+ selectAssignedRolesCount,
13
+ selectResults,
14
+ selectPaginationMemoized,
15
+ selectItemCount,
16
+ selectLoading,
17
+ selectAssignedPagination,
18
+ selectError,
19
+ } from './AnsibleRolesSwitcherSelectors';
20
+
21
+ const mapStateToProps = state => ({
22
+ results: selectResults(state),
23
+ pagination: selectPaginationMemoized(state),
24
+ itemCount: selectItemCount(state),
25
+ loading: selectLoading(state),
26
+ error: selectError(state),
27
+ assignedPagination: selectAssignedPagination(state),
28
+ assignedRolesCount: selectAssignedRolesCount(state),
29
+ assignedRoles: selectAssignedRolesPage(state),
30
+ allAssignedRoles: selectAssignedRoles(state),
31
+ unassignedRoles: selectUnassignedRoles(state),
32
+ });
33
+
34
+ const mapDispatchToProps = dispatch =>
35
+ bindActionCreators(AnsibleRolesSwitcherActions, dispatch);
36
+
37
+ export default withProtectedView(
38
+ connect(
39
+ mapStateToProps,
40
+ mapDispatchToProps
41
+ )(AnsibleRolesSwitcher),
42
+ AnsiblePermissionDenied,
43
+ props => props.data && props.data.canView
44
+ );
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import JSONTree from 'react-json-tree';
3
+ import PropTypes from 'prop-types';
3
4
 
4
5
  const theme = {
5
6
  scheme: 'foreman',
@@ -7,11 +8,14 @@ const theme = {
7
8
  base00: 'rgba(0, 0, 0, 0)',
8
9
  };
9
10
 
10
- class ReportJsonViewer extends React.Component {
11
- render() {
12
- return <div className="report-json-viewer">
13
- <JSONTree data={this.props.data} hideRoot theme={theme} />
14
- </div>;
15
- }
16
- }
11
+ const ReportJsonViewer = ({ data }) => (
12
+ <div className="report-json-viewer">
13
+ <JSONTree data={this.props.data} hideRoot theme={theme} />
14
+ </div>
15
+ );
16
+
17
+ ReportJsonViewer.propTypes = {
18
+ data: PropTypes.object.isRequired,
19
+ };
20
+
17
21
  export default ReportJsonViewer;
@@ -1,4 +1,17 @@
1
1
  import componentRegistry from 'foremanReact/components/componentRegistry';
2
+ import injectReducer from 'foremanReact/redux/reducers/registerReducer';
2
3
  import ReportJsonViewer from './components/ReportJsonViewer';
4
+ import AnsibleRolesSwitcher from './components/AnsibleRolesSwitcher';
3
5
 
4
- componentRegistry.register({ name: 'ReportJsonViewer', type: ReportJsonViewer });
6
+ import reducer from './reducer';
7
+
8
+ componentRegistry.register({
9
+ name: 'ReportJsonViewer',
10
+ type: ReportJsonViewer,
11
+ });
12
+ componentRegistry.register({
13
+ name: 'AnsibleRolesSwitcher',
14
+ type: AnsibleRolesSwitcher,
15
+ });
16
+
17
+ injectReducer('foremanAnsible', reducer);
@@ -0,0 +1,7 @@
1
+ import { combineReducers } from 'redux';
2
+
3
+ import ansibleRolesSwitcher from './components/AnsibleRolesSwitcher/AnsibleRolesSwitcherReducer';
4
+
5
+ export default combineReducers({
6
+ ansibleRolesSwitcher,
7
+ });
@@ -0,0 +1,11 @@
1
+ import 'babel-polyfill';
2
+
3
+ import { configure } from 'enzyme';
4
+ import Adapter from 'enzyme-adapter-react-16';
5
+
6
+ configure({ adapter: new Adapter() });
7
+
8
+ // Mocking translation function
9
+ global.__ = str => str;
10
+ global.n__ = str => str;
11
+ global.Jed = { sprintf: str => str };
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_ansible
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.6
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Lobato Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-14 00:00:00.000000000 Z
11
+ date: 2019-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -134,6 +134,7 @@ files:
134
134
  - app/controllers/foreman_ansible/concerns/hosts_controller_extensions.rb
135
135
  - app/controllers/foreman_ansible/concerns/import_controller_helper.rb
136
136
  - app/controllers/foreman_ansible/concerns/job_invocation_helper.rb
137
+ - app/controllers/ui_ansible_roles_controller.rb
137
138
  - app/helpers/foreman_ansible/ansible_plugin_helper.rb
138
139
  - app/helpers/foreman_ansible/ansible_reports_helper.rb
139
140
  - app/helpers/foreman_ansible/ansible_roles_helper.rb
@@ -212,6 +213,9 @@ files:
212
213
  - app/views/foreman_ansible/job_templates/puppet_run_once_-_ansible_default.erb
213
214
  - app/views/foreman_ansible/job_templates/run_command_-_ansible_default.erb
214
215
  - app/views/foreman_ansible/job_templates/service_action_-_ansible_default.erb
216
+ - app/views/ui_ansible_roles/index.json.rabl
217
+ - app/views/ui_ansible_roles/main.json.rabl
218
+ - app/views/ui_ansible_roles/show.json.rabl
215
219
  - config/routes.rb
216
220
  - db/migrate/20160705082036_create_ansible_role.rb
217
221
  - db/migrate/20160706074540_create_join_table_hosts_ansible_roles.rb
@@ -223,6 +227,7 @@ files:
223
227
  - db/migrate/20180410125416_rename_ansible_job_categories.rb
224
228
  - db/migrate/20180628125416_add_ansible_role_id_to_lookup_keys.rb
225
229
  - db/migrate/20190318094437_add_imported_attr_to_ansible_variables.rb
230
+ - db/migrate/20190328114657_remove_top_level_ansible_variables_setting.rb
226
231
  - db/seeds.d/62_ansible_proxy_feature.rb
227
232
  - db/seeds.d/75_job_templates.rb
228
233
  - db/seeds.d/90_notification_blueprints.rb
@@ -293,6 +298,7 @@ files:
293
298
  - test/functional/api/v2/hostgroups_controller_test.rb
294
299
  - test/functional/api/v2/hosts_controller_test.rb
295
300
  - test/functional/hosts_controller_test.rb
301
+ - test/functional/ui_ansible_roles_controller_test.rb
296
302
  - test/test_plugin_helper.rb
297
303
  - test/unit/actions/run_ansible_job_test.rb
298
304
  - test/unit/actions/run_proxy_ansible_command_test.rb
@@ -319,8 +325,43 @@ files:
319
325
  - test/unit/services/roles_importer_test.rb
320
326
  - test/unit/services/structured_fact_importer_test.rb
321
327
  - test/unit/services/ui_roles_importer_test.rb
328
+ - webpack/__mocks__/foremanReact/components/Pagination/PaginationWrapper.js
329
+ - webpack/__mocks__/foremanReact/components/common/EmptyState.js
330
+ - webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.js
331
+ - webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.scss
332
+ - webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherActions.js
333
+ - webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherConstants.js
334
+ - webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherHelpers.js
335
+ - webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherReducer.js
336
+ - webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherSelectors.js
337
+ - webpack/components/AnsibleRolesSwitcher/__fixtures__/ansibleRolesData.fixtures.js
338
+ - webpack/components/AnsibleRolesSwitcher/__fixtures__/ansibleRolesSwitcherReducer.fixtures.js
339
+ - webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcher.test.js
340
+ - webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherReducer.test.js
341
+ - webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherSelectors.test.js
342
+ - webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcher.test.js.snap
343
+ - webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcherReducer.test.js.snap
344
+ - webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcherSelectors.test.js.snap
345
+ - webpack/components/AnsibleRolesSwitcher/components/AnsiblePermissionDenied.js
346
+ - webpack/components/AnsibleRolesSwitcher/components/AnsiblePermissionDenied.test.js
347
+ - webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js
348
+ - webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.test.js
349
+ - webpack/components/AnsibleRolesSwitcher/components/AnsibleRoleActionButton.js
350
+ - webpack/components/AnsibleRolesSwitcher/components/AnsibleRolesSwitcherError.js
351
+ - webpack/components/AnsibleRolesSwitcher/components/AssignedRolesList.js
352
+ - webpack/components/AnsibleRolesSwitcher/components/AssignedRolesList.test.js
353
+ - webpack/components/AnsibleRolesSwitcher/components/AvailableRolesList.js
354
+ - webpack/components/AnsibleRolesSwitcher/components/AvailableRolesList.test.js
355
+ - webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AnsiblePermissionDenied.test.js.snap
356
+ - webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AnsibleRole.test.js.snap
357
+ - webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AssignedRolesList.test.js.snap
358
+ - webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AvailableRolesList.test.js.snap
359
+ - webpack/components/AnsibleRolesSwitcher/components/withProtectedView.js
360
+ - webpack/components/AnsibleRolesSwitcher/index.js
322
361
  - webpack/components/ReportJsonViewer.js
323
362
  - webpack/index.js
363
+ - webpack/reducer.js
364
+ - webpack/test_setup.js
324
365
  homepage: https://github.com/theforeman/foreman_ansible
325
366
  licenses:
326
367
  - GPL-3.0
@@ -377,6 +418,7 @@ test_files:
377
418
  - test/functional/api/v2/ansible_roles_controller_test.rb
378
419
  - test/functional/api/v2/ansible_variables_controller_test.rb
379
420
  - test/functional/api/v2/hostgroups_controller_test.rb
421
+ - test/functional/ui_ansible_roles_controller_test.rb
380
422
  - test/functional/ansible_roles_controller_test.rb
381
423
  - test/functional/ansible_variables_controller_test.rb
382
424
  - test/factories/ansible_roles.rb