Browse Source

Enable review keys in diffs, and close change on review

- Add a config option to enable closing a change after a review
  is saved, and going back to the change list.
- Enable reviewKeys from the change page to also work on the
  diff view.

Change-Id: I37d907132a012d074d38345f15ef83ec7d9f3e6c
changes/97/641197/2
Doug Wiegley 3 years ago
parent
commit
7892a19cb9
No known key found for this signature in database GPG Key ID: 4D3C112B76BBDB5F
  1. 3
      doc/source/configuration.rst
  2. 4
      examples/reference-gertty.yaml
  3. 5
      gertty/app.py
  4. 2
      gertty/config.py
  5. 2
      gertty/view/change.py
  6. 15
      gertty/view/diff.py

3
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
++++++++++

4
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

5
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

2
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', {})

2
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()

15
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:

Loading…
Cancel
Save