More conversions to browserify

This commit is contained in:
Aldo Cortesi 2014-12-30 22:12:26 +13:00
parent b847faf37f
commit 2152d4dd92
6 changed files with 463 additions and 39 deletions

File diff suppressed because one or more lines are too long

View File

@ -112,6 +112,9 @@ Query = {
module.exports = { module.exports = {
ActionTypes: ActionTypes, ActionTypes: ActionTypes,
ConnectionActions: ConnectionActions ConnectionActions: ConnectionActions,
FlowActions: FlowActions,
StoreCmds: StoreCmds
}; };

View File

@ -1,3 +1,11 @@
var React = require("react");
var _ = require("lodash");
var utils = require("./utils.jsx.js");
var actions = require("../actions.js");
var flowutils = require("../flow/utils.js");
var toputils = require("../utils.js");
var NavAction = React.createClass({ var NavAction = React.createClass({
onClick: function (e) { onClick: function (e) {
e.preventDefault(); e.preventDefault();
@ -34,19 +42,19 @@ var FlowDetailNav = React.createClass({
var acceptButton = null; var acceptButton = null;
if(flow.intercepted){ if(flow.intercepted){
acceptButton = <NavAction title="[a]ccept intercepted flow" icon="fa-play" onClick={FlowActions.accept.bind(null, flow)} />; acceptButton = <NavAction title="[a]ccept intercepted flow" icon="fa-play" onClick={actions.FlowActions.accept.bind(null, flow)} />;
} }
var revertButton = null; var revertButton = null;
if(flow.modified){ if(flow.modified){
revertButton = <NavAction title="revert changes to flow [V]" icon="fa-history" onClick={FlowActions.revert.bind(null, flow)} />; revertButton = <NavAction title="revert changes to flow [V]" icon="fa-history" onClick={actions.FlowActions.revert.bind(null, flow)} />;
} }
return ( return (
<nav ref="head" className="nav-tabs nav-tabs-sm"> <nav ref="head" className="nav-tabs nav-tabs-sm">
{tabs} {tabs}
<NavAction title="[d]elete flow" icon="fa-trash" onClick={FlowActions.delete.bind(null, flow)} /> <NavAction title="[d]elete flow" icon="fa-trash" onClick={actions.FlowActions.delete.bind(null, flow)} />
<NavAction title="[D]uplicate flow" icon="fa-copy" onClick={FlowActions.duplicate.bind(null, flow)} /> <NavAction title="[D]uplicate flow" icon="fa-copy" onClick={actions.FlowActions.duplicate.bind(null, flow)} />
<NavAction disabled title="[r]eplay flow" icon="fa-repeat" onClick={FlowActions.replay.bind(null, flow)} /> <NavAction disabled title="[r]eplay flow" icon="fa-repeat" onClick={actions.FlowActions.replay.bind(null, flow)} />
{acceptButton} {acceptButton}
{revertButton} {revertButton}
</nav> </nav>
@ -79,12 +87,12 @@ var FlowDetailRequest = React.createClass({
var flow = this.props.flow; var flow = this.props.flow;
var first_line = [ var first_line = [
flow.request.method, flow.request.method,
RequestUtils.pretty_url(flow.request), flowutils.RequestUtils.pretty_url(flow.request),
"HTTP/" + flow.request.httpversion.join(".") "HTTP/" + flow.request.httpversion.join(".")
].join(" "); ].join(" ");
var content = null; var content = null;
if (flow.request.contentLength > 0) { if (flow.request.contentLength > 0) {
content = "Request Content Size: " + formatSize(flow.request.contentLength); content = "Request Content Size: " + toputils.formatSize(flow.request.contentLength);
} else { } else {
content = <div className="alert alert-info">No Content</div>; content = <div className="alert alert-info">No Content</div>;
} }
@ -112,7 +120,7 @@ var FlowDetailResponse = React.createClass({
].join(" "); ].join(" ");
var content = null; var content = null;
if (flow.response.contentLength > 0) { if (flow.response.contentLength > 0) {
content = "Response Content Size: " + formatSize(flow.response.contentLength); content = "Response Content Size: " + toputils.formatSize(flow.response.contentLength);
} else { } else {
content = <div className="alert alert-info">No Content</div>; content = <div className="alert alert-info">No Content</div>;
} }
@ -138,7 +146,7 @@ var FlowDetailError = React.createClass({
<div className="alert alert-warning"> <div className="alert alert-warning">
{flow.error.msg} {flow.error.msg}
<div> <div>
<small>{ formatTimeStamp(flow.error.timestamp) }</small> <small>{ toputils.formatTimeStamp(flow.error.timestamp) }</small>
</div> </div>
</div> </div>
</section> </section>
@ -154,11 +162,11 @@ var TimeStamp = React.createClass({
return <tr></tr>; return <tr></tr>;
} }
var ts = formatTimeStamp(this.props.t); var ts = toputils.formatTimeStamp(this.props.t);
var delta; var delta;
if (this.props.deltaTo) { if (this.props.deltaTo) {
delta = formatTimeDelta(1000 * (this.props.t - this.props.deltaTo)); delta = toputils.formatTimeDelta(1000 * (this.props.t - this.props.deltaTo));
delta = <span className="text-muted">{"(" + delta + ")"}</span>; delta = <span className="text-muted">{"(" + delta + ")"}</span>;
} else { } else {
delta = null; delta = null;
@ -329,7 +337,7 @@ var allTabs = {
}; };
var FlowDetail = React.createClass({ var FlowDetail = React.createClass({
mixins: [StickyHeadMixin, Navigation, State], mixins: [utils.StickyHeadMixin, utils.Navigation, utils.State],
getTabs: function (flow) { getTabs: function (flow) {
var tabs = []; var tabs = [];
["request", "response", "error"].forEach(function (e) { ["request", "response", "error"].forEach(function (e) {
@ -385,3 +393,7 @@ var FlowDetail = React.createClass({
); );
} }
}); });
module.exports = {
FlowDetail: FlowDetail
};

View File

@ -4,6 +4,7 @@ var utils = require("./utils.jsx.js");
var views = require("../store/view.js"); var views = require("../store/view.js");
var Filt = require("../filt/filt.js"); var Filt = require("../filt/filt.js");
FlowTable = require("./flowtable.jsx.js"); FlowTable = require("./flowtable.jsx.js");
var flowdetail = require("./flowdetail.jsx.js");
var MainView = React.createClass({ var MainView = React.createClass({
@ -208,8 +209,8 @@ var MainView = React.createClass({
var details; var details;
if (selected) { if (selected) {
details = [ details = [
<Splitter key="splitter"/>, <utils.Splitter key="splitter"/>,
<FlowDetail key="flowDetails" ref="flowDetails" flow={selected}/> <flowdetail.FlowDetail key="flowDetails" ref="flowDetails" flow={selected}/>
]; ];
} else { } else {
details = null; details = null;

View File

@ -60,5 +60,7 @@ var ResponseUtils = _.extend(_MessageUtils, {});
module.exports = { module.exports = {
ResponseUtils: ResponseUtils ResponseUtils: ResponseUtils,
RequestUtils: RequestUtils
} }

View File

@ -91,7 +91,7 @@ _.extend(LiveStoreMixin.prototype, {
return this.fetch(); return this.fetch();
} }
if (event.type === this.type) { if (event.type === this.type) {
if (event.cmd === StoreCmds.RESET) { if (event.cmd === actions.StoreCmds.RESET) {
this.fetch(event.data); this.fetch(event.data);
} else if (this._updates_before_fetch) { } else if (this._updates_before_fetch) {
console.log("defer update", event); console.log("defer update", event);