-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #261 from seoyoochan/feature/ReduxDevTools
Show Redux Dev Tools in a New Window
- Loading branch information
Showing
19 changed files
with
239 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
5.0.0 | ||
5.5.0 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
client/app/bundles/comments/components/Navigationbar/Navigationbar.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import React, { PropTypes } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import BaseComponent from 'libs/components/BaseComponent'; | ||
|
||
export default class Navigationbar extends BaseComponent { | ||
static propTypes = { | ||
data: PropTypes.object.isRequired, | ||
}; | ||
|
||
constructor(props) { | ||
super(props); | ||
// set @comment_count prop to state | ||
// for updating the count of comments | ||
this.state = { | ||
comment_count: this.props.comments_count | ||
}; | ||
} | ||
|
||
componentDidUpdate() { | ||
if (this.props.data) { | ||
this.setState({comment_count: this.props.data.get('$$comments').size}); | ||
} | ||
} | ||
|
||
render() { | ||
return ( | ||
<nav className="navbar navbar-default" role="navigation"> | ||
<div className="container"> | ||
<div className="navbar-header"> | ||
<button | ||
type="button" | ||
className="navbar-toggle" | ||
data-toggle="collapse" | ||
data-target="#bs-example-navbar-collapse-1" | ||
> | ||
<span className="sr-only">Toggle navigation</span> | ||
<span className="icon-bar" /> | ||
<span className="icon-bar" /> | ||
<span className="icon-bar" /> | ||
</button> | ||
<a className="navbar-brand" href="http://www.shakacode.com">ShakaCode</a> | ||
</div> | ||
<div className="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> | ||
<ul className="nav navbar-nav"> | ||
<li className="active"><a href="/">React Router Demo</a></li> | ||
<li><a href="/no-router">React Demo</a></li> | ||
<li><a href="/simple">Simple React</a></li> | ||
<li><a href="/comments">Classic Rails</a></li> | ||
<li> | ||
<a href={ | ||
'https://github.com/' + | ||
'shakacode/react-webpack-rails-tutorial' | ||
}> | ||
Source on Github | ||
</a> | ||
</li> | ||
<li> | ||
<a href={ | ||
'http://www.railsonmaui.com/' + | ||
'blog/2014/10/03/integrating' + | ||
'-webpack-and-the-es6-transpiler' + | ||
'-into-an-existing-rails-project/' | ||
}>Tutorial Article</a> | ||
</li> | ||
<li> | ||
<a href={ | ||
'http://forum.shakacode.com/' + | ||
't/fast-rich-client-rails-development' + | ||
'-with-webpack-and-the-es6-transpiler/82/22' | ||
}>Forum Discussion</a> | ||
</li> | ||
<li> | ||
Comments: {this.state.comment_count} | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</nav> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
|
||
// Exported from redux-devtools | ||
import { createDevTools } from 'redux-devtools'; | ||
|
||
// Monitors are separate packages, and you can make a custom one | ||
import LogMonitor from 'redux-devtools-log-monitor'; | ||
import DockMonitor from 'redux-devtools-dock-monitor'; | ||
|
||
// createDevTools takes a monitor and produces a DevTools component | ||
const DevTools = createDevTools( | ||
|
||
// Monitors are individually adjustable with props. | ||
// Consult their repositories to learn about those props. | ||
// Here, we put LogMonitor inside a DockMonitor. | ||
<DockMonitor | ||
toggleVisibilityKey="ctrl-h" | ||
changePositionKey="ctrl-q" | ||
> | ||
<LogMonitor theme="tomorrow" /> | ||
</DockMonitor> | ||
); | ||
|
||
export default DevTools; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import { render } from 'react-dom'; | ||
import DevTools from './DevTools'; | ||
|
||
export default function showDevTools(store) { | ||
const popup = window.open(null, 'Redux DevTools', | ||
'menubar=no,location=no,resizable=yes,scrollbars=no,status=no'); | ||
|
||
// Reload in case it already exists | ||
popup.location.reload(); | ||
|
||
setTimeout(() => { | ||
popup.document.write('<div id="react-devtools-root"></div>'); | ||
render( | ||
<DevTools store={store} />, | ||
popup.document.getElementById('react-devtools-root') | ||
); | ||
}, 10); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
client/app/bundles/comments/startup/ClientReduxSharedStoreApp.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Top level component for client side. | ||
// Compare this to the ./ServerApp.jsx file which is used for server side rendering. | ||
|
||
import React from 'react'; | ||
import ReactOnRails from 'react-on-rails'; | ||
import RouterCommentsContainer from '../containers/RouterCommentsContainer'; | ||
import { Provider } from 'react-redux'; | ||
|
||
/* | ||
* Export a function that returns a ReactComponent, depending on a store named SharedReduxStore. | ||
* This is used for the client rendering hook after the page html is rendered. | ||
* React will see that the state is the same and not do anything. | ||
*/ | ||
export default () => { | ||
|
||
// This is where we get the existing store. | ||
const store = ReactOnRails.getStore('routerCommentsStore'); | ||
|
||
return ( | ||
<Provider store={store}> | ||
<RouterCommentsContainer /> | ||
</Provider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
client/app/bundles/comments/startup/ServerReduxSharedStoreApp.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Top level component for client side. | ||
// Compare this to the ./ServerApp.jsx file which is used for server side rendering. | ||
|
||
import React from 'react'; | ||
import ReactOnRails from 'react-on-rails'; | ||
import RouterCommentsContainer from '../containers/RouterCommentsContainer'; | ||
import { Provider } from 'react-redux'; | ||
|
||
/* | ||
* Export a function that returns a ReactComponent, depending on a store named SharedReduxStore. | ||
* This is used for the client rendering hook after the page html is rendered. | ||
* React will see that the state is the same and not do anything. | ||
*/ | ||
export default () => { | ||
|
||
// This is where we get the existing store. | ||
const store = ReactOnRails.getStore('routerCommentsStore'); | ||
|
||
return ( | ||
<Provider store={store}> | ||
<RouterCommentsContainer /> | ||
</Provider> | ||
); | ||
}; |
21 changes: 14 additions & 7 deletions
21
client/app/bundles/comments/startup/clientRegistration.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
import App from './ClientApp'; | ||
import RouterApp from './ClientRouterApp'; | ||
import Navigationbar from '../components/Navigationbar/Navigationbar'; | ||
import SimpleCommentScreen from '../components/SimpleCommentScreen/SimpleCommentScreen'; | ||
import routerCommentsStore from '../store/routerCommentsStore'; | ||
import ReduxSharedStoreApp from './ClientReduxSharedStoreApp'; | ||
import ReactOnRails from 'react-on-rails'; | ||
|
||
ReactOnRails.setOptions({ | ||
traceTurbolinks: TRACE_TURBOLINKS, // eslint-disable-line no-undef | ||
}); | ||
|
||
ReactOnRails.register( | ||
{ | ||
App, | ||
RouterApp, | ||
SimpleCommentScreen, | ||
} | ||
); | ||
ReactOnRails.register({ | ||
App, | ||
RouterApp, | ||
ReduxSharedStoreApp, | ||
SimpleCommentScreen, | ||
Navigationbar, | ||
}); | ||
|
||
ReactOnRails.registerStore({ | ||
routerCommentsStore, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.