Skip to content

Commit

Permalink
Add re-request-review command (#1)
Browse files Browse the repository at this point in the history
# Description

This PR adds new functionality to this extension, now when browsing the github site you can request review for all reviewers who previously requested changes to a PR.

## Usage

Press the `Alt+R` keyboard shortcut while on github.com.
This will request review for everyone who previously request changes to a pull request

![Peek 2023-02-24 17-05](https://user-images.githubusercontent.com/7268602/221282174-df49f42a-647b-4c96-a7f5-97b255352e3a.gif)
  • Loading branch information
leocostaba authored Feb 24, 2023
1 parent c6bb4b8 commit 15a3e57
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Github PR Shortcuts Extension

A simple Chrome extension that allows you to close all github PR files.
A simple Chrome extension that makes using github easier to review PR.

## Installation

Expand All @@ -15,11 +15,21 @@ To install follow these steps:

## Usage

To use the extension, simply press the `Ctrl+M` keyboard shortcut while on github.com.
### Close all open files

Press the `Ctrl+M` keyboard shortcut while on github.com.
This will close all PR files opened in the changed files tab.

<img src="https://user-images.githubusercontent.com/2291529/221005673-7de96934-2432-474e-a77d-2889e6e9f074.gif" width="500">

### Request review

Press the `Alt+R` keyboard shortcut while on github.com.
This will request review for everyone who previously request changes to a pull request

<img src="https://user-images.githubusercontent.com/7268602/221282174-df49f42a-647b-4c96-a7f5-97b255352e3a.gif" width="500">



## Contributing

Expand Down
15 changes: 11 additions & 4 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
function sendCommandToTab(command) {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {action: command});
});
}

chrome.commands.onCommand.addListener(function(command) {
console.log('Command:', command)
console.log('Command:', command);
if (command === "close-github-pr-files") {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {action: "closePRFiles"});
});
sendCommandToTab("closePRFiles");
}
if (command === "re-request-review") {
sendCommandToTab("requestReview");
}
});
6 changes: 6 additions & 0 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
.filter((btn) => btn.attributes['aria-expanded']?.value === "true")
.forEach((btn) => { btn.click() });
}

if (request.action === "requestReview") {
Array.prototype.slice.call(document.querySelectorAll('.discussion-sidebar-item .octicon-file-diff'))
.map((diffIcon) => diffIcon.closest('p')?.querySelector('button[name=re_request_reviewer_id]'))
.forEach((btn) => { btn.click() });
}
});
6 changes: 6 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
"default": "Ctrl+M"
},
"description": "Close github PR files"
},
"re-request-review": {
"suggested_key": {
"default": "Alt+R"
},
"description": "Requests review for reviewers who requested changes"
}
}
}

0 comments on commit 15a3e57

Please # to comment.