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

Add a copy bugzero checklist button to GH issues #200

Merged
merged 3 commits into from
Oct 28, 2024
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion assets/manifest-firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion assets/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
38 changes: 38 additions & 0 deletions src/js/lib/pages/github/issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/main/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]', '<button type="button" class="btn btn-sm k2-copy-checklist">HERE</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
Expand Down Expand Up @@ -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;
Expand Down
Loading