Skip to content

Commit 1e46c34

Browse files
committed
[WIP] runbot: migrate frontend to interactions api
1 parent f4459ba commit 1e46c34

File tree

5 files changed

+105
-43
lines changed

5 files changed

+105
-43
lines changed

runbot/__manifest__.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,48 @@
7979

8080
'runbot/static/lib/jquery/jquery.js',
8181
'runbot/static/lib/bootstrap/js/bootstrap.bundle.js',
82-
'runbot/static/src/js/runbot.js',
82+
83+
'web/static/src/module_loader.js',
84+
'web/static/lib/owl/owl.js',
85+
'web/static/lib/owl/odoo_module.js',
86+
'web/static/lib/luxon/luxon.js',
87+
'web/static/src/env.js',
88+
'web/static/src/session.js',
89+
'web/static/src/core/registry.js',
90+
'web/static/src/core/templates.js',
91+
'web/static/src/core/template_inheritance.js',
92+
'web/static/src/core/user.js',
93+
'web/static/src/core/browser/browser.js',
94+
'web/static/src/core/browser/cookie.js',
95+
'web/static/src/core/browser/feature_detection.js',
96+
'web/static/src/core/network/rpc.js',
97+
'web/static/src/core/utils/arrays.js',
98+
'web/static/src/core/utils/cache.js',
99+
'web/static/src/core/utils/concurrency.js',
100+
'web/static/src/core/utils/functions.js',
101+
'web/static/src/core/utils/html.js',
102+
'web/static/src/core/utils/hooks.js',
103+
'web/static/src/core/utils/objects.js',
104+
'web/static/src/core/utils/indexed_db.js',
105+
'web/static/src/core/utils/render.js',
106+
'web/static/src/core/utils/timing.js',
107+
'web/static/src/core/utils/ui.js',
108+
'web/static/src/core/utils/urls.js',
109+
'web/static/src/core/utils/strings.js',
110+
'web/static/src/core/l10n/dates.js',
111+
'web/static/src/core/l10n/translation.js',
112+
'web/static/src/core/l10n/localization.js',
113+
'web/static/src/core/l10n/localization_service.js',
114+
'web/static/src/core/l10n/utils.js',
115+
'web/static/src/core/l10n/utils/format_list.js',
116+
'web/static/src/core/l10n/utils/locales.js',
117+
'web/static/src/core/l10n/utils/normalize.js',
118+
'web/static/src/public/interaction.js',
119+
'web/static/src/public/utils.js',
120+
'web/static/src/public/colibri.js',
121+
'web/static/src/public/interaction_service.js',
122+
'runbot/static/src/public/interactions/**/*',
123+
'runbot/static/src/public/main.js',
83124
],
84125
},
85126
'post_load': 'runbot_post_load',

runbot/static/src/js/runbot.js

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { registry } from "@web/core/registry";
2+
import { Interaction } from "@web/public/interaction";
3+
4+
class Runbot extends Interaction {
5+
static selector = ".runbot-public";
6+
dynamicContent = {
7+
"[data-runbot]": {
8+
"t-on-click.prevent": this.onClickDataRunbot,
9+
},
10+
"[data-clipboard-copy]": {
11+
"t-on-click.prevent": this.onClickClipboardCopy
12+
}
13+
};
14+
15+
/**
16+
* @param {Event} ev
17+
*/
18+
async onClickDataRunbot({ currentTarget }) {
19+
const { runbot: operation, runbotBuild } = currentTarget.dataset;
20+
if (!operation) {
21+
return;
22+
}
23+
let url = currentTarget.href;
24+
if (runbotBuild) {
25+
url = `/runbot/build/${runbotBuild}/${operation}`;
26+
}
27+
const response = await fetch(url, {
28+
method: "POST",
29+
});
30+
const responseText = await response.text();
31+
if (operation === "rebuild" && window.location.pathname.endsWith(`/build/${runbotBuild}`)) {
32+
const currentURL = new URL(window.location.href);
33+
currentURL.pathname = `/build/${responseText}`;
34+
window.location.href = currentURL.toString();
35+
} else if (operation === "action") {
36+
currentTarget.parentElement.innerText = responseText;
37+
} else {
38+
window.location.reload();
39+
}
40+
}
41+
42+
/**
43+
* @param {Event} ev
44+
*/
45+
async onClickClipboardCopy({ currentTarget }) {
46+
navigator.clipboard.writeText(currentTarget.dataset.clipboardCopy);
47+
}
48+
}
49+
50+
registry.category("public.interactions").add("runbot", Runbot);

runbot/static/src/public/main.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { whenReady } from "@odoo/owl";
2+
import { makeEnv, startServices } from "@web/env";
3+
4+
export async function start() {
5+
await whenReady();
6+
7+
const env = makeEnv();
8+
await startServices(env);
9+
}
10+
11+
start();

runbot/templates/utils.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
<template id="runbot.layout" inherit_id="runbot.base_page" primary="True">
4545
<xpath expr="//body" position="replace">
46-
<body>
46+
<body class="runbot-public">
4747
<header>
4848
<nav class="navbar navbar-expand-md bg-body-tertiary">
4949
<a t-if="project" t-att-href="qu(search='')">
@@ -423,7 +423,7 @@
423423
</template>
424424

425425
<template id="runbot.branch_copy_button">
426-
<button t-attf-class="btn btn-default {{btn_size or 'btn-ssm'}}" title="Copy Bundle name" aria-label="Copy Bundle name" t-attf-onclick="copyToClipboard('{{ bundle.name.split(':')[-1] }}')">
426+
<button t-attf-class="btn btn-default {{btn_size or 'btn-ssm'}}" title="Copy Bundle name" aria-label="Copy Bundle name" t-attf-data-clipboard-copy="{{ bundle.name.split(':')[-1] }}">
427427
<i t-attf-class="fa fa-clipboard"/>
428428
</button>
429429
</template>

0 commit comments

Comments
 (0)