[ADD] runbot_merge: staging history per branch

Closes #175
This commit is contained in:
xmo-odoo 2019-08-21 14:15:10 +02:00 committed by GitHub
parent a84595ea04
commit c4b7604999
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 100 additions and 2 deletions

View File

@ -1,10 +1,23 @@
# -*- coding: utf-8 -*-
from odoo.http import Controller, route, request
LIMIT = 20
class MergebotDashboard(Controller):
@route('/runbot_merge', auth="public", type="http", website=True)
def dashboard(self):
return request.render('runbot_merge.dashboard', {
'projects': request.env['runbot_merge.project'].with_context(active_test=False).sudo().search([]),
})
@route('/runbot_merge/<int:branch_id>', auth='public', type='http', website=True)
def stagings(self, branch_id, until=None):
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)
return request.render('runbot_merge.branch_stagings', {
'branch': request.env['runbot_merge.branch'].browse(branch_id).sudo(),
'stagings': stagings[:LIMIT],
'next': stagings[-1].staged_at if len(stagings) > LIMIT else None,
})

View File

@ -45,7 +45,11 @@
</ul>
</div>
<section t-foreach="project.branch_ids" t-as="branch" t-if="branch.active" class="col-md-12">
<h2><t t-esc="branch.name"/></h2>
<h2>
<a t-attf-href="/runbot_merge/{{branch.id}}">
<t t-esc="branch.name"/>
</a>
</h2>
<t t-call="runbot_merge.stagings"/>
<t t-set="ready_unstaged" t-value="
project.env['runbot_merge.pull_requests'].search([
@ -160,4 +164,85 @@
</t>
</ul>
</template>
<template id="branch_stagings" name="mergebot stagings page">
<t t-call="website.layout">
<div id="wrap"><div class="container-fluid">
<section class="row">
<h1 class="col-md-12"><t t-esc="branch.project_id.name"/>: <t t-esc="branch.name"/></h1>
</section>
<t t-foreach="stagings" t-as="staging">
<t t-set="success" t-value="staging.state == 'success'"/>
<t t-set="failure" t-value="staging.state == 'failure'"/>
<t t-set="pending" t-value="staging.active and (not staging.state or staging.state == 'pending')"/>
<t t-set="stateclass">
<t t-if="success">bg-success</t>
<t t-if="failure">bg-danger</t>
<t t-if="pending">bg-info</t>
<t t-if="not (success or failure or pending)">bg-gray-lighter</t>
</t>
<t t-set="title">
<t t-if="staging.state == 'canceled'">Cancelled: <t t-esc="staging.reason"/></t>
<t t-if="staging.state == 'ff_failed'">Fast Forward Failed</t>
<t t-if="staging.state not in ('canceled', 'ff_failed')"><t t-esc="staging.reason"/></t>
</t>
<ul
t-attf-class="row border-bottom {{stateclass}} list-inline list-unstyled mb0"
t-att-title="title.strip() or None"
style="border-bottom: 1px solid gainsboro"
>
<t t-if="staging.heads">
<li class="dropdown">
<button class="btn btn-link dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span t-field="staging.staged_at" t-options="{'widget': 'text'}"/>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li groups="runbot_merge.group_admin">
<a t-attf-href="/web#id={{staging.id}}&amp;view_type=form&amp;model=runbot_merge.stagings" target="new">
Open Staging
</a>
</li>
<li t-foreach="staging.statuses" t-as="st" t-if="st[3]"
t-att-class="
'bg-success' if st[2] == 'success'
else 'bg-danger' if st[2] in ('error', 'failure')
else 'bg-info'"
>
<a t-att-href="st[3]" target="new">
<t t-esc="st[0]"/>: <t t-esc="st[1]"/>
</a>
</li>
</ul>
</li>
</t>
<t t-foreach="staging.batch_ids" t-as="batch">
<t t-set="first_pr" t-value="batch.prs[-1]"/>
<li class="dropdown">
<button class="btn btn-link dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"
t-att-title="first_pr.message.split('\n')[0]"
>
<t t-esc="first_pr.label"/>
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li t-foreach="batch.prs" t-as="pr">
<a t-attf-href="https://github.com/{{ pr.repository.name }}/pull/{{ pr.number }}"
t-att-title="pr.message.split('\n')[0]"
target="new">
<t t-esc="pr.repository.name"/>#<t t-esc="pr.number"/>
</a>
</li>
</ul>
</li>
</t>
</ul>
</t>
<t t-if="next">
<a t-attf-href="/runbot_merge/{{branch.id}}?until={{next}}">
Next >
</a>
</t>
</div></div>
</t>
</template>
</odoo>