[IMP] runbot_merge: filtering options and UX on stagings list

Allow filtering stagings by state (success or failure), and provide a
control to explicitly update the staging date limit.

Should make it easier to drill through stagings when looking for
specific information.

Related to #751
This commit is contained in:
Xavier Morel 2023-07-06 14:12:38 +02:00
parent 5bce73c97d
commit 780e20bfd6
3 changed files with 24 additions and 7 deletions

View File

@ -35,19 +35,24 @@ class MergebotDashboard(Controller):
})
@route('/runbot_merge/<int:branch_id>', auth='public', type='http', website=True, sitemap=False)
def stagings(self, branch_id, until=None):
def stagings(self, branch_id, until=None, state=''):
branch = request.env['runbot_merge.branch'].browse(branch_id).sudo().exists()
if not branch:
raise werkzeug.exceptions.NotFound()
stagings = request.env['runbot_merge.stagings'].with_context(active_test=False).sudo().search([
('target', '=', branch.id),
('staged_at', '<=', until) if until else (True, '=', True),
], order='staged_at desc', limit=LIMIT+1)
staging_domain = [('target', '=', branch.id)]
if until:
staging_domain.append(('staged_at', '<=', until))
if state:
staging_domain.append(('state', '=', state))
stagings = request.env['runbot_merge.stagings'].with_context(active_test=False).sudo().search(staging_domain, order='staged_at desc', limit=LIMIT + 1)
return request.render('runbot_merge.branch_stagings', {
'branch': branch,
'stagings': stagings[:LIMIT],
'until': until,
'state': state,
'next': stagings[-1].staged_at if len(stagings) > LIMIT else None,
})

View File

@ -1764,7 +1764,7 @@ class Stagings(models.Model):
('pending', 'Pending'),
('cancelled', "Cancelled"),
('ff_failed', "Fast forward failed")
], default='pending')
], default='pending', index=True)
active = fields.Boolean(default=True)
staged_at = fields.Datetime(default=fields.Datetime.now, index=True)

View File

@ -199,6 +199,18 @@
<section class="row">
<h1 class="col-md-12"><t t-esc="branch.project_id.name"/>: <t t-esc="branch.name"/></h1>
</section>
<form method="get">
<label for="until">Staged before:</label>
<input type="datetime-local" name="until" t-att-value="until"/>
(UTC)
<label for="state">State:</label>
<select name="state">
<option t-att-selected="'selected' if not state else None"/>
<option t-att-selected="'selected' if state == 'success' else None" value="success">Success</option>
<option t-att-selected="'selected' if state == 'failure' else None" value="failure">Failure</option>
</select>
<button type="submit">Apply</button>
</form>
<table>
<t t-foreach="stagings" t-as="staging">
<t t-set="success"
@ -270,7 +282,7 @@
</t>
</table>
<t t-if="next">
<a t-attf-href="/runbot_merge/{{branch.id}}?until={{next}}">
<a t-attf-href="/runbot_merge/{{branch.id}}?until={{next}}&amp;state={{state}}">
Next >
</a>
</t>