Skip to content

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

3.6 KB
Raw Blame
import { useTranslation } from "react-i18next";
import { useSearch } from "@tanstack/react-router";

import { PageTitle } from "@app/components/PageTitle";
import { LookingForOrgPageLink } from "@app/components/v3";
import { PageHeader } from "@app/components/v3/platform";
import { ROUTE_PATHS } from "@app/const/routes";
import { useProject } from "@app/context";
import { ProjectType, ProjectVersion } from "@app/hooks/api/projects/types";
import { ProjectGeneralTab } from "@app/pages/project/SettingsPage/components/ProjectGeneralTab";

import { EncryptionTab } from "./components/EncryptionTab";
import { EnvironmentsTab } from "./components/EnvironmentsTab";
import { PoliciesTab } from "./components/PoliciesTab";
import { TagsTab } from "./components/TagsTab";
import { WebhooksTab } from "./components/WebhooksTab";
import { WorkflowIntegrationTab } from "./components/WorkflowIntegrationSection";

export const SettingsPage = () => {
  const { t } = useTranslation();
  const { currentProject } = useProject();

  const { selectedTab } = useSearch({
    from: ROUTE_PATHS.SecretManager.SettingsPage.id
  });

  const tabs = [
    {
      name: "General",
      description: "Manage your project's name, audit log retention, and delete protection.",
      key: "tab-project-general",
      Component: ProjectGeneralTab
    },
    {
      name: "Environments",
      description:
        "Define the environments your secrets live in, such as development, staging, and production.",
      key: "tab-secret-environments",
      Component: EnvironmentsTab
    },
    {
      name: "Tags",
      description: "Organize secrets with tags to make them easier to find and govern.",
      key: "tab-secret-tags",
      Component: TagsTab
    },
    {
      name: "Policies",
      description:
        "Configure validation rules, retention, cross-project sharing, and other behaviors that govern this project's secrets.",
      key: "tab-secret-policies",
      Component: PoliciesTab
    },
    {
      name: "Encryption",
      description: "Choose the Key Management System used to encrypt this project's data.",
      key: "tab-project-encryption",
      isHidden: currentProject?.version !== ProjectVersion.V3,
      Component: EncryptionTab
    },
    {
      name: "Workflow Integrations",
      description: "Connect Slack and Microsoft Teams for approval and notification workflows.",
      key: "tab-workflow-integrations",
      Component: WorkflowIntegrationTab
    },
    {
      name: "Webhooks",
      description: "Manage webhooks that notify external services when your secrets change.",
      key: "tab-project-webhooks",
      Component: WebhooksTab
    }
  ];

  const visibleTabs = tabs.filter((tab) => !tab.isHidden);
  const activeTab =
    visibleTabs.find((tab) => tab.key === selectedTab) ??
    visibleTabs.find((tab) => tab.key === "tab-project-general") ??
    visibleTabs[0];
  const baseTitle = t("settings.project.title");
  const pageTitle = activeTab ? `${activeTab.name} - ${baseTitle}` : baseTitle;
  const ActiveTabComponent = activeTab?.Component;

  return (
    <div className="flex h-full w-full justify-center bg-page text-foreground-inverse">
      <PageTitle title={pageTitle} />
      <div className="w-full max-w-8xl">
        <PageHeader
          scope={ProjectType.SecretManager}
          title={activeTab?.name ?? baseTitle}
          description={activeTab?.description}
        >
          <LookingForOrgPageLink page="settings" />
        </PageHeader>
        <div className="grow rounded-br-md rounded-bl-md pb-5 outline-hidden xl:overflow-x-hidden xl:pb-0">
          {ActiveTabComponent ? <ActiveTabComponent /> : null}
        </div>
      </div>
    </div>
  );
};