Fix #2753. Fix resetting editings.

This commit is contained in:
Miroslav 2018-01-26 18:37:35 +02:00
parent 6dd336fcec
commit 4bb22bbe8a
4 changed files with 21 additions and 12 deletions

View File

@ -433,7 +433,6 @@ class FocusEditor(urwid.WidgetWrap, layoutwidget.LayoutWidget):
def __init__(self, master):
self.master = master
self.focus_changed()
def call(self, v, name, *args, **kwargs):
f = getattr(v, name, None)
@ -462,7 +461,7 @@ class FocusEditor(urwid.WidgetWrap, layoutwidget.LayoutWidget):
def layout_popping(self):
self.call(self._w, "layout_popping")
def focus_changed(self):
def layout_pushed(self, prev):
if self.master.view.focus.flow:
self._w = BaseGridEditor(
self.master,

View File

@ -27,15 +27,8 @@ class Column(base.Column):
)
return
elif key == "m_select":
editor.master.view_grideditor(
self.subeditor(
editor.master,
editor.walker.get_current_value(),
editor.set_subeditor_value,
editor.walker.focus,
editor.walker.focus_col
)
)
self.subeditor.grideditor = editor
editor.master.switch_view("edit_focus_setcookie_attrs")
else:
return key

View File

@ -1,3 +1,4 @@
import urwid
import typing
from mitmproxy import exceptions
@ -100,12 +101,13 @@ class CookieEditor(base.FocusEditor):
flow.request.cookies = vals
class CookieAttributeEditor(base.GridEditor):
class CookieAttributeEditor(base.FocusEditor):
title = "Editing Set-Cookie attributes"
columns = [
col_text.Column("Name"),
col_text.Column("Value"),
]
grideditor = None # type: base.BaseGridEditor
def data_in(self, data):
return [(k, v or "") for k, v in data]
@ -119,6 +121,20 @@ class CookieAttributeEditor(base.GridEditor):
ret.append(i)
return ret
def layout_pushed(self, prev):
if self.grideditor.master.view.focus.flow:
self._w = base.BaseGridEditor(
self.grideditor.master,
self.title,
self.columns,
self.grideditor.walker.get_current_value(),
self.grideditor.set_subeditor_value,
self.grideditor.walker.focus,
self.grideditor.walker.focus_col
)
else:
self._w = urwid.Pile([])
class SetCookieEditor(base.FocusEditor):
title = "Edit SetCookie Header"

View File

@ -63,6 +63,7 @@ class WindowStack:
edit_focus_query = grideditor.QueryEditor(master),
edit_focus_cookies = grideditor.CookieEditor(master),
edit_focus_setcookies = grideditor.SetCookieEditor(master),
edit_focus_setcookie_attrs = grideditor.CookieAttributeEditor(master),
edit_focus_form = grideditor.RequestFormEditor(master),
edit_focus_path = grideditor.PathEditor(master),
edit_focus_request_headers = grideditor.RequestHeaderEditor(master),