Skip to content

Commit e42576a

Browse files
Copilotalexr00
andcommitted
Add auto-merge status indicator to review area
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 362d5a9 commit e42576a

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

webviews/components/comment.tsx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,11 @@ export function AddComment({
363363
lastReviewType,
364364
busy,
365365
hasReviewDraft,
366+
autoMerge,
367+
autoMergeMethod,
368+
allowAutoMerge,
366369
}: PullRequest) {
367-
const { updatePR, requestChanges, approve, close, openOnGitHub, submit } = useContext(PullRequestContext);
370+
const { updatePR, requestChanges, approve, close, openOnGitHub, submit, updateAutoMerge } = useContext(PullRequestContext);
368371
const [isBusy, setBusy] = useState(false);
369372
const form = useRef<HTMLFormElement>();
370373
const textareaRef = useRef<HTMLTextAreaElement>();
@@ -449,6 +452,23 @@ export function AddComment({
449452
}
450453
}}
451454
/>
455+
{autoMerge && !isIssue && state === GithubItemStateEnum.Open ? (
456+
<div className="auto-merge-status" style={{ fontSize: '12px', padding: '8px 0', color: 'var(--vscode-descriptionForeground)', display: 'flex', alignItems: 'center', gap: '8px' }}>
457+
<span>Auto-merge is enabled{autoMergeMethod ? ` (${formatMergeMethod(autoMergeMethod)})` : ''}</span>
458+
{allowAutoMerge && hasWritePermission ? (
459+
<button
460+
type="button"
461+
className="secondary"
462+
style={{ fontSize: '12px', padding: '2px 8px' }}
463+
onClick={async () => {
464+
await updateAutoMerge({ autoMerge: false });
465+
}}
466+
>
467+
Disable
468+
</button>
469+
) : null}
470+
</div>
471+
) : null}
452472
<div className="form-actions">
453473
{(hasWritePermission || isAuthor) ? (
454474
<button
@@ -539,6 +559,19 @@ const makeCommentMenuContext = (availableActions: { comment?: string, approve?:
539559
return stringified;
540560
};
541561

562+
function formatMergeMethod(method: string): string {
563+
switch (method) {
564+
case 'merge':
565+
return 'Merge commit';
566+
case 'squash':
567+
return 'Squash and merge';
568+
case 'rebase':
569+
return 'Rebase and merge';
570+
default:
571+
return method;
572+
}
573+
}
574+
542575
export const AddCommentSimple = (pr: PullRequest) => {
543576
const { updatePR, requestChanges, approve, submit, openOnGitHub } = useContext(PullRequestContext);
544577
const [isBusy, setBusy] = useState(false);

0 commit comments

Comments
 (0)