Skip to content

Commit

Permalink
Don't allow approve and request changes for draft PRs (microsoft#5564)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexr00 authored Dec 18, 2023
1 parent 7ea95e4 commit e04e5fe
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions webviews/components/comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ export function AddComment({
hasWritePermission,
isIssue,
isAuthor,
isDraft,
continueOnGitHub,
currentUserReviewState,
lastReviewType,
Expand Down Expand Up @@ -351,7 +352,7 @@ export function AddComment({
updatePR({ pendingCommentText: '', pendingReviewType: undefined });
}

const availableActions: { comment?: string, approve?: string, requestChanges?: string } = isAuthor
const availableActions: { comment?: string, approve?: string, requestChanges?: string } = isAuthor || isDraft
? { comment: 'Comment' }
: continueOnGitHub
? {
Expand Down Expand Up @@ -391,7 +392,7 @@ export function AddComment({
defaultAction={submitAction}
defaultOptionLabel={() => availableActions[currentSelection]}
defaultOptionValue={() => currentSelection}
optionsTitle='Submit pull request'
optionsTitle='Submit pull request review'
disabled={isBusy || busy}
hasSingleAction={Object.keys(availableActions).length === 1}
/>
Expand Down Expand Up @@ -475,7 +476,7 @@ export const AddCommentSimple = (pr: PullRequest) => {
[submitAction],
);

const availableActions: { comment?: string, approve?: string, requestChanges?: string } = pr.isAuthor
const availableActions: { comment?: string, approve?: string, requestChanges?: string } = pr.isAuthor || pr.isDraft
? { comment: 'Comment' }
: pr.continueOnGitHub
? {
Expand Down Expand Up @@ -503,7 +504,7 @@ export const AddCommentSimple = (pr: PullRequest) => {
defaultAction={submitAction}
defaultOptionLabel={() => availableActions[currentSelection]}
defaultOptionValue={() => currentSelection}
optionsTitle='Submit pull request'
optionsTitle='Submit pull request review'
disabled={isBusy || pr.busy}
hasSingleAction={Object.keys(availableActions).length === 1}
/>
Expand Down

0 comments on commit e04e5fe

Please sign in to comment.