import { Layout } from "../components/Layout"; import type { Deployment } from "../index"; interface DeploymentsListProps { deployments: Deployment[]; } function getStatusBadge(status: string): string { const statusClass = status === "success" ? "badge-success" : status === "failed" ? "badge-failed" : status === "pending" ? "badge-pending" : "badge-in_progress"; return `${status}`; } function formatDate(dateString: string | undefined): string { if (!dateString) return "N/A"; const date = new Date(dateString); return date.toLocaleString(); } function escapeHtml(text: string | undefined): string { if (!text) return ""; return text .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """) .replace(/'/g, "'"); } export function DeploymentsList({ deployments }: DeploymentsListProps): string { const content = `
No deployments yet.
" : `| ID | Repository | Branch | Commit | Status | Created At | Actions |
|---|---|---|---|---|---|---|
| ${deployment.id} | ${escapeHtml(deployment.repository)} | ${escapeHtml(deployment.branch) || "N/A"} |
${deployment.commit_hash ?
`${escapeHtml(deployment.commit_hash.substring(0, 7))}` :
"N/A"}
|
${getStatusBadge(deployment.status)} | View |