foreman_ansible 6.0.2 → 6.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/ansible_roles_controller.rb +12 -8
  3. data/app/controllers/ansible_variables_controller.rb +4 -0
  4. data/app/controllers/api/v2/ansible_inventories_controller.rb +2 -2
  5. data/app/controllers/api/v2/ansible_roles_controller.rb +32 -11
  6. data/app/controllers/api/v2/ansible_variables_controller.rb +6 -4
  7. data/app/controllers/foreman_ansible/concerns/import_controller_helper.rb +3 -3
  8. data/app/helpers/foreman_ansible/ansible_reports_helper.rb +10 -5
  9. data/app/helpers/foreman_ansible/ansible_roles_data_preparations.rb +95 -0
  10. data/app/helpers/foreman_ansible/ansible_roles_helper.rb +20 -1
  11. data/app/jobs/sync_roles_and_variables.rb +20 -0
  12. data/app/models/concerns/foreman_ansible/host_managed_extensions.rb +10 -7
  13. data/app/models/concerns/foreman_ansible/hostgroup_extensions.rb +20 -5
  14. data/app/models/foreman_ansible/ansible_provider.rb +2 -1
  15. data/app/models/host_ansible_role.rb +1 -0
  16. data/app/models/hostgroup_ansible_role.rb +1 -0
  17. data/app/models/setting/ansible.rb +9 -0
  18. data/app/services/foreman_ansible/ansible_report_importer.rb +4 -0
  19. data/app/services/foreman_ansible/ansible_report_scanner.rb +15 -1
  20. data/app/services/foreman_ansible/api_roles_importer.rb +23 -11
  21. data/app/services/foreman_ansible/fact_parser.rb +21 -1
  22. data/app/services/foreman_ansible/import_roles_and_variables_error_notification.rb +31 -0
  23. data/app/services/foreman_ansible/import_roles_and_variables_success_notification.rb +26 -0
  24. data/app/services/foreman_ansible/inventory_creator.rb +3 -7
  25. data/app/services/foreman_ansible/operating_system_parser.rb +8 -2
  26. data/app/services/foreman_ansible/roles_importer.rb +3 -2
  27. data/app/services/foreman_ansible/ui_roles_importer.rb +2 -2
  28. data/app/services/foreman_ansible/variables_importer.rb +36 -1
  29. data/app/views/ansible_roles/import.html.erb +10 -50
  30. data/app/views/ansible_variables/index.html.erb +1 -2
  31. data/app/views/api/v2/ansible_roles/sync.json.rabl +5 -0
  32. data/app/views/foreman_ansible/ansible_roles/_select_tab_content.html.erb +8 -17
  33. data/app/views/foreman_ansible/config_reports/_ansible.html.erb +13 -6
  34. data/app/views/foreman_ansible/job_templates/ansible_collections_-_install_from_galaxy.erb +28 -0
  35. data/app/views/foreman_ansible/job_templates/ansible_roles_-_install_from_galaxy.erb +1 -1
  36. data/app/views/foreman_ansible/job_templates/capsule_upgrade_-_ansible_default.erb +2 -3
  37. data/app/views/foreman_ansible/job_templates/convert_to_rhel.erb +44 -0
  38. data/config/routes.rb +5 -4
  39. data/db/migrate/20210120150019_add_position_to_ansible_role.rb +27 -0
  40. data/db/seeds.d/100_common_parameters.rb +7 -0
  41. data/db/seeds.d/90_notification_blueprints.rb +19 -1
  42. data/lib/foreman_ansible/engine.rb +1 -0
  43. data/lib/foreman_ansible/register.rb +5 -5
  44. data/lib/foreman_ansible/version.rb +1 -1
  45. data/locale/ca/LC_MESSAGES/foreman_ansible.mo +0 -0
  46. data/locale/ca/foreman_ansible.po +1 -1
  47. data/locale/cs_CZ/LC_MESSAGES/foreman_ansible.mo +0 -0
  48. data/locale/cs_CZ/foreman_ansible.po +1 -1
  49. data/locale/de/LC_MESSAGES/foreman_ansible.mo +0 -0
  50. data/locale/de/foreman_ansible.po +1 -1
  51. data/locale/en/LC_MESSAGES/foreman_ansible.mo +0 -0
  52. data/locale/en/foreman_ansible.po +1 -1
  53. data/locale/en_GB/LC_MESSAGES/foreman_ansible.mo +0 -0
  54. data/locale/en_GB/foreman_ansible.po +1 -1
  55. data/locale/es/LC_MESSAGES/foreman_ansible.mo +0 -0
  56. data/locale/es/foreman_ansible.po +1 -1
  57. data/locale/fr/LC_MESSAGES/foreman_ansible.mo +0 -0
  58. data/locale/fr/foreman_ansible.po +1 -1
  59. data/locale/gl/LC_MESSAGES/foreman_ansible.mo +0 -0
  60. data/locale/gl/foreman_ansible.po +1 -1
  61. data/locale/it/LC_MESSAGES/foreman_ansible.mo +0 -0
  62. data/locale/it/foreman_ansible.po +1 -1
  63. data/locale/ja/LC_MESSAGES/foreman_ansible.mo +0 -0
  64. data/locale/ja/foreman_ansible.po +1 -1
  65. data/locale/ko/LC_MESSAGES/foreman_ansible.mo +0 -0
  66. data/locale/ko/foreman_ansible.po +1 -1
  67. data/locale/nl_NL/LC_MESSAGES/foreman_ansible.mo +0 -0
  68. data/locale/nl_NL/foreman_ansible.po +1 -1
  69. data/locale/pl/LC_MESSAGES/foreman_ansible.mo +0 -0
  70. data/locale/pl/foreman_ansible.po +1 -1
  71. data/locale/pt_BR/LC_MESSAGES/foreman_ansible.mo +0 -0
  72. data/locale/pt_BR/foreman_ansible.po +1 -1
  73. data/locale/ru/LC_MESSAGES/foreman_ansible.mo +0 -0
  74. data/locale/ru/foreman_ansible.po +1 -1
  75. data/locale/sv_SE/LC_MESSAGES/foreman_ansible.mo +0 -0
  76. data/locale/sv_SE/foreman_ansible.po +1 -1
  77. data/locale/zh_CN/LC_MESSAGES/foreman_ansible.mo +0 -0
  78. data/locale/zh_CN/foreman_ansible.po +1 -1
  79. data/locale/zh_TW/LC_MESSAGES/foreman_ansible.mo +0 -0
  80. data/locale/zh_TW/foreman_ansible.po +1 -1
  81. data/package.json +11 -42
  82. data/test/factories/ansible_roles.rb +12 -0
  83. data/test/factories/host_ansible_enhancements.rb +23 -0
  84. data/test/foreman_ansible/helpers/ansible_roles_helper_test.rb +45 -0
  85. data/test/functional/ansible_variables_controller_test.rb +0 -15
  86. data/test/functional/api/v2/ansible_roles_controller_test.rb +23 -0
  87. data/test/functional/api/v2/hostgroups_controller_test.rb +5 -4
  88. data/test/functional/api/v2/hosts_controller_test.rb +9 -8
  89. data/test/functional/hosts_controller_test.rb +10 -6
  90. data/test/unit/concerns/host_managed_extensions_test.rb +17 -3
  91. data/test/unit/concerns/hostgroup_extensions_test.rb +13 -7
  92. data/test/unit/host_ansible_role_test.rb +2 -1
  93. data/test/unit/hostgroup_ansible_role_test.rb +15 -1
  94. data/test/unit/ignore_roles_test.rb +43 -0
  95. data/test/unit/import_roles_and_variables.rb +60 -0
  96. data/test/unit/services/ansible_variables_importer_test.rb +13 -0
  97. data/test/unit/services/api_roles_importer_test.rb +22 -5
  98. data/test/unit/services/fact_parser_test.rb +16 -0
  99. data/test/unit/services/inventory_creator_test.rb +15 -7
  100. data/test/unit/services/ui_roles_importer_test.rb +2 -2
  101. data/webpack/__mocks__/foremanReact/common/helpers.js +13 -0
  102. data/webpack/__mocks__/foremanReact/components/common/forms/OrderableSelect/helpers.js +5 -0
  103. data/webpack/__mocks__/foremanReact/redux/API.js +7 -0
  104. data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariables.js +178 -0
  105. data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariables.scss +9 -0
  106. data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js +39 -0
  107. data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesConstants.js +4 -0
  108. data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesHelpers.js +11 -0
  109. data/webpack/components/AnsibleRolesAndVariables/__test__/AnsibleRolesAndVariablesHelpers.test.js +50 -0
  110. data/webpack/components/AnsibleRolesAndVariables/__test__/AnsibleRolesAndVariablesImport.test.js +39 -0
  111. data/webpack/components/AnsibleRolesAndVariables/__test__/__snapshots__/AnsibleRolesAndVariablesImport.test.js.snap +177 -0
  112. data/webpack/components/AnsibleRolesAndVariables/index.js +31 -0
  113. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.js +25 -27
  114. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.scss +1 -1
  115. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherActions.js +20 -14
  116. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherConstants.js +1 -2
  117. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherReducer.js +13 -8
  118. data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherSelectors.js +8 -28
  119. data/webpack/components/AnsibleRolesSwitcher/__fixtures__/ansibleRolesSwitcherReducer.fixtures.js +1 -0
  120. data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcher.test.js +6 -4
  121. data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherReducer.test.js +1 -9
  122. data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherSelectors.test.js +3 -16
  123. data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcher.test.js.snap +4 -8
  124. data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcherReducer.test.js.snap +8 -97
  125. data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcherSelectors.test.js.snap +5 -30
  126. data/webpack/components/AnsibleRolesSwitcher/components/AnsiblePermissionDenied.test.js +1 -1
  127. data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js +5 -2
  128. data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.test.js +1 -1
  129. data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRoleInputs.js +43 -0
  130. data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRoleInputs.test.js +19 -0
  131. data/webpack/components/AnsibleRolesSwitcher/components/AssignedRolesList.js +63 -51
  132. data/webpack/components/AnsibleRolesSwitcher/components/AssignedRolesList.test.js +4 -1
  133. data/webpack/components/AnsibleRolesSwitcher/components/AvailableRolesList.test.js +1 -1
  134. data/webpack/components/AnsibleRolesSwitcher/components/OrderedRolesTooltip.js +23 -0
  135. data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AnsibleRoleInputs.test.js.snap +51 -0
  136. data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AssignedRolesList.test.js.snap +28 -28
  137. data/webpack/components/AnsibleRolesSwitcher/index.js +4 -8
  138. data/webpack/index.js +6 -13
  139. metadata +84 -39
  140. data/app/views/ansible_variables/import.html.erb +0 -56
  141. data/webpack/test_setup.js +0 -12
@@ -0,0 +1,9 @@
1
+ #import-ansible-roles-variables {
2
+ .submit-cancel-btns {
3
+ padding-top: 20px;
4
+
5
+ button {
6
+ margin-right: 5px;
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ import { translate as __ } from 'foremanReact/common/I18n';
3
+ import { post } from 'foremanReact/redux/API';
4
+ import { push } from 'connected-react-router';
5
+ import { prepareResult } from './AnsibleRolesAndVariablesHelpers';
6
+ import {
7
+ ANSIBLE_ROLE_CONFIRM_IMPORT_PATH,
8
+ ANSIBLE_ROLES_INDEX,
9
+ } from './AnsibleRolesAndVariablesConstants';
10
+
11
+ export const foremanUrl = path => `${window.URL_PREFIX}${path}`;
12
+
13
+ export const onSubmit = (rows, proxy) => dispatch => {
14
+ const params = prepareResult(rows);
15
+ dispatch(
16
+ post({
17
+ key: 'import_ansible_v_r',
18
+ url: ANSIBLE_ROLE_CONFIRM_IMPORT_PATH,
19
+ params: { changed: params, proxy },
20
+ handleSuccess: () => {
21
+ setTimeout(() => dispatch(push(ANSIBLE_ROLES_INDEX)), 500);
22
+ },
23
+ successToast: response => (
24
+ <span>
25
+ {__('Import roles and variables started: ')}
26
+ <a
27
+ target="_blank"
28
+ rel="noopener noreferrer"
29
+ href={foremanUrl(`/foreman_tasks/tasks/${response.data?.task?.id}`)}
30
+ >
31
+ {__('view the task in progress')}
32
+ </a>
33
+ </span>
34
+ ),
35
+ errorToast: error =>
36
+ `${__('Failed to import roles and variables ')} ${error}`,
37
+ })
38
+ );
39
+ };
@@ -0,0 +1,4 @@
1
+ export const ANSIBLE_ROLES_INDEX = '/ansible/ansible_roles';
2
+ export const ANSIBLE_ROLE_CONFIRM_IMPORT_PATH =
3
+ '/ansible/ansible_roles/confirm_import';
4
+ export const DEFAULT_PER_PAGE = 5;
@@ -0,0 +1,11 @@
1
+ export const prepareResult = rows => {
2
+ const result = {};
3
+ const selectRows = rows.filter(row => row.selected === true);
4
+ selectRows.forEach(row => {
5
+ result[row.kind] = {};
6
+ });
7
+ selectRows.forEach(row => {
8
+ result[row.kind][row.role.name] = row.role;
9
+ });
10
+ return result;
11
+ };
@@ -0,0 +1,50 @@
1
+ import { prepareResult } from '../AnsibleRolesAndVariablesHelpers';
2
+
3
+ const bennojoy = { created_at: null, id: null, name: 'bennojoy.ntp' };
4
+ const gitRole = { created_at: null, id: null, name: '0ta2.git_role' };
5
+ const jriguera = { created_at: null, id: null, name: 'jriguera.monit' };
6
+ const rows = [
7
+ {
8
+ cells: [
9
+ 'bennojoy.ntp',
10
+ 'Update Role Variables',
11
+ 'Add: 1 Remove: 2 ',
12
+ '',
13
+ '',
14
+ ],
15
+ kind: 'old',
16
+ id: 'bennojoy.ntp',
17
+ role: bennojoy,
18
+ selected: true,
19
+ },
20
+ {
21
+ cells: ['0ta2.git_role', 'Import Role ', 'Add: 5 ', '', ''],
22
+ kind: 'new',
23
+ id: '0ta2.git_role',
24
+ role: gitRole,
25
+ selected: true,
26
+ },
27
+ {
28
+ cells: ['jriguera.monit', 'Import Role ', 'Add: 12 ', '', ''],
29
+ kind: 'new',
30
+ id: 'jriguera.monit',
31
+ role: jriguera,
32
+ },
33
+ ];
34
+
35
+ const result = {
36
+ old: {
37
+ 'bennojoy.ntp': bennojoy,
38
+ },
39
+ new: {
40
+ '0ta2.git_role': gitRole,
41
+ },
42
+ };
43
+
44
+ describe('AnsibleRolesAndVariablesHelpers', () => {
45
+ describe('prepareResult', () => {
46
+ it('should return correct results', () => {
47
+ expect(prepareResult(rows)).toStrictEqual(result);
48
+ });
49
+ });
50
+ });
@@ -0,0 +1,39 @@
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+ import ImportRolesAndVariablesTable from '../AnsibleRolesAndVariables';
3
+
4
+ const rowsData = [
5
+ {
6
+ cells: [
7
+ 'bennojoy.ntp',
8
+ 'Update Role Variables',
9
+ 'Add: 1 Remove: 2 ',
10
+ '',
11
+ '',
12
+ ],
13
+ kind: 'old',
14
+ id: 'bennojoy.ntp',
15
+ },
16
+ {
17
+ cells: ['0ta2.git_role', 'Import Role ', 'Add: 5 ', '', ''],
18
+ kind: 'new',
19
+ id: '0ta2.git_role',
20
+ },
21
+ ];
22
+
23
+ const columnsData = [
24
+ { title: 'Name' },
25
+ { title: 'Operation' },
26
+ { title: 'Variables' },
27
+ { title: 'Hosts Count' },
28
+ { title: 'Hostgroups count' },
29
+ ];
30
+
31
+ const fixtures = {
32
+ 'should render': {
33
+ rowsData,
34
+ columnsData,
35
+ },
36
+ };
37
+
38
+ describe('ImportRolesAndVariablesTable', () =>
39
+ testComponentSnapshotsWithFixtures(ImportRolesAndVariablesTable, fixtures));
@@ -0,0 +1,177 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ImportRolesAndVariablesTable should render 1`] = `
4
+ <div
5
+ id="import-ansible-roles-variables"
6
+ >
7
+ <Toolbar>
8
+ <ToolbarContent
9
+ isExpanded={false}
10
+ showClearFiltersButton={false}
11
+ >
12
+ <ForwardRef
13
+ variant="icon-button-group"
14
+ >
15
+ <ToolbarItem>
16
+ <Checkbox
17
+ aria-label="select all checkbox"
18
+ className=""
19
+ id="select-all"
20
+ isChecked={false}
21
+ isDisabled={false}
22
+ isValid={true}
23
+ label="Select all"
24
+ name="select-all"
25
+ onChange={[Function]}
26
+ />
27
+ </ToolbarItem>
28
+ </ForwardRef>
29
+ </ToolbarContent>
30
+ </Toolbar>
31
+ <Table
32
+ aria-label="import roles and variables"
33
+ borders={true}
34
+ canSelectAll={false}
35
+ canSortFavorites={true}
36
+ cells={
37
+ Array [
38
+ Object {
39
+ "title": "Name",
40
+ "transforms": Array [
41
+ [Function],
42
+ ],
43
+ },
44
+ Object {
45
+ "title": "Operation",
46
+ "transforms": Array [
47
+ [Function],
48
+ ],
49
+ },
50
+ Object {
51
+ "title": "Variables",
52
+ "transforms": Array [
53
+ [Function],
54
+ ],
55
+ },
56
+ Object {
57
+ "title": "Hosts Count",
58
+ "transforms": Array [
59
+ [Function],
60
+ ],
61
+ },
62
+ Object {
63
+ "title": "Hostgroups count",
64
+ "transforms": Array [
65
+ [Function],
66
+ ],
67
+ },
68
+ ]
69
+ }
70
+ className=""
71
+ contentId="expanded-content"
72
+ dropdownDirection="down"
73
+ dropdownPosition="right"
74
+ expandId="expandable-toggle"
75
+ gridBreakPoint="grid-md"
76
+ isStickyHeader={false}
77
+ onSelect={[Function]}
78
+ ouiaSafe={true}
79
+ role="grid"
80
+ rowLabeledBy="simple-node"
81
+ rows={
82
+ Array [
83
+ Object {
84
+ "cells": Array [
85
+ "bennojoy.ntp",
86
+ "Update Role Variables",
87
+ "Add: 1 Remove: 2 ",
88
+ "",
89
+ "",
90
+ ],
91
+ "id": "bennojoy.ntp",
92
+ "kind": "old",
93
+ },
94
+ Object {
95
+ "cells": Array [
96
+ "0ta2.git_role",
97
+ "Import Role ",
98
+ "Add: 5 ",
99
+ "",
100
+ "",
101
+ ],
102
+ "id": "0ta2.git_role",
103
+ "kind": "new",
104
+ },
105
+ ]
106
+ }
107
+ selectVariant="checkbox"
108
+ variant={null}
109
+ >
110
+ <TableHeader />
111
+ <Component />
112
+ </Table>
113
+ <Pagination
114
+ className=""
115
+ defaultToFullPage={true}
116
+ firstPage={1}
117
+ isCompact={true}
118
+ isDisabled={false}
119
+ isSticky={false}
120
+ itemCount={2}
121
+ itemsEnd={null}
122
+ itemsStart={null}
123
+ offset={0}
124
+ onFirstClick={[Function]}
125
+ onLastClick={[Function]}
126
+ onNextClick={[Function]}
127
+ onPageInput={[Function]}
128
+ onPerPageSelect={[Function]}
129
+ onPreviousClick={[Function]}
130
+ onSetPage={[Function]}
131
+ ouiaSafe={true}
132
+ page={0}
133
+ perPage={5}
134
+ perPageOptions={
135
+ Array [
136
+ Object {
137
+ "title": "3",
138
+ "value": 3,
139
+ },
140
+ Object {
141
+ "title": "5",
142
+ "value": 5,
143
+ },
144
+ Object {
145
+ "title": "10",
146
+ "value": 10,
147
+ },
148
+ ]
149
+ }
150
+ titles={
151
+ Object {
152
+ "paginationTitle": "top pagination",
153
+ }
154
+ }
155
+ toggleTemplate={[Function]}
156
+ variant="top"
157
+ widgetId="pagination-options-menu"
158
+ />
159
+ <div
160
+ className="submit-cancel-btns"
161
+ >
162
+ <br />
163
+ <br />
164
+ <Button
165
+ onClick={[Function]}
166
+ variant="primary"
167
+ >
168
+ Submit
169
+ </Button>
170
+ <Button
171
+ variant="secondary"
172
+ >
173
+ Cancel
174
+ </Button>
175
+ </div>
176
+ </div>
177
+ `;
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { useDispatch } from 'react-redux';
3
+ import { push } from 'connected-react-router';
4
+
5
+ import ImportRolesAndVariablesTable from './AnsibleRolesAndVariables';
6
+ import { onSubmit } from './AnsibleRolesAndVariablesActions';
7
+ import { ANSIBLE_ROLES_INDEX } from './AnsibleRolesAndVariablesConstants';
8
+
9
+ const WrappedImportRolesAndVariables = props => {
10
+ const cols = [
11
+ { title: 'Name' },
12
+ { title: 'Operation' },
13
+ { title: 'Variables' },
14
+ { title: 'Hosts Count' },
15
+ { title: 'Hostgroups count' },
16
+ ];
17
+ const dispatch = useDispatch();
18
+ const submit = (rows, proxy) => dispatch(onSubmit(rows, proxy));
19
+ const onCancel = () => {
20
+ dispatch(push(ANSIBLE_ROLES_INDEX));
21
+ };
22
+ return (
23
+ <ImportRolesAndVariablesTable
24
+ {...props}
25
+ columnsData={cols}
26
+ onSubmit={submit}
27
+ onCancel={onCancel}
28
+ />
29
+ );
30
+ };
31
+ export default WrappedImportRolesAndVariables;
@@ -7,6 +7,7 @@ import { translate as __ } from 'foremanReact/common/I18n';
7
7
  import AvailableRolesList from './components/AvailableRolesList';
8
8
  import AssignedRolesList from './components/AssignedRolesList';
9
9
  import AnsibleRolesSwitcherError from './components/AnsibleRolesSwitcherError';
10
+ import OrderedRolesTooltip from './components/OrderedRolesTooltip';
10
11
  import { excludeAssignedRolesSearch } from './AnsibleRolesSwitcherHelpers';
11
12
 
12
13
  class AnsibleRolesSwitcher extends React.Component {
@@ -17,7 +18,7 @@ class AnsibleRolesSwitcher extends React.Component {
17
18
  inheritedRoleIds,
18
19
  resourceId,
19
20
  resourceName,
20
- } = this.props.data;
21
+ } = this.props;
21
22
 
22
23
  this.props.getAnsibleRoles(
23
24
  availableRolesUrl,
@@ -37,13 +38,11 @@ class AnsibleRolesSwitcher extends React.Component {
37
38
  itemCount,
38
39
  addAnsibleRole,
39
40
  removeAnsibleRole,
41
+ moveAnsibleRole,
40
42
  getAnsibleRoles,
41
- changeAssignedPage,
42
- assignedPagination,
43
- assignedRolesCount,
44
43
  assignedRoles,
45
- allAssignedRoles,
46
44
  unassignedRoles,
45
+ toDestroyRoles,
47
46
  error,
48
47
  } = this.props;
49
48
 
@@ -52,17 +51,17 @@ class AnsibleRolesSwitcher extends React.Component {
52
51
  inheritedRoleIds,
53
52
  resourceId,
54
53
  resourceName,
55
- } = this.props.data;
54
+ } = this.props;
56
55
 
57
56
  const onListingChange = paginationArgs =>
58
57
  getAnsibleRoles(
59
58
  availableRolesUrl,
60
- allAssignedRoles,
59
+ assignedRoles,
61
60
  inheritedRoleIds,
62
61
  resourceId,
63
62
  resourceName,
64
63
  paginationArgs,
65
- excludeAssignedRolesSearch(allAssignedRoles)
64
+ excludeAssignedRolesSearch(assignedRoles)
66
65
  );
67
66
 
68
67
  return (
@@ -85,16 +84,18 @@ class AnsibleRolesSwitcher extends React.Component {
85
84
 
86
85
  <Col sm={6} className="assigned-roles-container">
87
86
  <div className="assigned-roles-header">
88
- <h2>{__('Assigned Ansible Roles')}</h2>
87
+ <h2>
88
+ <OrderedRolesTooltip />
89
+ {__('Assigned Ansible Roles')}
90
+ </h2>
89
91
  </div>
90
92
  <AssignedRolesList
91
93
  assignedRoles={assignedRoles}
92
- allAssignedRoles={allAssignedRoles}
93
- pagination={assignedPagination}
94
- itemCount={assignedRolesCount}
95
- onPaginationChange={changeAssignedPage}
94
+ unassignedRoles={unassignedRoles}
96
95
  onRemoveRole={removeAnsibleRole}
96
+ onMoveRole={moveAnsibleRole}
97
97
  resourceName={lowerCase(resourceName || '')}
98
+ toDestroyRoles={toDestroyRoles}
98
99
  />
99
100
  </Col>
100
101
  </Row>
@@ -104,13 +105,11 @@ class AnsibleRolesSwitcher extends React.Component {
104
105
  }
105
106
 
106
107
  AnsibleRolesSwitcher.propTypes = {
107
- data: PropTypes.shape({
108
- initialAssignedRoles: PropTypes.arrayOf(PropTypes.object),
109
- availableRolesUrl: PropTypes.string,
110
- inheritedRoleIds: PropTypes.arrayOf(PropTypes.number),
111
- resourceId: PropTypes.number,
112
- resourceName: PropTypes.string,
113
- }).isRequired,
108
+ initialAssignedRoles: PropTypes.arrayOf(PropTypes.object),
109
+ availableRolesUrl: PropTypes.string.isRequired,
110
+ inheritedRoleIds: PropTypes.arrayOf(PropTypes.number),
111
+ resourceId: PropTypes.number,
112
+ resourceName: PropTypes.string,
114
113
  getAnsibleRoles: PropTypes.func.isRequired,
115
114
  loading: PropTypes.bool.isRequired,
116
115
  pagination: PropTypes.shape({
@@ -120,14 +119,9 @@ AnsibleRolesSwitcher.propTypes = {
120
119
  itemCount: PropTypes.number.isRequired,
121
120
  addAnsibleRole: PropTypes.func.isRequired,
122
121
  removeAnsibleRole: PropTypes.func.isRequired,
123
- changeAssignedPage: PropTypes.func.isRequired,
124
- assignedPagination: PropTypes.shape({
125
- page: PropTypes.number,
126
- perPage: PropTypes.number,
127
- }).isRequired,
128
- assignedRolesCount: PropTypes.number.isRequired,
122
+ moveAnsibleRole: PropTypes.func.isRequired,
129
123
  assignedRoles: PropTypes.arrayOf(PropTypes.object).isRequired,
130
- allAssignedRoles: PropTypes.arrayOf(PropTypes.object).isRequired,
124
+ toDestroyRoles: PropTypes.arrayOf(PropTypes.object).isRequired,
131
125
  unassignedRoles: PropTypes.arrayOf(PropTypes.object).isRequired,
132
126
  error: PropTypes.shape({
133
127
  errorMsg: PropTypes.string,
@@ -137,6 +131,10 @@ AnsibleRolesSwitcher.propTypes = {
137
131
 
138
132
  AnsibleRolesSwitcher.defaultProps = {
139
133
  error: {},
134
+ resourceId: null,
135
+ resourceName: '',
136
+ initialAssignedRoles: [],
137
+ inheritedRoleIds: [],
140
138
  };
141
139
 
142
140
  export default AnsibleRolesSwitcher;