diff --git a/gertty/app.py b/gertty/app.py index 3f6241a..46675b4 100644 --- a/gertty/app.py +++ b/gertty/app.py @@ -160,6 +160,12 @@ class App(object): self.loop.widget = widget self.refresh() + def clearHistory(self): + self.log.debug("Clearing screen history") + while self.screens: + widget = self.screens.pop() + self.loop.widget = widget + def refresh(self, data=None): widget = self.loop.widget while isinstance(widget, urwid.Overlay): @@ -180,8 +186,15 @@ class App(object): def help(self): if not hasattr(self.loop.widget, 'help'): return - dialog = mywid.MessageDialog('Help', self.loop.widget.help) - lines = self.loop.widget.help.split('\n') + text = mywid.GLOBAL_HELP + for d in self.config.dashboards.values(): + space = max(9 - len(d['key']), 0) * ' ' + text += '<%s>%s %s\n' % (d['key'], space, d['name']) + text += "\nThis Screen\n" + text += "===========\n" + text += self.loop.widget.help + dialog = mywid.MessageDialog('Help', text) + lines = text.split('\n') urwid.connect_signal(dialog, 'close', lambda button: self.backScreen()) self.popup(dialog, min_width=76, min_height=len(lines)+4) @@ -283,6 +296,11 @@ class App(object): self.quit() elif key == 'ctrl o': self.searchDialog() + elif key in self.config.dashboards: + d = self.config.dashboards[key] + self.clearHistory() + view = view_change_list.ChangeListView(self, d['query'], d['name']) + self.changeScreen(view) def getRepo(self, project_name): local_path = os.path.join(self.config.git_root, project_name) diff --git a/gertty/config.py b/gertty/config.py index c975c47..07db3d2 100644 --- a/gertty/config.py +++ b/gertty/config.py @@ -1,4 +1,5 @@ # Copyright 2014 OpenStack Foundation +# Copyright 2014 Hewlett-Packard Development Company, L.P. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -58,10 +59,17 @@ class ConfigSchema(object): commentlinks = [commentlink] + dashboard = {v.Required('name'): str, + v.Required('query'): str, + v.Required('key'): str} + + dashboards = [dashboard] + def getSchema(self, data): schema = v.Schema({v.Required('servers'): self.servers, 'palettes': self.palettes, 'commentlinks': self.commentlinks, + 'dashboards': self.dashboards, }) return schema @@ -114,6 +122,10 @@ class Config(object): text="{url}", url="{url}"))]))) + self.dashboards = {} + for d in self.config.get('dashboards', []): + self.dashboards[d['key']] = d + def getServer(self, name=None): for server in self.config['servers']: if name is None or name == server['name']: diff --git a/gertty/db.py b/gertty/db.py index 3de4617..cce5154 100644 --- a/gertty/db.py +++ b/gertty/db.py @@ -456,6 +456,8 @@ class DatabaseSession(object): elif key == 'status': if data == 'open': q = q.filter(change_table.c.status.notin_(['MERGED', 'ABANDONED'])) + else: + q = q.filter(change_table.c.status==data) if unreviewed: q = q.filter(change_table.c.hidden==False, change_table.c.reviewed==False) try: diff --git a/gertty/view/change.py b/gertty/view/change.py index 6698f3a..06fc676 100644 --- a/gertty/view/change.py +++ b/gertty/view/change.py @@ -293,9 +293,7 @@ class ChangeMessageBox(mywid.HyperText): self.set_text(text+comment_text) class ChangeView(urwid.WidgetWrap): - help = mywid.GLOBAL_HELP + """ -This Screen -=========== + help = """ <c> Checkout the most recent revision into the local repo. <d> Show the diff of the mont recent revision. <k> Toggle the hidden flag for the current change. diff --git a/gertty/view/change_list.py b/gertty/view/change_list.py index d53aa0a..2fe5e7d 100644 --- a/gertty/view/change_list.py +++ b/gertty/view/change_list.py @@ -67,15 +67,13 @@ class ChangeListHeader(urwid.WidgetWrap): self._w.contents.append((urwid.Text(' %s' % category[0]), self._w.options('given', 3))) class ChangeListView(urwid.WidgetWrap): - help = mywid.GLOBAL_HELP + """ -This Screen -=========== + help = """ <k> Toggle the hidden flag for the currently selected change. <l> Toggle whether only unreviewed or all changes are displayed. <v> Toggle the reviewed flag for the currently selected change. """ - def __init__(self, app, query, query_desc=None, unreviewed=True): + def __init__(self, app, query, query_desc=None, unreviewed=False): super(ChangeListView, self).__init__(urwid.Pile([])) self.app = app self.query = query @@ -98,7 +96,7 @@ This Screen if self.unreviewed: self.title = u'Unreviewed changes in %s' % self.query_desc else: - self.title = u'Open changes in %s' % self.query_desc + self.title = u'All changes in %s' % self.query_desc self.app.status.update(title=self.title) i = 0 for change in lst: diff --git a/gertty/view/diff.py b/gertty/view/diff.py index c4a8031..39e651b 100644 --- a/gertty/view/diff.py +++ b/gertty/view/diff.py @@ -210,9 +210,7 @@ class DiffContextButton(urwid.WidgetWrap): self.view.expandChunk(self.diff, self.chunk, from_end=-10) class DiffView(urwid.WidgetWrap): - help = mywid.GLOBAL_HELP + """ -This Screen -=========== + help = """ <Enter> Add an inline comment <p> Select old/new patchsets to diff """ diff --git a/gertty/view/project_list.py b/gertty/view/project_list.py index d7d4cfe..9cb8a12 100644 --- a/gertty/view/project_list.py +++ b/gertty/view/project_list.py @@ -66,9 +66,7 @@ class ProjectListHeader(urwid.WidgetWrap): super(ProjectListHeader, self).__init__(urwid.Columns(cols)) class ProjectListView(urwid.WidgetWrap): - help = mywid.GLOBAL_HELP + """ -This Screen -=========== + help = """ <l> Toggle whether only subscribed projects or all projects are listed. <s> Toggle the subscription flag for the currently selected project. """