Skip to content

Commit b2c731e

Browse files
Copilotalexr00
andauthored
Sort status checks to group failures first (#8297)
* Initial plan * Initial plan: Group failing checks together Co-authored-by: alexr00 <[email protected]> * Sort status checks by state: failures first, then pending, neutral, and success Co-authored-by: alexr00 <[email protected]> * Move CHECK_STATE_ORDER constant outside component to avoid recreating on every render Co-authored-by: alexr00 <[email protected]> * Fix code style: remove extra space in function parameter declaration Co-authored-by: alexr00 <[email protected]> * Fix sort order * Don't do the unneeded spread --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: alexr00 <[email protected]>
1 parent 0a4aae5 commit b2c731e

File tree

1 file changed

+42
-25
lines changed

1 file changed

+42
-25
lines changed

webviews/components/merge.tsx

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -570,32 +570,49 @@ export const MergeSelect = React.forwardRef<HTMLSelectElement, MergeSelectProps>
570570
},
571571
);
572572

573-
const StatusCheckDetails = ( { statuses }: { statuses: PullRequestCheckStatus[] }) => (
574-
<div className='status-scroll'>
575-
{statuses.map(s => (
576-
<div key={s.id} className="status-check">
577-
<div className="status-check-details">
578-
<StateIcon state={s.state} />
579-
<Avatar for={{ avatarUrl: s.avatarUrl, url: s.url }} />
580-
<span className="status-check-detail-text">
581-
{/* allow-any-unicode-next-line */}
582-
{s.workflowName ? `${s.workflowName} / ` : null}{s.context}{s.event ? ` (${s.event})` : null} {s.description ? `— ${s.description}` : null}
583-
</span>
584-
</div>
585-
<div>
586-
{s.isRequired ? (
587-
<span className="label">Required</span>
588-
) : null }
589-
{!!s.targetUrl ? (
590-
<a href={s.targetUrl} title={s.targetUrl}>
591-
Details
592-
</a>
593-
) : null}
573+
// State order for sorting status checks: failure first, then pending, neutral, success, and unknown
574+
const CHECK_STATE_ORDER: Record<CheckState, number> = {
575+
[CheckState.Failure]: 0,
576+
[CheckState.Pending]: 1,
577+
[CheckState.Unknown]: 2,
578+
[CheckState.Neutral]: 3,
579+
[CheckState.Success]: 4,
580+
581+
};
582+
583+
const StatusCheckDetails = ({ statuses }: { statuses: PullRequestCheckStatus[] }) => {
584+
// Sort statuses to group by state: failure first, then pending, neutral, and success
585+
const sortedStatuses = statuses.sort((a, b) => {
586+
return CHECK_STATE_ORDER[a.state] - CHECK_STATE_ORDER[b.state];
587+
});
588+
589+
return (
590+
<div className='status-scroll'>
591+
{sortedStatuses.map(s => (
592+
<div key={s.id} className="status-check">
593+
<div className="status-check-details">
594+
<StateIcon state={s.state} />
595+
<Avatar for={{ avatarUrl: s.avatarUrl, url: s.url }} />
596+
<span className="status-check-detail-text">
597+
{/* allow-any-unicode-next-line */}
598+
{s.workflowName ? `${s.workflowName} / ` : null}{s.context}{s.event ? ` (${s.event})` : null} {s.description ? `— ${s.description}` : null}
599+
</span>
600+
</div>
601+
<div>
602+
{s.isRequired ? (
603+
<span className="label">Required</span>
604+
) : null}
605+
{!!s.targetUrl ? (
606+
<a href={s.targetUrl} title={s.targetUrl}>
607+
Details
608+
</a>
609+
) : null}
610+
</div>
594611
</div>
595-
</div>
596-
))}
597-
</div>
598-
);
612+
))}
613+
</div>
614+
);
615+
};
599616

600617
function getSummaryLabel(statuses: PullRequestCheckStatus[]) {
601618
const statusTypes = groupBy(statuses, (status: PullRequestCheckStatus) => {

0 commit comments

Comments
 (0)