mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-04-29 04:35:02 +08:00
Merge remote-tracking branch 'origin/master' into flow_editing_v2
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import React, { PropTypes } from 'react'
|
||||
import classnames from 'classnames'
|
||||
import columns from './FlowColumns'
|
||||
import { pure } from '../../utils'
|
||||
|
||||
FlowRow.propTypes = {
|
||||
onSelect: PropTypes.func.isRequired,
|
||||
@@ -9,7 +10,7 @@ FlowRow.propTypes = {
|
||||
selected: PropTypes.bool,
|
||||
}
|
||||
|
||||
export default function FlowRow({ flow, selected, highlighted, onSelect }) {
|
||||
function FlowRow({ flow, selected, highlighted, onSelect }) {
|
||||
const className = classnames({
|
||||
'selected': selected,
|
||||
'highlighted': highlighted,
|
||||
@@ -19,10 +20,12 @@ export default function FlowRow({ flow, selected, highlighted, onSelect }) {
|
||||
})
|
||||
|
||||
return (
|
||||
<tr className={className} onClick={() => onSelect(flow)}>
|
||||
<tr className={className} onClick={() => onSelect(flow.id)}>
|
||||
{columns.map(Column => (
|
||||
<Column key={Column.name} flow={flow}/>
|
||||
))}
|
||||
</tr>
|
||||
)
|
||||
}
|
||||
|
||||
export default pure(FlowRow)
|
||||
|
||||
@@ -22,7 +22,7 @@ class MainView extends Component {
|
||||
flows={flows}
|
||||
selected={selectedFlow}
|
||||
highlight={highlight}
|
||||
onSelect={flow => this.props.selectFlow(flow.id)}
|
||||
onSelect={this.props.selectFlow}
|
||||
/>
|
||||
{selectedFlow && [
|
||||
<Splitter key="splitter"/>,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import _ from "lodash";
|
||||
import _ from 'lodash'
|
||||
import React from 'react'
|
||||
import shallowEqual from 'shallowequal'
|
||||
|
||||
window._ = _;
|
||||
window.React = require("react");
|
||||
window.React = React;
|
||||
|
||||
export var Key = {
|
||||
UP: 38,
|
||||
@@ -106,15 +108,27 @@ fetchApi.put = (url, json, options) => fetchApi(
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
export function getDiff(obj1, obj2) {
|
||||
let result = {...obj2};
|
||||
for(let key in obj1) {
|
||||
if(_.isEqual(obj2[key], obj1[key]))
|
||||
result[key] = undefined;
|
||||
result[key] = undefined
|
||||
else if(!(Array.isArray(obj2[key]) && Array.isArray(obj1[key])) &&
|
||||
typeof obj2[key] == 'object' && typeof obj1[key] == 'object')
|
||||
result[key] = getDiff(obj1[key], obj2[key]);
|
||||
result[key] = getDiff(obj1[key], obj2[key])
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export const pure = renderFn => class extends React.Component {
|
||||
static displayName = renderFn.name
|
||||
|
||||
shouldComponentUpdate(nextProps) {
|
||||
console.log(!shallowEqual(this.props, nextProps))
|
||||
return !shallowEqual(this.props, nextProps)
|
||||
}
|
||||
|
||||
render() {
|
||||
return renderFn(this.props)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user