foreman_ansible 6.0.1 → 6.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/ansible_roles_controller.rb +12 -8
- data/app/controllers/ansible_variables_controller.rb +4 -0
- data/app/controllers/api/v2/ansible_inventories_controller.rb +2 -2
- data/app/controllers/api/v2/ansible_roles_controller.rb +32 -11
- data/app/controllers/api/v2/ansible_variables_controller.rb +6 -4
- data/app/controllers/foreman_ansible/concerns/import_controller_helper.rb +3 -3
- data/app/helpers/foreman_ansible/ansible_reports_helper.rb +10 -5
- data/app/helpers/foreman_ansible/ansible_roles_data_preparations.rb +95 -0
- data/app/helpers/foreman_ansible/ansible_roles_helper.rb +20 -1
- data/app/jobs/sync_roles_and_variables.rb +20 -0
- data/app/models/concerns/foreman_ansible/host_managed_extensions.rb +10 -7
- data/app/models/concerns/foreman_ansible/hostgroup_extensions.rb +19 -4
- data/app/models/foreman_ansible/ansible_provider.rb +3 -2
- data/app/models/host_ansible_role.rb +1 -0
- data/app/models/hostgroup_ansible_role.rb +1 -0
- data/app/models/setting/ansible.rb +9 -0
- data/app/services/foreman_ansible/ansible_report_importer.rb +4 -0
- data/app/services/foreman_ansible/ansible_report_scanner.rb +15 -1
- data/app/services/foreman_ansible/api_roles_importer.rb +23 -11
- data/app/services/foreman_ansible/fact_parser.rb +21 -1
- data/app/services/foreman_ansible/import_roles_and_variables_error_notification.rb +31 -0
- data/app/services/foreman_ansible/import_roles_and_variables_success_notification.rb +26 -0
- data/app/services/foreman_ansible/inventory_creator.rb +3 -7
- data/app/services/foreman_ansible/operating_system_parser.rb +8 -2
- data/app/services/foreman_ansible/roles_importer.rb +3 -2
- data/app/services/foreman_ansible/ui_roles_importer.rb +2 -2
- data/app/services/foreman_ansible/variables_importer.rb +36 -1
- data/app/views/ansible_roles/import.html.erb +10 -50
- data/app/views/ansible_variables/index.html.erb +1 -2
- data/app/views/api/v2/ansible_roles/sync.json.rabl +5 -0
- data/app/views/foreman_ansible/ansible_roles/_select_tab_content.html.erb +8 -17
- data/app/views/foreman_ansible/config_reports/_ansible.html.erb +13 -6
- data/app/views/foreman_ansible/job_templates/ansible_collections_-_install_from_galaxy.erb +28 -0
- data/app/views/foreman_ansible/job_templates/ansible_roles_-_install_from_galaxy.erb +1 -1
- data/app/views/foreman_ansible/job_templates/capsule_upgrade_-_ansible_default.erb +2 -3
- data/app/views/foreman_ansible/job_templates/convert_to_rhel.erb +44 -0
- data/config/routes.rb +5 -4
- data/db/migrate/20210120150019_add_position_to_ansible_role.rb +27 -0
- data/db/seeds.d/100_common_parameters.rb +7 -0
- data/db/seeds.d/90_notification_blueprints.rb +19 -1
- data/lib/foreman_ansible/engine.rb +1 -0
- data/lib/foreman_ansible/register.rb +5 -5
- data/lib/foreman_ansible/version.rb +1 -1
- data/locale/ca/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ca/foreman_ansible.po +1 -1
- data/locale/cs_CZ/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/cs_CZ/foreman_ansible.po +1 -1
- data/locale/de/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/de/foreman_ansible.po +1 -1
- data/locale/en/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/en/foreman_ansible.po +1 -1
- data/locale/en_GB/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/en_GB/foreman_ansible.po +1 -1
- data/locale/es/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/es/foreman_ansible.po +1 -1
- data/locale/fr/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/fr/foreman_ansible.po +1 -1
- data/locale/gl/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/gl/foreman_ansible.po +1 -1
- data/locale/it/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/it/foreman_ansible.po +1 -1
- data/locale/ja/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ja/foreman_ansible.po +1 -1
- data/locale/ko/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ko/foreman_ansible.po +1 -1
- data/locale/nl_NL/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/nl_NL/foreman_ansible.po +1 -1
- data/locale/pl/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/pl/foreman_ansible.po +1 -1
- data/locale/pt_BR/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/pt_BR/foreman_ansible.po +1 -1
- data/locale/ru/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ru/foreman_ansible.po +1 -1
- data/locale/sv_SE/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/sv_SE/foreman_ansible.po +1 -1
- data/locale/zh_CN/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/zh_CN/foreman_ansible.po +1 -1
- data/locale/zh_TW/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/zh_TW/foreman_ansible.po +1 -1
- data/package.json +11 -42
- data/test/factories/ansible_roles.rb +12 -0
- data/test/factories/host_ansible_enhancements.rb +23 -0
- data/test/foreman_ansible/helpers/ansible_roles_helper_test.rb +45 -0
- data/test/functional/ansible_variables_controller_test.rb +0 -15
- data/test/functional/api/v2/ansible_roles_controller_test.rb +23 -0
- data/test/functional/api/v2/hostgroups_controller_test.rb +5 -4
- data/test/functional/api/v2/hosts_controller_test.rb +9 -8
- data/test/functional/hosts_controller_test.rb +10 -6
- data/test/unit/ansible_provider_test.rb +1 -1
- data/test/unit/concerns/host_managed_extensions_test.rb +17 -3
- data/test/unit/concerns/hostgroup_extensions_test.rb +13 -7
- data/test/unit/host_ansible_role_test.rb +2 -1
- data/test/unit/hostgroup_ansible_role_test.rb +2 -1
- data/test/unit/ignore_roles_test.rb +43 -0
- data/test/unit/import_roles_and_variables.rb +60 -0
- data/test/unit/lib/foreman_ansible_core/ansible_runner_test.rb +3 -3
- data/test/unit/lib/foreman_ansible_core/playbook_runner_test.rb +3 -3
- data/test/unit/services/ansible_variables_importer_test.rb +13 -0
- data/test/unit/services/api_roles_importer_test.rb +22 -5
- data/test/unit/services/fact_parser_test.rb +16 -0
- data/test/unit/services/inventory_creator_test.rb +16 -8
- data/test/unit/services/ui_roles_importer_test.rb +2 -2
- data/webpack/__mocks__/foremanReact/common/helpers.js +13 -0
- data/webpack/__mocks__/foremanReact/components/common/forms/OrderableSelect/helpers.js +5 -0
- data/webpack/__mocks__/foremanReact/redux/API.js +7 -0
- data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariables.js +178 -0
- data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariables.scss +9 -0
- data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesActions.js +39 -0
- data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesConstants.js +4 -0
- data/webpack/components/AnsibleRolesAndVariables/AnsibleRolesAndVariablesHelpers.js +11 -0
- data/webpack/components/AnsibleRolesAndVariables/__test__/AnsibleRolesAndVariablesHelpers.test.js +50 -0
- data/webpack/components/AnsibleRolesAndVariables/__test__/AnsibleRolesAndVariablesImport.test.js +39 -0
- data/webpack/components/AnsibleRolesAndVariables/__test__/__snapshots__/AnsibleRolesAndVariablesImport.test.js.snap +177 -0
- data/webpack/components/AnsibleRolesAndVariables/index.js +31 -0
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.js +25 -27
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.scss +1 -1
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherActions.js +20 -14
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherConstants.js +1 -2
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherReducer.js +13 -8
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherSelectors.js +8 -28
- data/webpack/components/AnsibleRolesSwitcher/__fixtures__/ansibleRolesSwitcherReducer.fixtures.js +1 -0
- data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcher.test.js +6 -4
- data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherReducer.test.js +1 -9
- data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherSelectors.test.js +3 -16
- data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcher.test.js.snap +4 -8
- data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcherReducer.test.js.snap +8 -97
- data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcherSelectors.test.js.snap +5 -30
- data/webpack/components/AnsibleRolesSwitcher/components/AnsiblePermissionDenied.test.js +1 -1
- data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js +5 -2
- data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.test.js +1 -1
- data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRoleInputs.js +43 -0
- data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRoleInputs.test.js +19 -0
- data/webpack/components/AnsibleRolesSwitcher/components/AssignedRolesList.js +63 -51
- data/webpack/components/AnsibleRolesSwitcher/components/AssignedRolesList.test.js +4 -1
- data/webpack/components/AnsibleRolesSwitcher/components/AvailableRolesList.test.js +1 -1
- data/webpack/components/AnsibleRolesSwitcher/components/OrderedRolesTooltip.js +23 -0
- data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AnsibleRoleInputs.test.js.snap +51 -0
- data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AssignedRolesList.test.js.snap +28 -28
- data/webpack/components/AnsibleRolesSwitcher/index.js +4 -8
- data/webpack/index.js +6 -13
- metadata +60 -15
- data/app/views/ansible_variables/import.html.erb +0 -56
- data/webpack/test_setup.js +0 -12
@@ -0,0 +1,178 @@
|
|
1
|
+
import React, { useState } from 'react';
|
2
|
+
import {
|
3
|
+
Table,
|
4
|
+
TableHeader,
|
5
|
+
TableBody,
|
6
|
+
cellWidth,
|
7
|
+
} from '@patternfly/react-table';
|
8
|
+
import {
|
9
|
+
Button,
|
10
|
+
Toolbar,
|
11
|
+
ToolbarGroup,
|
12
|
+
ToolbarContent,
|
13
|
+
ToolbarItem,
|
14
|
+
Checkbox,
|
15
|
+
Pagination,
|
16
|
+
} from '@patternfly/react-core';
|
17
|
+
|
18
|
+
import PropTypes from 'prop-types';
|
19
|
+
import { DEFAULT_PER_PAGE } from './AnsibleRolesAndVariablesConstants';
|
20
|
+
import './AnsibleRolesAndVariables.scss';
|
21
|
+
|
22
|
+
const ImportRolesAndVariablesTable = ({
|
23
|
+
columnsData,
|
24
|
+
rowsData,
|
25
|
+
proxy,
|
26
|
+
onSubmit,
|
27
|
+
onCancel,
|
28
|
+
}) => {
|
29
|
+
const columns = columnsData.map(col => ({
|
30
|
+
...col,
|
31
|
+
transforms: [cellWidth(10)],
|
32
|
+
}));
|
33
|
+
const [rows, setRows] = useState(rowsData);
|
34
|
+
|
35
|
+
const [isChecked, setIsChecked] = useState(false);
|
36
|
+
const [selectedRowsCount, setSelectRowsCount] = useState(0);
|
37
|
+
|
38
|
+
const [page, setPage] = useState();
|
39
|
+
const [perPage, setPerPage] = useState(DEFAULT_PER_PAGE);
|
40
|
+
const [paginatedRows, setPaginatedRows] = useState(rows.slice(0, perPage));
|
41
|
+
|
42
|
+
const onSelect = (event, isSelected, rowId, row) => {
|
43
|
+
const selectableRowLength = rows.filter(
|
44
|
+
tempRow => tempRow.parent === undefined
|
45
|
+
).length;
|
46
|
+
let rowsCount = selectedRowsCount;
|
47
|
+
const tempRows = rows.map(tempRow => {
|
48
|
+
if (rowId === -1) {
|
49
|
+
tempRow.selected = isSelected;
|
50
|
+
setIsChecked(isSelected);
|
51
|
+
setSelectRowsCount(isSelected ? selectableRowLength : 0);
|
52
|
+
} else if (tempRow.id === row.id) {
|
53
|
+
tempRow.selected = isSelected;
|
54
|
+
rowsCount = isSelected ? selectedRowsCount + 1 : selectedRowsCount - 1;
|
55
|
+
if (rowsCount > 0 && rowsCount === selectableRowLength) {
|
56
|
+
setIsChecked(true);
|
57
|
+
} else {
|
58
|
+
setIsChecked(false);
|
59
|
+
}
|
60
|
+
setSelectRowsCount(rowsCount);
|
61
|
+
}
|
62
|
+
return tempRow;
|
63
|
+
});
|
64
|
+
setRows(tempRows);
|
65
|
+
};
|
66
|
+
|
67
|
+
const SelectAll = checked => {
|
68
|
+
onSelect(null, checked, -1);
|
69
|
+
};
|
70
|
+
|
71
|
+
const handleSetPage = (event, newPage) => {
|
72
|
+
const startIdx = (newPage - 1) * perPage;
|
73
|
+
const endIdx =
|
74
|
+
rows.length < newPage * perPage ? rows.length : newPage * perPage;
|
75
|
+
setPage(newPage);
|
76
|
+
setPaginatedRows(rows.slice(startIdx, endIdx));
|
77
|
+
};
|
78
|
+
|
79
|
+
const handlePerPageSelect = (
|
80
|
+
event,
|
81
|
+
newPerPage,
|
82
|
+
newPage,
|
83
|
+
startIdx,
|
84
|
+
endIdx
|
85
|
+
) => {
|
86
|
+
setPerPage(newPerPage);
|
87
|
+
setPage(newPage);
|
88
|
+
setPaginatedRows(rows.slice(startIdx, endIdx));
|
89
|
+
};
|
90
|
+
|
91
|
+
const renderPagination = (variant = 'top') => (
|
92
|
+
<Pagination
|
93
|
+
isCompact
|
94
|
+
itemCount={rows.length}
|
95
|
+
page={page}
|
96
|
+
perPage={perPage}
|
97
|
+
defaultToFullPage
|
98
|
+
onSetPage={handleSetPage}
|
99
|
+
onPerPageSelect={handlePerPageSelect}
|
100
|
+
perPageOptions={[
|
101
|
+
{ title: '3', value: 3 },
|
102
|
+
{ title: '5', value: 5 },
|
103
|
+
{ title: '10', value: 10 },
|
104
|
+
]}
|
105
|
+
titles={{
|
106
|
+
paginationTitle: `${variant} pagination`,
|
107
|
+
}}
|
108
|
+
/>
|
109
|
+
);
|
110
|
+
|
111
|
+
const renderSelectAll = () => (
|
112
|
+
<Toolbar>
|
113
|
+
<ToolbarContent>
|
114
|
+
<ToolbarGroup variant="icon-button-group">
|
115
|
+
<ToolbarItem>
|
116
|
+
<Checkbox
|
117
|
+
isChecked={isChecked}
|
118
|
+
onChange={SelectAll}
|
119
|
+
aria-label="select all checkbox"
|
120
|
+
id="select-all"
|
121
|
+
name="select-all"
|
122
|
+
label={isChecked ? 'Deselect all' : 'Select all'}
|
123
|
+
/>
|
124
|
+
</ToolbarItem>
|
125
|
+
</ToolbarGroup>
|
126
|
+
</ToolbarContent>
|
127
|
+
</Toolbar>
|
128
|
+
);
|
129
|
+
|
130
|
+
const renderSubmitAndCancel = () => (
|
131
|
+
<div className="submit-cancel-btns">
|
132
|
+
<br />
|
133
|
+
<br />
|
134
|
+
<Button variant="primary" onClick={() => onSubmit(rows, proxy)}>
|
135
|
+
Submit
|
136
|
+
</Button>
|
137
|
+
<Button variant="secondary" onClick={onCancel}>
|
138
|
+
Cancel
|
139
|
+
</Button>
|
140
|
+
</div>
|
141
|
+
);
|
142
|
+
|
143
|
+
return (
|
144
|
+
<div id="import-ansible-roles-variables">
|
145
|
+
{renderSelectAll()}
|
146
|
+
<Table
|
147
|
+
aria-label="import roles and variables"
|
148
|
+
onSelect={onSelect}
|
149
|
+
rows={paginatedRows}
|
150
|
+
cells={columns}
|
151
|
+
canSelectAll={false}
|
152
|
+
>
|
153
|
+
<TableHeader />
|
154
|
+
<TableBody />
|
155
|
+
</Table>
|
156
|
+
{renderPagination()}
|
157
|
+
{renderSubmitAndCancel()}
|
158
|
+
</div>
|
159
|
+
);
|
160
|
+
};
|
161
|
+
|
162
|
+
ImportRolesAndVariablesTable.defaultProps = {
|
163
|
+
columnsData: undefined,
|
164
|
+
rowsData: [],
|
165
|
+
proxy: undefined,
|
166
|
+
onSubmit: undefined,
|
167
|
+
onCancel: undefined,
|
168
|
+
};
|
169
|
+
|
170
|
+
ImportRolesAndVariablesTable.propTypes = {
|
171
|
+
columnsData: PropTypes.array,
|
172
|
+
rowsData: PropTypes.array,
|
173
|
+
proxy: PropTypes.number,
|
174
|
+
onSubmit: PropTypes.func,
|
175
|
+
onCancel: PropTypes.func,
|
176
|
+
};
|
177
|
+
|
178
|
+
export default ImportRolesAndVariablesTable;
|
@@ -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,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
|
+
};
|
data/webpack/components/AnsibleRolesAndVariables/__test__/AnsibleRolesAndVariablesHelpers.test.js
ADDED
@@ -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
|
+
});
|
data/webpack/components/AnsibleRolesAndVariables/__test__/AnsibleRolesAndVariablesImport.test.js
ADDED
@@ -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
|
+
`;
|