mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 15:37:45 +00:00
[web] remove prompt
This commit is contained in:
parent
51d3fb8ea1
commit
f870ccd949
@ -14,7 +14,6 @@ html {
|
|||||||
@import (less) "flowtable.less";
|
@import (less) "flowtable.less";
|
||||||
@import (less) "flowdetail.less";
|
@import (less) "flowdetail.less";
|
||||||
@import (less) "flowview.less";
|
@import (less) "flowview.less";
|
||||||
@import (less) "prompt.less";
|
|
||||||
@import (less) "eventlog.less";
|
@import (less) "eventlog.less";
|
||||||
@import (less) "footer.less";
|
@import (less) "footer.less";
|
||||||
@import (less) "codemirror.less";
|
@import (less) "codemirror.less";
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
.prompt-dialog {
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
position: fixed;
|
|
||||||
z-index: 100;
|
|
||||||
background-color: rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.prompt-content {
|
|
||||||
position: fixed;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
height: 25px;
|
|
||||||
padding: 2px 5px;
|
|
||||||
background-color: white;
|
|
||||||
box-shadow: 0 -1px 3px lightgray;
|
|
||||||
|
|
||||||
.option {
|
|
||||||
cursor: pointer;
|
|
||||||
&:not(:last-child)::after {
|
|
||||||
content: ", ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,7 +5,6 @@ import _ from 'lodash'
|
|||||||
import Nav from './FlowView/Nav'
|
import Nav from './FlowView/Nav'
|
||||||
import { Request, Response, ErrorView as Error } from './FlowView/Messages'
|
import { Request, Response, ErrorView as Error } from './FlowView/Messages'
|
||||||
import Details from './FlowView/Details'
|
import Details from './FlowView/Details'
|
||||||
import Prompt from './Prompt'
|
|
||||||
|
|
||||||
import { selectTab } from '../ducks/ui/flow'
|
import { selectTab } from '../ducks/ui/flow'
|
||||||
|
|
||||||
@ -80,7 +79,7 @@ class FlowView extends Component {
|
|||||||
/>
|
/>
|
||||||
<Tab ref={ tab => this.tabComponent = tab } flow={flow} updateFlow={updateFlow} />
|
<Tab ref={ tab => this.tabComponent = tab } flow={flow} updateFlow={updateFlow} />
|
||||||
{this.props.promptOpen && (
|
{this.props.promptOpen && (
|
||||||
<Prompt options={this.getPromptOptions()} done={this.onPromptFinish} />
|
<div>fixme</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -20,7 +20,7 @@ FileMenu.onNewClick = (e, clearFlows) => {
|
|||||||
clearFlows()
|
clearFlows()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function FileMenu ({clearFlows, loadFlows, saveFlows, openModal}) {
|
export function FileMenu ({clearFlows, loadFlows, saveFlows, openOptions}) {
|
||||||
return (
|
return (
|
||||||
<Dropdown className="pull-left" btnClass="special" text="mitmproxy">
|
<Dropdown className="pull-left" btnClass="special" text="mitmproxy">
|
||||||
<a href="#" onClick={e => FileMenu.onNewClick(e, clearFlows)}>
|
<a href="#" onClick={e => FileMenu.onNewClick(e, clearFlows)}>
|
||||||
@ -38,7 +38,7 @@ export function FileMenu ({clearFlows, loadFlows, saveFlows, openModal}) {
|
|||||||
</a>
|
</a>
|
||||||
|
|
||||||
<HideInStatic>
|
<HideInStatic>
|
||||||
<a href="#" onClick={e => { e.preventDefault(); openModal(); }}>
|
<a href="#" onClick={e => { e.preventDefault(); openOptions(); }}>
|
||||||
<i className="fa fa-fw fa-cog"></i>
|
<i className="fa fa-fw fa-cog"></i>
|
||||||
Options
|
Options
|
||||||
</a>
|
</a>
|
||||||
@ -59,6 +59,6 @@ export default connect(
|
|||||||
clearFlows: flowsActions.clear,
|
clearFlows: flowsActions.clear,
|
||||||
loadFlows: flowsActions.upload,
|
loadFlows: flowsActions.upload,
|
||||||
saveFlows: flowsActions.download,
|
saveFlows: flowsActions.download,
|
||||||
openModal: () => modalActions.setActiveModal('OptionModal'),
|
openOptions: () => modalActions.setActiveModal('OptionModal'),
|
||||||
}
|
}
|
||||||
)(FileMenu)
|
)(FileMenu)
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
import PropTypes from 'prop-types'
|
|
||||||
import ReactDOM from 'react-dom'
|
|
||||||
import _ from 'lodash'
|
|
||||||
|
|
||||||
import {Key} from '../utils.js'
|
|
||||||
|
|
||||||
Prompt.propTypes = {
|
|
||||||
options: PropTypes.array.isRequired,
|
|
||||||
done: PropTypes.func.isRequired,
|
|
||||||
prompt: PropTypes.string,
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Prompt({ prompt, done, options }) {
|
|
||||||
const opts = []
|
|
||||||
|
|
||||||
for (let i = 0; i < options.length; i++) {
|
|
||||||
let opt = options[i]
|
|
||||||
if (_.isString(opt)) {
|
|
||||||
let str = opt
|
|
||||||
while (str.length > 0 && keyTaken(str[0])) {
|
|
||||||
str = str.substr(1)
|
|
||||||
}
|
|
||||||
opt = { text: opt, key: str[0] }
|
|
||||||
}
|
|
||||||
if (!opt.text || !opt.key || keyTaken(opt.key)) {
|
|
||||||
throw 'invalid options'
|
|
||||||
}
|
|
||||||
opts.push(opt)
|
|
||||||
}
|
|
||||||
|
|
||||||
function keyTaken(k) {
|
|
||||||
return _.map(opts, 'key').includes(k)
|
|
||||||
}
|
|
||||||
|
|
||||||
function onKeyDown(event) {
|
|
||||||
event.stopPropagation()
|
|
||||||
event.preventDefault()
|
|
||||||
const key = opts.find(opt => Key[opt.key.toUpperCase()] === event.keyCode)
|
|
||||||
if (!key && event.keyCode !== Key.ESC && event.keyCode !== Key.ENTER) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
done(key.key || false)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div tabIndex="0" onKeyDown={onKeyDown} className="prompt-dialog">
|
|
||||||
<div className="prompt-content">
|
|
||||||
{prompt || <strong>Select: </strong> }
|
|
||||||
{opts.map(opt => {
|
|
||||||
const idx = opt.text.indexOf(opt.key)
|
|
||||||
function onClick(event) {
|
|
||||||
done(opt.key)
|
|
||||||
event.stopPropagation()
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<span key={opt.key} className="option" onClick={onClick}>
|
|
||||||
{idx !== -1 ? opt.text.substring(0, idx) : opt.text + '('}
|
|
||||||
<strong className="text-primary">{opt.key}</strong>
|
|
||||||
{idx !== -1 ? opt.text.substring(idx + 1) : ')'}
|
|
||||||
</span>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user