diff --git a/app/containers/App/reducer.js b/app/containers/App/reducer.js index 4d67ea60f7..ca65cfb006 100644 --- a/app/containers/App/reducer.js +++ b/app/containers/App/reducer.js @@ -10,7 +10,7 @@ const initialState = fromJS({ function appReducer(state = initialState, action) { switch (action.type) { case REGISTER_PLUGIN: - return state.setIn(['plugins', action.plugin.name], action.plugin); + return state.setIn(['plugins', action.plugin.id], action.plugin); default: return state; } diff --git a/app/containers/Content/index.js b/app/containers/Content/index.js index 7f26dfe792..8ead2240bd 100644 --- a/app/containers/Content/index.js +++ b/app/containers/Content/index.js @@ -7,17 +7,38 @@ import React from 'react'; import { connect } from 'react-redux'; import styles from './styles.css'; +import { createSelector } from 'reselect'; +import { selectPlugins } from '../App/selectors'; export class Content extends React.Component { // eslint-disable-line react/prefer-stateless-function render() { + let plugin; + + this.props.plugins.map(p => { + plugin = p; + return p; + }); + + const Elem = plugin.mainComponent; + return (

Content

+
); } } +Content.propTypes = { + plugins: React.PropTypes.object, + onRegisterPluginClicked: React.PropTypes.func, +}; + +const mapStateToProps = createSelector( + selectPlugins(), + (plugins) => ({ plugins }) +); function mapDispatchToProps(dispatch) { return { @@ -25,4 +46,4 @@ function mapDispatchToProps(dispatch) { }; } -export default connect(mapDispatchToProps)(Content); +export default connect(mapStateToProps, mapDispatchToProps)(Content); diff --git a/app/containers/HomePage/sagas.js b/app/containers/HomePage/sagas.js new file mode 100644 index 0000000000..be1188378f --- /dev/null +++ b/app/containers/HomePage/sagas.js @@ -0,0 +1,42 @@ +// /** +// * Gets the repositories of the user from Github +// */ +// +// import { take, call, put, select, fork, cancel } from 'redux-saga/effects'; +// import { LOCATION_CHANGE } from 'react-router-redux'; +// import { REGISTER_PLUGIN } from 'containers/App/constants'; +// +// import { getAsyncInjectors } from 'utils/asyncInjectors'; +// // const { injectReducer, injectSagas } = getAsyncInjectors(store); // eslint-disable-line no-unused-vars +// import { Router, Route, Link } from 'react-router' +// +// /** +// * Register plugin +// */ +// export function* registerPlugin() { +// +// } +// +// /** +// * Watches for REGISTER_PLUGIN action and calls handler +// */ +// export function* getPluginsWatcher() { +// yield call(registerPlugin); +// } +// +// /** +// * Root saga manages watcher lifecycle +// */ +// export function* pluginData() { +// // Fork watcher so we can continue execution +// const watcher = yield fork(getPluginsWatcher); +// +// // Suspend execution until location changes +// yield take(LOCATION_CHANGE); +// yield cancel(watcher); +// } +// +// // Bootstrap sagas +// export default [ +// pluginData, +// ]; diff --git a/app/containers/LeftMenu/index.js b/app/containers/LeftMenu/index.js index 308b31a7b6..2cfd1a583d 100644 --- a/app/containers/LeftMenu/index.js +++ b/app/containers/LeftMenu/index.js @@ -8,10 +8,16 @@ import React from 'react'; import { connect } from 'react-redux'; import styles from './styles.css'; import { Link } from 'react-router'; +import classNames from 'classnames'; export class LeftMenu extends React.Component { // eslint-disable-line react/prefer-stateless-function render() { - const links = this.props.plugins.map(plugin =>
  • {plugin.name}
  • ); + const links = this.props.plugins.map(plugin => { + const className = classNames({ + active: this.props.params && this.props.params.plugin && this.props.params.plugin === plugin.id, + }); + return
  • {plugin.name}
  • ; + }); return (