In patch list and patch detail pages.
Signed-off-by: Franciszek Stachura <[email protected]>
---
pkg/web/layout.templ | 1 +
pkg/web/patch.templ | 4 +++-
pkg/web/patches.templ | 6 ++++--
pkg/web/static/script.js | 15 +++++++++++++++
pkg/web/static/style.css | 8 ++++++++
5 files changed, 31 insertions(+), 3 deletions(-)
create mode 100644 pkg/web/static/script.js
diff --git a/pkg/web/layout.templ b/pkg/web/layout.templ
index 669e63d..929d03a 100644
--- a/pkg/web/layout.templ
+++ b/pkg/web/layout.templ
@@ -30,6 +30,7 @@ templ layout(title string, crumbs []breadcrumb, pc
pageContext) {
<meta name="viewport" content="width=device-width,
initial-scale=1"/>
<title>{ title } - Patchwork</title>
<link rel="stylesheet" href="/static/style.css"/>
+ <script src="/static/script.js"></script>
if pc.CustomCSS {
<link rel="stylesheet"
href="/static/custom.css"/>
}
diff --git a/pkg/web/patch.templ b/pkg/web/patch.templ
index af946e3..5f4df92 100644
--- a/pkg/web/patch.templ
+++ b/pkg/web/patch.templ
@@ -39,7 +39,9 @@ type patchDetailData struct {
templ downloadLinks(submissionid int, linkname, msgid string, series
*db.Series) {
<download-links>
- <button>{ submissionid }</button>
+ <button class="btn-copy" data-clipboard-text={ submissionid }
title="Copy to Clipboard">
+ { submissionid }
+ </button>
<a href={ templ.SafeURL(patchURL(linkname, msgid) + "/mbox")
}>mbox</a>
if series != nil {
<a href={ templ.SafeURL(fmt.Sprintf("/series/%d/mbox",
series.ID)) }>series</a>
diff --git a/pkg/web/patches.templ b/pkg/web/patches.templ
index 833664d..4090b3a 100644
--- a/pkg/web/patches.templ
+++ b/pkg/web/patches.templ
@@ -255,8 +255,10 @@ templ patchRow(d *patchListData, p *db.Patch) {
</td>
}
if d.User != nil && d.User.ShowIds {
- <td>
- { p.ID }
+ <td class="col-id">
+ <button type="button" class="btn-copy"
data-clipboard-text={ p.ID } title="Copy to Clipboard">
+ { p.ID }
+ </button>
</td>
}
<td>
diff --git a/pkg/web/static/script.js b/pkg/web/static/script.js
new file mode 100644
index 0000000..f3b71ea
--- /dev/null
+++ b/pkg/web/static/script.js
@@ -0,0 +1,15 @@
+/* Patchwork - automated patch tracking system
+ * Copyright (C) The Patchwork Contributors (see CONTRIBUTORS)
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later */
+
+"use strict";
+
+document.addEventListener("DOMContentLoaded", _ => {
+ document.querySelectorAll(".btn-copy")
+ .forEach(el => el.addEventListener("click", ev => {
+ let text = ev.target.getAttribute("data-clipboard-text");
+ let item = new ClipboardItem({["text/plain"]: text});
+ navigator.clipboard.write([item]);
+ }));
+});
diff --git a/pkg/web/static/style.css b/pkg/web/static/style.css
index 3e3fdd9..3269931 100644
--- a/pkg/web/static/style.css
+++ b/pkg/web/static/style.css
@@ -307,6 +307,14 @@ patch-list .checkbox {
text-align: center;
}
+.col-id > button {
+ border-radius: 3px;
+ padding: 1px 8px;
+ border: 1px solid #ccc;
+ background: #f5f5f5;
+ color: #555;
+}
+
/* --- patch actions --- */
patch-actions {
display: flex;
--
2.56.0
_______________________________________________
Patchwork mailing list
[email protected]
https://lists.ozlabs.org/listinfo/patchwork