[FIX] runbot_merge: dashboard display nits

- fix staging reasons containing escaped quotes (would render as
  ` ` to the end user)
- remove extra spacing around PR title @title/popovers
- simplify a few view conditionals through judicious use of `t-elif`
  and nesting
- make `staging_end` non-computed as it's not computed anymore, just
  set if and when the staging gets disabled
  (146564a90a)
This commit is contained in:
Xavier Morel 2024-09-27 14:13:43 +02:00
parent 430ccab2cb
commit aac987f2bb
2 changed files with 21 additions and 23 deletions

View File

@ -2048,7 +2048,7 @@ class Stagings(models.Model):
active = fields.Boolean(default=True) active = fields.Boolean(default=True)
staged_at = fields.Datetime(default=fields.Datetime.now, index=True) staged_at = fields.Datetime(default=fields.Datetime.now, index=True)
staging_end = fields.Datetime(store=True, compute='_compute_state') staging_end = fields.Datetime(store=True)
staging_duration = fields.Float(compute='_compute_duration') staging_duration = fields.Float(compute='_compute_duration')
timeout_limit = fields.Datetime(store=True, compute='_compute_timeout_limit') timeout_limit = fields.Datetime(store=True, compute='_compute_timeout_limit')
reason = fields.Text("Reason for final state (if any)") reason = fields.Text("Reason for final state (if any)")

View File

@ -5,21 +5,18 @@
</function> </function>
<template id="link-pr" name="create a link to `pr`"> <template id="link-pr" name="create a link to `pr`">
<t t-set="title"
t-value="pr.message.split('\n', 1)[0] if pr.repository.group_id &lt;= env.user.groups_id else ''"/>
<t t-set="title"> <t t-set="title">
<t t-if="pr.repository.group_id &lt;= env.user.groups_id"> <t t-if="title and pr.blocked" >
<t t-out="pr.message.split('\n', 1)[0]"/> <t t-out="title"/>: <t t-out="pr.blocked"/>
</t>
</t>
<t t-set="title">
<t t-if="title.strip() and pr.blocked" >
<t t-out="title.strip()"/>: <t t-out="pr.blocked"/>
</t> </t>
<t t-else=""> <t t-else="">
<t t-out="pr.blocked or title.strip()"/> <t t-out="pr.blocked or title"/>
</t> </t>
</t> </t>
<a t-attf-href="https://github.com/{{ pr.repository.name }}/pull/{{ pr.number }}" <a t-attf-href="https://github.com/{{ pr.repository.name }}/pull/{{ pr.number }}"
t-att-title="title" t-att-title="title.strip()"
t-att-target="target or None" t-att-target="target or None"
t-att-class="classes or None" t-att-class="classes or None"
><t t-esc="pr.display_name"/></a> ><t t-esc="pr.display_name"/></a>
@ -177,14 +174,15 @@
<t t-if="staging_index >= 4">d-none d-lg-block</t> <t t-if="staging_index >= 4">d-none d-lg-block</t>
</t> </t>
<t t-set="title"> <t t-set="title">
<t t-if="staging.state == 'ff_failed'">fast forward failed (<t t-esc="staging.reason"/>)</t> <t t-if="staging.state == 'success'"/>
<t t-if="staging.state == 'pending'">last status</t> <t t-else="">
<t t-if="staging.state == 'pending'">last status</t
><t t-elif="staging.state == 'ff_failed'">fast forward failed (<t t-out="(staging.reason or '').replace('\'', '')"/>)</t
><t t-else="" t-out="(staging.reason or '').replace('\'', '')"
/> at <t t-out="(staging.staging_end or staging.write_date).replace(microsecond=0)"/>Z
</t>
</t> </t>
<!-- separate concatenation to avoid having line-break in title as some browsers trigger it --> <li t-attf-class="staging {{stateclass.strip()}} {{decorationclass.strip()}}" t-att-title="title.strip() or None">
<!-- write-date may have microsecond precision, strip that information -->
<!-- use write-date under assumption that a staging is last modified when it ends -->
<t t-set="title"><t t-esc="title.strip() or staging.reason"/> at <t t-esc="staging.write_date.replace(microsecond=0)"/>Z</t>
<li t-attf-class="staging {{stateclass.strip()}} {{decorationclass.strip()}}" t-att-title="title">
<ul class="list-unstyled"> <ul class="list-unstyled">
<li t-foreach="staging.batch_ids" t-as="batch" class="batch"> <li t-foreach="staging.batch_ids" t-as="batch" class="batch">
<t t-esc="batch.prs[:1].label"/> <t t-esc="batch.prs[:1].label"/>
@ -241,14 +239,14 @@
</t> </t>
</t> </t>
<t t-set="title"> <t t-set="title">
<t t-if="staging.state == 'canceled'">Cancelled: <t t-if="staging.state == 'ff_failed'">
<t t-esc="staging.reason"/> Fast Forward Failed
</t> </t>
<t t-if="staging.state == 'ff_failed'">Fast <t t-elif="staging.state == 'canceled'">
Forward Failed Cancelled<t t-if="staging.reason">: <t t-out="staging.reason.replace('\'', '')"/></t>
</t> </t>
<t t-if="staging.state not in ('canceled', 'ff_failed')"> <t t-else="">
<t t-esc="staging.reason"/> <t t-out="(staging.reason or '').replace('\'', '')"/>
</t> </t>
</t> </t>
<tr t-att-class="stateclass" <tr t-att-class="stateclass"