Skip to content

Commit 6c45fac

Browse files
committed
[REF] runbot: rewrite copy button
1 parent 0c9dc02 commit 6c45fac

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

runbot/__manifest__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@
8383
'runbot/static/lib/jquery/jquery.js',
8484
'runbot/static/lib/bootstrap/js/bootstrap.bundle.js',
8585

86-
# legacy
87-
'runbot/static/src/js/runbot.js',
88-
8986
# module loader
9087
'web/static/src/module_loader.js',
9188
'runbot/static/src/public/**/*',

runbot/static/src/js/runbot.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

runbot/static/src/public/runbot.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export class Runbot extends DelegatedInteractionLite {
77
"[data-runbot]": {
88
"t-on-click.prevent": this.onDataRunbotClick,
99
},
10+
"[data-clipboard-copy]": {
11+
"t-on-click": this.onClipboardCopy,
12+
},
1013
};
1114

1215
async onDataRunbotClick({ delegatedTarget }) {
@@ -36,4 +39,12 @@ export class Runbot extends DelegatedInteractionLite {
3639
window.location.reload();
3740
}
3841
}
42+
43+
onClipboardCopy({ delegatedTarget }) {
44+
if (!navigator.clipboard) {
45+
console.warn("Clipboard not supported");
46+
return;
47+
}
48+
navigator.clipboard.writeText(delegatedTarget.dataset.clipboardCopy);
49+
}
3950
}

runbot/templates/utils.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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-att-data-clipboard-copy="bundle.name.split(':')[-1]">
427427
<i t-attf-class="fa fa-clipboard"/>
428428
</button>
429429
</template>

0 commit comments

Comments
 (0)