summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-03-19 14:46:53 +0000
committerGerrit Code Review <review@openstack.org>2019-03-19 14:46:53 +0000
commit21a1cda3902b33c4e674344b66315ebd77d2a9ac (patch)
tree951c185f37d9165d90e65968f27e4a15b218df40
parent7e3f18bc04a1518e16507a077b40605745fc6abc (diff)
parent7892a19cb9e6bec37702022de886dea3ab72afb4 (diff)
Merge "Enable review keys in diffs, and close change on review"
-rw-r--r--doc/source/configuration.rst3
-rw-r--r--examples/reference-gertty.yaml4
-rw-r--r--gertty/app.py5
-rw-r--r--gertty/config.py2
-rw-r--r--gertty/view/change.py2
-rw-r--r--gertty/view/diff.py15
6 files changed, 30 insertions, 1 deletions
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:
320 Specifies how patch diffs should be displayed. The values `unified` 320 Specifies how patch diffs should be displayed. The values `unified`
321 or `side-by-side` (the default) are supported. 321 or `side-by-side` (the default) are supported.
322 322
323**close-change-on-review**
324 When a review is saved, close the change view and pop up to the
325 previous screen, which will be the change list for the repo.
323 326
324Dashboards 327Dashboards
325++++++++++ 328++++++++++
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:
166# at the bottom of the screen: 166# at the bottom of the screen:
167# breadcrumbs: false 167# breadcrumbs: false
168 168
169# Uncomment the following line to close a change after saving
170# a review.
171# close-change-on-review: true
172
169# Uncomment the following line to use a unified diff view instead 173# Uncomment the following line to use a unified diff view instead
170# of the default side-by-side: 174# of the default side-by-side:
171# diff-view: unified 175# diff-view: unified
diff --git a/gertty/app.py b/gertty/app.py
index a6060cc..190f61d 100644
--- a/gertty/app.py
+++ b/gertty/app.py
@@ -401,6 +401,11 @@ class App(object):
401 self.clearInputBuffer() 401 self.clearInputBuffer()
402 self.frame.body = widget 402 self.frame.body = widget
403 403
404 def getPreviousScreen(self):
405 if not self.screens:
406 return None
407 return self.screens[-1]
408
404 def backScreen(self, target_widget=None): 409 def backScreen(self, target_widget=None):
405 if not self.screens: 410 if not self.screens:
406 return 411 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):
133 'display-times-in-utc': bool, 133 'display-times-in-utc': bool,
134 'handle-mouse': bool, 134 'handle-mouse': bool,
135 'breadcrumbs': bool, 135 'breadcrumbs': bool,
136 'close-change-on-review': bool,
136 'change-list-options': self.change_list_options, 137 'change-list-options': self.change_list_options,
137 'expire-age': str, 138 'expire-age': str,
138 'size-column': self.size_column, 139 'size-column': self.size_column,
@@ -248,6 +249,7 @@ class Config(object):
248 self.thread_changes = self.config.get('thread-changes', True) 249 self.thread_changes = self.config.get('thread-changes', True)
249 self.utc = self.config.get('display-times-in-utc', False) 250 self.utc = self.config.get('display-times-in-utc', False)
250 self.breadcrumbs = self.config.get('breadcrumbs', True) 251 self.breadcrumbs = self.config.get('breadcrumbs', True)
252 self.close_change_on_review = self.config.get('close-change-on-review', False)
251 self.handle_mouse = self.config.get('handle-mouse', True) 253 self.handle_mouse = self.config.get('handle-mouse', True)
252 254
253 change_list_options = self.config.get('change-list-options', {}) 255 change_list_options = self.config.get('change-list-options', {})
diff --git a/gertty/view/change.py b/gertty/view/change.py
index 6a75227..e7bf373 100644
--- a/gertty/view/change.py
+++ b/gertty/view/change.py
@@ -1193,3 +1193,5 @@ class ChangeView(urwid.WidgetWrap):
1193 self.app.sync.submitTask( 1193 self.app.sync.submitTask(
1194 sync.UploadReviewTask(message_key, sync.HIGH_PRIORITY)) 1194 sync.UploadReviewTask(message_key, sync.HIGH_PRIORITY))
1195 self.refresh() 1195 self.refresh()
1196 if self.app.config.close_change_on_review:
1197 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):
170 def help(self): 170 def help(self):
171 key = self.app.config.keymap.formatKeys 171 key = self.app.config.keymap.formatKeys
172 commands = self.getCommands() 172 commands = self.getCommands()
173 return [(c[0], key(c[0]), c[1]) for c in commands] 173 ret = [(c[0], key(c[0]), c[1]) for c in commands]
174 for k in self.app.config.reviewkeys.values():
175 action = ', '.join(['{category}:{value}'.format(**a) for a in k['approvals']])
176 ret.append(('', keymap.formatKey(k['key']), action))
177 return ret
174 178
175 def __init__(self, app, new_revision_key): 179 def __init__(self, app, new_revision_key):
176 super(BaseDiffView, self).__init__(urwid.Pile([])) 180 super(BaseDiffView, self).__init__(urwid.Pile([]))
@@ -471,6 +475,9 @@ class BaseDiffView(urwid.WidgetWrap, mywid.Searchable):
471 if keymap.INTERACTIVE_SEARCH in commands: 475 if keymap.INTERACTIVE_SEARCH in commands:
472 self.searchStart() 476 self.searchStart()
473 return None 477 return None
478 if key in self.app.config.reviewkeys:
479 self.reviewKey(self.app.config.reviewkeys[key])
480 return None
474 return key 481 return key
475 482
476 def mouse_event(self, size, event, button, x, y, focus): 483 def mouse_event(self, size, event, button, x, y, focus):
@@ -521,6 +528,12 @@ class BaseDiffView(urwid.WidgetWrap, mywid.Searchable):
521 key = comment.key 528 key = comment.key
522 return key 529 return key
523 530
531 def reviewKey(self, reviewkey):
532 change_view = self.app.getPreviousScreen()
533 if change_view:
534 change_view.reviewKey(reviewkey)
535 self.app.backScreen()
536
524 def openPatchsetDialog(self): 537 def openPatchsetDialog(self):
525 revisions = [] 538 revisions = []
526 with self.app.db.getSession() as session: 539 with self.app.db.getSession() as session: