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

Restore PR review buttons on GitHub Enterprise #6635

Merged
merged 9 commits into from May 9, 2023
Merged

Restore PR review buttons on GitHub Enterprise #6635

merged 9 commits into from May 9, 2023

Conversation

fregante
Copy link
Member

@fregante fregante commented May 9, 2023

@fregante fregante added the bug label May 9, 2023
@fregante fregante requested a review from busches May 9, 2023 08:11
@fregante fregante marked this pull request as ready for review May 9, 2023 08:11
source/features/one-click-review-submission.tsx Outdated Show resolved Hide resolved
Comment on lines +10 to +13
function replaceCheckboxes(originalSubmitButton: HTMLButtonElement): void {
const form = originalSubmitButton.form!;
const actionsRow = originalSubmitButton.closest('.form-actions')!;
const formAttribute = originalSubmitButton.getAttribute('form')!;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By targeting the original submit button, it's easier to extrapolate all the necessary elements without conditions


// Do not use `select.all` because elements can be outside `form`
// `RadioNodeList` is dynamic, so we need to make a copy
const radios = [...form.elements.namedItem('pull_request_review[event]') as RadioNodeList] as HTMLInputElement[];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Delay disabling the fields to let them be submitted first
setTimeout(() => {
for (const control of select.all('button, textarea', event.delegateTarget)) {
control.disabled = true;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved below, handled via temporary preventDefault instead.

const pendingComments = looseParseInt(select('.js-reviews-toggle .js-pending-review-comment-count'));
const submissionRequiresComment = pendingComments === 0 && (value === 'reject' || value === 'comment');
select('#pull_request_review_body', form!)!.toggleAttribute('required', submissionRequiresComment);
}, {signal});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped. This can fail once the .js-reviews-toggle .js-pending-review-comment-count is not found the the number of comments loosely becomes 0, blocking submission.

}

void features.add(import.meta.url, {
include: [
pageDetect.isPR,
pageDetect.isPRFiles,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this was so broad

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The review option shows on a specific commit of a PR, that no longer works now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here: added isPRCommit as done everywhere else in the extension.

@busches
Copy link
Member

busches commented May 9, 2023

Confirmed this is working on GHE 3.8.2, with the caveat from my comment on your review.

Ack, spoke too soon, comment works, approve/request changes also appear to comment and not actually approve/request changes.

@fregante
Copy link
Member Author

fregante commented May 9, 2023

approve/request changes also appear to comment and not actually approve/request changes.

That's strange. Is that GHE? It works here: refined-github/sandbox#53 (review)

Would you be able to see why that's happening?

This works because each button has a value and name and the browser submits only name/value that was clicked, replacing GitHub‘s radio which do the same.

@busches
Copy link
Member

busches commented May 9, 2023 via email

@busches
Copy link
Member

busches commented May 9, 2023

Narrowed it down to there's a hidden input at the end of the form making it a comment all the time. Haven't gotten to see why or where it's coming from.

@fregante
Copy link
Member Author

fregante commented May 9, 2023

Ohhh we have that in our code right in this file. It’s used to ensure that the default action for ctrl-enter is a comment, regardless of the order of buttons in a PR. I can look into another solution and then ship it

@busches
Copy link
Member

busches commented May 9, 2023

Swapping to prepend and it works for both scenarios again on GHE.

@fregante
Copy link
Member Author

fregante commented May 9, 2023

Thank you! That makes sense. It used to be:

  • form
    • .form-actions
      • default hidden field (append 1)
      • other buttons (append 2)

but now it was

  • form
    • .form-actions
      • other buttons (append 2)
    • default hidden field (append 1)

@fregante fregante merged commit 12532fc into main May 9, 2023
9 checks passed
@fregante fregante deleted the restore-ghe branch May 9, 2023 19:45
@fregante
Copy link
Member Author

fregante commented May 9, 2023

Since I disabled the feature via hotfix, this isn't as urgent anymore. I hope to get a couple more bugfixes before releasing a new version

@fregante
Copy link
Member Author

fregante commented May 9, 2023

Uhm, I'm confused. This feature has been "disabled" on GHE for the past 7 months. Why is it enabled?

include: [
pageDetect.isPRFiles,
pageDetect.isPRCommit,
],
exclude: [
pageDetect.isPRFile404,
pageDetect.isEnterprise, // #5820
],

@busches
Copy link
Member

busches commented May 9, 2023

I use on GHE all the time, it has been disabled since the hot fix though and I've missed it.

@fregante
Copy link
Member Author

fregante commented May 9, 2023

uhm I'm blind… wrong feature 😂

Screenshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

PR Review actions don't work (one-click-review-submission)
3 participants