diff --git a/src/containers/sidebar-container.js b/src/containers/sidebar-container.js index beb1f25..bac307e 100644 --- a/src/containers/sidebar-container.js +++ b/src/containers/sidebar-container.js @@ -9,13 +9,12 @@ import * as Actions from '../data/actions'; // This function passes values/objects from the Redux state to the React component as props const mapStateToProps = state => ({ general: state.general, + account: state.account, currentEvent: state.events.current, isCollapsed: state.sidebar.isCollapsed, sidebarMode: state.sidebar.mode, possibleLabels: state.labels.labelList, - selectedLabels: state.events.current - ? state.events.current.labels - : state.labels.visibleLabels, + selectedLabels: state.events.current ? state.events.current.labels : state.labels.visibleLabels, }); // This function passes functions from /srcs/data/actions.jsx to the React component as props diff --git a/src/data/reducers.js b/src/data/reducers.js index 6af7cf3..6e4aa2f 100644 --- a/src/data/reducers.js +++ b/src/data/reducers.js @@ -1,7 +1,7 @@ // This file contains a bunch of Redux reducers -import { ActionTypes } from './actions'; import SidebarModes from '../data/sidebar-modes'; +import { ActionTypes } from './actions'; export function general(state = {}, action) { const newState = Object.assign({}, state); @@ -11,7 +11,7 @@ export function general(state = {}, action) { alert(action.message); return state; case ActionTypes.DISPLAY_ERROR: - alert((action.message) ? action.message : action.error); + alert(action.message ? action.message : action.error); console.error(action.error); return state; case ActionTypes.SET_PAGE_TITLE_PREFIX: @@ -23,6 +23,10 @@ export function general(state = {}, action) { } } +export function account(state = {}, _action) { + return state; +} + export function calendar(state = {}, action) { const newState = Object.assign({}, state); @@ -87,9 +91,8 @@ export function labels(state = {}, action) { // If the visible labels array hasn't been set yet, set it to be the default if (!state.visibleLabels) { const labelsArray = Object.values(labelList); - newState.visibleLabels = (labelsArray.length > 0) - ? labelsArray.filter(l => l.default).map(l => l.name) - : []; + newState.visibleLabels = + labelsArray.length > 0 ? labelsArray.filter(l => l.default).map(l => l.name) : []; } return newState; } diff --git a/src/data/setup-store.js b/src/data/setup-store.js index d92c51c..1ac2180 100644 --- a/src/data/setup-store.js +++ b/src/data/setup-store.js @@ -1,11 +1,10 @@ -import { createStore, applyMiddleware, combineReducers } from 'redux'; -import thunkMiddleware from 'redux-thunk'; import ReactGA from 'react-ga'; -import { routerReducer, routerMiddleware } from 'react-router-redux'; +import { routerMiddleware, routerReducer } from 'react-router-redux'; +import { applyMiddleware, combineReducers, createStore } from 'redux'; +import thunkMiddleware from 'redux-thunk'; import * as reducers from './reducers'; import SidebarMode from './sidebar-modes'; - export default function setupStore(history) { const debug = process.env.DEBUG || false; const googleAnalyticsId = process.env.GA_ID; @@ -50,6 +49,15 @@ export default function setupStore(history) { }, }, }, + // TODO: replace this by the response to GET /account, on implementaion of olinlibrary/ABE#214 + account: { + authenticated: true, + permissions: { + add_events: true, + edit_events: true, + view_all_events: true, + }, + }, events: { current: null, events: null, @@ -80,15 +88,16 @@ export default function setupStore(history) { } // Load the Redux middleware if the Redux devtools extension is available - const middleware = (debug && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) - ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__(applyMiddleware( - thunkMiddleware, // lets us dispatch() functions - routerMiddleware(history), - )) - : applyMiddleware( - thunkMiddleware, // lets us dispatch() functions - routerMiddleware(history), - ); + const middleware = + debug && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ + ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__(applyMiddleware( + thunkMiddleware, // lets us dispatch() functions + routerMiddleware(history), + )) + : applyMiddleware( + thunkMiddleware, // lets us dispatch() functions + routerMiddleware(history), + ); return createStore( combineReducers({ ...reducers, router: routerReducer }), diff --git a/src/sidebar/sidebar.jsx b/src/sidebar/sidebar.jsx index ab744b8..ceb2945 100644 --- a/src/sidebar/sidebar.jsx +++ b/src/sidebar/sidebar.jsx @@ -13,22 +13,34 @@ import MarkdownGuide from './markdown-guide'; import SidebarItemContainer from './sidebar-item-wrapper'; const Sidebar = (props) => { - const { sidebarMode: mode } = props; + const { + account: { permissions }, + sidebarMode: mode, + } = props; const content = (
+ You are viewing the public calendar. Visit the calendar from on campus to see all events + and to add and edit events. +
)} - {mode.EVENT_ACTIONS && ( -