Sha256: 51741bf196becdad6135faf1c42555f39fbcd75c11b50eefd652dd954c540792
Contents?: true
Size: 1.51 KB
Versions: 33
Compression:
Stored size: 1.51 KB
Contents
import api from 'foremanReact/API'; import { propsToSnakeCase, propsToCamelCase, } from 'foremanReact/common/helpers'; import { ANSIBLE_ROLES_REQUEST, ANSIBLE_ROLES_SUCCESS, ANSIBLE_ROLES_FAILURE, ANSIBLE_ROLES_ADD, ANSIBLE_ROLES_REMOVE, ANSIBLE_ROLES_ASSIGNED_PAGE_CHANGE, } from './AnsibleRolesSwitcherConstants'; export const getAnsibleRoles = ( url, initialAssignedRoles, inheritedRoleIds, resourceId, resourceName, pagination, search ) => dispatch => { dispatch({ type: ANSIBLE_ROLES_REQUEST }); const params = { ...propsToSnakeCase(pagination || {}), ...(search || {}), ...propsToSnakeCase({ resourceId, resourceName }), }; return api .get(url, {}, params) .then(({ data }) => dispatch({ type: ANSIBLE_ROLES_SUCCESS, payload: { initialAssignedRoles, inheritedRoleIds, ...propsToCamelCase(data), }, }) ) .catch(error => dispatch(errorHandler(ANSIBLE_ROLES_FAILURE, error))); }; const errorHandler = (msg, err) => { const error = { errorMsg: 'Failed to fetch Ansible Roles from server.', statusText: err.response.statusText, }; return { type: msg, payload: { error } }; }; export const addAnsibleRole = role => ({ type: ANSIBLE_ROLES_ADD, payload: { role }, }); export const removeAnsibleRole = role => ({ type: ANSIBLE_ROLES_REMOVE, payload: { role }, }); export const changeAssignedPage = pagination => ({ type: ANSIBLE_ROLES_ASSIGNED_PAGE_CHANGE, payload: { pagination }, });
Version data entries
33 entries across 33 versions & 1 rubygems