Sha256: f5fe353c74e1c194e6939fd70ae9b69a0bdb1d583e94cfde6ae6f777e0e3b96b
Contents?: true
Size: 1.51 KB
Versions: 65
Compression:
Stored size: 1.51 KB
Contents
import { differenceBy, includes } from 'lodash'; import Immutable from 'seamless-immutable'; import { createSelector } from 'reselect'; import { propsToCamelCase } from 'foremanReact/common/helpers'; const switcherState = state => state.foremanAnsible.ansibleRolesSwitcher; const markInheritedRoles = (roles, inheritedRoleIds) => roles.map(role => includes(inheritedRoleIds, role.id) ? { ...role, inherited: true } : role ); export const selectResults = state => Immutable( Immutable.asMutable(switcherState(state).results.map(propsToCamelCase)) ); export const selectItemCount = state => switcherState(state).itemCount; export const selectAssignedRoles = state => Immutable.asMutable( markInheritedRoles( switcherState(state).assignedRoles.map(propsToCamelCase), switcherState(state).inheritedRoleIds ) ); export const selectToDestroyRoles = state => switcherState(state).toDestroyRoles; export const selectLoading = state => switcherState(state).loading; export const selectError = state => switcherState(state).error; export const selectPagination = state => switcherState(state).pagination; export const selectPaginationMemoized = createSelector( selectPagination, selectResults, (pagination, results) => results.length > pagination.perPage ? { ...pagination, perPage: results.length } : pagination ); export const selectUnassignedRoles = createSelector( selectResults, selectAssignedRoles, (results, assignedRoles) => differenceBy(results, assignedRoles, 'id') );
Version data entries
65 entries across 65 versions & 1 rubygems