diff --git a/CHANGELOG.md b/CHANGELOG.md index 77af9e6a6..666cd7d33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/web/src/js/__tests__/ducks/ui/keyboardSpec.tsx b/web/src/js/__tests__/ducks/ui/keyboardSpec.tsx index 9f15ab4a4..514cfb98c 100644 --- a/web/src/js/__tests__/ducks/ui/keyboardSpec.tsx +++ b/web/src/js/__tests__/ducks/ui/keyboardSpec.tsx @@ -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'}) diff --git a/web/src/js/ducks/ui/keyboard.tsx b/web/src/js/ducks/ui/keyboard.tsx index 76981814d..e318e808f 100644 --- a/web/src/js/ducks/ui/keyboard.tsx +++ b/web/src/js/ducks/ui/keyboard.tsx @@ -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