mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 15:35:46 +07:00
[IMP] runbot: add a widget for pull requests url's
While it's useful to have a clickable link to the fixing pull request on the runbot error list, we cannot display the entire url as it takes too much space. So a static text `View PR` is used. As this static text is of limited use, this commit adds a new widget that displays a shortened URL for the github pull request only showing the repo and the PR number.
This commit is contained in:
parent
1add8d56f5
commit
5d99d535ec
@ -14,6 +14,7 @@ import { useRef, xml, Component } from "@odoo/owl";
|
||||
import { useAutoresize } from "@web/core/utils/autoresize";
|
||||
import { getFormattedValue } from "@web/views/utils";
|
||||
|
||||
import { UrlField } from "@web/views/fields/url/url_field";
|
||||
|
||||
function stringify(obj) {
|
||||
return JSON.stringify(obj, null, '\t')
|
||||
@ -135,6 +136,29 @@ registry.category("fields").add("char_frontend_url", {
|
||||
component: FieldCharFrontendUrl,
|
||||
});
|
||||
|
||||
|
||||
// Pull Request URL Widget
|
||||
class PullRequestUrlField extends UrlField {
|
||||
static template = xml`
|
||||
<a class="o_field_widget o_form_uri" t-on-click.stop="" t-att-href="formattedHref" t-esc="props.record.data[props.name].replace('https://github.com/odoo','').replace('/pull','') || ''" target="_blank"/>
|
||||
`;
|
||||
static components = { UrlField }
|
||||
setup() {
|
||||
if (!this.props.readonly) {
|
||||
throw new Error("This widget works only on readonly fields");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PullRequestUrlField.supportedTypes = ["char"];
|
||||
|
||||
|
||||
registry.category("fields").add("pull_request_url", {
|
||||
supportedTypes: ["char"],
|
||||
component: PullRequestUrlField,
|
||||
});
|
||||
|
||||
|
||||
//export class GithubTeamWidget extends CharField {
|
||||
|
||||
//this.value.split(',').forEach((value) => {
|
||||
|
@ -33,7 +33,7 @@
|
||||
<field name="customer"/>
|
||||
<field name="team_id"/>
|
||||
<field name="fixing_pr_id"/>
|
||||
<field name="fixing_pr_url" widget="url"/>
|
||||
<field name="fixing_pr_url" widget="pull_request_url"/>
|
||||
<field name="active"/>
|
||||
<field name="test_tags" decoration-danger="True" readonly="1" groups="!runbot.group_runbot_admin"/>
|
||||
<field name="test_tags" decoration-danger="True" groups="runbot.group_runbot_admin"/>
|
||||
@ -236,7 +236,7 @@
|
||||
<field name="tags_max_version_id" string="Tags Max" optional="hide"/>
|
||||
<field name="fixing_pr_id" optional="hide"/>
|
||||
<field name="fixing_pr_alive" optional="hide"/>
|
||||
<field name="fixing_pr_url" widget="url" text="view PR" readonly="1" invisible="not fixing_pr_url"/>
|
||||
<field name="fixing_pr_url" widget="pull_request_url" text="view PR" readonly="1" invisible="not fixing_pr_url"/>
|
||||
</list>
|
||||
</field>
|
||||
</record>
|
||||
|
Loading…
Reference in New Issue
Block a user