add keyboard shortcut n to mitmweb (by using runCommand inside the kb shortcut handler) (#5061)

* add keyboard shortcut n to mitmweb (by creating /flows/create route)

* add keyboard shortcut n to mitmweb (simplified, by using runCommand instead of a new route)
This commit is contained in:
ian klatzco 2022-01-16 15:34:07 +01:00 committed by GitHub
parent 2455632a9c
commit 1abb8f6921
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -22,6 +22,7 @@
* Fix a bug where `running()` is invoked twice on startup (#3584, @mhils)
* Correct documentation example for User-Agent header modification (#4997, @jamesyale)
* Fix random connection stalls (#5040, @EndUser509)
* Add `n` new flow keybind to mitmweb (#5061, @ianklatzco)
## 28 September 2021: mitmproxy 7.0.4

View File

@ -2,7 +2,7 @@ import reduceFlows, * as flowsActions from "../../../ducks/flows";
import {onKeyDown} from '../../../ducks/ui/keyboard'
import * as UIActions from '../../../ducks/ui/flow'
import * as modalActions from '../../../ducks/ui/modal'
import {fetchApi} from '../../../utils'
import {fetchApi, runCommand} from '../../../utils'
import {TStore} from "../tutils";
jest.mock('../../../utils')
@ -102,6 +102,11 @@ describe('onKeyDown', () => {
})
it('should handle create action', () => {
store.dispatch(createKeyEvent("n"))
expect(runCommand).toBeCalledWith('view.flows.create', "get", "https://example.com/")
})
it('should handle duplicate action', () => {
store.dispatch(createKeyEvent("D"))
expect(fetchApi).toBeCalledWith('/flows/1/duplicate', {method: 'POST'})

View File

@ -2,6 +2,7 @@ import {selectTab} from "./flow"
import * as flowsActions from "../flows"
import * as modalActions from "./modal"
import {tabsForFlow} from "../../components/FlowView";
import {runCommand} from "../../utils"
export function onKeyDown(e: KeyboardEvent) {
@ -80,6 +81,11 @@ export function onKeyDown(e: KeyboardEvent) {
break
}
case "n": {
runCommand("view.flows.create", "get", "https://example.com/")
break
}
case "D": {
if (!flow) {
return