Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

1.2 KB
Raw Blame
import { useTranslation } from "react-i18next";
import { CodeBlock, Modal } from "@editor/ui";
import "@processor/components/pipelines/PipelineDefinitionModal.css";
import { privateContentClassName } from "@editor/components/shared/privateContentClassName";

export interface PipelineDefinitionModalProps {
  open: boolean;
  onClose: () => void;
  /** The pipeline as it would be saved, pretty-printed. Re-read while the modal is open. */
  json: string;
}

/**
 * The pipeline's definition as it would be saved.
 *
 * Pipeline-scoped, so it opens from the header rather than the node inspector, and a modal rather
 * than a panel because a definition grows with the chain and needs the width.
 */
export function PipelineDefinitionModal({
  open,
  onClose,
  json,
}: PipelineDefinitionModalProps) {
  const { t } = useTranslation();

  return (
    <Modal
      open={open}
      onClose={onClose}
      width="lg"
      title={t("portal.pipelines.definition.title")}
      subtitle={t("portal.pipelines.definition.subtitle")}
      className="portal-definition__modal"
    >
      <CodeBlock
        code={json}
        lang="json"
        maxHeight={420}
        className={`portal-definition__code ${privateContentClassName}`}
      />
    </Modal>
  );
}