From 851bb4bf68c20f22c195a4397dacb8cdfdb65fba Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 9 Jun 2016 13:35:41 +0800 Subject: [web] rewrite ProxyApp and MainView with es6 --- web/src/js/components/proxyapp.js | 154 -------------------------------------- 1 file changed, 154 deletions(-) delete mode 100644 web/src/js/components/proxyapp.js (limited to 'web/src/js/components/proxyapp.js') diff --git a/web/src/js/components/proxyapp.js b/web/src/js/components/proxyapp.js deleted file mode 100644 index e4489e18..00000000 --- a/web/src/js/components/proxyapp.js +++ /dev/null @@ -1,154 +0,0 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import _ from "lodash"; -import {connect} from 'react-redux' -import { Route, Router as ReactRouter, hashHistory, Redirect} from "react-router" - -import {Splitter} from "./common.js" -import MainView from "./mainview.js"; -import Footer from "./footer.js"; -import {Header, MainMenu} from "./header.js"; -import EventLog from "./eventlog.js" -import {SettingsStore} from "../store/store.js"; -import {Key} from "../utils.js"; - - -//TODO: Move out of here, just a stub. -var Reports = React.createClass({ - render: function () { - return
ReportEditor
; - } -}); - - -var ProxyAppMain = React.createClass({ - childContextTypes: { - returnFocus: React.PropTypes.func.isRequired, - location: React.PropTypes.object.isRequired, - }, - contextTypes: { - router: React.PropTypes.object.isRequired - }, - updateLocation: function (pathname, queryUpdate) { - if (pathname === undefined) { - pathname = this.props.location.pathname; - } - var query = this.props.location.query; - if (queryUpdate !== undefined) { - for (var i in queryUpdate) { - if (queryUpdate.hasOwnProperty(i)) { - query[i] = queryUpdate[i] || undefined; //falsey values shall be removed. - } - } - } - this.context.router.replace({pathname, query}); - }, - getQuery: function () { - // For whatever reason, react-router always returns the same object, which makes comparing - // the current props with nextProps impossible. As a workaround, we just clone the query object. - return _.clone(this.props.location.query); - }, - componentDidMount: function () { - this.focus(); - this.settingsStore.addListener("recalculate", this.onSettingsChange); - }, - componentWillUnmount: function () { - this.settingsStore.removeListener("recalculate", this.onSettingsChange); - }, - onSettingsChange: function () { - this.setState({ settings: this.settingsStore.dict }); - }, - getChildContext: function () { - return { - returnFocus: this.focus, - location: this.props.location - }; - }, - getInitialState: function () { - var settingsStore = new SettingsStore(); - - this.settingsStore = settingsStore; - // Default Settings before fetch - _.extend(settingsStore.dict, {}); - return { - settings: settingsStore.dict, - }; - }, - focus: function () { - document.activeElement.blur(); - window.getSelection().removeAllRanges(); - ReactDOM.findDOMNode(this).focus(); - }, - getMainComponent: function () { - return this.refs.view.getWrappedInstance ? this.refs.view.getWrappedInstance() : this.refs.view; - }, - onKeydown: function (e) { - - var selectFilterInput = function (name) { - var headerComponent = this.refs.header; - headerComponent.setState({active: MainMenu}, function () { - headerComponent.refs.active.refs[name].select(); - }); - }.bind(this); - - switch (e.keyCode) { - case Key.I: - selectFilterInput("intercept"); - break; - case Key.L: - selectFilterInput("search"); - break; - case Key.H: - selectFilterInput("highlight"); - break; - default: - var main = this.getMainComponent(); - if (main.onMainKeyDown) { - main.onMainKeyDown(e); - } - return; // don't prevent default then - } - e.preventDefault(); - }, - render: function () { - var query = this.getQuery(); - var eventlog; - if (this.props.showEventLog) { - eventlog = [ - , - - ]; - } else { - eventlog = null; - } - return ( -
-
- {React.cloneElement( - this.props.children, - { ref: "view", location: this.props.location , updateLocation: this.updateLocation, query } - )} - {eventlog} -
-
- ); - } -}); - -const AppContainer = connect( - state => ({ - showEventLog: state.eventLog.visible - }) -)(ProxyAppMain); - - -export var App = ( - - - - - - - - -); -- cgit v1.2.3