-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add comment-on-draft-pr-indicator feature
#4541
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
3b95c31
Add `comment-to-draft-pr-button` feature
darkred 5b6f05c
Followed all suggestions + updated screenshot
darkred 0c88d6b
lint
darkred e4cc154
Replace `innerHTML` with `textContent`
darkred cfa04ee
Change 'to' to 'on', and 'Draft' to 'draft'
darkred ec48f0a
Update source/features/comment-to-draft-pr-button.tsx
darkred 3a26a8a
Rename the feature
darkred bf2b3d1
Remove unnecessary selector
darkred eddb086
lint
darkred dd1ae92
Update readme.md
darkred 7eb7eb7
Rename the feature one last time + improve description
darkred b385a84
Do what the reviewers say
fregante 6a3f2af
Update readme.md
fregante 5125614
Consistent style
fregante 6a30be8
Use lightweight listener to catch dynamic "Add comment"
fregante 6382167
Lint
fregante aa27d4d
Copy
fregante 569ba1a
Arid
fregante 3c7788a
Also support review threads on the Conversation tab
fregante a4b1c54
More specific page select
fregante b0d5fb8
Merge branch 'main' into comment-on-draft-pr-indicator
fregante 92f14ba
Bye boolean trap
fregante f2ec4c9
Lint
fregante 414ce68
Merge remote-tracking branch 'origin/main' into comment-on-draft-pr-i…
fregante 4488c12
I need to enable XO in my linter…
fregante File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import select from 'select-dom'; | ||
| import * as pageDetect from 'github-url-detection'; | ||
|
|
||
| import features from '.'; | ||
| import onReplacedElement from '../helpers/on-replaced-element'; | ||
|
|
||
| function addIndicator(button: HTMLElement): void { | ||
| const preposition = button.textContent!.includes('Add') ? ' to ' : ' on '; | ||
| button.textContent += preposition + 'draft PR'; | ||
| } | ||
|
|
||
| function init(): void { | ||
| const buttons = select.all([ | ||
| '.review-simple-reply-button', // "Add single comment" button | ||
| '.add-comment-label', // "Add review comment" button | ||
| '.start-review-label', // "Start a review" button | ||
| ]); | ||
| for (const button of buttons) { | ||
| addIndicator(button); | ||
| } | ||
|
|
||
| if (pageDetect.isPRConversation()) { | ||
| // The button is part of a .js-updatable-content partial | ||
| void onReplacedElement('#partial-new-comment-form-actions .btn-primary', addIndicator, {runCallbackOnStart: true}); | ||
| } | ||
| } | ||
|
|
||
| void features.add(__filebasename, { | ||
| include: [ | ||
| pageDetect.isPRConversation, | ||
| pageDetect.isPRFiles, | ||
| ], | ||
| exclude: [ | ||
| () => !pageDetect.isDraftPR(), | ||
| ], | ||
| init, | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be changed to an object? Isn't it a boolean trap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://ariya.io/2011/08/hall-of-api-shame-boolean-trap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you meant to comment on the
callNowline since there's no boolean here 😃Good point, changing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I was on mobile and selected the wrong line.