diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index d2bbcc3..3a29377 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -320,6 +320,9 @@ For example, to hide comments from a CI system: Specifies how patch diffs should be displayed. The values `unified` or `side-by-side` (the default) are supported. +**close-change-on-review** + When a review is saved, close the change view and pop up to the + previous screen, which will be the change list for the repo. Dashboards ++++++++++ diff --git a/examples/reference-gertty.yaml b/examples/reference-gertty.yaml index 19b5407..fcdab93 100644 --- a/examples/reference-gertty.yaml +++ b/examples/reference-gertty.yaml @@ -166,6 +166,10 @@ commentlinks: # at the bottom of the screen: # breadcrumbs: false +# Uncomment the following line to close a change after saving +# a review. +# close-change-on-review: true + # Uncomment the following line to use a unified diff view instead # of the default side-by-side: # diff-view: unified diff --git a/gertty/app.py b/gertty/app.py index 2c14e66..7df90fe 100644 --- a/gertty/app.py +++ b/gertty/app.py @@ -401,6 +401,11 @@ class App(object): self.clearInputBuffer() self.frame.body = widget + def getPreviousScreen(self): + if not self.screens: + return None + return self.screens[-1] + def backScreen(self, target_widget=None): if not self.screens: return diff --git a/gertty/config.py b/gertty/config.py index 494c210..3f7f711 100644 --- a/gertty/config.py +++ b/gertty/config.py @@ -133,6 +133,7 @@ class ConfigSchema(object): 'display-times-in-utc': bool, 'handle-mouse': bool, 'breadcrumbs': bool, + 'close-change-on-review': bool, 'change-list-options': self.change_list_options, 'expire-age': str, 'size-column': self.size_column, @@ -248,6 +249,7 @@ class Config(object): self.thread_changes = self.config.get('thread-changes', True) self.utc = self.config.get('display-times-in-utc', False) self.breadcrumbs = self.config.get('breadcrumbs', True) + self.close_change_on_review = self.config.get('close-change-on-review', False) self.handle_mouse = self.config.get('handle-mouse', True) change_list_options = self.config.get('change-list-options', {}) diff --git a/gertty/view/change.py b/gertty/view/change.py index d9e464d..8393823 100644 --- a/gertty/view/change.py +++ b/gertty/view/change.py @@ -1170,3 +1170,5 @@ class ChangeView(urwid.WidgetWrap): self.app.sync.submitTask( sync.UploadReviewTask(message_key, sync.HIGH_PRIORITY)) self.refresh() + if self.app.config.close_change_on_review: + self.app.backScreen() diff --git a/gertty/view/diff.py b/gertty/view/diff.py index 0509a04..e815269 100644 --- a/gertty/view/diff.py +++ b/gertty/view/diff.py @@ -170,7 +170,11 @@ class BaseDiffView(urwid.WidgetWrap, mywid.Searchable): def help(self): key = self.app.config.keymap.formatKeys commands = self.getCommands() - return [(c[0], key(c[0]), c[1]) for c in commands] + ret = [(c[0], key(c[0]), c[1]) for c in commands] + for k in self.app.config.reviewkeys.values(): + action = ', '.join(['{category}:{value}'.format(**a) for a in k['approvals']]) + ret.append(('', keymap.formatKey(k['key']), action)) + return ret def __init__(self, app, new_revision_key): super(BaseDiffView, self).__init__(urwid.Pile([])) @@ -471,6 +475,9 @@ class BaseDiffView(urwid.WidgetWrap, mywid.Searchable): if keymap.INTERACTIVE_SEARCH in commands: self.searchStart() return None + if key in self.app.config.reviewkeys: + self.reviewKey(self.app.config.reviewkeys[key]) + return None return key def mouse_event(self, size, event, button, x, y, focus): @@ -521,6 +528,12 @@ class BaseDiffView(urwid.WidgetWrap, mywid.Searchable): key = comment.key return key + def reviewKey(self, reviewkey): + change_view = self.app.getPreviousScreen() + if change_view: + change_view.reviewKey(reviewkey) + self.app.backScreen() + def openPatchsetDialog(self): revisions = [] with self.app.db.getSession() as session: