Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autofill new patch description based on selected thread #30

Merged
merged 1 commit into from
Feb 15, 2025
Merged
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
28 changes: 27 additions & 1 deletion media/commitfest/js/commitfest.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function findLatestThreads() {
sel.append(
$("<option/>")
.text(`${i.from}: ${i.subj} (${i.date})`)
.data("subject", i.subj)
.val(i.msgid),
);
});
Expand Down Expand Up @@ -60,12 +61,18 @@ function browseThreads(attachfunc, closefunc) {
if (!msgid || msgid === "") {
msgid = $("#attachThreadList").val();
if (!msgid) return;
subject = $("#attachThreadList option:selected").data("subject");
subject = subject.replace(/\bre: /gi, "");
subject = subject.replace(/\bfwd: /gi, "");
// Strips [PATCH], [POC], etc. prefixes
subject = subject.replace(/\[\w+\]: /gi, "");
subject = subject.replace(/\[\w+\] /gi, "");
}

$("#attachThreadListWrap").addClass("loading");
$("#attachThreadSearchButton").addClass("disabled");
$("#attachThreadButton").addClass("disabled");
if (attachfunc(msgid)) {
if (attachfunc(msgid, subject)) {
$("#attachModal").modal("hide");
}
$("#attachThreadListWrap").removeClass("loading");
Expand Down Expand Up @@ -351,3 +358,22 @@ git fetch commitfest cf/${patchId}
git checkout commitfest/cf/${patchId}
`);
}

/* Build our button callbacks */
$(document).ready(() => {
$("button.attachThreadButton").each((i, o) => {
const b = $(o);
b.click(() => {
$("#attachThreadAttachOnly").val("1");
browseThreads((msgid, subject) => {
b.prev().val(msgid);
const description_field = $("#id_name");
if (description_field.val() === "") {
description_field.val(subject);
}
return true;
});
return false;
});
});
});
15 changes: 0 additions & 15 deletions pgcommitfest/commitfest/templates/base_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,5 @@ <h3>Search user</h3>
$('#searchUserSearchField').focus();
});
{%endif%}

/* Build our button callbacks */
$(document).ready(function() {
$('button.attachThreadButton').each(function (i,o) {
var b = $(o);
b.click(function() {
$('#attachThreadAttachOnly').val('1');
browseThreads(function(msgid) {
b.prev().val(msgid);
return true;
});
return false;
});
});
});
</script>
{%endblock%}