Skip to content

Commit a698959

Browse files
Copilotalexr00
andcommitted
Convert icon button to dropdown in ReadyForReview component
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 980b2b8 commit a698959

1 file changed

Lines changed: 15 additions & 31 deletions

File tree

webviews/components/merge.tsx

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import React, {
1414
} from 'react';
1515
import { AutoMerge, QueuedToMerge } from './automergeSelect';
1616
import { Dropdown } from './dropdown';
17-
import { checkAllIcon, checkIcon, circleFilledIcon, closeIcon, gitMergeIcon, loadingIcon, requestChangesIcon, skipIcon, warningIcon } from './icon';
17+
import { checkIcon, circleFilledIcon, closeIcon, gitMergeIcon, requestChangesIcon, skipIcon, warningIcon } from './icon';
1818
import { nbsp } from './space';
1919
import { Avatar } from './user';
2020
import { EventType, ReviewEvent } from '../../src/common/timelineEvent';
@@ -284,31 +284,26 @@ export const OfferToUpdate = ({ mergeable, isSimple, isCurrentlyCheckedOut, canU
284284
};
285285

286286
export const ReadyForReview = ({ isSimple, isCopilotOnMyBehalf, mergeMethod }: { isSimple: boolean; isCopilotOnMyBehalf?: boolean; mergeMethod: MergeMethod }) => {
287-
const [isBusy, setBusy] = useState(false);
288-
const [isMergeBusy, setMergeBusy] = useState(false);
289287
const { readyForReview, readyForReviewAndMerge, updatePR } = useContext(PullRequestContext);
290288

291-
const markReadyForReview = useCallback(async () => {
292-
try {
293-
setBusy(true);
289+
const submitAction = useCallback(async (selected: string) => {
290+
if (selected === 'readyAndMerge') {
291+
const result = await readyForReviewAndMerge({ mergeMethod: mergeMethod });
292+
updatePR(result);
293+
} else {
294294
const result = await readyForReview();
295295
updatePR(result);
296-
} finally {
297-
setBusy(false);
298296
}
299-
}, [setBusy, readyForReview, updatePR]);
297+
}, [readyForReview, readyForReviewAndMerge, updatePR, mergeMethod]);
300298

301-
const markReadyAndMerge = useCallback(async () => {
302-
try {
303-
setBusy(true);
304-
setMergeBusy(true);
305-
const result = await readyForReviewAndMerge({ mergeMethod: mergeMethod });
306-
updatePR(result);
307-
} finally {
308-
setBusy(false);
309-
setMergeBusy(false);
299+
const options = isCopilotOnMyBehalf
300+
? {
301+
ready: 'Ready for Review',
302+
readyAndMerge: 'Ready, Approve, and Auto-Merge'
310303
}
311-
}, [readyForReviewAndMerge, updatePR, mergeMethod]);
304+
: {
305+
ready: 'Ready for Review'
306+
};
312307

313308
return (
314309
<div className="ready-for-review-container">
@@ -320,18 +315,7 @@ export const ReadyForReview = ({ isSimple, isCopilotOnMyBehalf, mergeMethod }: {
320315
</div>
321316
</div>
322317
<div className='button-container'>
323-
{isCopilotOnMyBehalf && (
324-
<button
325-
className="icon-button"
326-
disabled={isBusy}
327-
onClick={markReadyAndMerge}
328-
title="Mark as ready for review, approve, and enable auto-merge with default merge method"
329-
aria-label="Ready for Review, Approve, and Auto-Merge"
330-
>
331-
{isMergeBusy ? loadingIcon : checkAllIcon}
332-
</button>
333-
)}
334-
<button disabled={isBusy} onClick={markReadyForReview}>Ready for Review</button>
318+
<Dropdown options={options} defaultOption='ready' submitAction={submitAction} />
335319
</div>
336320
</div>
337321
);

0 commit comments

Comments
 (0)