diff --git a/browser/main/HomePage/SideNav/index.js b/browser/main/HomePage/SideNav/index.js index 4d76847c..373c1677 100644 --- a/browser/main/HomePage/SideNav/index.js +++ b/browser/main/HomePage/SideNav/index.js @@ -35,8 +35,18 @@ class SideNav extends React.Component { openModal(Preferences) } + handleHomeButtonClick (e) { + let { router } = this.context + router.push('/repositories') + } + + handleStarredButtonClick (e) { + let { router } = this.context + router.push('/starred') + } + render () { - let { repositories, dispatch } = this.props + let { repositories, dispatch, location } = this.props let repositorieElements = repositories.map((repo) => { return }) + let isHomeActive = location.pathname.match(/^\/home$/) + let isStarredActive = location.pathname.match(/^\/starred$/) return (
- -
@@ -84,6 +98,10 @@ class SideNav extends React.Component { } } +SideNav.contextTypes = { + router: PropTypes.shape({}) +} + SideNav.propTypes = { dispatch: PropTypes.func, repositories: PropTypes.array diff --git a/browser/main/Main.js b/browser/main/Main.js index 43bacd4b..90841d0b 100644 --- a/browser/main/Main.js +++ b/browser/main/Main.js @@ -27,7 +27,7 @@ export default class MainContainer extends React.Component { {this.state.updateAvailable ? ( ) : null} - +
) } diff --git a/browser/main/index.js b/browser/main/index.js index 22ba4213..8f2d8eb5 100644 --- a/browser/main/index.js +++ b/browser/main/index.js @@ -6,9 +6,11 @@ import ReactDOM from 'react-dom' require('!!style!css!stylus?sourceMap!../styles/main/index.styl') import activityRecord from 'browser/lib/activityRecord' import fetchConfig from '../lib/fetchConfig' +import { Router, Route, IndexRoute, IndexRedirect, hashHistory } from 'react-router' const electron = require('electron') const ipc = electron.ipcRenderer const path = require('path') +import { syncHistoryWithStore } from 'react-router-redux' const remote = electron.remote @@ -73,12 +75,26 @@ ipc.on('open-finder', function () { }) let el = document.getElementById('content') +const history = syncHistoryWithStore(hashHistory, store) +history.listen((location) => console.info(location)) ReactDOM.render(( -
- -
- -
+ + + + + + + + + + + + + + + + + ), el, function () { let loadingCover = document.getElementById('loadingCover') loadingCover.parentNode.removeChild(loadingCover) diff --git a/browser/main/store.js b/browser/main/store.js index 109d2dfd..70cb444c 100644 --- a/browser/main/store.js +++ b/browser/main/store.js @@ -1,5 +1,6 @@ import { combineReducers, createStore } from 'redux' import _ from 'lodash' +import { syncHistoryWithStore, routerReducer } from 'react-router-redux' /** * Repositories @@ -110,7 +111,8 @@ function repositories (state = initialRepositories, action) { } let reducer = combineReducers({ - repositories + repositories, + routing: routerReducer }) let store = createStore(reducer) diff --git a/package.json b/package.json index 06327ff8..fedb4d03 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "font-awesome": "^4.3.0", "fs-jetpack": "^0.7.0", "highlight.js": "^9.3.0", - "lodash": "^3.10.1", + "lodash": "^4.11.1", "markdown-it": "^6.0.1", "markdown-it-checkbox": "^1.1.0", "markdown-it-emoji": "^1.1.1", @@ -73,6 +73,8 @@ "nib": "^1.1.0", "oh-my-cdn": "^0.1.1", "react-css-modules": "^3.7.6", + "react-router": "^2.4.0", + "react-router-redux": "^4.0.4", "standard": "^6.0.8", "style-loader": "^0.12.4", "stylus": "^0.52.4",