All files / src/components/spe SpeColdStartNotice.tsx

100% Statements 5/5
83.33% Branches 5/6
100% Functions 2/2
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 522x                       4x 4x 4x             4x                                                            
"use client";
 
import { Loader2, PowerOff } from "lucide-react";
import type { SpeColdStartBody } from "@/lib/spe";
import { useT } from "@/lib/i18n/translate";
 
/**
 * What a researcher sees instead of an error when a federated query needs a
 * workspace that is not up (ADR-072): which one, that it is starting or
 * stopped, and roughly how long.
 */
export function SpeColdStartNotice({ body }: { body: SpeColdStartBody }) {
  const t = useT("research");
  const entries = body.spes?.length ? body.spes : [body.spe];
  return (
    <div
      role="status"
      aria-label={t("Secure processing environment not ready")}
      className="bg-(--warning)/10 border border-(--warning)/30 rounded-lg px-4 py-3 text-sm text-(--warning-text) space-y-1"
    >
      {entries.map((spe) => (
        <p key={spe.id} className="flex items-start gap-2">
          {spe.state === "starting" ? (
            <Loader2
              size={16}
              className="animate-spin mt-0.5 shrink-0"
              aria-hidden="true"
            />
          ) : (
            <PowerOff
              size={16}
              className="mt-0.5 shrink-0"
              aria-hidden="true"
            />
          )}
          <span>
            {spe.state === "starting"
              ? t(
                  "{id} is starting (cold start, about 3 to 4 minutes): attesting, releasing the key, loading the data. Try again in a few minutes.",
                  { id: spe.id },
                )
              : t(
                  "{id} is stopped. An operator or the access body can start it.",
                  { id: spe.id },
                )}
          </span>
        </p>
      ))}
    </div>
  );
}