Browse Source

Merge "Enable review keys in diffs, and close change on review"

tags/1.6.0
Zuul 3 months ago
parent
commit
21a1cda390
6 changed files with 30 additions and 1 deletions
  1. 3
    0
      doc/source/configuration.rst
  2. 4
    0
      examples/reference-gertty.yaml
  3. 5
    0
      gertty/app.py
  4. 2
    0
      gertty/config.py
  5. 2
    0
      gertty/view/change.py
  6. 14
    1
      gertty/view/diff.py

+ 3
- 0
doc/source/configuration.rst View File

@@ -320,6 +320,9 @@ For example, to hide comments from a CI system:
320 320
   Specifies how patch diffs should be displayed.  The values `unified`
321 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
 
324 327
 Dashboards
325 328
 ++++++++++

+ 4
- 0
examples/reference-gertty.yaml View File

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

+ 5
- 0
gertty/app.py View File

@@ -401,6 +401,11 @@ class App(object):
401 401
         self.clearInputBuffer()
402 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 409
     def backScreen(self, target_widget=None):
405 410
         if not self.screens:
406 411
             return

+ 2
- 0
gertty/config.py View File

@@ -133,6 +133,7 @@ class ConfigSchema(object):
133 133
                            'display-times-in-utc': bool,
134 134
                            'handle-mouse': bool,
135 135
                            'breadcrumbs': bool,
136
+                           'close-change-on-review': bool,
136 137
                            'change-list-options': self.change_list_options,
137 138
                            'expire-age': str,
138 139
                            'size-column': self.size_column,
@@ -248,6 +249,7 @@ class Config(object):
248 249
         self.thread_changes = self.config.get('thread-changes', True)
249 250
         self.utc = self.config.get('display-times-in-utc', False)
250 251
         self.breadcrumbs = self.config.get('breadcrumbs', True)
252
+        self.close_change_on_review = self.config.get('close-change-on-review', False)
251 253
         self.handle_mouse = self.config.get('handle-mouse', True)
252 254
 
253 255
         change_list_options = self.config.get('change-list-options', {})

+ 2
- 0
gertty/view/change.py View File

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

+ 14
- 1
gertty/view/diff.py View File

@@ -170,7 +170,11 @@ class BaseDiffView(urwid.WidgetWrap, mywid.Searchable):
170 170
     def help(self):
171 171
         key = self.app.config.keymap.formatKeys
172 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 179
     def __init__(self, app, new_revision_key):
176 180
         super(BaseDiffView, self).__init__(urwid.Pile([]))
@@ -471,6 +475,9 @@ class BaseDiffView(urwid.WidgetWrap, mywid.Searchable):
471 475
         if keymap.INTERACTIVE_SEARCH in commands:
472 476
             self.searchStart()
473 477
             return None
478
+        if key in self.app.config.reviewkeys:
479
+            self.reviewKey(self.app.config.reviewkeys[key])
480
+            return None
474 481
         return key
475 482
 
476 483
     def mouse_event(self, size, event, button, x, y, focus):
@@ -521,6 +528,12 @@ class BaseDiffView(urwid.WidgetWrap, mywid.Searchable):
521 528
             key = comment.key
522 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 537
     def openPatchsetDialog(self):
525 538
         revisions = []
526 539
         with self.app.db.getSession() as session:

Loading…
Cancel
Save