From 2ba17d6f8d5f67c96d7d928845afed7f1e980da3 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Mon, 28 Oct 2024 10:41:24 -0600 Subject: [PATCH 1/3] Add copy checklist button --- src/js/lib/pages/github/issue.js | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/js/lib/pages/github/issue.js b/src/js/lib/pages/github/issue.js index a30f3951..8a8e3b70 100644 --- a/src/js/lib/pages/github/issue.js +++ b/src/js/lib/pages/github/issue.js @@ -22,6 +22,41 @@ function catchError(e) { }, 30000); } +/** + * Gets the contents of the reviewer checklist from GitHub and then posts it as a comment to the current PR + * @param {Event} e + */ +const copyReviewerChecklist = (e) => { + e.preventDefault(); + const pathToChecklist = 'https://raw.githubusercontent.com/Expensify/App/f1e20914e4a9f3065457048e6a396fa0c841b0ad/contributingGuides/BUGZERO_CHECKLIST.md'; + $.get(pathToChecklist) + .done((fileContents) => { + if (!fileContents) { + console.error(`could not load contents of ${pathToChecklist} for some reason`); + return; + } + + API.addComment(fileContents); + }); +}; + +const renderCopyChecklistButton = () => { + // Look through all the comments on the page to find one that has the template for the copy/paste checklist button + // eslint-disable-next-line rulesdir/prefer-underscore-method + $('.js-comment-body').each((i, el) => { + const commentHtml = $(el).html(); + + // When the button template is found, replace it with an HTML button and then put that back into the DOM so someone can click on it + if (commentHtml && commentHtml.indexOf('you can simply click: [this button]') > -1) { + const newHtml = commentHtml.replace('[this button]', ''); + $(el).html(newHtml); + + // Now that the button is on the page, add a click handler to it (always remove all handlers first so that we know there will always be one handler attached) + $('.k2-copy-checklist').off().on('click', copyReviewerChecklist); + } + }); +}; + /** * Sets the owner of an issue when it doesn't have an owner yet * @param {String} owner to set @@ -166,6 +201,9 @@ export default function () { refreshAssignees(); } }, 1000); + + // Waiting 2 seconds to call this gives the page enough time to load so that there is a better chance that all the comments will be rendered + setInterval(renderCopyChecklistButton, 2000); }; return IssuePage; From 7311b2690fb782b7fe1aa615d9133a7e6298781d Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Mon, 28 Oct 2024 10:42:59 -0600 Subject: [PATCH 2/3] Bump version --- CHANGELOG.md | 5 ++++- assets/manifest-firefox.json | 2 +- assets/manifest.json | 2 +- package-lock.json | 2 +- package.json | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8774f33e..19dccb35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ +#1.3.68 +- Added a button to GH issues to copy the bugzero checklist + #1.3.67 -- Added additional linting and CI for Firefox +- Added additional linting and CI for Firefox #1.3.66 - Added Firefox build script for Manifest V3 compatibility diff --git a/assets/manifest-firefox.json b/assets/manifest-firefox.json index ef2bac96..c5c5da81 100644 --- a/assets/manifest-firefox.json +++ b/assets/manifest-firefox.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "K2 for GitHub", - "version": "1.3.67", + "version": "1.3.68", "description": "Manage your Kernel Scheduling from directly inside GitHub", "browser_specific_settings": { diff --git a/assets/manifest.json b/assets/manifest.json index 697187f8..19bec158 100644 --- a/assets/manifest.json +++ b/assets/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "K2 for GitHub", - "version": "1.3.67", + "version": "1.3.68", "description": "Manage your Kernel Scheduling from directly inside GitHub", "icons": { diff --git a/package-lock.json b/package-lock.json index 0bbd88ee..a1b8acea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "k2-extension", - "version": "1.3.64", + "version": "1.3.68", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index a2829caf..3ebbcd8b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "k2-extension", - "version": "1.3.64", + "version": "1.3.68", "description": "A Chrome Extension for Kernel Schedule", "private": true, "scripts": { From b3c4b43b3a58246e1108c97c7788565251ae5e69 Mon Sep 17 00:00:00 2001 From: Tim Golen Date: Mon, 28 Oct 2024 10:49:43 -0600 Subject: [PATCH 3/3] Update PR now --- src/js/lib/pages/github/issue.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/lib/pages/github/issue.js b/src/js/lib/pages/github/issue.js index 8a8e3b70..a537ebc5 100644 --- a/src/js/lib/pages/github/issue.js +++ b/src/js/lib/pages/github/issue.js @@ -28,7 +28,7 @@ function catchError(e) { */ const copyReviewerChecklist = (e) => { e.preventDefault(); - const pathToChecklist = 'https://raw.githubusercontent.com/Expensify/App/f1e20914e4a9f3065457048e6a396fa0c841b0ad/contributingGuides/BUGZERO_CHECKLIST.md'; + const pathToChecklist = 'https://raw.githubusercontent.com/Expensify/App/main/contributingGuides/BUGZERO_CHECKLIST.md'; $.get(pathToChecklist) .done((fileContents) => { if (!fileContents) {