Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion runbot/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,48 @@

'runbot/static/lib/jquery/jquery.js',
'runbot/static/lib/bootstrap/js/bootstrap.bundle.js',
'runbot/static/src/js/runbot.js',

'web/static/src/module_loader.js',
'web/static/lib/owl/owl.js',
'web/static/lib/owl/odoo_module.js',
'web/static/lib/luxon/luxon.js',
'web/static/src/env.js',
'web/static/src/session.js',
'web/static/src/core/registry.js',
'web/static/src/core/templates.js',
'web/static/src/core/template_inheritance.js',
'web/static/src/core/user.js',
'web/static/src/core/browser/browser.js',
'web/static/src/core/browser/cookie.js',
'web/static/src/core/browser/feature_detection.js',
'web/static/src/core/network/rpc.js',
'web/static/src/core/utils/arrays.js',
'web/static/src/core/utils/cache.js',
'web/static/src/core/utils/concurrency.js',
'web/static/src/core/utils/functions.js',
'web/static/src/core/utils/html.js',
'web/static/src/core/utils/hooks.js',
'web/static/src/core/utils/objects.js',
'web/static/src/core/utils/indexed_db.js',
'web/static/src/core/utils/render.js',
'web/static/src/core/utils/timing.js',
'web/static/src/core/utils/ui.js',
'web/static/src/core/utils/urls.js',
'web/static/src/core/utils/strings.js',
'web/static/src/core/l10n/dates.js',
'web/static/src/core/l10n/translation.js',
'web/static/src/core/l10n/localization.js',
'web/static/src/core/l10n/localization_service.js',
'web/static/src/core/l10n/utils.js',
'web/static/src/core/l10n/utils/format_list.js',
'web/static/src/core/l10n/utils/locales.js',
'web/static/src/core/l10n/utils/normalize.js',
'web/static/src/public/interaction.js',
'web/static/src/public/utils.js',
'web/static/src/public/colibri.js',
'web/static/src/public/interaction_service.js',
'runbot/static/src/public/interactions/**/*',
'runbot/static/src/public/main.js',
],
},
'post_load': 'runbot_post_load',
Expand Down
40 changes: 0 additions & 40 deletions runbot/static/src/js/runbot.js

This file was deleted.

50 changes: 50 additions & 0 deletions runbot/static/src/public/interactions/runbot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { registry } from "@web/core/registry";
import { Interaction } from "@web/public/interaction";

class Runbot extends Interaction {
static selector = ".runbot-public";
dynamicContent = {
"[data-runbot]": {
"t-on-click.prevent": this.onClickDataRunbot,
},
"[data-clipboard-copy]": {
"t-on-click.prevent": this.onClickClipboardCopy
}
};

/**
* @param {Event} ev
*/
async onClickDataRunbot({ currentTarget }) {
const { runbot: operation, runbotBuild } = currentTarget.dataset;
if (!operation) {
return;
}
let url = currentTarget.href;
if (runbotBuild) {
url = `/runbot/build/${runbotBuild}/${operation}`;
}
const response = await fetch(url, {
method: "POST",
});
const responseText = await response.text();
if (operation === "rebuild" && window.location.pathname.endsWith(`/build/${runbotBuild}`)) {
const currentURL = new URL(window.location.href);
currentURL.pathname = `/build/${responseText}`;
window.location.href = currentURL.toString();
} else if (operation === "action") {
currentTarget.parentElement.innerText = responseText;
} else {
window.location.reload();
}
}

/**
* @param {Event} ev
*/
async onClickClipboardCopy({ currentTarget }) {
navigator.clipboard.writeText(currentTarget.dataset.clipboardCopy);
}
}

registry.category("public.interactions").add("runbot", Runbot);
11 changes: 11 additions & 0 deletions runbot/static/src/public/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { whenReady } from "@odoo/owl";
import { makeEnv, startServices } from "@web/env";

export async function start() {
await whenReady();

const env = makeEnv();
await startServices(env);
}

start();
4 changes: 2 additions & 2 deletions runbot/templates/utils.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

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

<template id="runbot.branch_copy_button">
<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] }}')">
<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] }}">
<i t-attf-class="fa fa-clipboard"/>
</button>
</template>
Expand Down