[IMP] runbot_merge: add color key to freeze wizard

Was difficult to understand what the colors meant on the required PRs.

Part of #718
This commit is contained in:
Xavier Morel 2023-01-24 07:41:14 +01:00
parent 1cea247e6c
commit fb60c38731
4 changed files with 23 additions and 1 deletions

View File

@ -21,6 +21,7 @@
'runbot_merge/static/scss/runbot_merge.scss',
],
'web.assets_backend': [
'runbot_merge/static/scss/runbot_merge_backend.scss',
'runbot_merge/static/project_freeze/index.js',
],
},

View File

@ -6,6 +6,8 @@ import logging
import time
from collections import Counter
from markupsafe import Markup
from odoo import models, fields, api, Command
from odoo.exceptions import UserError
from odoo.addons.runbot_merge.exceptions import FastForwardError
@ -25,6 +27,17 @@ class FreezeWizard(models.Model):
help="Pull requests which must have been merged before the freeze is allowed",
)
pr_state_key = fields.Html(string="Color Key", compute='_compute_state_key', readonly=True)
def _compute_state_key(self):
s = dict(self.env['runbot_merge.pull_requests']._fields['state'].selection)
self.pr_state_key = Markup("""
<p>%s</p>
""") % Markup(" ").join(
Markup('<span class="badge border-0 fucking_color_key_{}">{}</span>').format(v, s[k])
for k, v in STATE_COLORMAP.items()
if v
)
release_label = fields.Char(
string="Find by label",
help="Setting a (complete) PR label will automatically find and "
@ -411,7 +424,7 @@ STATE_COLORMAP = {
'merged': Colors.Green,
'error': Colors.Red,
}
class PullRequestColor(models.Model):
class PullRequest(models.Model):
_inherit = 'runbot_merge.pull_requests'
state_color = fields.Integer(compute='_compute_state_color')

View File

@ -14,6 +14,7 @@
<field name="branch_name"/>
<field name="required_pr_ids" widget="many2many_tags"
options="{'color_field': 'state_color', 'no_create': True}"/>
<field name="pr_state_key" readonly="1"/>
</group>
</group>
<group string="Release">

View File

@ -0,0 +1,7 @@
@for $item from 2 through length($o-colors) {
.fucking_color_key_#{$item - 1} {
$background-color: nth($o-colors, $item);
color: color-contrast($background-color);
background-color: $background-color;
}
}