import React, { PropTypes } from 'react' 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 (
{prompt || Select: } {opts.map(opt => { const idx = opt.text.indexOf(opt.key) function onClick(event) { done(opt.key) event.stopPropagation() } return ( {idx !== -1 ? opt.text.substring(0, idx) : opt.text + '('} {opt.key} {idx !== -1 ? opt.text.substring(idx + 1) : ')'} ) })}
) } 4bb58c1951f79e630'>diffstats
path: root/test/mitmproxy/test_flow_export/locust_get.py
blob: 632d5d53727bd06ce66ec98bb87aebe3317e8e05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35