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"; import { useTranslation } from "react-i18next"; 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, t: (key: string, values?: Record) => string, ): string { if (!pipeline) return t("gitlab:noPipeline"); 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 { t } = useTranslation(); 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 && {t("gitlab:draft")}} {mr.head_branch} {t("gitlab:into")} {mr.base_branch}
{t("gitlab:mergeability")}

{mergeable ? ( ) : ( )} {mr.has_conflicts ? t("gitlab:conflicts") : mr.merge_status.replaceAll("_", " ")}

{t("gitlab:approvals")}

{feedback.approvals.length > 0 ? ( ) : ( )} {t("gitlab:approvedCount", { count: feedback.approvals.length })}

{t("gitlab:pipeline")}

{pipelineSummary(pipeline, t)}

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

{t("gitlab:linkedMergeRequest")} {taskMR.project_path}!{taskMR.mr_iid}

); }