Skip to content

Commit f1011af

Browse files
authored
Added tabs for queues. (#266)
1 parent 4bed622 commit f1011af

File tree

5 files changed

+103
-0
lines changed

5 files changed

+103
-0
lines changed

.TRACFREEZE.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ trac.wiki.web_api.wikirenderer
102102
trac.wiki.web_ui.defaultwikipolicy
103103
tracdjangoplugin.plugins.customnavigationbar
104104
tracdjangoplugin.plugins.customnewticket
105+
tracdjangoplugin.plugins.customsubnavigationbar
105106
tracdjangoplugin.plugins.customtheme
106107
tracdjangoplugin.plugins.customwikimodule
107108
tracdjangoplugin.plugins.githubbrowserwithsvnchangesets

DjangoPlugin/tracdjangoplugin/plugins.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,84 @@ def get_navigation_items(self, req):
8888
]
8989

9090

91+
class CustomSubNavigationBar(Component):
92+
"""Add queue items for the sub navigation bar."""
93+
94+
implements(INavigationContributor)
95+
96+
queues = [
97+
{
98+
"name": "unreviewed",
99+
"label": "Needs Triage",
100+
"params": "stage=Unreviewed&status=!closed&order=changetime&desc=1",
101+
},
102+
{
103+
"name": "needs_patch",
104+
"label": "Needs Patch",
105+
"params": "has_patch=0&stage=Accepted&status=!closed&order=changetime&desc=1",
106+
},
107+
{
108+
"name": "needs_pr_review",
109+
"label": "Needs PR Review",
110+
"params": (
111+
"has_patch=1&needs_better_patch=0&needs_docs=0&needs_tests=0&stage=Accepted"
112+
"&status=!closed&order=changetime&desc=1"
113+
),
114+
},
115+
{
116+
"name": "waiting_on_author",
117+
"label": "Waiting On Author",
118+
"params": (
119+
"has_patch=1&needs_better_patch=1&stage=Accepted&status=assigned&status=new"
120+
"&or&has_patch=1&needs_docs=1&stage=Accepted&status=assigned&status=new"
121+
"&or&has_patch=1&needs_tests=1&stage=Accepted&status=assigned&status=new"
122+
"&order=changetime&desc=1"
123+
),
124+
},
125+
{
126+
"name": "ready_for_checkin",
127+
"label": "Ready For Checkin",
128+
"params": "stage=Ready+for+checkin&status=!closed&order=changetime&desc=1",
129+
},
130+
]
131+
132+
def get_active_navigation_item(self, req):
133+
stage = req.args.get("stage")
134+
135+
if stage == "Unreviewed":
136+
return "unreviewed"
137+
if stage == "Ready for checkin":
138+
return "ready_for_checkin"
139+
if stage == "Accepted":
140+
if req.query_string == self.queues[1]["params"]:
141+
return "needs_patch"
142+
elif req.query_string == self.queues[2]["params"]:
143+
return "needs_pr_review"
144+
elif req.query_string == self.queues[3]["params"]:
145+
return "waiting_on_author"
146+
147+
return ""
148+
149+
def _get_active_class(self, active_item, subnav_name):
150+
return "active" if active_item == subnav_name else None
151+
152+
def get_navigation_items(self, req):
153+
if req.path_info.startswith("/query"):
154+
active_item = self.get_active_navigation_item(req)
155+
return [
156+
(
157+
"subnav",
158+
queue["name"],
159+
tag.a(
160+
queue["label"],
161+
href="/query?" + queue["params"],
162+
class_=self._get_active_class(active_item, queue["name"]),
163+
),
164+
)
165+
for queue in self.queues
166+
]
167+
168+
91169
class GitHubBrowserWithSVNChangesets(GitHubBrowser):
92170
def _format_changeset_link(self, formatter, ns, chgset, label, fullmatch=None):
93171
# Dead-simple version for SVN changesets.

scss/trachacks.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,22 @@ div[role="main"]{
330330
}
331331
}
332332

333+
#subnav {
334+
@include sans-serif;
335+
336+
ul {
337+
text-align: left;
338+
339+
li {
340+
a {
341+
&.active {
342+
font-weight: bold;
343+
}
344+
}
345+
}
346+
}
347+
}
348+
333349
#main {
334350
@include sans-serif;
335351

trac-env/conf/trac.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ tickets.order = 2.0
8484
timeline.order = 4.0
8585
wiki.order = 5.0
8686

87+
[subnav]
88+
unreviewed.order = 1.0
89+
needs_patch.order = 2.0
90+
needs_pr_review.order = 3.0
91+
waiting_on_author.order = 4.0
92+
ready_for_checkin.order = 5.0
93+
8794
[metanav]
8895
; The metanav is hardcoded in templates/django_theme.html
8996
; because it was too hard to make the login plugins play nice with each other

trac-env/templates/django_theme.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
</ul>
3535
</div>
3636
${navigation('mainnav')}
37+
${navigation('subnav')}
3738
<div id="main" ${{'class': {
3839
'uisymbols': req.session.get('ui.use_symbols'),
3940
'uinohelp': req.session.get('ui.hide_help'),

0 commit comments

Comments
 (0)