Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

1.8 KB
Raw Blame
import { Alert, AlertTitle, Box } from "@mui/material";
import type { TemplateValidation } from "../../data/api";

/**
 * What the checker made of the document.
 *
 * Most of it is advice: the registry stores documents in shapes this server
 * may not understand, so the form reports and the person decides. The one
 * exception is a document that is not YAML at all, which the server refuses —
 * said plainly here rather than left to a failed upload to explain.
 */
export default function TemplateFindings({
  result,
  checking,
}: {
  result: TemplateValidation | null;
  checking: boolean;
}) {
  if (checking || result === null) return null;
  if (result.errors.length === 0 && result.warnings.length === 0) return null;

  return (
    <Box sx={{ display: "flex", flexDirection: "column", gap: 1 }}>
      {result.errors.length > 0 && (
        <Alert severity="error">
          <AlertTitle>
            {result.errors.length === 1
              ? "This does not look like a valid template"
              : `${result.errors.length} problems with this template`}
          </AlertTitle>
          <Box component="ul" sx={{ m: 0, pl: 2.5 }}>
            {result.errors.map((f, i) => (
              <li key={`${f.code}-${f.subject ?? i}`}>{f.message}</li>
            ))}
          </Box>
          {result.blocked
            ? "This cannot be uploaded until it parses."
            : "You can still upload it — the registry stores documents it does not understand — but check this is what you meant."}
        </Alert>
      )}
      {result.warnings.length > 0 && (
        <Alert severity="warning">
          <Box component="ul" sx={{ m: 0, pl: 2.5 }}>
            {result.warnings.map((f, i) => (
              <li key={`${f.code}-${f.subject ?? i}`}>{f.message}</li>
            ))}
          </Box>
        </Alert>
      )}
    </Box>
  );
}