Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

2.3 KB
Raw Blame
import { faWarning } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Link } from "@tanstack/react-router";

import { useOrganization } from "@app/context";
import { useImplicitProjectId } from "@app/hooks";
import { useCertManagerInstanceState } from "@app/hooks/api/certManagerInstance";

export const CertManagerInstanceBanner = () => {
  const projectId = useImplicitProjectId();
  const { currentOrg } = useOrganization();
  const { data, isPending } = useCertManagerInstanceState();

  if (isPending || !data || !data.isMultiInstance) return null;

  const activeProject = data.projects.find((p) => p.id === data.activeProjectId);
  const isViewingActive = activeProject?.id === projectId;

  return (
    <div className="flex w-full items-start gap-x-2 border-b border-warning/50 bg-warning/30 px-4 py-2 text-sm text-warning">
      <FontAwesomeIcon icon={faWarning} className="mt-0.5 shrink-0 text-base text-warning" />
      {isViewingActive ? (
        <p>
          This is your organization&apos;s active project. Use this for all work going forward.{" "}
          <Link
            to="/organizations/$orgId/settings"
            params={{ orgId: currentOrg.id }}
            search={{ selectedTab: "product-settings" }}
            className="underline underline-offset-2 hover:text-warning"
          >
            Manage projects
          </Link>
        </p>
      ) : (
        <p>
          You&apos;re viewing a legacy Certificate Manager project.{" "}
          {activeProject ? (
            <Link
              to="/organizations/$orgId/projects/cert-manager/$projectId/$"
              params={{ orgId: currentOrg.id, projectId: activeProject.id, _splat: "overview" }}
              reloadDocument
              className="underline underline-offset-2 hover:text-warning"
            >
              Switch to your active project →
            </Link>
          ) : (
            <a
              href="https://infisical.com/docs/documentation/platform/pki/migration"
              target="_blank"
              rel="noopener noreferrer"
              className="underline underline-offset-2 hover:text-warning"
            >
              Migration guide
            </a>
          )}
        </p>
      )}
    </div>
  );
};