Skip to content
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
26 changes: 16 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3480,16 +3480,19 @@
"group": "1_create@2"
},
{
"command": "review.approve",
"when": "webviewId == 'github:activePullRequest' && github:reviewCommentMenu && github:reviewCommentApprove"
"command": "review.comment",
"when": "webviewId == 'github:activePullRequest' && github:reviewCommentMenu && github:reviewCommentComment",
"group": "1_review@1"
},
{
"command": "review.comment",
"when": "webviewId == 'github:activePullRequest' && github:reviewCommentMenu && github:reviewCommentComment"
"command": "review.approve",
"when": "webviewId == 'github:activePullRequest' && github:reviewCommentMenu && github:reviewCommentApprove",
"group": "1_review@2"
},
{
"command": "review.requestChanges",
"when": "webviewId == 'github:activePullRequest' && github:reviewCommentMenu && github:reviewCommentRequestChanges"
"when": "webviewId == 'github:activePullRequest' && github:reviewCommentMenu && github:reviewCommentRequestChanges",
"group": "1_review@3"
},
{
"command": "review.approveOnDotCom",
Expand All @@ -3500,16 +3503,19 @@
"when": "webviewId == 'github:activePullRequest' && github:reviewCommentMenu && github:reviewCommentRequestChangesOnDotCom"
},
{
"command": "review.approveDescription",
"when": "webviewId == PullRequestOverview && github:reviewCommentMenu && github:reviewCommentApprove"
"command": "review.commentDescription",
"when": "webviewId == PullRequestOverview && github:reviewCommentMenu && github:reviewCommentComment",
"group": "1_review@1"
},
{
"command": "review.commentDescription",
"when": "webviewId == PullRequestOverview && github:reviewCommentMenu && github:reviewCommentComment"
"command": "review.approveDescription",
"when": "webviewId == PullRequestOverview && github:reviewCommentMenu && github:reviewCommentApprove",
"group": "1_review@2"
},
{
"command": "review.requestChangesDescription",
"when": "webviewId == PullRequestOverview && github:reviewCommentMenu && github:reviewCommentRequestChanges"
"when": "webviewId == PullRequestOverview && github:reviewCommentMenu && github:reviewCommentRequestChanges",
"group": "1_review@3"
},
{
"command": "review.approveOnDotComDescription",
Expand Down
14 changes: 8 additions & 6 deletions webviews/components/comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,12 @@ export function AddComment({
defaultOptionValue={() => currentSelection}
allOptions={() => {
const actions: { label: string; value: string; optionDisabled: boolean; action: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void }[] = [];
if (availableActions.approve) {
actions.push({ label: availableActions[ReviewType.Approve]!, value: ReviewType.Approve, action: () => submitAction(ReviewType.Approve), optionDisabled: shouldDisableApproveButton });
}
if (availableActions.comment) {
actions.push({ label: availableActions[ReviewType.Comment]!, value: ReviewType.Comment, action: () => submitAction(ReviewType.Comment), optionDisabled: shouldDisableNonApproveButtons });
}
if (availableActions.approve) {
actions.push({ label: availableActions[ReviewType.Approve]!, value: ReviewType.Approve, action: () => submitAction(ReviewType.Approve), optionDisabled: shouldDisableApproveButton });
}
if (availableActions.requestChanges) {
actions.push({ label: availableActions[ReviewType.RequestChanges]!, value: ReviewType.RequestChanges, action: () => submitAction(ReviewType.RequestChanges), optionDisabled: shouldDisableNonApproveButtons });
}
Expand All @@ -475,6 +475,7 @@ export function AddComment({
disabled={isBusy || busy}
hasSingleAction={Object.keys(availableActions).length === 1}
spreadable={true}
primaryOptionValue={ReviewType.Comment}
/>
</div>
</form>
Expand Down Expand Up @@ -608,12 +609,12 @@ export const AddCommentSimple = (pr: PullRequest) => {
defaultOptionValue={() => currentSelection}
allOptions={() => {
const actions: { label: string; value: string; optionDisabled: boolean; action: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void }[] = [];
if (availableActions.approve) {
actions.push({ label: availableActions[ReviewType.Approve]!, value: ReviewType.Approve, action: () => submitAction(ReviewType.Approve), optionDisabled: shouldDisableApproveButton });
}
if (availableActions.comment) {
actions.push({ label: availableActions[ReviewType.Comment]!, value: ReviewType.Comment, action: () => submitAction(ReviewType.Comment), optionDisabled: shouldDisableNonApproveButtons });
}
if (availableActions.approve) {
actions.push({ label: availableActions[ReviewType.Approve]!, value: ReviewType.Approve, action: () => submitAction(ReviewType.Approve), optionDisabled: shouldDisableApproveButton });
}
if (availableActions.requestChanges) {
actions.push({ label: availableActions[ReviewType.RequestChanges]!, value: ReviewType.RequestChanges, action: () => submitAction(ReviewType.RequestChanges), optionDisabled: shouldDisableNonApproveButtons });
}
Expand All @@ -623,6 +624,7 @@ export const AddCommentSimple = (pr: PullRequest) => {
disabled={isBusy || pr.busy}
hasSingleAction={Object.keys(availableActions).length === 1}
spreadable={true}
primaryOptionValue={ReviewType.Comment}
/>
</div>
</span>
Expand Down
7 changes: 5 additions & 2 deletions webviews/components/contextDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface ContextDropdownProps {
hasSingleAction?: boolean;
spreadable: boolean;
isSecondary?: boolean;
primaryOptionValue?: string;
}

function useWindowSize() {
Expand All @@ -32,7 +33,7 @@ function useWindowSize() {
return size;
}

export const ContextDropdown = ({ optionsContext, defaultOptionLabel, defaultOptionValue, defaultAction, allOptions: options, optionsTitle, disabled, hasSingleAction, spreadable, isSecondary }: ContextDropdownProps) => {
export const ContextDropdown = ({ optionsContext, defaultOptionLabel, defaultOptionValue, defaultAction, allOptions: options, optionsTitle, disabled, hasSingleAction, spreadable, isSecondary, primaryOptionValue }: ContextDropdownProps) => {
const [expanded, setExpanded] = useState(false);
const onHideAction = (e: MouseEvent | KeyboardEvent) => {
if (e.target instanceof HTMLElement && e.target.classList.contains('split-right')) {
Expand All @@ -56,7 +57,9 @@ export const ContextDropdown = ({ optionsContext, defaultOptionLabel, defaultOpt

return <div className={`dropdown-container${spreadable ? ' spreadable' : ''}`} ref={divRef}>
{divRef.current && spreadable && (divRef.current.clientWidth > 375) && options && !hasSingleAction ? options().map(({ label, value, action, optionDisabled }) => {
return <button className='inlined-dropdown' key={value} title={label} disabled={optionDisabled || disabled} onClick={action} value={value}>{label}</button>;
// Only the primary option should use the primary (blue) button style when expanded
const isPrimary = primaryOptionValue && value === primaryOptionValue;
return <button className={`inlined-dropdown${isPrimary ? '' : ' secondary'}`} key={value} title={label} disabled={optionDisabled || disabled} onClick={action} value={value}>{label}</button>;
})
:
<div className='primary-split-button'>
Expand Down