mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[IMP] runbot_merge: backend UI
- Update branch name to prefix with project as it can be hard to differentiate when filtering by or trying to set targets, given some targets are extremely common (e.g. `master`/`main`) and not all fields are filtered by project (or even can be). - Add a proper menu item and list view for batches, maybe it'll be of use one day. - Upgrade label in PR search, it's more likely to be needed than author or target. - Put PRs first in the mergebot menu, as it's *by far* the most likely item to look for, unless it's staging in order to cancel one.
This commit is contained in:
parent
47df8fac84
commit
7a0a6d4415
@ -52,8 +52,9 @@ class Batch(models.Model):
|
|||||||
_description = "batch of pull request"
|
_description = "batch of pull request"
|
||||||
_inherit = ['mail.thread']
|
_inherit = ['mail.thread']
|
||||||
_parent_store = True
|
_parent_store = True
|
||||||
|
_order = "id desc"
|
||||||
|
|
||||||
name = fields.Char(compute="_compute_name")
|
name = fields.Char(compute="_compute_name", search="_search_name")
|
||||||
target = fields.Many2one('runbot_merge.branch', store=True, compute='_compute_target')
|
target = fields.Many2one('runbot_merge.branch', store=True, compute='_compute_target')
|
||||||
batch_staging_ids = fields.One2many('runbot_merge.staging.batch', 'runbot_merge_batch_id')
|
batch_staging_ids = fields.One2many('runbot_merge.staging.batch', 'runbot_merge_batch_id')
|
||||||
staging_ids = fields.Many2many(
|
staging_ids = fields.Many2many(
|
||||||
@ -183,6 +184,9 @@ class Batch(models.Model):
|
|||||||
for batch in self:
|
for batch in self:
|
||||||
batch.name = batch.prs[:1].label or batch.all_prs[:1].label
|
batch.name = batch.prs[:1].label or batch.all_prs[:1].label
|
||||||
|
|
||||||
|
def _search_name(self, operator, value):
|
||||||
|
return [('all_prs.label', operator, value)]
|
||||||
|
|
||||||
@api.depends("all_prs.target")
|
@api.depends("all_prs.target")
|
||||||
def _compute_target(self):
|
def _compute_target(self):
|
||||||
for batch in self:
|
for batch in self:
|
||||||
|
@ -284,7 +284,13 @@ class Branch(models.Model):
|
|||||||
self._table, ['name', 'project_id'])
|
self._table, ['name', 'project_id'])
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.depends('active')
|
def name_get(self):
|
||||||
|
return [
|
||||||
|
(id, f"{b.project_id.name}:{name}")
|
||||||
|
for b, (id, name) in zip(self, super().name_get())
|
||||||
|
]
|
||||||
|
|
||||||
|
@api.depends('active', 'project_id.name')
|
||||||
def _compute_display_name(self):
|
def _compute_display_name(self):
|
||||||
super()._compute_display_name()
|
super()._compute_display_name()
|
||||||
for b in self.filtered(lambda b: not b.active):
|
for b in self.filtered(lambda b: not b.active):
|
||||||
|
@ -770,7 +770,7 @@ def test_ff_failure_batch(env, repo, users, config):
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TestPREdition:
|
class TestPREdition:
|
||||||
def test_edit(self, env, repo, config):
|
def test_edit(self, env, project, repo, config):
|
||||||
""" Editing PR:
|
""" Editing PR:
|
||||||
|
|
||||||
* title (-> message)
|
* title (-> message)
|
||||||
@ -814,7 +814,7 @@ class TestPREdition:
|
|||||||
assert pr.target == branch_1
|
assert pr.target == branch_1
|
||||||
assert not pr.staging_id, "updated the base of a staged PR should have unstaged it"
|
assert not pr.staging_id, "updated the base of a staged PR should have unstaged it"
|
||||||
assert st.state == 'cancelled', f"expected cancellation, got {st.state}"
|
assert st.state == 'cancelled', f"expected cancellation, got {st.state}"
|
||||||
assert st.reason == f"{pr.display_name} target (base) branch was changed from 'master' to '1.0'"
|
assert st.reason == f"{pr.display_name} target (base) branch was changed from '{project.name}:master' to '{project.name}:1.0'"
|
||||||
|
|
||||||
with repo: prx.base = '2.0'
|
with repo: prx.base = '2.0'
|
||||||
assert not pr.exists()
|
assert not pr.exists()
|
||||||
|
@ -1,4 +1,40 @@
|
|||||||
<odoo>
|
<odoo>
|
||||||
|
<record id="runbot_merge_action_batches" model="ir.actions.act_window">
|
||||||
|
<field name="name">Batches</field>
|
||||||
|
<field name="res_model">runbot_merge.batch</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="runbot_merge_batch_search" model="ir.ui.view">
|
||||||
|
<field name="name">batches search</field>
|
||||||
|
<field name="model">runbot_merge.batch</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<search>
|
||||||
|
<filter name="all" domain="['|', ('active', '=', True), ('active', '=', False)]"/>
|
||||||
|
<filter name="inactive" domain="[('active', '=', False)]"/>
|
||||||
|
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="target"/>
|
||||||
|
<field name="id"/>
|
||||||
|
</search>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="runbot_merge_batch_tree" model="ir.ui.view">
|
||||||
|
<field name="name">batches list</field>
|
||||||
|
<field name="model">runbot_merge.batch</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree decoration-muted="not active">
|
||||||
|
<field name="id"/>
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="target"/>
|
||||||
|
<field name="prs" widget="many2many_tags"/>
|
||||||
|
<field name="blocked"/>
|
||||||
|
<field name="active" invisible="1"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record id="runbot_merge_batch_form" model="ir.ui.view">
|
<record id="runbot_merge_batch_form" model="ir.ui.view">
|
||||||
<field name="name">Batch form</field>
|
<field name="name">Batch form</field>
|
||||||
<field name="model">runbot_merge.batch</field>
|
<field name="model">runbot_merge.batch</field>
|
||||||
|
@ -88,9 +88,9 @@
|
|||||||
name="open" string="Open"
|
name="open" string="Open"
|
||||||
domain="[('state', 'not in', ['merged', 'closed'])]"
|
domain="[('state', 'not in', ['merged', 'closed'])]"
|
||||||
/>
|
/>
|
||||||
|
<field name="label"/>
|
||||||
<field name="number"/>
|
<field name="number"/>
|
||||||
<field name="author"/>
|
<field name="author"/>
|
||||||
<field name="label"/>
|
|
||||||
<field name="target"/>
|
<field name="target"/>
|
||||||
<field name="repository"/>
|
<field name="repository"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
@ -416,17 +416,16 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<menuitem name="Mergebot" id="runbot_merge_menu"/>
|
<menuitem name="Mergebot" id="runbot_merge_menu">
|
||||||
<menuitem name="Projects" id="runbot_merge_menu_project"
|
|
||||||
parent="runbot_merge_menu"
|
|
||||||
action="runbot_merge_action_projects"/>
|
|
||||||
<menuitem name="Pull Requests" id="runbot_merge_menu_prs"
|
<menuitem name="Pull Requests" id="runbot_merge_menu_prs"
|
||||||
parent="runbot_merge_menu"
|
action="runbot_merge_action_prs" sequence="5"/>
|
||||||
action="runbot_merge_action_prs"/>
|
|
||||||
<menuitem name="Stagings" id="runbot_merge_menu_stagings"
|
<menuitem name="Stagings" id="runbot_merge_menu_stagings"
|
||||||
parent="runbot_merge_menu"
|
action="runbot_merge_action_stagings" sequence="8"/>
|
||||||
action="runbot_merge_action_stagings"/>
|
<menuitem name="Projects" id="runbot_merge_menu_project"
|
||||||
|
action="runbot_merge_action_projects"/>
|
||||||
|
<menuitem name="Batches" id="runbot_merge_menu_batches"
|
||||||
|
action="runbot_merge_action_batches"/>
|
||||||
<menuitem name="Commits" id="runbot_merge_menu_commits"
|
<menuitem name="Commits" id="runbot_merge_menu_commits"
|
||||||
parent="runbot_merge_menu"
|
|
||||||
action="runbot_merge_action_commits"/>
|
action="runbot_merge_action_commits"/>
|
||||||
|
</menuitem>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
Loading…
Reference in New Issue
Block a user