import Link from "next/link"; import type { ReactNode } from "react"; import { deleteReleaseAction } from "@/app/actions/releases"; import { CopyButton } from "@/components/clone-button"; import { ConfirmButton } from "@/components/confirm-button"; import { ShaChip } from "@/components/file-table"; import { CodeIcon, DownloadIcon, PackageIcon, PencilIcon, TagIcon } from "@/components/icons"; import { Markdown } from "@/components/markdown"; import { liftRowClass, plateHeadingClass } from "@/components/repo-rows"; import { Avatar, Box, ButtonLink, Label, RefChip } from "@/components/ui"; import { encodePath, formatBytes, formatDate, timeAgo } from "@/lib/format"; import { releaseTitle, type Release } from "@/lib/releases"; import type { Repo } from "@/lib/repo"; export const releaseHref = (repo: Repo, tag: string) => `${repo.base}/releases/tag/${encodePath(tag)}`; export const assetHref = (repo: Repo, tag: string, name: string) => `${repo.base}/releases/download/${encodePath(tag)}/${encodeURIComponent(name)}`; function Time({ ms, prefix }: { ms: number; prefix?: string }) { return ( {prefix && `${prefix} `} ); } function AssetRow({ href, name, icon, children }: { href: string; name: string; icon: ReactNode; children?: ReactNode }) { return (
  • {icon} {name} {children}
  • ); } /** * A release on its plate: what it is (title, state, tag, commit, who and when), its notes, and its * files with the source code at the tag. */ export function ReleaseCard({ repo, release, sha, latest, linkTitle = true }: { repo: Repo; release: Release; sha: string | null; latest: boolean; linkTitle?: boolean }) { const title = releaseTitle(release); const tagPath = `refs/tags/${encodePath(release.tag)}`; return (

    {linkTitle ? ( {title} ) : ( title )}

    {release.draft && } {release.prerelease && } {latest && } {repo.canWrite && (
    }> Edit Delete
    )}
    {release.tag} {sha ? ( ) : ( {release.draft ? <>Tag is created from {release.target} when published : "Tag no longer exists"} )} {release.author && ( {release.author} )} {release.publishedAt ?
    {release.body.trim() && (
    {release.body}
    )}

    Assets {release.assets.length + (sha ? 2 : 0)}

    {release.assets.length === 0 && !sha &&

    No files yet.

    }
    ); }