[IMP] runbot_merge: only show required statuses in the dashboard

Apparently a long-running issue but not really a concern before the
new mergebot started sending a lot more statuses: stagings would show
a list of all statuses they received, including optional / irrelevant
statuses.

Get a list of required statuses and only show that on the staging
dropdowns.

Closes #387
This commit is contained in:
Xavier Morel 2020-07-22 08:42:39 +02:00 committed by xmo-odoo
parent 04ad4f6b67
commit 7781d8b09c
2 changed files with 34 additions and 27 deletions

View File

@ -87,10 +87,8 @@ def test_trivial_flow(env, repo, page, users, config):
p = html.fromstring(page('/runbot_merge')) p = html.fromstring(page('/runbot_merge'))
s = p.cssselect('.staging div.dropdown li') s = p.cssselect('.staging div.dropdown li')
assert len(s) == 2 assert len(s) == 2
assert s[0].get('class') == 'bg-success' assert s[1].get('class') == 'bg-success'
assert s[0][0].text.strip() == '{}: ci/runbot'.format(repo.name) assert s[1][0].text.strip() == '{}: ci/runbot'.format(repo.name)
assert s[1].get('class') == 'bg-danger'
assert s[1][0].text.strip() == '{}: ci/lint'.format(repo.name)
assert re.match('^force rebuild', staging_head.message) assert re.match('^force rebuild', staging_head.message)

View File

@ -115,6 +115,7 @@
</t> </t>
</template> </template>
<template id="stagings" name="mergebot branch stagings"> <template id="stagings" name="mergebot branch stagings">
<t t-set="repo_statuses" t-value="branch.project_id.repo_ids.having_branch(branch).status_ids"/>
<ul class="list-unstyled stagings"> <ul class="list-unstyled stagings">
<t t-foreach="branch.staging_ids.sorted(lambda s: s.staged_at, reverse=True)[:6]" t-as="staging"> <t t-foreach="branch.staging_ids.sorted(lambda s: s.staged_at, reverse=True)[:6]" t-as="staging">
<t t-set="success" t-value="staging.state == 'success'"/> <t t-set="success" t-value="staging.state == 'success'"/>
@ -157,16 +158,20 @@
Open Staging Open Staging
</a> </a>
</li> </li>
<li t-foreach="staging.statuses" t-as="st" t-if="st[3]"
t-att-class=" <t t-set="statuses" t-value="{c: (s, t) for h, c, s, t in staging.statuses}"/>
'bg-success' if st[2] == 'success' <t t-foreach="repo_statuses._for_staging(staging)" t-as="req">
else 'bg-danger' if st[2] in ('error', 'failure') <t t-set="st" t-value="statuses.get(req.context) or ('pending', None)"/>
else 'bg-info'" <li t-att-class="
> 'bg-success' if st[0] == 'success'
<a t-att-href="st[3]" target="new"> else 'bg-danger' if st[0] in ('error', 'failure')
<t t-esc="st[0]"/>: <t t-esc="st[1]"/> else 'bg-info'"
</a> >
</li> <a t-att-href="st[1]" target="new">
<t t-esc="req.repo_id.name"/>: <t t-esc="req.context"/>
</a>
</li>
</t>
</ul> </ul>
</div> </div>
</t> </t>
@ -175,6 +180,7 @@
</ul> </ul>
</template> </template>
<template id="branch_stagings" name="mergebot stagings page"> <template id="branch_stagings" name="mergebot stagings page">
<t t-set="repo_statuses" t-value="branch.project_id.repo_ids.having_branch(branch).status_ids"/>
<t t-call="website.layout"> <t t-call="website.layout">
<div id="wrap"><div class="container-fluid"> <div id="wrap"><div class="container-fluid">
<section class="row"> <section class="row">
@ -231,19 +237,22 @@
Open Staging Open Staging
</a> </a>
</li> </li>
<li t-foreach="staging.statuses"
t-as="st" t-if="st[3]" <t t-set="statuses" t-value="{c: (s, t) for h, c, s, t in staging.statuses}"/>
t-att-class=" <t t-foreach="repo_statuses._for_staging(staging)" t-as="req">
'bg-success' if st[2] == 'success' <t t-set="st" t-value="statuses.get(req.context) or ('pending', None)"/>
else 'bg-danger' if st[2] in ('error', 'failure') <li t-att-class="
else 'bg-info'" 'bg-success' if st[0] == 'success'
> else 'bg-danger' if st[0] in ('error', 'failure')
<a t-att-href="st[3]" else 'bg-info'"
target="new"> >
<t t-esc="st[0]"/>: <a t-att-href="st[1]"
<t t-esc="st[1]"/> target="new">
</a> <t t-esc="req.repo_id.name"/>:
</li> <t t-esc="req.context"/>
</a>
</li>
</t>
</ul> </ul>
</div> </div>
</th> </th>