foreman_ansible 7.1.3 → 7.1.5

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: 2754fa1c5a9834d8b174906f4848ce5ba7e5699a9c757e6761b24c1ced021f52
4
- data.tar.gz: b9c7d3e372fbde5eb5a6e5b94af335293ec660b81511c23f4cd519868632988a
3
+ metadata.gz: 6988da0b98785b524a517950e7af3143cb869a83a4880e07930c5db47a466d8c
4
+ data.tar.gz: 6cdfa6a0f7dce34cae4b4c39004d9dea499e3f70d9b0687784c3acc45e548bf1
5
5
  SHA512:
6
- metadata.gz: 933f56fb3c7eb0389397067189f9b64f7fc2ec44fb631e26b0943748b80c80f51b23e2897f4175ff4e8f28b5dbd1232e51641a429b07de1fd2786ba7d44fc4bc
7
- data.tar.gz: d9c4973117fa530f4dfbd93720692a9331c1172b120f66aa6df4cb59f9dfe3162b2004c5f7e2e9b1f3bf99283524154fb2e1fe4a8045839c97823895a446a8e6
6
+ metadata.gz: e56067be85f66f973b8f4ebc1244f17e052539977cb022df27e0206087844d6aef590c4a5ab7d4b69265d7e2b1a21285363f01676d5e563b03749208628a2173
7
+ data.tar.gz: a92d028988fd669b325492b8fb7c01dbf8b266bb1f9e53fb7a69d461133f5d8c93114da3606369f8ab36590d6ae6d1af2453a9416236465455c98ff342a15996
@@ -4,5 +4,5 @@
4
4
  # This way other parts of Foreman can just call ForemanAnsible::VERSION
5
5
  # and detect what version the plugin is running.
6
6
  module ForemanAnsible
7
- VERSION = '7.1.3'
7
+ VERSION = '7.1.5'
8
8
  end
@@ -85,12 +85,16 @@ const validateRegexp = (variable, value) => {
85
85
  };
86
86
 
87
87
  const validateList = (variable, value) => {
88
- if (variable.validatorRule.split(',').find(item => item.trim() === value)) {
88
+ let { validatorRule } = variable;
89
+ if (typeof validatorRule !== 'string') {
90
+ validatorRule = validatorRule.toString();
91
+ }
92
+ if (validatorRule.split(',').find(item => item.trim() === value)) {
89
93
  return validationSuccess;
90
94
  }
91
95
  return {
92
96
  key: 'error',
93
- msg: sprintf(__('Invalid, expected one of: %s'), variable.validatorRule),
97
+ msg: sprintf(__('Invalid, expected one of: %s'), validatorRule),
94
98
  };
95
99
  };
96
100
 
@@ -21,7 +21,8 @@ import {
21
21
  assignRolesErrorMock,
22
22
  } from './RolesTab.fixtures';
23
23
 
24
- const TestComponent = withReactRouter(withRedux(withMockedProvider(RolesTab)));
24
+ jest.mock('axios');
25
+ const TestComponent = withRedux(withReactRouter(withMockedProvider(RolesTab)));
25
26
 
26
27
  describe('assigning Ansible roles', () => {
27
28
  it('should assign Ansible roles', async () => {
@@ -6,6 +6,7 @@ import {
6
6
  tick,
7
7
  withMockedProvider,
8
8
  withReactRouter,
9
+ withRedux,
9
10
  } from '../../../../../testHelper';
10
11
 
11
12
  import {
@@ -18,7 +19,8 @@ import {
18
19
 
19
20
  import RolesTab from '../';
20
21
 
21
- const TestComponent = withReactRouter(withMockedProvider(RolesTab));
22
+ jest.mock('axios');
23
+ const TestComponent = withRedux(withReactRouter(withMockedProvider(RolesTab)));
22
24
 
23
25
  describe('RolesTab', () => {
24
26
  it('should load Ansible Roles as admin', async () => {
@@ -2,7 +2,10 @@ import React, { useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { useQuery } from '@apollo/client';
4
4
  import { Button } from '@patternfly/react-core';
5
+ import { Link, Route } from 'react-router-dom';
5
6
  import { translate as __ } from 'foremanReact/common/I18n';
7
+ import { foremanUrl } from 'foremanReact/common/helpers';
8
+ import { useAPI } from 'foremanReact/common/hooks/API/APIHooks';
6
9
 
7
10
  import ansibleRolesQuery from '../../../../graphql/queries/hostAnsibleRoles.gql';
8
11
  import { encodeId } from '../../../../globalIdHelper';
@@ -12,6 +15,7 @@ import {
12
15
  useCurrentPagination,
13
16
  } from '../../../../helpers/pageParamsHelper';
14
17
  import EditRolesModal from './EditRolesModal';
18
+ import AllRolesModal from './AllRolesModal';
15
19
 
16
20
  const RolesTab = ({ hostId, history, canEditHost }) => {
17
21
  const hostGlobalId = encodeId('Host', hostId);
@@ -33,9 +37,28 @@ const RolesTab = ({ hostId, history, canEditHost }) => {
33
37
  onClick={() => setAssignModal(true)}
34
38
  aria-label="edit ansible roles"
35
39
  >
36
- {__('Assign Ansible roles')}
40
+ {__('Assign roles directly to the host')}
37
41
  </Button>
38
42
  ) : null;
43
+
44
+ const url = hostId && foremanUrl(`/api/v2/hosts/${hostId}/ansible_roles`);
45
+ const { response: allAnsibleRoles } = useAPI('get', url, {
46
+ key: 'ANSIBLE_ROLES',
47
+ });
48
+ const emptyStateDescription = allAnsibleRoles.length > 0 && (
49
+ <>
50
+ <Route path="/Ansible/roles/all">
51
+ <AllRolesModal
52
+ onClose={() => history.push('/Ansible/roles')}
53
+ isOpen
54
+ hostGlobalId={hostGlobalId}
55
+ history={history}
56
+ />
57
+ </Route>
58
+ <Link to="/Ansible/roles/all">{__('View inherited roles')}</Link>
59
+ </>
60
+ );
61
+
39
62
  return (
40
63
  <>
41
64
  <RolesTable
@@ -46,8 +69,9 @@ const RolesTab = ({ hostId, history, canEditHost }) => {
46
69
  history={history}
47
70
  hostGlobalId={hostGlobalId}
48
71
  emptyStateProps={{
49
- header: __('No Ansible roles assigned'),
72
+ header: __('No roles assigned directly to the host'),
50
73
  action: editBtn,
74
+ description: emptyStateDescription,
51
75
  }}
52
76
  pagination={pagination}
53
77
  canEditHost={canEditHost}
@@ -1,15 +1,24 @@
1
1
  import React from 'react';
2
2
  import { Provider } from 'react-redux';
3
+ import thunk from 'redux-thunk';
4
+ import { applyMiddleware, createStore, compose, combineReducers } from 'redux';
3
5
  import { MockedProvider } from '@apollo/react-testing';
4
6
  import { Router, MemoryRouter } from 'react-router-dom';
5
7
  import { createMemoryHistory } from 'history';
6
8
 
7
- import store from 'foremanReact/redux';
8
- import ConfirmModal from 'foremanReact/components/ConfirmModal';
9
+ import { reducers as apiReducer, APIMiddleware } from 'foremanReact/redux/API';
10
+ import ConfirmModal, {
11
+ reducers as confirmModalReducers,
12
+ } from 'foremanReact/components/ConfirmModal';
9
13
  import { getForemanContext } from 'foremanReact/Root/Context/ForemanContext';
10
14
 
15
+ const reducers = combineReducers({ ...apiReducer, ...confirmModalReducers });
16
+
17
+ export const generateStore = () =>
18
+ createStore(reducers, compose(applyMiddleware(thunk, APIMiddleware)));
19
+
11
20
  export const withRedux = Component => props => (
12
- <Provider store={store}>
21
+ <Provider store={generateStore()}>
13
22
  <Component {...props} />
14
23
  <ConfirmModal />
15
24
  </Provider>
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: 7.1.3
4
+ version: 7.1.5
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: 2022-08-25 00:00:00.000000000 Z
11
+ date: 2023-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: acts_as_list
@@ -42,30 +42,30 @@ dependencies:
42
42
  name: foreman_remote_execution
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 4.4.0
47
+ version: 7.2.2
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 4.4.0
54
+ version: 7.2.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: foreman-tasks
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 5.2.0
61
+ version: 6.0.3
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 5.2.0
68
+ version: 6.0.3
69
69
  description: Ansible integration with Foreman
70
70
  email:
71
71
  - elobatocs@gmail.com
@@ -458,7 +458,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
458
458
  - !ruby/object:Gem::Version
459
459
  version: '0'
460
460
  requirements: []
461
- rubygems_version: 3.2.26
461
+ rubygems_version: 3.1.4
462
462
  signing_key:
463
463
  specification_version: 4
464
464
  summary: Ansible integration with Foreman (theforeman.org)
@@ -469,16 +469,16 @@ test_files:
469
469
  - test/factories/host_ansible_enhancements.rb
470
470
  - test/fixtures/insights_playbook.yaml
471
471
  - test/fixtures/playbooks_example_output.json
472
- - test/fixtures/report.json
473
472
  - test/fixtures/sample_facts.json
474
473
  - test/fixtures/sample_playbooks.json
474
+ - test/fixtures/report.json
475
475
  - test/foreman_ansible/helpers/ansible_roles_helper_test.rb
476
476
  - test/functional/ansible_roles_controller_test.rb
477
477
  - test/functional/ansible_variables_controller_test.rb
478
- - test/functional/api/v2/ansible_inventories_controller_test.rb
479
478
  - test/functional/api/v2/ansible_playbooks_controller_test.rb
480
479
  - test/functional/api/v2/ansible_roles_controller_test.rb
481
480
  - test/functional/api/v2/ansible_variables_controller_test.rb
481
+ - test/functional/api/v2/ansible_inventories_controller_test.rb
482
482
  - test/functional/api/v2/hostgroups_controller_test.rb
483
483
  - test/functional/api/v2/hosts_controller_test.rb
484
484
  - test/functional/hosts_controller_test.rb
@@ -487,9 +487,6 @@ test_files:
487
487
  - test/graphql/queries/ansible_roles_query_test.rb
488
488
  - test/graphql/queries/host_ansible_roles_query_test.rb
489
489
  - test/test_plugin_helper.rb
490
- - test/unit/actions/run_ansible_job_test.rb
491
- - test/unit/actions/run_proxy_ansible_command_test.rb
492
- - test/unit/ansible_provider_test.rb
493
490
  - test/unit/ansible_role_test.rb
494
491
  - test/unit/ansible_variable_test.rb
495
492
  - test/unit/concerns/config_reports_extensions_test.rb
@@ -510,3 +507,6 @@ test_files:
510
507
  - test/unit/services/override_resolver_test.rb
511
508
  - test/unit/services/roles_importer_test.rb
512
509
  - test/unit/services/ui_roles_importer_test.rb
510
+ - test/unit/actions/run_ansible_job_test.rb
511
+ - test/unit/actions/run_proxy_ansible_command_test.rb
512
+ - test/unit/ansible_provider_test.rb