react-redux-permissions
Version:
A permissions library for react and redux applications.
1 lines • 804 B
JavaScript
Object.defineProperty(exports,"__esModule",{value:true});exports.reducer=undefined;var _constants=require("./constants");function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i]}return arr2}else{return Array.from(arr)}}var reducer=exports.reducer=function reducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var action=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};switch(action.type){case _constants.RRP_ADD_PERMISSION:return[].concat(_toConsumableArray(state),_toConsumableArray(action.roles));case _constants.RRP_REMOVE_PERMISSION:return state.filter(function(role){return role!==action.role});case _constants.RRP_CLEAR:return[];default:return state;}};exports.default=reducer;
;