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
This commit is contained in:
Doug Wiegley 2019-03-05 21:54:07 -07:00
parent d92570abd4
commit 7892a19cb9
No known key found for this signature in database
GPG Key ID: 4D3C112B76BBDB5F
6 changed files with 30 additions and 1 deletions

View File

@ -320,6 +320,9 @@ For example, to hide comments from a CI system:
Specifies how patch diffs should be displayed. The values `unified` Specifies how patch diffs should be displayed. The values `unified`
or `side-by-side` (the default) are supported. 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 Dashboards
++++++++++ ++++++++++

View File

@ -166,6 +166,10 @@ commentlinks:
# at the bottom of the screen: # at the bottom of the screen:
# breadcrumbs: false # 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 # Uncomment the following line to use a unified diff view instead
# of the default side-by-side: # of the default side-by-side:
# diff-view: unified # diff-view: unified

View File

@ -401,6 +401,11 @@ class App(object):
self.clearInputBuffer() self.clearInputBuffer()
self.frame.body = widget self.frame.body = widget
def getPreviousScreen(self):
if not self.screens:
return None
return self.screens[-1]
def backScreen(self, target_widget=None): def backScreen(self, target_widget=None):
if not self.screens: if not self.screens:
return return

View File

@ -133,6 +133,7 @@ class ConfigSchema(object):
'display-times-in-utc': bool, 'display-times-in-utc': bool,
'handle-mouse': bool, 'handle-mouse': bool,
'breadcrumbs': bool, 'breadcrumbs': bool,
'close-change-on-review': bool,
'change-list-options': self.change_list_options, 'change-list-options': self.change_list_options,
'expire-age': str, 'expire-age': str,
'size-column': self.size_column, 'size-column': self.size_column,
@ -248,6 +249,7 @@ class Config(object):
self.thread_changes = self.config.get('thread-changes', True) self.thread_changes = self.config.get('thread-changes', True)
self.utc = self.config.get('display-times-in-utc', False) self.utc = self.config.get('display-times-in-utc', False)
self.breadcrumbs = self.config.get('breadcrumbs', True) 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) self.handle_mouse = self.config.get('handle-mouse', True)
change_list_options = self.config.get('change-list-options', {}) change_list_options = self.config.get('change-list-options', {})

View File

@ -1170,3 +1170,5 @@ class ChangeView(urwid.WidgetWrap):
self.app.sync.submitTask( self.app.sync.submitTask(
sync.UploadReviewTask(message_key, sync.HIGH_PRIORITY)) sync.UploadReviewTask(message_key, sync.HIGH_PRIORITY))
self.refresh() self.refresh()
if self.app.config.close_change_on_review:
self.app.backScreen()

View File

@ -170,7 +170,11 @@ class BaseDiffView(urwid.WidgetWrap, mywid.Searchable):
def help(self): def help(self):
key = self.app.config.keymap.formatKeys key = self.app.config.keymap.formatKeys
commands = self.getCommands() 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): def __init__(self, app, new_revision_key):
super(BaseDiffView, self).__init__(urwid.Pile([])) super(BaseDiffView, self).__init__(urwid.Pile([]))
@ -471,6 +475,9 @@ class BaseDiffView(urwid.WidgetWrap, mywid.Searchable):
if keymap.INTERACTIVE_SEARCH in commands: if keymap.INTERACTIVE_SEARCH in commands:
self.searchStart() self.searchStart()
return None return None
if key in self.app.config.reviewkeys:
self.reviewKey(self.app.config.reviewkeys[key])
return None
return key return key
def mouse_event(self, size, event, button, x, y, focus): def mouse_event(self, size, event, button, x, y, focus):
@ -521,6 +528,12 @@ class BaseDiffView(urwid.WidgetWrap, mywid.Searchable):
key = comment.key key = comment.key
return 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): def openPatchsetDialog(self):
revisions = [] revisions = []
with self.app.db.getSession() as session: with self.app.db.getSession() as session: