mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
[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:
parent
1cea247e6c
commit
fb60c38731
@ -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',
|
||||
],
|
||||
},
|
||||
|
@ -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')
|
||||
|
@ -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">
|
||||
|
7
runbot_merge/static/scss/runbot_merge_backend.scss
Normal file
7
runbot_merge/static/scss/runbot_merge_backend.scss
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user