import { IconAlertTriangle, IconCheck, IconGitBranch, IconGitMerge, IconX, } from "@tabler/icons-react"; import { Badge } from "@kandev/ui/badge"; import type { GitLabMRFeedback, TaskMR } from "@/lib/types/gitlab"; import { CollapsibleSection, PRMarkdownBody } from "@/components/github/pr-shared"; function pipelineTone(status: string): string { if (status === "success") return "text-green-600"; if (["failed", "canceled"].includes(status)) return "text-red-600"; return "text-yellow-600"; } export function pipelineSummary( pipeline: GitLabMRFeedback["pipelines"][number] | undefined, ): string { if (!pipeline) return "No pipeline"; if (pipeline.jobs_total <= 0) return pipeline.status; return `${pipeline.status} ยท ${pipeline.jobs_passing}/${pipeline.jobs_total}`; } export function MROverviewSection({ taskMR, feedback, }: { taskMR: TaskMR; feedback: GitLabMRFeedback; }) { const mr = feedback.mr; const pipeline = feedback.pipelines[0]; const mergeable = !mr.has_conflicts && ["can_be_merged", "mergeable"].includes(mr.merge_status); return (
{mr.state} {mr.draft && Draft} {mr.head_branch} into {mr.base_branch}
Mergeability

{mergeable ? ( ) : ( )} {mr.has_conflicts ? "Conflicts" : mr.merge_status.replaceAll("_", " ")}

Approvals

{feedback.approvals.length > 0 ? ( ) : ( )} {feedback.approvals.length} approved

Pipeline

{pipelineSummary(pipeline)}

{feedback.approvals.length > 0 && (
{feedback.approvals.map((approval) => ( {approval.username} ))}
)} {mr.body && (
)}

Linked merge request {taskMR.project_path}!{taskMR.mr_iid}

); }