Permalink
Browse files

Converted to Redux

  • Loading branch information...
Phoenixmatrix committed Jan 2, 2016
1 parent d6237ac commit e40db6ec4844f01b19af14b776c66f466a8cb3db
Showing with 433 additions and 430 deletions.
  1. +1 −1 .babelrc
  2. +2 −1 .eslintrc
  3. +34 −34 app.js
  4. +1 −1 gulpfile.babel.js
  5. +0 −10 js/actions/config-actions.js
  6. +0 −30 js/actions/request-actions.js
  7. +0 −11 js/app.js
  8. +0 −28 js/components/LeftSection.jsx
  9. +0 −74 js/components/PhoenixMatrixApp.jsx
  10. +0 −38 js/stores/config-store.js
  11. +0 −158 js/stores/request-store.js
  12. +4 −0 package.json
  13. +14 −0 src/actions/config.js
  14. +24 −0 src/actions/requests.js
  15. +20 −0 src/app.js
  16. 0 {js → src}/components/Footer.jsx
  17. +7 −8 {js → src}/components/Header.jsx
  18. 0 {js → src}/components/HttpHeaders.jsx
  19. +50 −0 src/components/LeftSection.jsx
  20. 0 {js → src}/components/MainSection.jsx
  21. +118 −0 src/components/PhoenixMatrixApp.jsx
  22. +35 −0 src/components/Proxy.jsx
  23. 0 {js → src}/components/RequestBody.jsx
  24. 0 {js → src}/components/RequestDetail.jsx
  25. 0 {js → src}/components/RequestDetailHeader.jsx
  26. +7 −7 {js → src}/components/RequestList.jsx
  27. +6 −8 {js → src}/components/RequestListItem.jsx
  28. 0 {js → src}/components/ResponseDetail.jsx
  29. 0 {js → src}/components/Splitter.jsx
  30. +11 −21 {js → src}/components/VerticalButtonBar.jsx
  31. 0 {js → src}/constants/config-constants.js
  32. 0 {js → src}/constants/request-constants.js
  33. 0 {js → src}/dispatchers/AppDispatcher.js
  34. 0 {js → src}/lib/angular.js
  35. 0 {js → src}/lib/certificate.js
  36. 0 {js → src}/lib/config.js
  37. 0 {js → src}/lib/helpers.js
  38. 0 js/lib/proxy.js → src/lib/proxyFactory.js
  39. 0 {js → src}/lib/pure.js
  40. 0 {js → src}/main.js
  41. +16 −0 src/reducers/config.js
  42. +12 −0 src/reducers/index.js
  43. +71 −0 src/reducers/requests.js
View
@@ -1,4 +1,4 @@
{
- "presets": [ "react", "es2015-node5" ],
+ "presets": [ "react", "es2015-node5", "stage-1" ],
"plugins": [ "transform-runtime" ]
}
View
@@ -24,7 +24,8 @@
},
"ecmaFeatures": {
"modules": true,
- "generators": true
+ "generators": true,
+ "experimentalObjectRestSpread": true
},
"globals": {
"chai": true,
View
68 app.js
@@ -1,34 +1,34 @@
-// This will eventually become a command line version of the proxy. For now though, it's very broken.
-
-var proxyFactory = require('./js/lib/proxy');
-
-var onRequest = function(data) {
- console.log('request: ' + data.method + ' ' + data.url);
-};
-
-var onResponse = function(data) {
- console.log('response: ' + data.method + ' ' + data.url);
-};
-
-var httpProxy;
-proxyFactory.createHttpProxy({port: 3002}).then(function(proxy) {
- httpProxy = proxy;
- proxy.on('proxyRequest', onRequest);
- proxy.on('proxyResponse', onResponse);
- proxy.on('proxyConnect', function(data) {
- console.log('connect request: ' + data.state + ' ' + data.url + ':' + data.port);
- });
- return proxyFactory.createHttpsProxy({port: 8443});
-})
-.then(function(httpsProxy) {
- httpsProxy.on('proxyRequest', onRequest);
- httpsProxy.on('proxyResponse', onResponse);
- httpProxy.enableHttpsProxy(httpsProxy);
-});
-
-
-
-
-
-
-
+// This will eventually become a command line version of the proxy. For now though, it's very broken.
+
+var proxyFactory = require('./src/lib/proxy');
+
+var onRequest = function(data) {
+ console.log('request: ' + data.method + ' ' + data.url);
+};
+
+var onResponse = function(data) {
+ console.log('response: ' + data.method + ' ' + data.url);
+};
+
+var httpProxy;
+proxyFactory.createHttpProxy({port: 3002}).then(function(proxy) {
+ httpProxy = proxy;
+ proxy.on('proxyRequest', onRequest);
+ proxy.on('proxyResponse', onResponse);
+ proxy.on('proxyConnect', function(data) {
+ console.log('connect request: ' + data.state + ' ' + data.url + ':' + data.port);
+ });
+ return proxyFactory.createHttpsProxy({port: 8443});
+})
+.then(function(httpsProxy) {
+ httpsProxy.on('proxyRequest', onRequest);
+ httpsProxy.on('proxyResponse', onResponse);
+ httpProxy.enableHttpsProxy(httpsProxy);
+});
+
+
+
+
+
+
+
View
@@ -22,7 +22,7 @@ gulp.task('rebuild', (cb) => {
});
gulp.task('build:js', () => {
- return gulp.src(['./js/**/*.js', './js/**/*.jsx'])
+ return gulp.src(['./src/**/*.js', './src/**/*.jsx'])
.pipe(babel())
.pipe(gulp.dest('dist'));
});
@@ -1,10 +0,0 @@
-import AppDispatcher from '../dispatchers/AppDispatcher';
-import configConstants from '../constants/config-constants';
-
-export default {
- toggleConnect() {
- AppDispatcher.dispatch({
- action: configConstants.TOGGLE_CONNECT
- });
- }
-};
@@ -1,30 +0,0 @@
-import AppDispatcher from '../dispatchers/AppDispatcher';
-import requestConstants from '../constants/request-constants';
-
-export default {
- selectRequest(request) {
- AppDispatcher.dispatch({
- action: requestConstants.SELECT_REQUEST,
- request
- });
- },
-
- setFilter(expression) {
- AppDispatcher.dispatch({
- action: requestConstants.SET_FILTER,
- expression
- });
- },
-
- clear() {
- AppDispatcher.dispatch({
- action: requestConstants.CLEAR
- });
- },
-
- togglePause() {
- AppDispatcher.dispatch({
- action: requestConstants.TOGGLE_PAUSE
- });
- }
-};
View
@@ -1,11 +0,0 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
-import PhoenixMatrixApp from './components/PhoenixMatrixApp';
-import requestStore from './stores/request-store';
-
-requestStore.init();
-
-ReactDOM.render(
- <PhoenixMatrixApp />,
- document.getElementById('main')
-);
@@ -1,28 +0,0 @@
-import React from 'react';
-import pure from '../lib/pure';
-import VerticalButtonBar from './VerticalButtonBar';
-import RequestList from './RequestList';
-
-export default class LeftSection extends React.Component {
- render() {
- return (
- <div className="left-section">
- <VerticalButtonBar paused={this.props.paused} config={this.props.config} />
- <RequestList
- requests={this.props.requests}
- selectedRequest={this.props.selectedRequest}
- />
- </div>
- );
- }
-}
-
-LeftSection.propTypes = {
- paused: React.PropTypes.bool,
- config: React.PropTypes.object,
- requests: React.PropTypes.array,
- selectedRequest: React.PropTypes.object
-};
-
-
-pure(LeftSection);
@@ -1,74 +0,0 @@
-import React from 'react';
-import pure from '../lib/pure';
-import _ from 'lodash';
-
-import Header from './Header';
-import LeftSection from './LeftSection';
-import MainSection from './MainSection';
-import Footer from './Footer';
-import Splitter from './Splitter';
-import requestStore from '../stores/request-store';
-import configStore from '../stores/config-store';
-
-const getRequests = () => {
- return {
- requests: requestStore.getView(),
- selected: requestStore.getSelectedRequest(),
- paused: requestStore.isPaused()
- };
-};
-
-const getConfig = () => {
- return configStore.getConfig();
-};
-
-export default class PhoenixMatrixApp extends React.Component {
- constructor() {
- super();
- this.state = Object.assign({}, {config: getConfig()}, getRequests());
- }
-
- componentDidMount() {
- requestStore.on('change', () => this.onRequestChange());
- configStore.on('change', () => this.onConfigChange());
- }
-
- componentWillUnmount() {
- this.removeListener('change', () => this.onRequestChange());
- this.removeListener('change', () => this.onConfigChange());
- }
-
- onRequestChange() {
- this.setState(getRequests());
- }
-
- onConfigChange() {
- this.setState({config: getConfig()});
- }
-
- render() {
- return (
- <div className="view-wrapper">
- <div className="main-section">
- <Header />
- <Splitter orientation="horizontal" initialPosition={400}>
- <div className="leftPane" minSize={275}>
- <LeftSection
- requests={this.state.requests}
- selectedRequest={this.state.selected}
- paused={this.state.paused}
- config={this.state.config}
- />
- </div>
- <div className="rightPane" minSize={300}>
- <MainSection requests={this.state.requests} selectedRequest={this.state.selected} />
- </div>
- </Splitter>
- </div>
- <Footer />
- </div>
- );
- }
-}
-
-pure(PhoenixMatrixApp);
View
@@ -1,38 +0,0 @@
-import { EventEmitter } from 'events';
-import _ from 'lodash';
-import config from '../lib/config';
-import AppDispatcher from '../dispatchers/AppDispatcher';
-import configConstants from '../constants/config-constants';
-
-const CHANGE_EVENT = 'change';
-
-const configStore = _.extend({}, EventEmitter.prototype, {
- emitChange: function() {
- this.emit(CHANGE_EVENT);
- },
-
- toggleConnect: function() {
- config.includeConnect = !config.includeConnect;
- },
-
- getConfig: function() {
- return _.cloneDeep(config);
- }
-});
-
-AppDispatcher.register(function(payload) {
- var action = payload.action;
-
- switch(action) {
- case configConstants.TOGGLE_CONNECT:
- configStore.toggleConnect();
- configStore.emitChange();
- break;
- default:
- return true;
- }
-
- return true;
-});
-
-export default configStore;
Oops, something went wrong.

0 comments on commit e40db6e

Please sign in to comment.