Sha256: 072f385eaed597826214beb726f046e8f6251d5c9a62c9266634998d053411ab
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 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 ) => async dispatch => { dispatch({ type: ANSIBLE_ROLES_REQUEST }); const params = { ...propsToSnakeCase(pagination || {}), ...(search || {}), ...propsToSnakeCase({ resourceId, resourceName }), }; try { const res = await api.get(url, {}, params); return dispatch({ type: ANSIBLE_ROLES_SUCCESS, payload: { initialAssignedRoles, inheritedRoleIds, ...propsToCamelCase(res.data), }, }); } catch (error) { return 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
foreman_ansible-6.2.0 | webpack/components/AnsibleRolesSwitcher/AnsibleRolesSwitcherActions.js |