AttestationItem

tcmts.hub.pages.AttestationItem · #h6skxb7c · term · runs anywhere

A review, advisory or yank in the feed: who said what about which release.

import type { Trusted } from "#codebase/tcmts/cli/attest";
import { libraryHref, said, whoHref } from "#codebase/tcmts/hub";
import type { HubAttestation, HubRelease } from "#codebase/tcmts/hub";
import { Initial } from "#codebase/tcmts/hub/pages";
import { ago } from "#codebase/tcmts/share";

export function AttestationItem({
  a,
  who,
  r,
  author,
}: {
  a: HubAttestation;
  who: Trusted;
  r?: HubRelease | undefined;
  author?: Trusted | undefined;
}) {
  const what =
    r && author ? (
      <a className="mono" href={libraryHref(author, r.package, r.version)}>
        {said(author)}/{r.package} {r.version}
      </a>
    ) : (
      <span className="mono">{a.release ?? a.namespace.slice(0, 8)}</span>
    );
  const verb =
    a.kind === "review" ? (
      "reviewed"
    ) : a.kind === "advisory" ? (
      <span className="bad">flagged</span>
    ) : (
      "yanked"
    );
  return (
    <div className="ev">
      <Initial who={who} />
      <div>
        <div>
          <a href={whoHref(who)}>
            <b>{said(who)}</b>
          </a>{" "}
          {verb} {what} <span className="when">· {ago(Date.parse(a.createdAt))}</span>
        </div>
        <blockquote>
          {a.kind === "advisory" && (
            <span className={`badge ${a.severity === "low" ? "b-edit" : "b-rm"}`}>
              {a.severity}
            </span>
          )}{" "}
          {a.body.split("\n")[0]}
          {a.fixedIn ? ` Fixed in ${a.fixedIn}.` : ""}
        </blockquote>
      </div>
    </div>
  );
}

uses

used by