foreman_ansible 2.3.4 → 2.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/foreman_ansible/ansible_roles_helper.rb +0 -4
- data/app/models/ansible_role.rb +0 -1
- data/app/views/foreman_ansible/ansible_roles/_select_tab_content.html.erb +13 -21
- data/config/routes.rb +1 -3
- data/lib/foreman_ansible/register.rb +1 -2
- data/lib/foreman_ansible/version.rb +1 -1
- data/locale/de/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/de/foreman_ansible.edit.po +696 -0
- data/locale/de/foreman_ansible.po.time_stamp +0 -0
- data/locale/en/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/en/foreman_ansible.edit.po +694 -0
- data/locale/en/foreman_ansible.po.time_stamp +0 -0
- data/locale/es/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/es/foreman_ansible.edit.po +696 -0
- data/locale/es/foreman_ansible.po.time_stamp +0 -0
- data/locale/fr/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/fr/foreman_ansible.edit.po +696 -0
- data/locale/fr/foreman_ansible.po.time_stamp +0 -0
- data/locale/it/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/it/foreman_ansible.edit.po +696 -0
- data/locale/it/foreman_ansible.po.time_stamp +0 -0
- data/locale/ja/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ja/foreman_ansible.edit.po +696 -0
- data/locale/ja/foreman_ansible.po.time_stamp +0 -0
- data/locale/ko/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ko/foreman_ansible.edit.po +696 -0
- data/locale/ko/foreman_ansible.po.time_stamp +0 -0
- data/locale/pt_BR/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/pt_BR/foreman_ansible.edit.po +696 -0
- data/locale/pt_BR/foreman_ansible.po.time_stamp +0 -0
- data/locale/ru/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/ru/foreman_ansible.edit.po +697 -0
- data/locale/ru/foreman_ansible.po.time_stamp +0 -0
- data/locale/zh_CN/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/zh_CN/foreman_ansible.edit.po +696 -0
- data/locale/zh_CN/foreman_ansible.po.time_stamp +0 -0
- data/locale/zh_TW/LC_MESSAGES/foreman_ansible.mo +0 -0
- data/locale/zh_TW/foreman_ansible.edit.po +696 -0
- data/locale/zh_TW/foreman_ansible.po.time_stamp +0 -0
- data/package.json +9 -50
- data/webpack/components/ReportJsonViewer.js +7 -11
- data/webpack/index.js +1 -25
- metadata +65 -73
- data/app/controllers/ui_ansible_roles_controller.rb +0 -14
- data/app/views/ui_ansible_roles/index.json.rabl +0 -3
- data/app/views/ui_ansible_roles/main.json.rabl +0 -3
- data/app/views/ui_ansible_roles/show.json.rabl +0 -3
- data/test/functional/ui_ansible_roles_controller_test.rb +0 -14
- data/webpack/__mocks__/foremanReact/components/Pagination/PaginationWrapper.js +0 -2
- data/webpack/__mocks__/foremanReact/components/common/EmptyState.js +0 -5
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.js +0 -140
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcher.scss +0 -45
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherActions.js +0 -69
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherConstants.js +0 -7
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherHelpers.js +0 -7
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherReducer.js +0 -69
- data/webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherSelectors.js +0 -68
- data/webpack/components/AnsibleRolesSwitcher/__fixtures__/ansibleRolesData.fixtures.js +0 -20
- data/webpack/components/AnsibleRolesSwitcher/__fixtures__/ansibleRolesSwitcherReducer.fixtures.js +0 -36
- data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcher.test.js +0 -30
- data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherReducer.test.js +0 -73
- data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherSelectors.test.js +0 -43
- data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcher.test.js.snap +0 -79
- data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcherReducer.test.js.snap +0 -399
- data/webpack/components/AnsibleRolesSwitcher/__tests__/__snapshots__/AnsibleRolesSwitcherSelectors.test.js.snap +0 -60
- data/webpack/components/AnsibleRolesSwitcher/components/AnsiblePermissionDenied.js +0 -33
- data/webpack/components/AnsibleRolesSwitcher/components/AnsiblePermissionDenied.test.js +0 -9
- data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.js +0 -56
- data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRole.test.js +0 -26
- data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRoleActionButton.js +0 -16
- data/webpack/components/AnsibleRolesSwitcher/components/AnsibleRolesSwitcherError.js +0 -32
- data/webpack/components/AnsibleRolesSwitcher/components/AssignedRolesList.js +0 -67
- data/webpack/components/AnsibleRolesSwitcher/components/AssignedRolesList.test.js +0 -19
- data/webpack/components/AnsibleRolesSwitcher/components/AvailableRolesList.js +0 -52
- data/webpack/components/AnsibleRolesSwitcher/components/AvailableRolesList.test.js +0 -22
- data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AnsiblePermissionDenied.test.js.snap +0 -26
- data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AnsibleRole.test.js.snap +0 -108
- data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AssignedRolesList.test.js.snap +0 -64
- data/webpack/components/AnsibleRolesSwitcher/components/__snapshots__/AvailableRolesList.test.js.snap +0 -54
- data/webpack/components/AnsibleRolesSwitcher/components/withProtectedView.js +0 -14
- data/webpack/components/AnsibleRolesSwitcher/index.js +0 -44
- data/webpack/reducer.js +0 -7
- data/webpack/test_setup.js +0 -11
@@ -1,45 +0,0 @@
|
|
1
|
-
@import '~patternfly/dist/sass/patternfly/_color-variables';
|
2
|
-
@import '~patternfly/dist/sass/patternfly/_variables';
|
3
|
-
@import '~patternfly/dist/sass/patternfly/_loading-state';
|
4
|
-
|
5
|
-
#ansibleRolesSwitcher {
|
6
|
-
.list-view-pf {
|
7
|
-
.list-group-item.ansible-role-disabled {
|
8
|
-
background-color: $color-pf-black-200;
|
9
|
-
color: $color-pf-black-500;
|
10
|
-
border-left-color: $color-pf-black-200;
|
11
|
-
border-right-color: $color-pf-black-200;
|
12
|
-
}
|
13
|
-
|
14
|
-
.list-group-item.ansible-role-movable:hover {
|
15
|
-
cursor: pointer;
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
.loading-state-pf {
|
20
|
-
padding-top: 5%;
|
21
|
-
background-color: $color-pf-white;
|
22
|
-
}
|
23
|
-
|
24
|
-
.role-add-remove-btn {
|
25
|
-
background-color: initial;
|
26
|
-
border: none;
|
27
|
-
color: #0388ce;
|
28
|
-
}
|
29
|
-
|
30
|
-
.list-view-pf-main-info {
|
31
|
-
padding-top: 10px;
|
32
|
-
padding-bottom: 10px;
|
33
|
-
}
|
34
|
-
|
35
|
-
.list-view-pf-actions {
|
36
|
-
margin-top: 0;
|
37
|
-
margin-bottom: 0;
|
38
|
-
}
|
39
|
-
|
40
|
-
.list-group-item-heading {
|
41
|
-
margin-bottom: 0;
|
42
|
-
font-size: 12px;
|
43
|
-
font-weight: normal;
|
44
|
-
}
|
45
|
-
}
|
@@ -1,69 +0,0 @@
|
|
1
|
-
import api from 'foremanReact/API';
|
2
|
-
import {
|
3
|
-
propsToSnakeCase,
|
4
|
-
propsToCamelCase,
|
5
|
-
} from 'foremanReact/common/helpers';
|
6
|
-
|
7
|
-
import {
|
8
|
-
ANSIBLE_ROLES_REQUEST,
|
9
|
-
ANSIBLE_ROLES_SUCCESS,
|
10
|
-
ANSIBLE_ROLES_FAILURE,
|
11
|
-
ANSIBLE_ROLES_ADD,
|
12
|
-
ANSIBLE_ROLES_REMOVE,
|
13
|
-
ANSIBLE_ROLES_ASSIGNED_PAGE_CHANGE,
|
14
|
-
} from './AnsibleRolesSwitcherConstants';
|
15
|
-
|
16
|
-
export const getAnsibleRoles = (
|
17
|
-
url,
|
18
|
-
initialAssignedRoles,
|
19
|
-
inheritedRoleIds,
|
20
|
-
resourceId,
|
21
|
-
resourceName,
|
22
|
-
pagination,
|
23
|
-
search
|
24
|
-
) => dispatch => {
|
25
|
-
dispatch({ type: ANSIBLE_ROLES_REQUEST });
|
26
|
-
|
27
|
-
const params = {
|
28
|
-
...propsToSnakeCase(pagination || {}),
|
29
|
-
...(search || {}),
|
30
|
-
...propsToSnakeCase({ resourceId, resourceName }),
|
31
|
-
};
|
32
|
-
|
33
|
-
return api
|
34
|
-
.get(url, {}, params)
|
35
|
-
.then(({ data }) =>
|
36
|
-
dispatch({
|
37
|
-
type: ANSIBLE_ROLES_SUCCESS,
|
38
|
-
payload: {
|
39
|
-
initialAssignedRoles,
|
40
|
-
inheritedRoleIds,
|
41
|
-
...propsToCamelCase(data),
|
42
|
-
},
|
43
|
-
})
|
44
|
-
)
|
45
|
-
.catch(error => dispatch(errorHandler(ANSIBLE_ROLES_FAILURE, error)));
|
46
|
-
};
|
47
|
-
|
48
|
-
const errorHandler = (msg, err) => {
|
49
|
-
const error = {
|
50
|
-
errorMsg: 'Failed to fetch Ansible Roles from server.',
|
51
|
-
statusText: err.response.statusText,
|
52
|
-
};
|
53
|
-
return { type: msg, payload: { error } };
|
54
|
-
};
|
55
|
-
|
56
|
-
export const addAnsibleRole = role => ({
|
57
|
-
type: ANSIBLE_ROLES_ADD,
|
58
|
-
payload: { role },
|
59
|
-
});
|
60
|
-
|
61
|
-
export const removeAnsibleRole = role => ({
|
62
|
-
type: ANSIBLE_ROLES_REMOVE,
|
63
|
-
payload: { role },
|
64
|
-
});
|
65
|
-
|
66
|
-
export const changeAssignedPage = pagination => ({
|
67
|
-
type: ANSIBLE_ROLES_ASSIGNED_PAGE_CHANGE,
|
68
|
-
payload: { pagination },
|
69
|
-
});
|
@@ -1,7 +0,0 @@
|
|
1
|
-
export const ANSIBLE_ROLES_REQUEST = 'ANSIBLE_ROLES_REQUEST';
|
2
|
-
export const ANSIBLE_ROLES_SUCCESS = 'ANSIBLE_ROLES_SUCCESS';
|
3
|
-
export const ANSIBLE_ROLES_FAILURE = 'ANSIBLE_ROLES_FAILURE';
|
4
|
-
export const ANSIBLE_ROLES_ADD = 'ANSIBLE_ROLES_ADD';
|
5
|
-
export const ANSIBLE_ROLES_REMOVE = 'ANSIBLE_ROLES_REMOVE';
|
6
|
-
export const ANSIBLE_ROLES_ASSIGNED_PAGE_CHANGE =
|
7
|
-
'ANSIBLE_ROLES_ASSIGNED_PAGE_CHANGE';
|
@@ -1,69 +0,0 @@
|
|
1
|
-
import Immutable from 'seamless-immutable';
|
2
|
-
|
3
|
-
import {
|
4
|
-
ANSIBLE_ROLES_REQUEST,
|
5
|
-
ANSIBLE_ROLES_SUCCESS,
|
6
|
-
ANSIBLE_ROLES_FAILURE,
|
7
|
-
ANSIBLE_ROLES_ADD,
|
8
|
-
ANSIBLE_ROLES_REMOVE,
|
9
|
-
ANSIBLE_ROLES_ASSIGNED_PAGE_CHANGE,
|
10
|
-
} from './AnsibleRolesSwitcherConstants';
|
11
|
-
|
12
|
-
export const initialState = Immutable({
|
13
|
-
loading: false,
|
14
|
-
itemCount: 0,
|
15
|
-
pagination: {
|
16
|
-
page: 1,
|
17
|
-
perPage: 10,
|
18
|
-
},
|
19
|
-
assignedRoles: [],
|
20
|
-
inheritedRoleIds: [],
|
21
|
-
results: [],
|
22
|
-
assignedPagination: {
|
23
|
-
page: 1,
|
24
|
-
perPage: 10,
|
25
|
-
},
|
26
|
-
error: { errorMsg: '', status: '', statusText: '' },
|
27
|
-
});
|
28
|
-
|
29
|
-
const ansibleRoles = (state = initialState, action) => {
|
30
|
-
const { payload } = action;
|
31
|
-
|
32
|
-
switch (action.type) {
|
33
|
-
case ANSIBLE_ROLES_REQUEST:
|
34
|
-
return state.set('loading', true);
|
35
|
-
case ANSIBLE_ROLES_SUCCESS:
|
36
|
-
return state.merge({
|
37
|
-
loading: false,
|
38
|
-
itemCount: Number(payload.subtotal),
|
39
|
-
pagination: {
|
40
|
-
page: Number(payload.page),
|
41
|
-
perPage: Number(payload.perPage),
|
42
|
-
},
|
43
|
-
results: payload.results,
|
44
|
-
assignedRoles: payload.initialAssignedRoles,
|
45
|
-
inheritedRoleIds: payload.inheritedRoleIds,
|
46
|
-
});
|
47
|
-
case ANSIBLE_ROLES_FAILURE:
|
48
|
-
return state.merge({ error: payload.error, loading: false });
|
49
|
-
case ANSIBLE_ROLES_ADD:
|
50
|
-
return state.merge({
|
51
|
-
assignedRoles: state.assignedRoles.concat([payload.role]),
|
52
|
-
itemCount: state.itemCount - 1,
|
53
|
-
});
|
54
|
-
case ANSIBLE_ROLES_REMOVE:
|
55
|
-
return state.merge({
|
56
|
-
assignedRoles: Immutable.flatMap(state.assignedRoles, item =>
|
57
|
-
item.id === payload.role.id ? [] : item
|
58
|
-
),
|
59
|
-
results: state.results.concat([payload.role]),
|
60
|
-
itemCount: state.itemCount + 1,
|
61
|
-
});
|
62
|
-
case ANSIBLE_ROLES_ASSIGNED_PAGE_CHANGE:
|
63
|
-
return state.set('assignedPagination', payload.pagination);
|
64
|
-
default:
|
65
|
-
return state;
|
66
|
-
}
|
67
|
-
};
|
68
|
-
|
69
|
-
export default ansibleRoles;
|
@@ -1,68 +0,0 @@
|
|
1
|
-
import { differenceBy, slice, includes, uniq } from 'lodash';
|
2
|
-
import Immutable from 'seamless-immutable';
|
3
|
-
import { createSelector } from 'reselect';
|
4
|
-
|
5
|
-
const compare = (a, b) => {
|
6
|
-
if (a.name < b.name) {
|
7
|
-
return -1;
|
8
|
-
}
|
9
|
-
if (a.name > b.name) {
|
10
|
-
return 1;
|
11
|
-
}
|
12
|
-
return 0;
|
13
|
-
};
|
14
|
-
|
15
|
-
const switcherState = state => state.foremanAnsible.ansibleRolesSwitcher;
|
16
|
-
|
17
|
-
const markInheritedRoles = (roles, inheritedRoleIds) =>
|
18
|
-
roles.map(role =>
|
19
|
-
includes(inheritedRoleIds, role.id) ? { ...role, inherited: true } : role
|
20
|
-
);
|
21
|
-
|
22
|
-
export const selectResults = state =>
|
23
|
-
Immutable(
|
24
|
-
Immutable.asMutable(uniq(switcherState(state).results)).sort(compare)
|
25
|
-
);
|
26
|
-
|
27
|
-
export const selectItemCount = state => switcherState(state).itemCount;
|
28
|
-
|
29
|
-
export const selectAssignedRoles = state =>
|
30
|
-
Immutable.asMutable(
|
31
|
-
markInheritedRoles(
|
32
|
-
switcherState(state).assignedRoles,
|
33
|
-
switcherState(state).inheritedRoleIds
|
34
|
-
)
|
35
|
-
).sort(compare);
|
36
|
-
|
37
|
-
export const selectAssignedRolesCount = state =>
|
38
|
-
selectAssignedRoles(state).length;
|
39
|
-
export const selectLoading = state => switcherState(state).loading;
|
40
|
-
export const selectAssignedPagination = state =>
|
41
|
-
switcherState(state).assignedPagination;
|
42
|
-
export const selectError = state => switcherState(state).error;
|
43
|
-
export const selectPagination = state => switcherState(state).pagination;
|
44
|
-
|
45
|
-
export const selectPaginationMemoized = createSelector(
|
46
|
-
selectPagination,
|
47
|
-
selectResults,
|
48
|
-
(pagination, results) =>
|
49
|
-
results.length > pagination.perPage
|
50
|
-
? { ...pagination, perPage: results.length }
|
51
|
-
: pagination
|
52
|
-
);
|
53
|
-
|
54
|
-
export const selectUnassignedRoles = createSelector(
|
55
|
-
selectResults,
|
56
|
-
selectAssignedRoles,
|
57
|
-
(results, assignedRoles) => differenceBy(results, assignedRoles, 'id')
|
58
|
-
);
|
59
|
-
|
60
|
-
export const selectAssignedRolesPage = createSelector(
|
61
|
-
selectAssignedPagination,
|
62
|
-
selectAssignedRoles,
|
63
|
-
(assignedPagination, assignedRoles) => {
|
64
|
-
const offset = (assignedPagination.page - 1) * assignedPagination.perPage;
|
65
|
-
|
66
|
-
return slice(assignedRoles, offset, offset + assignedPagination.perPage);
|
67
|
-
}
|
68
|
-
);
|
@@ -1,20 +0,0 @@
|
|
1
|
-
export const ansibleRolesShort = [
|
2
|
-
{ id: 1, name: 'sthirugn.motd' },
|
3
|
-
{ id: 2, name: 'jtyr.ntp' },
|
4
|
-
{ id: 3, name: 'rvm.ruby' },
|
5
|
-
{ id: 4, name: 'geerlingguy.java' },
|
6
|
-
];
|
7
|
-
|
8
|
-
export const ansibleRolesLong = [
|
9
|
-
{ id: 1, name: 'sthirugn.motd' },
|
10
|
-
{ id: 2, name: 'jtyr.ntp' },
|
11
|
-
{ id: 3, name: 'rvm.ruby' },
|
12
|
-
{ id: 4, name: 'geerlingguy.java' },
|
13
|
-
{ id: 5, name: 'naftulikay.golang' },
|
14
|
-
{ id: 6, name: 'theforeman.foreman_scap_client' },
|
15
|
-
{ id: 7, name: 'ansible.ansible' },
|
16
|
-
{ id: 8, name: 'puppet.puppet' },
|
17
|
-
{ id: 9, name: 'chef.chef' },
|
18
|
-
{ id: 10, name: 'salt.salt' },
|
19
|
-
{ id: 11, name: 'anonymous.something' },
|
20
|
-
];
|
data/webpack/components/AnsibleRolesSwitcher/__fixtures__/ansibleRolesSwitcherReducer.fixtures.js
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
import Immutable from 'seamless-immutable';
|
2
|
-
|
3
|
-
import { ansibleRolesLong } from './ansibleRolesData.fixtures';
|
4
|
-
|
5
|
-
export const successPayload = {
|
6
|
-
page: 1,
|
7
|
-
perPage: 5,
|
8
|
-
subtotal: 11,
|
9
|
-
results: ansibleRolesLong,
|
10
|
-
initialAssignedRoles: ansibleRolesLong.slice(3, 6),
|
11
|
-
inheritedRoleIds: [4],
|
12
|
-
};
|
13
|
-
|
14
|
-
export const successState = Immutable({
|
15
|
-
loading: false,
|
16
|
-
itemCount: 11,
|
17
|
-
pagination: {
|
18
|
-
page: 1,
|
19
|
-
perPage: 5,
|
20
|
-
},
|
21
|
-
assignedRoles: [
|
22
|
-
{ ...ansibleRolesLong[3], inherited: true },
|
23
|
-
...ansibleRolesLong.slice(4, 6),
|
24
|
-
],
|
25
|
-
results: ansibleRolesLong,
|
26
|
-
assignedPagination: {
|
27
|
-
page: 1,
|
28
|
-
perPage: 20,
|
29
|
-
},
|
30
|
-
error: { errorMsg: '', status: '', statusText: '' },
|
31
|
-
});
|
32
|
-
|
33
|
-
export const errorPayload = {
|
34
|
-
errorMsg: 'Failed to fetch Ansible Roles from server.',
|
35
|
-
statusText: '500',
|
36
|
-
};
|
@@ -1,30 +0,0 @@
|
|
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));
|
@@ -1,73 +0,0 @@
|
|
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));
|
data/webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherSelectors.test.js
DELETED
@@ -1,43 +0,0 @@
|
|
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));
|