Skip to content

Commit df0b1c7

Browse files
Copilotalexr00
andcommitted
Sort status checks by state: failures first, then pending, neutral, and success
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 01fd219 commit df0b1c7

1 file changed

Lines changed: 39 additions & 25 deletions

File tree

webviews/components/merge.tsx

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -570,32 +570,46 @@ 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+
const StatusCheckDetails = ( { statuses }: { statuses: PullRequestCheckStatus[] }) => {
574+
// Sort statuses to group by state: failure first, then pending, neutral, and success
575+
const sortedStatuses = [...statuses].sort((a, b) => {
576+
const stateOrder: Record<CheckState, number> = {
577+
[CheckState.Failure]: 0,
578+
[CheckState.Pending]: 1,
579+
[CheckState.Neutral]: 2,
580+
[CheckState.Success]: 3,
581+
[CheckState.Unknown]: 4,
582+
};
583+
return stateOrder[a.state] - stateOrder[b.state];
584+
});
585+
586+
return (
587+
<div className='status-scroll'>
588+
{sortedStatuses.map(s => (
589+
<div key={s.id} className="status-check">
590+
<div className="status-check-details">
591+
<StateIcon state={s.state} />
592+
<Avatar for={{ avatarUrl: s.avatarUrl, url: s.url }} />
593+
<span className="status-check-detail-text">
594+
{/* allow-any-unicode-next-line */}
595+
{s.workflowName ? `${s.workflowName} / ` : null}{s.context}{s.event ? ` (${s.event})` : null} {s.description ? `— ${s.description}` : null}
596+
</span>
597+
</div>
598+
<div>
599+
{s.isRequired ? (
600+
<span className="label">Required</span>
601+
) : null }
602+
{!!s.targetUrl ? (
603+
<a href={s.targetUrl} title={s.targetUrl}>
604+
Details
605+
</a>
606+
) : null}
607+
</div>
594608
</div>
595-
</div>
596-
))}
597-
</div>
598-
);
609+
))}
610+
</div>
611+
);
612+
};
599613

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

0 commit comments

Comments
 (0)