Skip to content

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

feat(ui): split project templates by product type (#8563)

Andrew Huang141cd728bdda
diff --git a/frontend/src/components/V3_MIGRATION.md b/frontend/src/components/V3_MIGRATION.md
index 9d4c4f9c22..7c88fdcce9 100644
--- a/frontend/src/components/V3_MIGRATION.md
+++ b/frontend/src/components/V3_MIGRATION.md
@@ -77,7 +77,7 @@ In the table, E is the number of external consumer files and I is the number of
| `Table/Table.tsx` | 30 / 0 | V3 Table/DataGrid chosen by workflow; preserve selection, sort, resize, virtualization and pagination state. | `frontend/src/pages/organization/GroupDetailsByIDPage/components/AddGroupProjectModal.tsx:109` |
| `Tabs/Tabs.tsx` | 10 / 0 | V3 Tabs; preserve controlled/default state, URL state, panel lifetime and keyboard navigation. | `frontend/src/pages/kms/SettingsPage/SettingsPage.tsx:33` |
| `Tag/Tag.tsx` | 3 / 0 | V3 Badge composition; preserve diff/status intent and accessible text. | `frontend/src/components/secrets/diff/FieldDiffRenderers.tsx:128` |
-| `TextArea/TextArea.tsx` | 15 / 0 | V3 TextArea + Field; preserve controlled values, multiline input and validation. | `frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/ProjectTemplateDetailsModal.tsx:159` |
+| `TextArea/TextArea.tsx` | 15 / 0 | V3 TextArea + Field; preserve controlled values, multiline input and validation. | `frontend/src/pages/cert-manager/ApprovalsPage/components/RequestsTab/RequestDetailModal.tsx:396` |
| `Tooltip/Tooltip.tsx` | 64 / 3 | V3 Tooltip; preserve providers, disabled triggers, long text and focus access. | `frontend/src/pages/root.tsx:53` |
First wave deletes **17 families / 35 files** plus their root exports. The candidate retains **35 families / 72 V2 files including the barrel**, and the same 312 external consumer files. These are candidate-worktree numbers until the PR is explicitly merged; the baseline does not change because a PR was opened.
@@ -90,7 +90,7 @@ Counts below are baseline runtime consumer files, excluding the one menu type-on
| --- | ---: | --- | --- |
| Certificate Manager routes | 81 | `pages/cert-manager/PkiSubscribersPage/components/PkiSubscriberModal.tsx` | Split subscribers/issuance, authorities, applications, discovery and settings; preserve certificate mutations, validation, selection and permissions. |
| Secret Manager routes | 80 | `pages/secret-manager/integrations/SelectIntegrationAuthPage/SelectIntegrationAuthPage.tsx` | Integrations, settings, old dashboard, approvals; preserve hidden values, leases, bulk/table state and environment/path semantics. Held secret edit forms remain owned separately. |
-| Organization routes | 53 | `pages/organization/SettingsPage/components/ProjectTemplatesTab/components/ProjectTemplateDetailsModal.tsx` | Groups/membership, projects/settings, auth policies; preserve RBAC and async form recovery. UpgradeGate held choices stay separate. |
+| Organization routes | 53 | `pages/organization/UserDetailsByIDPage/components/UserOrgMembershipModal.tsx` | Groups/membership, projects/settings, auth policies; preserve RBAC and async form recovery. UpgradeGate held choices stay separate. |
| Secret Scanning routes | 23 | `pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningFindingRow.tsx` | Tables/detail/settings; preserve filtering, finding states, and mutations. Include the shared provider forms below. |
| PAM routes | 18 | `pages/pam/PamDiscoveryPage/PamDiscoveryPage.tsx` | Focused page headers, loading and confirmations; preserve org-scoped project resolution and access gates. |
| KMS routes | 13 | `pages/kms/OverviewPage/components/CmekEncryptModal.tsx` | Crypto operation overlays/settings; preserve operation-specific validation, masking and permission checks. |
diff --git a/frontend/src/helpers/project.ts b/frontend/src/helpers/project.ts
index a18e1facf9..ea03455853 100644
--- a/frontend/src/helpers/project.ts
+++ b/frontend/src/helpers/project.ts
@@ -123,6 +123,16 @@ const PROJECT_TYPES_WITH_INTERMEDIATE_VIEW = new Set<ProjectType>([
export const hasIntermediateProjectsView = (type: ProjectType) =>
PROJECT_TYPES_WITH_INTERMEDIATE_VIEW.has(type);
+const PROJECT_TYPES_WITH_PROJECT_TEMPLATES = new Set<ProjectType>([
+ ProjectType.SecretManager,
+ ProjectType.KMS,
+ ProjectType.SecretScanning,
+ ProjectType.PAM
+]);
+
+export const hasProjectTemplates = (type: ProjectType) =>
+ PROJECT_TYPES_WITH_PROJECT_TEMPLATES.has(type);
+
// Products that live at /organizations/$orgId/<slug> over a single implicit project, with no $projectId
// in the URL.
const ORG_SCOPED_PRODUCT_TYPES = new Set<ProjectType>([
diff --git a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/OrgSidebar.tsx b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/OrgSidebar.tsx
index 55aaf0e5ac..b956b81da4 100644
--- a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/OrgSidebar.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/OrgSidebar.tsx
@@ -32,7 +32,9 @@ export const OrgSidebar = () => {
const effectiveTypeSlug = typeSlug ?? parseProjectSlugFromPath(pathname);
const projectType = effectiveTypeSlug ? urlSlugToProjectType(effectiveTypeSlug) : null;
const isOnProjectTypeListing =
- !isInsideProject && Boolean(projectType) && hasIntermediateProjectsView(projectType!);
+ !isInsideProject &&
+ Boolean(projectType) &&
+ (hasIntermediateProjectsView(projectType!) || pathname.includes("/product-settings"));
const { isSubOrganization } = useOrganization();
let scope: "project" | "sub-org" | "org" | "pam" | "agent-vault" = "org";
diff --git a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/OrgSubmenuView.tsx b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/OrgSubmenuView.tsx
index fecad2a54f..42f79b43c5 100644
--- a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/OrgSubmenuView.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/OrgSubmenuView.tsx
@@ -3,7 +3,6 @@ import {
ChevronLeft,
Cog,
KeyRound,
- LayoutTemplate,
Lock,
Network,
ShieldUser,
@@ -65,12 +64,6 @@ export const OrgSettingsSubmenuView = ({ onBack }: { onBack: () => void }) => {
pathSuffix: "settings",
search: { selectedTab: "tab-org-encryption" }
},
- {
- label: "Project Templates",
- icon: LayoutTemplate,
- pathSuffix: "settings",
- search: { selectedTab: "project-templates" }
- },
{
label: "Product Settings",
icon: SlidersHorizontal,
diff --git a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectNav.tsx b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectNav.tsx
index 78558536de..fb9d5c1bde 100644
--- a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectNav.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectNav.tsx
@@ -1,12 +1,25 @@
import { useEffect, useState } from "react";
-import { useLocation, useNavigate } from "@tanstack/react-router";
-import { ChevronLeft } from "lucide-react";
+import { Link, useLocation, useNavigate } from "@tanstack/react-router";
+import { ChevronLeft, SlidersHorizontal } from "lucide-react";
import { AnimatePresence, motion } from "motion/react";
-import { SidebarGroup, SidebarGroupLabel } from "@app/components/v3";
-import { useOrganization, useProject } from "@app/context";
+import {
+ SidebarGroup,
+ SidebarGroupLabel,
+ SidebarMenu,
+ SidebarMenuButton,
+ SidebarMenuItem
+} from "@app/components/v3";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useOrgPermission,
+ useProject
+} from "@app/context";
import {
hasIntermediateProjectsView,
+ hasProjectTemplates,
isOrgScopedProduct,
projectTypeToUrlSlug
} from "@app/helpers/project";
@@ -50,6 +63,7 @@ export const ProjectNav = () => {
const { currentOrg, isSubOrganization } = useOrganization();
const { pathname, search: locationSearch } = useLocation();
const navigate = useNavigate();
+ const { permission } = useOrgPermission();
const isLegacyView = (locationSearch as { legacy?: string })?.legacy === "true";
const hasApplicationContext = Boolean(
(locationSearch as { applicationName?: string })?.applicationName
@@ -66,6 +80,11 @@ export const ProjectNav = () => {
else if (isSubOrganization) projectLabel = "Sub-Organization";
else projectLabel = "Organization";
const NavComponent = PROJECT_NAV_COMPONENT[currentProject.type];
+ // Products with a projects listing link Product Settings from there; the rest link it here.
+ const showProductSettings =
+ !intermediateAvailable &&
+ hasProjectTemplates(currentProject.type) &&
+ permission.can(OrgPermissionActions.Read, OrgPermissionSubjects.ProjectTemplates);
// scott: we currently have to use this flaky inclusion for routes/nested routes because we haven't
// been consistent in using a route structure that reflects nested pages; once we refactor we can switch
@@ -177,6 +196,24 @@ export const ProjectNav = () => {
</button>
</SidebarGroupLabel>
<NavComponent onSubmenuOpen={handleSubmenuOpen} />
+ {showProductSettings && (
+ <SidebarMenu>
+ <SidebarMenuItem>
+ <SidebarMenuButton size="lg" asChild closeOnMobile tooltip="Product Settings">
+ <Link
+ to="/organizations/$orgId/projects/product-settings/$type"
+ params={{
+ orgId: currentOrg.id,
+ type: projectTypeToUrlSlug(currentProject.type)
+ }}
+ >
+ <SlidersHorizontal className="size-4" />
+ <span>Product Settings</span>
+ </Link>
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ </SidebarMenu>
+ )}
</SidebarGroup>
</motion.div>
)}
diff --git a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectTypeNav.tsx b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectTypeNav.tsx
index 01441d51d2..3ad1a26ffd 100644
--- a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectTypeNav.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectTypeNav.tsx
@@ -9,8 +9,17 @@ import {
SidebarMenuButton,
SidebarMenuItem
} from "@app/components/v3";
-import { useOrganization } from "@app/context";
-import { parseProjectSlugFromPath, urlSlugToProjectType } from "@app/helpers/project";
+import {
+ OrgPermissionActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useOrgPermission
+} from "@app/context";
+import {
+ hasProjectTemplates,
+ parseProjectSlugFromPath,
+ urlSlugToProjectType
+} from "@app/helpers/project";
import { ProjectType } from "@app/hooks/api/projects/types";
export const ProjectTypeNav = () => {
@@ -20,6 +29,7 @@ export const ProjectTypeNav = () => {
};
const { pathname } = useLocation();
const { currentOrg } = useOrganization();
+ const { permission } = useOrgPermission();
const resolvedOrgId = orgId ?? currentOrg.id;
// KMIP servers and Secret Sharing live at literal /projects/<slug>/<resource> paths (no $type
@@ -28,15 +38,17 @@ export const ProjectTypeNav = () => {
const isKms = typeSlug === ProjectType.KMS;
// Secret Manager's URL slug ("secret-management") differs from the enum value ("secret-manager"),
// so resolve through the helper rather than comparing the slug directly.
- const isSecretManager = typeSlug
- ? urlSlugToProjectType(typeSlug) === ProjectType.SecretManager
- : false;
+ const projectType = typeSlug ? urlSlugToProjectType(typeSlug) : null;
+ const isSecretManager = projectType === ProjectType.SecretManager;
+ const hasProductSettings =
+ isSecretManager ||
+ (projectType !== null &&
+ hasProjectTemplates(projectType) &&
+ permission.can(OrgPermissionActions.Read, OrgPermissionSubjects.ProjectTemplates));
const isOnKmipServers = pathname.includes("/kmip-servers");
const isOnSecretSharing = pathname.includes("/secret-sharing");
const isOnSecretManagementInsights = pathname.includes("/secret-management/insights");
- const isOnSecretManagementProductSettings = pathname.includes(
- "/secret-management/product-settings"
- );
+ const isOnProductSettings = pathname.includes("/product-settings");
return (
<SidebarGroup>
@@ -61,7 +73,7 @@ export const ProjectTypeNav = () => {
!isOnKmipServers &&
!isOnSecretSharing &&
!isOnSecretManagementInsights &&
- !isOnSecretManagementProductSettings
+ !isOnProductSettings
}
tooltip="Projects"
>
@@ -134,23 +146,33 @@ export const ProjectTypeNav = () => {
</SidebarMenuButton>
</SidebarMenuItem>
)}
- {isSecretManager && (
+ {hasProductSettings && (
<SidebarMenuItem>
<SidebarMenuButton
size="lg"
scope="project"
asChild
closeOnMobile
- isActive={isOnSecretManagementProductSettings}
+ isActive={isOnProductSettings}
tooltip="Product Settings"
>
- <Link
- to="/organizations/$orgId/projects/secret-management/product-settings"
- params={{ orgId: resolvedOrgId }}
- >
- <SlidersHorizontal className="size-4" />
- <span>Product Settings</span>
- </Link>
+ {isSecretManager ? (
+ <Link
+ to="/organizations/$orgId/projects/secret-management/product-settings"
+ params={{ orgId: resolvedOrgId }}
+ >
+ <SlidersHorizontal className="size-4" />
+ <span>Product Settings</span>
+ </Link>
+ ) : (
+ <Link
+ to="/organizations/$orgId/projects/product-settings/$type"
+ params={{ orgId: resolvedOrgId, type: typeSlug ?? "" }}
+ >
+ <SlidersHorizontal className="size-4" />
+ <span>Product Settings</span>
+ </Link>
+ )}
</SidebarMenuButton>
</SidebarMenuItem>
)}
diff --git a/frontend/src/pages/organization/ProductSettingsPage/ProjectTemplates/ProductSettingsPage.tsx b/frontend/src/pages/organization/ProductSettingsPage/ProjectTemplates/ProductSettingsPage.tsx
new file mode 100644
index 0000000000..212a5380d2
--- /dev/null
+++ b/frontend/src/pages/organization/ProductSettingsPage/ProjectTemplates/ProductSettingsPage.tsx
@@ -0,0 +1,60 @@
+import { Helmet } from "react-helmet";
+import { useNavigate, useParams } from "@tanstack/react-router";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import { PageHeader } from "@app/components/v3/platform";
+import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
+import { getProjectTitle, urlSlugToProjectType } from "@app/helpers/project";
+import { ProjectType } from "@app/hooks/api/projects/types";
+import { TProjectTemplate } from "@app/hooks/api/projectTemplates";
+
+import { ProjectTemplatesSection } from "../project-templates/ProjectTemplatesSection";
+
+export const ProductSettingsPage = () => {
+ const navigate = useNavigate();
+ const { currentOrg } = useOrganization();
+ const { type } = useParams({
+ from: "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type/"
+ });
+ const projectType = urlSlugToProjectType(type) as ProjectType;
+
+ const navigateToTemplate = (template: TProjectTemplate) => {
+ navigate({
+ to: "/organizations/$orgId/projects/product-settings/$type/project-templates/$templateId",
+ params: { orgId: currentOrg.id, type, templateId: template.id }
+ });
+ };
+
+ return (
+ <>
+ <Helmet>
+ <title>Product Settings | Infisical</title>
+ <link rel="icon" href="/infisical.ico" />
+ </Helmet>
+ <div className="h-full">
+ <div className="mx-auto h-full w-full max-w-8xl bg-page text-foreground-inverse">
+ <PageHeader
+ scope={projectType}
+ title="Product Settings"
+ description={`Configure organization-wide settings for ${getProjectTitle(projectType)} projects.`}
+ />
+ <div className="flex flex-col gap-4 pb-8">
+ <OrgPermissionCan
+ I={OrgPermissionActions.Read}
+ a={OrgPermissionSubjects.ProjectTemplates}
+ >
+ {(isAllowed) =>
+ isAllowed && (
+ <ProjectTemplatesSection
+ projectType={projectType}
+ onTemplateSelect={navigateToTemplate}
+ />
+ )
+ }
+ </OrgPermissionCan>
+ </div>
+ </div>
+ </div>
+ </>
+ );
+};
diff --git a/frontend/src/pages/organization/ProductSettingsPage/ProjectTemplates/project-templates/ProjectTemplatePage.tsx b/frontend/src/pages/organization/ProductSettingsPage/ProjectTemplates/project-templates/ProjectTemplatePage.tsx
new file mode 100644
index 0000000000..2dc294899a
--- /dev/null
+++ b/frontend/src/pages/organization/ProductSettingsPage/ProjectTemplates/project-templates/ProjectTemplatePage.tsx
@@ -0,0 +1,26 @@
+import { useNavigate, useParams } from "@tanstack/react-router";
+
+import { urlSlugToProjectType } from "@app/helpers/project";
+import { ProjectType } from "@app/hooks/api/projects/types";
+
+import { ProjectTemplatePage as ProjectTemplatePageBase } from "../../project-templates/ProjectTemplatePage";
+
+export const ProjectTemplatePage = () => {
+ const navigate = useNavigate();
+ const { orgId, type, templateId } = useParams({
+ from: "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type/project-templates/$templateId"
+ });
+
+ return (
+ <ProjectTemplatePageBase
+ templateId={templateId}
+ projectType={urlSlugToProjectType(type) as ProjectType}
+ onBack={() =>
+ navigate({
+ to: "/organizations/$orgId/projects/product-settings/$type",
+ params: { orgId, type }
+ })
+ }
+ />
+ );
+};
diff --git a/frontend/src/pages/organization/ProductSettingsPage/ProjectTemplates/project-templates/route.tsx b/frontend/src/pages/organization/ProductSettingsPage/ProjectTemplates/project-templates/route.tsx
new file mode 100644
index 0000000000..4ad2c06be6
--- /dev/null
+++ b/frontend/src/pages/organization/ProductSettingsPage/ProjectTemplates/project-templates/route.tsx
@@ -0,0 +1,49 @@
+import { createFileRoute, linkOptions, redirect } from "@tanstack/react-router";
+
+import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
+import { hasProjectTemplates, urlSlugToProjectType } from "@app/helpers/project";
+import { withPermission } from "@app/hoc";
+import { ProjectType } from "@app/hooks/api/projects/types";
+
+import { ProjectTemplatePage } from "./ProjectTemplatePage";
+
+const RouteComponent = withPermission(() => <ProjectTemplatePage />, {
+ action: OrgPermissionActions.Read,
+ subject: OrgPermissionSubjects.ProjectTemplates,
+ accessRestrictedMode: "dialog"
+});
+
+export const Route = createFileRoute(
+ "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type/project-templates/$templateId"
+)({
+ component: RouteComponent,
+ context: ({ params }) => ({
+ breadcrumbs: [
+ {
+ label: "Product Settings",
+ link: linkOptions({
+ to: "/organizations/$orgId/projects/product-settings/$type" as const,
+ params: { orgId: params.orgId, type: params.type }
+ })
+ },
+ {
+ label: "Project Templates"
+ }
+ ]
+ }),
+ beforeLoad: ({ params }) => {
+ const projectType = urlSlugToProjectType(params.type);
+ if (projectType === ProjectType.SecretManager) {
+ throw redirect({
+ to: "/organizations/$orgId/projects/secret-management/product-settings",
+ params: { orgId: params.orgId }
+ });
+ }
+ if (!projectType || !hasProjectTemplates(projectType)) {
+ throw redirect({
+ to: "/organizations/$orgId/projects",
+ params: { orgId: params.orgId }
+ });
+ }
+ }
+});
diff --git a/frontend/src/pages/organization/ProductSettingsPage/ProjectTemplates/route.tsx b/frontend/src/pages/organization/ProductSettingsPage/ProjectTemplates/route.tsx
new file mode 100644
index 0000000000..d15243fc0a
--- /dev/null
+++ b/frontend/src/pages/organization/ProductSettingsPage/ProjectTemplates/route.tsx
@@ -0,0 +1,34 @@
+import { createFileRoute, redirect } from "@tanstack/react-router";
+
+import { hasProjectTemplates, urlSlugToProjectType } from "@app/helpers/project";
+import { ProjectType } from "@app/hooks/api/projects/types";
+
+import { ProductSettingsPage } from "./ProductSettingsPage";
+
+export const Route = createFileRoute(
+ "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type/"
+)({
+ component: ProductSettingsPage,
+ context: () => ({
+ breadcrumbs: [
+ {
+ label: "Product Settings"
+ }
+ ]
+ }),
+ beforeLoad: ({ params }) => {
+ const projectType = urlSlugToProjectType(params.type);
+ if (projectType === ProjectType.SecretManager) {
+ throw redirect({
+ to: "/organizations/$orgId/projects/secret-management/product-settings",
+ params: { orgId: params.orgId }
+ });
+ }
+ if (!projectType || !hasProjectTemplates(projectType)) {
+ throw redirect({
+ to: "/organizations/$orgId/projects",
+ params: { orgId: params.orgId }
+ });
+ }
+ }
+});
diff --git a/frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplatePage.tsx b/frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplatePage.tsx
index 99e8308fc3..157e467d5b 100644
--- a/frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplatePage.tsx
+++ b/frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplatePage.tsx
@@ -35,8 +35,11 @@ export const ProjectTemplatePage = ({ templateId, projectType, onBack }: Props)
"editDetails"
] as const);
+ const matchingProjectTemplate =
+ projectTemplate?.type === projectType ? projectTemplate : undefined;
const templateName =
- projectTemplate?.name ?? projectTemplates.find((t) => t.id === templateId)?.name;
+ matchingProjectTemplate?.name ??
+ projectTemplates.find((t) => t.id === templateId && t.type === projectType)?.name;
const isInfisicalTemplate = templateName === InfisicalProjectTemplate.Default;
@@ -73,16 +76,16 @@ export const ProjectTemplatePage = ({ templateId, projectType, onBack }: Props)
description={
<>
{getProjectTitle(projectType)}
- {projectTemplate?.description && (
+ {matchingProjectTemplate?.description && (
<>
<span className="px-2 text-surface-selected">&bull;</span>
- {projectTemplate.description}
+ {matchingProjectTemplate.description}
</>
)}
</>
}
>
- {!isInfisicalTemplate && (
+ {matchingProjectTemplate && !isInfisicalTemplate && (
<>
<OrgPermissionCan
I={OrgPermissionActions.Edit}
@@ -122,17 +125,17 @@ export const ProjectTemplatePage = ({ templateId, projectType, onBack }: Props)
</div>
</div>
</div>
- {projectTemplate && (
+ {matchingProjectTemplate && (
<>
<ProjectTemplateDetailsModal
projectType={projectType}
isOpen={popUp.editDetails.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("editDetails", isOpen)}
- projectTemplate={projectTemplate}
+ projectTemplate={matchingProjectTemplate}
/>
<DeleteActionModal
isOpen={popUp.removeTemplate.isOpen}
- title={`Are you sure you want to delete ${projectTemplate.name}?`}
+ title={`Are you sure you want to delete ${matchingProjectTemplate.name}?`}
deleteKey="confirm"
onChange={(isOpen) => handlePopUpToggle("removeTemplate", isOpen)}
onDeleteApproved={handleRemoveTemplate}
diff --git a/frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplatesSection.tsx b/frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplatesSection.tsx
index 7174214c11..5336b6a187 100644
--- a/frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplatesSection.tsx
+++ b/frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplatesSection.tsx
@@ -41,8 +41,9 @@ export const ProjectTemplatesSection = ({ projectType, onTemplateSelect }: Props
Project Templates
</CardTitle>
<CardDescription>
- Create and configure templates with predefined roles and environments to streamline
- project setup.
+ Create and configure templates with predefined roles
+ {projectType === ProjectType.SecretManager && " and environments"} to streamline project
+ setup.
</CardDescription>
<CardAction>
<OrgPermissionCan
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgProductSettingsTab/OrgProductSettingsTab.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgProductSettingsTab/OrgProductSettingsTab.tsx
index ffcb77d924..c5333dd372 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgProductSettingsTab/OrgProductSettingsTab.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgProductSettingsTab/OrgProductSettingsTab.tsx
@@ -1,12 +1,27 @@
import { Link } from "@tanstack/react-router";
-import { InfoIcon } from "lucide-react";
+import { InfoIcon, LayoutTemplate } from "lucide-react";
-import { AlertDescription, AlertTitle, DismissableAlert } from "@app/components/v3";
-import { useOrganization } from "@app/context";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ AlertDescription,
+ AlertTitle,
+ Button,
+ Card,
+ CardDescription,
+ CardFooter,
+ CardHeader,
+ CardTitle,
+ DismissableAlert
+} from "@app/components/v3";
+import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
+import { getProjectTitle, projectTypeToUrlSlug } from "@app/helpers/project";
+import { ProjectType } from "@app/hooks/api/projects/types";
import { OrgCertManagerTab } from "../OrgCertManagerTab";
import { OrgSecretScanningTab } from "../OrgSecretScanningTab";
+const TEMPLATE_PRODUCTS = [ProjectType.KMS, ProjectType.SecretScanning, ProjectType.PAM];
+
export const OrgProductSettingsTab = () => {
const { currentOrg } = useOrganization();
@@ -30,6 +45,35 @@ export const OrgProductSettingsTab = () => {
.
</AlertDescription>
</DismissableAlert>
+ <OrgPermissionCan I={OrgPermissionActions.Read} a={OrgPermissionSubjects.ProjectTemplates}>
+ {(isAllowed) =>
+ isAllowed && (
+ <Card>
+ <CardHeader>
+ <CardTitle>
+ <LayoutTemplate className="size-4 text-accent" />
+ Project Templates
+ </CardTitle>
+ <CardDescription>
+ Project templates are managed in each product&apos;s settings.
+ </CardDescription>
+ </CardHeader>
+ <CardFooter className="flex-wrap gap-2">
+ {TEMPLATE_PRODUCTS.map((type) => (
+ <Button key={type} variant="outline" asChild>
+ <Link
+ to="/organizations/$orgId/projects/product-settings/$type"
+ params={{ orgId: currentOrg.id, type: projectTypeToUrlSlug(type) }}
+ >
+ {getProjectTitle(type)}
+ </Link>
+ </Button>
+ ))}
+ </CardFooter>
+ </Card>
+ )
+ }
+ </OrgPermissionCan>
<OrgCertManagerTab />
<OrgSecretScanningTab />
</div>
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgTabGroup/OrgTabGroup.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgTabGroup/OrgTabGroup.tsx
index 793b6f2f82..79eb880da1 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgTabGroup/OrgTabGroup.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgTabGroup/OrgTabGroup.tsx
@@ -18,7 +18,6 @@ import { OrgGeneralTab } from "../OrgGeneralTab";
import { OrgProductSettingsTab } from "../OrgProductSettingsTab";
import { OrgSecurityTab } from "../OrgSecurityTab";
import { OrgSubOrgsTab } from "../OrgSubOrgsTab";
-import { ProjectTemplatesTab } from "../ProjectTemplatesTab";
export const OrgTabGroup = () => {
const { t } = useTranslation();
@@ -53,13 +52,6 @@ export const OrgTabGroup = () => {
isSubOrganization ? "sub-" : ""
}organization's data.`
},
- {
- name: "Project Templates",
- key: "project-templates",
- component: ProjectTemplatesTab,
- description:
- "Create reusable templates that standardize roles and environments for new projects."
- },
{
name: "Product Settings",
key: "product-settings",
diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/ProjectTemplatesTab.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/ProjectTemplatesTab.tsx
deleted file mode 100644
index 7ef4cb25a1..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/ProjectTemplatesTab.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import { Link } from "@tanstack/react-router";
-import { InfoIcon } from "lucide-react";
-
-import { AlertDescription, AlertTitle, DismissableAlert } from "@app/components/v3";
-import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
-import { withPermission } from "@app/hoc";
-
-import { ProjectTemplatesSection } from "./components";
-
-export const ProjectTemplatesTab = withPermission(
- () => {
- const { currentOrg } = useOrganization();
-
- return (
- <div className="flex flex-col gap-4">
- <DismissableAlert
- variant="info"
- actionKey="secret_management_templates_moved_banner_dismissed"
- >
- <InfoIcon />
- <AlertTitle>Secret Management Templates Have Moved</AlertTitle>
- <AlertDescription className="inline">
- Secret management templates are now defined under{" "}
- <Link
- to="/organizations/$orgId/projects/secret-management/product-settings"
- params={{ orgId: currentOrg.id }}
- className="inline underline hover:opacity-80"
- >
- Secret Management Product Settings
- </Link>
- .
- </AlertDescription>
- </DismissableAlert>
- <ProjectTemplatesSection />
- </div>
- );
- },
- {
- action: OrgPermissionActions.Read,
- subject: OrgPermissionSubjects.ProjectTemplates,
- accessRestrictedMode: "dialog"
- }
-);
diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/DeleteProjectTemplateModal.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/DeleteProjectTemplateModal.tsx
deleted file mode 100644
index 33b54afcab..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/DeleteProjectTemplateModal.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { createNotification } from "@app/components/notifications";
-import { DeleteActionModal } from "@app/components/v2";
-import { TProjectTemplate, useDeleteProjectTemplate } from "@app/hooks/api/projectTemplates";
-
-type Props = {
- template?: TProjectTemplate;
- isOpen: boolean;
- onOpenChange: (isOpen: boolean) => void;
-};
-
-export const DeleteProjectTemplateModal = ({ isOpen, onOpenChange, template }: Props) => {
- const deleteTemplate = useDeleteProjectTemplate();
-
- if (!template) return null;
-
- const { id: templateId, name } = template;
-
- const handleDeleteProjectTemplate = async () => {
- await deleteTemplate.mutateAsync({
- templateId
- });
-
- createNotification({
- text: "Successfully removed project template",
- type: "success"
- });
-
- onOpenChange(false);
- };
-
- return (
- <DeleteActionModal
- isOpen={isOpen}
- onChange={onOpenChange}
- title={`Are you sure you want to delete ${name}?`}
- deleteKey="confirm"
- onDeleteApproved={handleDeleteProjectTemplate}
- />
- );
-};
diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/EditProjectTemplateSection.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/EditProjectTemplateSection.tsx
deleted file mode 100644
index 439f71718a..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/EditProjectTemplateSection.tsx
+++ /dev/null
@@ -1,56 +0,0 @@
-import { faChevronLeft } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-
-import { Button, EmptyState, Spinner } from "@app/components/v2";
-import {
- InfisicalProjectTemplate,
- TProjectTemplate,
- useGetProjectTemplateById
-} from "@app/hooks/api/projectTemplates";
-
-import { EditProjectTemplate } from "./components";
-
-type Props = {
- template: TProjectTemplate;
- onBack: () => void;
-};
-
-export const EditProjectTemplateSection = ({ template, onBack }: Props) => {
- const isInfisicalTemplate = Object.values(InfisicalProjectTemplate).includes(
- template.name as InfisicalProjectTemplate
- );
-
- const { data: projectTemplate, isPending } = useGetProjectTemplateById(template.id, {
- initialData: template,
- enabled: !isInfisicalTemplate
- });
- const finalTemplate = isInfisicalTemplate ? template : projectTemplate;
-
- return (
- <div>
- <Button
- variant="link"
- type="submit"
- leftIcon={<FontAwesomeIcon icon={faChevronLeft} />}
- onClick={onBack}
- className="mb-4"
- >
- Back to Templates
- </Button>
- {/* eslint-disable-next-line no-nested-ternary */}
- {isPending ? (
- <div className="flex h-[60vh] w-full items-center justify-center p-24">
- <Spinner />
- </div>
- ) : finalTemplate ? (
- <EditProjectTemplate
- isInfisicalTemplate={isInfisicalTemplate}
- projectTemplate={finalTemplate}
- onBack={onBack}
- />
- ) : (
- <EmptyState title="Error: Unable to find project template." className="py-12" />
- )}
- </div>
- );
-};
diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/EditProjectTemplate.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/EditProjectTemplate.tsx
deleted file mode 100644
index c3c682a9a3..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/EditProjectTemplate.tsx
+++ /dev/null
@@ -1,128 +0,0 @@
-import { faPencil, faTrash } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-
-import { createNotification } from "@app/components/notifications";
-import { OrgPermissionCan } from "@app/components/permissions";
-import { Button, DeleteActionModal } from "@app/components/v2";
-import { OrgPermissionActions, OrgPermissionSubjects } from "@app/context";
-import { getProjectTitle } from "@app/helpers/project";
-import { usePopUp } from "@app/hooks";
-import { ProjectType } from "@app/hooks/api/projects/types";
-import { TProjectTemplate, useDeleteProjectTemplate } from "@app/hooks/api/projectTemplates";
-
-import { ProjectTemplateDetailsModal } from "../../ProjectTemplateDetailsModal";
-import { ProjectTemplateEnvironmentsForm } from "./ProjectTemplateEnvironmentsForm";
-import { ProjectTemplateGroupsSection } from "./ProjectTemplateGroupsSection";
-import { ProjectTemplateIdentitiesSection } from "./ProjectTemplateIdentitiesSection";
-import { ProjectTemplateRolesSection } from "./ProjectTemplateRolesSection";
-import { ProjectTemplateUsersSection } from "./ProjectTemplateUsersSection";
-
-type Props = {
- projectTemplate: TProjectTemplate;
- onBack: () => void;
- isInfisicalTemplate: boolean;
-};
-
-export const EditProjectTemplate = ({ isInfisicalTemplate, projectTemplate, onBack }: Props) => {
- const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
- "removeTemplate",
- "editDetails"
- ] as const);
-
- const { id: templateId, name, description, type } = projectTemplate;
-
- const deleteProjectTemplate = useDeleteProjectTemplate();
-
- const handleRemoveTemplate = async () => {
- await deleteProjectTemplate.mutateAsync({
- templateId
- });
- createNotification({
- text: "Successfully removed project template",
- type: "success"
- });
- onBack();
- handlePopUpClose("removeTemplate");
- };
-
- return (
- <>
- <div className="mb-4 flex items-start justify-between border-b border-border-secondary-strong pb-4">
- <div className="flex-col">
- <h3 className="text-xl font-normal">{name}</h3>
- <h2 className="text-sm text-muted">
- {`${getProjectTitle(type)} - `}
- {description || "Project Template"}
- </h2>
- </div>
- {!isInfisicalTemplate && (
- <div className="flex gap-2">
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <Button
- isDisabled={!isAllowed}
- leftIcon={<FontAwesomeIcon icon={faPencil} />}
- size="xs"
- colorSchema="secondary"
- onClick={() => handlePopUpOpen("editDetails")}
- >
- Edit Details
- </Button>
- )}
- </OrgPermissionCan>
- <OrgPermissionCan
- I={OrgPermissionActions.Delete}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <Button
- isDisabled={!isAllowed}
- onClick={() => {
- handlePopUpOpen("removeTemplate");
- }}
- leftIcon={<FontAwesomeIcon icon={faTrash} />}
- size="xs"
- colorSchema="danger"
- >
- Delete Template
- </Button>
- )}
- </OrgPermissionCan>
- </div>
- )}
- </div>
- {type === ProjectType.SecretManager && (
- <ProjectTemplateEnvironmentsForm
- isInfisicalTemplate={isInfisicalTemplate}
- projectTemplate={projectTemplate}
- />
- )}
- <ProjectTemplateRolesSection
- isInfisicalTemplate={isInfisicalTemplate}
- projectTemplate={projectTemplate}
- />
- {!isInfisicalTemplate && (
- <>
- <ProjectTemplateUsersSection projectTemplate={projectTemplate} />
- <ProjectTemplateGroupsSection projectTemplate={projectTemplate} />
- <ProjectTemplateIdentitiesSection projectTemplate={projectTemplate} />
- </>
- )}
- <ProjectTemplateDetailsModal
- isOpen={popUp.editDetails.isOpen}
- onOpenChange={(isOpen) => handlePopUpToggle("editDetails", isOpen)}
- projectTemplate={projectTemplate}
- />
- <DeleteActionModal
- isOpen={popUp.removeTemplate.isOpen}
- title={`Are you sure you want to delete ${projectTemplate.name}?`}
- deleteKey="confirm"
- onChange={(isOpen) => handlePopUpToggle("removeTemplate", isOpen)}
- onDeleteApproved={handleRemoveTemplate}
- />
- </>
- );
-};
diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateEditRoleForm.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateEditRoleForm.tsx
deleted file mode 100644
index e337614afc..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateEditRoleForm.tsx
+++ /dev/null
@@ -1,235 +0,0 @@
-import { useEffect, useMemo, useState } from "react";
-import { Controller, FormProvider, useForm, useWatch } from "react-hook-form";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { ChevronLeftIcon, SaveIcon } from "lucide-react";
-import { z } from "zod";
-
-import { createNotification } from "@app/components/notifications";
-import { FormControl, Input } from "@app/components/v2";
-import { Accordion, Button } from "@app/components/v3";
-import { ProjectPermissionSub } from "@app/context";
-import { isCustomProjectRole } from "@app/helpers/roles";
-import { TProjectTemplate, useUpdateProjectTemplate } from "@app/hooks/api/projectTemplates";
-import { slugSchema } from "@app/lib/schemas";
-import { AddPoliciesButton } from "@app/pages/project/RoleDetailsBySlugPage/components/AddPoliciesButton";
-import {
- GeneralPermissionPolicies,
- PermissionScope,
- TPermissionAction
-} from "@app/pages/project/RoleDetailsBySlugPage/components/GeneralPermissionPolicies";
-import { PermissionEmptyState } from "@app/pages/project/RoleDetailsBySlugPage/components/PermissionEmptyState";
-import {
- formRolePermission2API,
- isConditionalSubjects,
- PROJECT_PERMISSION_OBJECT,
- projectRoleFormSchema,
- rolePermission2Form
-} from "@app/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils";
-import { renderConditionalComponents } from "@app/pages/project/RoleDetailsBySlugPage/components/RolePermissionsSection";
-
-type Props = {
- projectTemplate: TProjectTemplate;
- role?: TProjectTemplate["roles"][number];
- onGoBack: () => void;
- isDisabled?: boolean;
-};
-
-const formSchema = z.object({
- slug: slugSchema(),
- name: z.string().trim().min(1),
- permissions: projectRoleFormSchema.shape.permissions
-});
-
-type TFormSchema = z.infer<typeof formSchema>;
-
-export const ProjectTemplateEditRoleForm = ({
- onGoBack,
- projectTemplate,
- role,
- isDisabled
-}: Props) => {
- const [openPolicies, setOpenPolicies] = useState<string[]>([]);
-
- const formMethods = useForm<TFormSchema>({
- resolver: zodResolver(formSchema),
- defaultValues: {
- name: "",
- slug: "",
- permissions: {}
- }
- });
-
- const {
- handleSubmit,
- control,
- formState: { isDirty, isSubmitting },
- reset
- } = formMethods;
-
- useEffect(() => {
- if (role) {
- reset({ ...role, permissions: rolePermission2Form(role.permissions) });
- }
- }, [role, reset]);
-
- const updateProjectTemplate = useUpdateProjectTemplate();
-
- const permissions = useWatch({ control, name: "permissions" });
-
- const hasPermissions = useMemo(
- () => Object.entries(permissions || {}).some(([key, value]) => key && value?.length > 0),
- [permissions]
- );
-
- const onSubmit = async (form: TFormSchema) => {
- await updateProjectTemplate.mutateAsync({
- templateId: projectTemplate.id,
- roles: [
- ...projectTemplate.roles.filter(
- (r) => r.slug !== role?.slug && isCustomProjectRole(r.slug) // filter out default roles as well
- ),
- {
- ...form,
- permissions: formRolePermission2API(form.permissions)
- }
- ]
- });
- onGoBack();
- createNotification({
- text: "Template roles successfully updated",
- type: "success"
- });
- };
-
- // Expand accordion items that have validation errors
- const handleFormSubmit = handleSubmit(onSubmit, (formErrors) => {
- if (formErrors.permissions) {
- const subjectsWithErrors = Object.keys(formErrors.permissions) as ProjectPermissionSub[];
- setOpenPolicies((prev) => {
- const newOpenPolicies = new Set(prev);
- subjectsWithErrors.forEach((permissionSubject) => newOpenPolicies.add(permissionSubject));
- return Array.from(newOpenPolicies);
- });
- }
- });
-
- return (
- <form
- onSubmit={handleFormSubmit}
- className="w-full rounded-lg border border-border-control bg-surface-base p-4"
- >
- <FormProvider {...formMethods}>
- <div className="flex items-center justify-between border-b border-border-emphasis pb-2">
- <Button variant="ghost" disabled={isSubmitting} onClick={onGoBack}>
- <ChevronLeftIcon />
- {isDisabled ? "Back" : "Cancel"}
- </Button>
- {!isDisabled && (
- <div className="flex items-center gap-2">
- {isDirty && (
- <Button
- type="button"
- className="mr-4 text-muted"
- variant="ghost"
- disabled={isSubmitting}
- onClick={() => {
- if (role) {
- reset({ ...role, permissions: rolePermission2Form(role.permissions) });
- } else {
- onGoBack();
- }
- }}
- >
- Discard
- </Button>
- )}
- <Button variant="project" type="submit" disabled={isSubmitting || !isDirty}>
- <SaveIcon />
- Save
- </Button>
- <div className="ml-2 border-l border-border pl-4">
- <AddPoliciesButton isDisabled={isDisabled} projectType={projectTemplate.type} />
- </div>
- </div>
- )}
- </div>
- <div className="mt-2 border-b border-border-cool-subtle p-4 pt-2 first:rounded-t-md last:rounded-b-md">
- {isDisabled ? (
- <div className="flex flex-col">
- <span className="text-lg font-medium">{role?.name}</span>
- <span className="text-muted">{role?.slug}</span>
- </div>
- ) : (
- <div className="flex w-full gap-2">
- <Controller
- control={control}
- name="name"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- isError={Boolean(error?.message)}
- errorText={error?.message}
- label="Name"
- className="mb-0 flex-1"
- >
- <Input
- {...field}
- autoFocus
- placeholder="Role name..."
- autoComplete="off"
- name="project-template-role-name"
- />
- </FormControl>
- )}
- />
- <Controller
- control={control}
- name="slug"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- isError={Boolean(error?.message)}
- errorText={error?.message}
- label="Slug"
- className="mb-0 flex-1"
- >
- <Input {...field} placeholder="Role slug..." />
- </FormControl>
- )}
- />
- </div>
- )}
- </div>
- <div className="p-4">
- <div className="mb-2 text-lg">Policies</div>
- <PermissionEmptyState />
- {hasPermissions && (
- <Accordion
- type="multiple"
- value={openPolicies}
- onValueChange={setOpenPolicies}
- className="overflow-clip rounded-md border border-border bg-container"
- >
- {(Object.keys(PROJECT_PERMISSION_OBJECT) as ProjectPermissionSub[]).map((subject) => (
- <GeneralPermissionPolicies
- subject={subject}
- subjectScope={PermissionScope.Project}
- actions={PROJECT_PERMISSION_OBJECT[subject].actions as TPermissionAction[]}
- title={PROJECT_PERMISSION_OBJECT[subject].title}
- description={PROJECT_PERMISSION_OBJECT[subject].description}
- key={`project-permission-${subject}`}
- isDisabled={isDisabled}
- isOpen={openPolicies.includes(subject)}
- onPolicyAdded={() =>
- setOpenPolicies((prev) => (prev.includes(subject) ? prev : [...prev, subject]))
- }
- isConditional={isConditionalSubjects(subject)}
- >
- {renderConditionalComponents(subject, isDisabled)}
- </GeneralPermissionPolicies>
- ))}
- </Accordion>
- )}
- </div>
- </FormProvider>
- </form>
- );
-};
diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateEnvironmentsForm.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateEnvironmentsForm.tsx
deleted file mode 100644
index aa5ae42626..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateEnvironmentsForm.tsx
+++ /dev/null
@@ -1,281 +0,0 @@
-import { Controller, useFieldArray, useForm } from "react-hook-form";
-import { faArrowDown, faArrowUp, faPlus, faSave, faTrash } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { z } from "zod";
-
-import { createNotification } from "@app/components/notifications";
-import { OrgPermissionCan } from "@app/components/permissions";
-import {
- Button,
- FormControl,
- IconButton,
- Input,
- Table,
- TableContainer,
- TBody,
- Td,
- Th,
- THead,
- Tr
-} from "@app/components/v2";
-import { OrgPermissionActions, OrgPermissionSubjects, useSubscription } from "@app/context";
-import { TProjectTemplate, useUpdateProjectTemplate } from "@app/hooks/api/projectTemplates";
-import { slugSchema } from "@app/lib/schemas";
-
-type Props = {
- projectTemplate: TProjectTemplate;
- isInfisicalTemplate: boolean;
-};
-
-const formSchema = z.object({
- environments: z
- .object({
- name: z.string().trim().min(1),
- slug: slugSchema({ min: 1, max: 64 })
- })
- .array()
- .nullish()
-});
-
-type TFormSchema = z.infer<typeof formSchema>;
-
-export const ProjectTemplateEnvironmentsForm = ({
- projectTemplate,
- isInfisicalTemplate
-}: Props) => {
- const {
- control,
- handleSubmit,
- formState: { isDirty, errors },
- reset
- } = useForm<TFormSchema>({
- defaultValues: {
- environments: projectTemplate.environments
- },
- resolver: zodResolver(formSchema)
- });
-
- const { subscription } = useSubscription();
-
- const {
- fields: environments,
- move,
- remove,
- append
- } = useFieldArray({ control, name: "environments" });
-
- const updateProjectTemplate = useUpdateProjectTemplate();
-
- const onFormSubmit = async (form: TFormSchema) => {
- const { environments: updatedEnvs } = await updateProjectTemplate.mutateAsync({
- environments: form.environments?.map((env, index) => ({
- ...env,
- position: index + 1
- })),
- templateId: projectTemplate.id
- });
-
- reset({ environments: updatedEnvs });
-
- createNotification({
- text: "Project template updated successfully",
- type: "success"
- });
- };
-
- const isEnvironmentLimitExceeded =
- Boolean(subscription.environmentLimit) && environments.length >= subscription.environmentLimit;
-
- return (
- <form
- onSubmit={handleSubmit(onFormSubmit)}
- className="mb-6 rounded-lg border border-border-control bg-surface-base p-4"
- >
- <div className="mb-4 flex items-center justify-between border-b border-border-emphasis pb-4">
- <div>
- <h2 className="text-lg font-normal">Project Environments</h2>
- {!isInfisicalTemplate && (
- <p className="text-sm text-muted">
- Add, rename, remove and reorder environments for this project template
- </p>
- )}
- </div>
- {!isInfisicalTemplate && (
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <Button
- type="submit"
- colorSchema="primary"
- className="ml-auto w-40"
- variant={isDirty ? "solid" : "outline_bg"}
- leftIcon={<FontAwesomeIcon icon={faSave} />}
- isDisabled={!isAllowed || !isDirty}
- >
- {isDirty ? "Save" : "No"} Changes
- </Button>
- )}
- </OrgPermissionCan>
- )}
- </div>
- {errors.environments && (
- <span className="my-4 text-sm text-danger">{errors.environments.message}</span>
- )}
- <TableContainer>
- <Table>
- <THead>
- <Tr>
- <Th>Friendly Name</Th>
- <Th>Slug</Th>
- {!isInfisicalTemplate && (
- <Th>
- <div className="flex w-full justify-end normal-case">
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- renderTooltip={isEnvironmentLimitExceeded ? true : undefined}
- allowedLabel={`Plan environment limit of ${subscription.environmentLimit} exceeded. Contact Infisical to increase limit.`}
- >
- {(isAllowed) => (
- <Button
- onClick={() => append({ name: "", slug: "" })}
- colorSchema="secondary"
- className="ml-auto"
- variant="solid"
- size="xs"
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- isDisabled={!isAllowed || isEnvironmentLimitExceeded}
- >
- Add Environment
- </Button>
- )}
- </OrgPermissionCan>
- </div>
- </Th>
- )}
- </Tr>
- </THead>
- <TBody>
- {environments.map(({ id, name, slug }, pos) => (
- <Tr key={id}>
- <Td>
- {isInfisicalTemplate ? (
- name
- ) : (
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <Controller
- control={control}
- name={`environments.${pos}.name`}
- render={({ field, fieldState: { error } }) => (
- <FormControl
- isError={Boolean(error?.message)}
- errorText={error?.message}
- className="mb-0 grow"
- >
- <Input isDisabled={!isAllowed} {...field} placeholder="Name..." />
- </FormControl>
- )}
- />
- )}
- </OrgPermissionCan>
- )}
- </Td>
- <Td>
- {isInfisicalTemplate ? (
- slug
- ) : (
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <Controller
- control={control}
- name={`environments.${pos}.slug`}
- render={({ field, fieldState: { error } }) => (
- <FormControl
- isError={Boolean(error?.message)}
- errorText={error?.message}
- className="mb-0 grow"
- >
- <Input isDisabled={!isAllowed} {...field} placeholder="Slug..." />
- </FormControl>
- )}
- />
- )}
- </OrgPermissionCan>
- )}
- </Td>
- {!isInfisicalTemplate && (
- <Td className="flex items-center justify-end">
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <IconButton
- className={`mr-3 py-2 ${
- pos === environments.length - 1 ? "pointer-events-none opacity-50" : ""
- }`}
- onClick={() => move(pos, pos + 1)}
- colorSchema="primary"
- variant="plain"
- ariaLabel="Increase position"
- isDisabled={pos === environments.length - 1 || !isAllowed}
- >
- <FontAwesomeIcon icon={faArrowDown} />
- </IconButton>
- )}
- </OrgPermissionCan>
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <IconButton
- className={`mr-3 py-2 ${
- pos === 0 ? "pointer-events-none opacity-50" : ""
- }`}
- onClick={() => move(pos, pos - 1)}
- colorSchema="primary"
- variant="plain"
- ariaLabel="Decrease position"
- isDisabled={pos === 0 || !isAllowed}
- >
- <FontAwesomeIcon icon={faArrowUp} />
- </IconButton>
- )}
- </OrgPermissionCan>
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <IconButton
- onClick={() => remove(pos)}
- colorSchema="danger"
- variant="plain"
- ariaLabel="Remove environment"
- isDisabled={!isAllowed}
- >
- <FontAwesomeIcon icon={faTrash} />
- </IconButton>
- )}
- </OrgPermissionCan>
- </Td>
- )}
- </Tr>
- ))}
- </TBody>
- </Table>
- </TableContainer>
- </form>
- );
-};
diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateGroupsSection.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateGroupsSection.tsx
deleted file mode 100644
index 97842a3a41..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateGroupsSection.tsx
+++ /dev/null
@@ -1,421 +0,0 @@
-import { useMemo, useState } from "react";
-import { Controller, useFieldArray, useForm } from "react-hook-form";
-import { faPlus, faSave, faTrash, faUsers } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { z } from "zod";
-
-import { createNotification } from "@app/components/notifications";
-import { OrgPermissionCan } from "@app/components/permissions";
-import {
- Button,
- EmptyState,
- FilterableSelect,
- FormControl,
- IconButton,
- Modal,
- ModalContent,
- Table,
- TableContainer,
- TBody,
- Td,
- Th,
- THead,
- Tr
-} from "@app/components/v2";
-import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
-import { useGetOrganizationGroups } from "@app/hooks/api";
-import {
- TProjectTemplate,
- TProjectTemplateGroup,
- useUpdateProjectTemplate
-} from "@app/hooks/api/projectTemplates";
-
-type Props = {
- projectTemplate: TProjectTemplate;
-};
-
-const formSchema = z.object({
- groups: z
- .object({
- groupSlug: z.string().min(1),
- roles: z.array(z.string()).min(1, "At least one role is required")
- })
- .array()
-});
-
-type TFormSchema = z.infer<typeof formSchema>;
-
-const addGroupFormSchema = z.object({
- selectedGroups: z
- .array(
- z.object({
- slug: z.string(),
- name: z.string()
- })
- )
- .min(1, "Select at least one group"),
- roles: z
- .array(
- z.object({
- slug: z.string(),
- name: z.string()
- })
- )
- .min(1, "Select at least one role")
-});
-
-type TAddGroupForm = z.infer<typeof addGroupFormSchema>;
-
-export const ProjectTemplateGroupsSection = ({ projectTemplate }: Props) => {
- const { currentOrg } = useOrganization();
- const orgId = currentOrg?.id || "";
- const [isAddGroupModalOpen, setIsAddGroupModalOpen] = useState(false);
-
- const { data: orgGroups } = useGetOrganizationGroups(orgId);
-
- const {
- control,
- handleSubmit,
- formState: { isDirty, errors },
- reset,
- watch
- } = useForm<TFormSchema>({
- defaultValues: {
- groups: (projectTemplate.groups || []) as TProjectTemplateGroup[]
- },
- resolver: zodResolver(formSchema)
- });
-
- const { fields: groups, remove, append } = useFieldArray({ control, name: "groups" });
-
- const updateProjectTemplate = useUpdateProjectTemplate();
-
- const onFormSubmit = async (form: TFormSchema) => {
- await updateProjectTemplate.mutateAsync({
- groups: form.groups.length > 0 ? form.groups : null,
- templateId: projectTemplate.id
- });
-
- reset({ groups: form.groups });
-
- createNotification({
- text: "Project template groups updated successfully",
- type: "success"
- });
- };
-
- const handleDiscard = () => {
- reset({ groups: (projectTemplate.groups || []) as TProjectTemplateGroup[] });
- };
-
- // Available roles from template (predefined + custom)
- const availableRoles = useMemo(() => {
- const predefinedRoles = [
- { slug: "admin", name: "Admin" },
- { slug: "member", name: "Member" },
- { slug: "viewer", name: "Viewer" },
- { slug: "no-access", name: "No Access" }
- ];
-
- const customRoles = projectTemplate.roles
- .filter((role) => !["admin", "member", "viewer", "no-access", "custom"].includes(role.slug))
- .map((role) => ({ slug: role.slug, name: role.name }));
-
- return [...predefinedRoles, ...customRoles];
- }, [projectTemplate.roles]);
-
- // Org groups for dropdown, excluding already added groups
- const currentGroups = watch("groups");
- const availableOrgGroups = useMemo(() => {
- const addedGroupSlugs = new Set(currentGroups.map((g) => g.groupSlug.toLowerCase()));
- return (orgGroups || [])
- .filter((group) => !addedGroupSlugs.has(group.slug.toLowerCase()))
- .map((group) => ({
- slug: group.slug,
- name: group.name
- }));
- }, [orgGroups, currentGroups]);
-
- const getGroupName = (groupSlug: string) => {
- const group = orgGroups?.find((g) => g.slug.toLowerCase() === groupSlug.toLowerCase());
- return group?.name || groupSlug;
- };
-
- // Add group modal form
- const {
- control: addGroupControl,
- handleSubmit: handleAddGroupSubmit,
- reset: resetAddGroupForm,
- watch: watchAddGroup,
- formState: { errors: addGroupErrors }
- } = useForm<TAddGroupForm>({
- resolver: zodResolver(addGroupFormSchema),
- defaultValues: {
- selectedGroups: [],
- roles: []
- }
- });
-
- const selectedGroupsInModal = watchAddGroup("selectedGroups");
- const selectedRolesInModal = watchAddGroup("roles");
-
- const handleAddGroups = (form: TAddGroupForm) => {
- form.selectedGroups.forEach((group) => {
- append({
- groupSlug: group.slug,
- roles: form.roles.map((r) => r.slug)
- });
- });
- resetAddGroupForm();
- setIsAddGroupModalOpen(false);
- };
-
- const handleCloseAddGroupModal = () => {
- resetAddGroupForm();
- setIsAddGroupModalOpen(false);
- };
-
- return (
- <>
- <form
- onSubmit={handleSubmit(onFormSubmit)}
- className="mb-6 rounded-lg border border-border-control bg-surface-base p-4"
- >
- <div className="mb-4 flex items-center justify-between border-b border-border-emphasis pb-4">
- <div>
- <h2 className="text-lg font-normal">Project Groups</h2>
- <p className="text-sm text-muted">
- Add groups that will be automatically added to projects created from this template
- </p>
- </div>
-
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <div className="flex gap-3">
- {isAllowed && isDirty && (
- <>
- <Button
- onClick={handleDiscard}
- colorSchema="secondary"
- variant="plain"
- type="button"
- >
- Discard
- </Button>
- <Button
- type="submit"
- colorSchema="primary"
- variant="solid"
- leftIcon={<FontAwesomeIcon icon={faSave} />}
- >
- Save
- </Button>
- </>
- )}
- <Button
- onClick={() => setIsAddGroupModalOpen(true)}
- colorSchema="primary"
- variant="outline_bg"
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- isDisabled={!isAllowed || availableOrgGroups.length === 0}
- type="button"
- >
- Add Group
- </Button>
- </div>
- )}
- </OrgPermissionCan>
- </div>
- {errors.groups && <span className="my-4 text-sm text-danger">{errors.groups.message}</span>}
- <TableContainer>
- <Table>
- <THead>
- <Tr>
- <Th>Group</Th>
- <Th>Roles</Th>
- <Th className="w-16" />
- </Tr>
- </THead>
- <TBody>
- {groups.length > 0 ? (
- groups.map(({ id }, pos) => (
- <Tr key={id}>
- <Td className="w-1/4 max-w-0">
- <Controller
- control={control}
- name={`groups.${pos}.groupSlug`}
- render={({ field }) => (
- <p className="truncate">
- <span className="text-sm">{getGroupName(field.value)}</span>
- </p>
- )}
- />
- </Td>
- <Td>
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <Controller
- control={control}
- name={`groups.${pos}.roles`}
- render={({ field, fieldState: { error } }) => {
- // Include orphaned roles
- const availableRoleSlugs = new Set(availableRoles.map((r) => r.slug));
- const orphanedRoles = field.value
- .filter((slug) => !availableRoleSlugs.has(slug))
- .map((slug) => ({ slug, name: slug }));
- const allOptions = [...availableRoles, ...orphanedRoles];
-
- const selectedValues = allOptions.filter((role) =>
- field.value.includes(role.slug)
- );
-
- return (
- <FormControl
- isError={Boolean(error?.message)}
- errorText={error?.message}
- className="mb-0"
- >
- <FilterableSelect
- isMulti
- isDisabled={!isAllowed}
- options={allOptions}
- value={selectedValues}
- onChange={(selected) => {
- field.onChange(
- (selected as { slug: string; name: string }[]).map(
- (s) => s.slug
- )
- );
- }}
- getOptionValue={(option) => option.slug}
- getOptionLabel={(option) => option.name}
- placeholder="Select roles..."
- menuPosition="fixed"
- />
- </FormControl>
- );
- }}
- />
- )}
- </OrgPermissionCan>
- </Td>
- <Td>
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <IconButton
- onClick={() => remove(pos)}
- colorSchema="danger"
- variant="plain"
- ariaLabel="Remove group"
- isDisabled={!isAllowed}
- >
- <FontAwesomeIcon icon={faTrash} />
- </IconButton>
- )}
- </OrgPermissionCan>
- </Td>
- </Tr>
- ))
- ) : (
- <Tr>
- <Td colSpan={3}>
- <EmptyState title="No groups assigned to this template" icon={faUsers} />
- </Td>
- </Tr>
- )}
- </TBody>
- </Table>
- </TableContainer>
- </form>
-
- {/* Add Group Modal */}
- <Modal isOpen={isAddGroupModalOpen} onOpenChange={setIsAddGroupModalOpen}>
- <ModalContent
- title="Add Groups to Template"
- subTitle="Select groups and roles to add to this project template"
- bodyClassName="overflow-visible"
- >
- <form onSubmit={handleAddGroupSubmit(handleAddGroups)}>
- <div className="flex flex-col gap-4">
- <Controller
- control={addGroupControl}
- name="selectedGroups"
- render={({ field }) => (
- <FormControl
- label="Select groups"
- isError={Boolean(addGroupErrors.selectedGroups)}
- errorText={addGroupErrors.selectedGroups?.message}
- >
- <FilterableSelect
- isMulti
- options={availableOrgGroups}
- value={field.value}
- onChange={field.onChange}
- getOptionValue={(option) => option.slug}
- getOptionLabel={(option) => option.name}
- placeholder="Select one or more groups..."
- noOptionsMessage={() =>
- availableOrgGroups.length === 0
- ? "All organization groups have been added"
- : "No matching groups found"
- }
- />
- </FormControl>
- )}
- />
- <Controller
- control={addGroupControl}
- name="roles"
- render={({ field }) => (
- <FormControl
- label="Select roles"
- isError={Boolean(addGroupErrors.roles)}
- errorText={addGroupErrors.roles?.message}
- tooltipText="Select the roles that will be assigned to the selected groups"
- >
- <FilterableSelect
- isMulti
- options={availableRoles}
- value={field.value}
- onChange={field.onChange}
- getOptionValue={(option) => option.slug}
- getOptionLabel={(option) => option.name}
- placeholder="Select roles..."
- />
- </FormControl>
- )}
- />
- </div>
- <div className="mt-8 flex items-center gap-4">
- <Button
- type="submit"
- colorSchema="primary"
- isDisabled={selectedGroupsInModal.length === 0 || selectedRolesInModal.length === 0}
- >
- Add Groups
- </Button>
- <Button
- type="button"
- colorSchema="secondary"
- variant="plain"
- onClick={handleCloseAddGroupModal}
- >
- Cancel
- </Button>
- </div>
- </form>
- </ModalContent>
- </Modal>
- </>
- );
-};
diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateIdentitiesSection.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateIdentitiesSection.tsx
deleted file mode 100644
index 6e472b94ac..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateIdentitiesSection.tsx
+++ /dev/null
@@ -1,692 +0,0 @@
-import { useMemo, useState } from "react";
-import { Controller, useFieldArray, useForm } from "react-hook-form";
-import { faPlus, faSave, faServer, faTrash } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { InfoIcon } from "lucide-react";
-import { twMerge } from "tailwind-merge";
-import { z } from "zod";
-
-import { createNotification } from "@app/components/notifications";
-import { OrgPermissionCan } from "@app/components/permissions";
-import {
- Button,
- EmptyState,
- FilterableSelect,
- FormControl,
- IconButton,
- Input,
- Modal,
- ModalContent,
- Table,
- TableContainer,
- TBody,
- Td,
- Th,
- THead,
- Tooltip,
- Tr
-} from "@app/components/v2";
-import { Badge, OrgIcon, ProjectIcon } from "@app/components/v3";
-import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
-import { useDebounce } from "@app/hooks";
-import { useSearchOrgIdentityMemberships } from "@app/hooks/api";
-import {
- TProjectTemplate,
- TProjectTemplateIdentity,
- TProjectTemplateProjectManagedIdentity,
- useUpdateProjectTemplate
-} from "@app/hooks/api/projectTemplates";
-
-type Props = {
- projectTemplate: TProjectTemplate;
-};
-
-const formSchema = z.object({
- identities: z
- .object({
- identityId: z.string().uuid(),
- identityName: z.string(),
- roles: z.array(z.string()).min(1, "At least one role is required")
- })
- .array(),
- projectManagedIdentities: z
- .object({
- name: z.string().trim().min(1),
- roles: z.array(z.string()).min(1, "At least one role is required")
- })
- .array()
-});
-
-type TFormSchema = z.infer<typeof formSchema>;
-
-const addOrgIdentityFormSchema = z.object({
- selectedIdentity: z.object({
- id: z.string().uuid(),
- name: z.string()
- }),
- roles: z
- .array(
- z.object({
- slug: z.string(),
- name: z.string()
- })
- )
- .min(1, "Select at least one role")
-});
-
-type TAddOrgIdentityForm = z.infer<typeof addOrgIdentityFormSchema>;
-
-const addProjectIdentityFormSchema = z.object({
- name: z.string().trim().min(1, "Name is required"),
- roles: z
- .array(
- z.object({
- slug: z.string(),
- name: z.string()
- })
- )
- .min(1, "Select at least one role")
-});
-
-type TAddProjectIdentityForm = z.infer<typeof addProjectIdentityFormSchema>;
-
-enum AddIdentityType {
- CreateNew,
- AssignExisting
-}
-
-export const ProjectTemplateIdentitiesSection = ({ projectTemplate }: Props) => {
- const { currentOrg } = useOrganization();
-
- const [isAddIdentityModalOpen, setIsAddIdentityModalOpen] = useState(false);
-
- const [addMachineIdentityType, setAddMachineIdentityType] = useState<AddIdentityType>(
- AddIdentityType.CreateNew
- );
-
- const [identitySearchInput, setIdentitySearchInput] = useState("");
- const [debouncedIdentitySearch] = useDebounce(identitySearchInput, 300);
-
- const { data: searchedIdentitiesResponse, isPending: isSearchingIdentities } =
- useSearchOrgIdentityMemberships({
- orgId: currentOrg.id,
- limit: 100,
- search: debouncedIdentitySearch ? { name: { $contains: debouncedIdentitySearch } } : {}
- });
- const searchedIdentities = searchedIdentitiesResponse
- ? searchedIdentitiesResponse.identities.map((v) => v.identity)
- : [];
-
- const {
- control,
- handleSubmit,
- formState: { isDirty, errors },
- reset,
- watch
- } = useForm<TFormSchema>({
- defaultValues: {
- identities: (projectTemplate.identities || []) as TProjectTemplateIdentity[],
- projectManagedIdentities: (projectTemplate.projectManagedIdentities ||
- []) as TProjectTemplateProjectManagedIdentity[]
- },
- resolver: zodResolver(formSchema)
- });
-
- const {
- fields: identities,
- remove: removeIdentity,
- append: appendIdentity
- } = useFieldArray({ control, name: "identities" });
-
- const {
- fields: projectManagedIdentities,
- remove: removeProjectManagedIdentity,
- append: appendProjectManagedIdentity
- } = useFieldArray({ control, name: "projectManagedIdentities" });
-
- const updateProjectTemplate = useUpdateProjectTemplate();
-
- const onFormSubmit = async (form: TFormSchema) => {
- await updateProjectTemplate.mutateAsync({
- identities: form.identities.length > 0 ? form.identities : null,
- projectManagedIdentities:
- form.projectManagedIdentities.length > 0 ? form.projectManagedIdentities : null,
- templateId: projectTemplate.id
- });
-
- reset({
- identities: form.identities,
- projectManagedIdentities: form.projectManagedIdentities
- });
-
- createNotification({
- text: "Project template identities updated successfully",
- type: "success"
- });
- };
-
- const handleDiscard = () => {
- reset({
- identities: (projectTemplate.identities || []) as TProjectTemplateIdentity[],
- projectManagedIdentities: (projectTemplate.projectManagedIdentities ||
- []) as TProjectTemplateProjectManagedIdentity[]
- });
- };
-
- // Available roles from template (predefined + custom)
- const availableRoles = useMemo(() => {
- const predefinedRoles = [
- { slug: "admin", name: "Admin" },
- { slug: "member", name: "Member" },
- { slug: "viewer", name: "Viewer" },
- { slug: "no-access", name: "No Access" }
- ];
-
- const customRoles = projectTemplate.roles
- .filter((role) => !["admin", "member", "viewer", "no-access", "custom"].includes(role.slug))
- .map((role) => ({ slug: role.slug, name: role.name }));
-
- return [...predefinedRoles, ...customRoles];
- }, [projectTemplate.roles]);
-
- // Org identities for dropdown, excluding already added identities
- const currentIdentities = watch("identities");
- const availableOrgIdentities = useMemo(() => {
- const addedIdentityIds = new Set(currentIdentities.map((i) => i.identityId));
- return searchedIdentities
- .filter((identity) => !addedIdentityIds.has(identity.id))
- .map((identity) => ({
- id: identity.id,
- name: identity.name
- }));
- }, [searchedIdentities, currentIdentities]);
-
- // Add org identity modal form
- const {
- control: addOrgIdentityControl,
- handleSubmit: handleAddOrgIdentitySubmit,
- reset: resetAddOrgIdentityForm,
- watch: watchAddOrgIdentity,
- formState: { errors: addOrgIdentityErrors }
- } = useForm<TAddOrgIdentityForm>({
- resolver: zodResolver(addOrgIdentityFormSchema),
- defaultValues: {
- roles: []
- }
- });
-
- const selectedOrgIdentity = watchAddOrgIdentity("selectedIdentity");
- const selectedOrgRolesInModal = watchAddOrgIdentity("roles");
-
- const handleAddOrgIdentity = (form: TAddOrgIdentityForm) => {
- appendIdentity({
- identityId: form.selectedIdentity.id,
- identityName: form.selectedIdentity.name,
- roles: form.roles.map((r) => r.slug)
- });
- resetAddOrgIdentityForm();
- setIdentitySearchInput("");
- setIsAddIdentityModalOpen(false);
- };
-
- // Add project-managed identity modal form
- const {
- control: addProjectIdentityControl,
- handleSubmit: handleAddProjectIdentitySubmit,
- reset: resetAddProjectIdentityForm,
- watch: watchAddProjectIdentity,
- formState: { errors: addProjectIdentityErrors }
- } = useForm<TAddProjectIdentityForm>({
- resolver: zodResolver(addProjectIdentityFormSchema),
- defaultValues: {
- name: "",
- roles: []
- }
- });
-
- const projectIdentityName = watchAddProjectIdentity("name");
- const selectedProjectRolesInModal = watchAddProjectIdentity("roles");
-
- const handleAddProjectIdentity = (form: TAddProjectIdentityForm) => {
- appendProjectManagedIdentity({
- name: form.name,
- roles: form.roles.map((r) => r.slug)
- });
- resetAddProjectIdentityForm();
- setIsAddIdentityModalOpen(false);
- };
-
- const handleCloseAddIdentityModal = () => {
- resetAddOrgIdentityForm();
- resetAddProjectIdentityForm();
- setIdentitySearchInput("");
- setIsAddIdentityModalOpen(false);
- };
-
- // Combined list of all identities for the table
- const allIdentitiesForTable = useMemo(() => {
- const orgManaged = identities.map((identity, index) => ({
- type: "org" as const,
- index,
- id: identity.id,
- identityId: identity.identityId,
- name: identity.identityName,
- roles: currentIdentities[index]?.roles || []
- }));
-
- const projectManaged = projectManagedIdentities.map((identity, index) => ({
- type: "project" as const,
- index,
- id: identity.id,
- name: identity.name,
- roles: watch(`projectManagedIdentities.${index}.roles`) || []
- }));
-
- return [...projectManaged, ...orgManaged];
- }, [identities, projectManagedIdentities, currentIdentities, watch]);
-
- return (
- <>
- <form
- onSubmit={handleSubmit(onFormSubmit)}
- className="mb-6 rounded-lg border border-border-control bg-surface-base p-4"
- >
- <div className="mb-4 flex items-center justify-between border-b border-border-emphasis pb-4">
- <div>
- <h2 className="text-lg font-normal">Project Machine Identities</h2>
- <p className="text-sm text-muted">
- Add machine identities that will be automatically added to projects created from this
- template
- </p>
- </div>
-
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <div className="flex gap-3">
- {isAllowed && isDirty && (
- <>
- <Button
- onClick={handleDiscard}
- colorSchema="secondary"
- variant="plain"
- type="button"
- >
- Discard
- </Button>
- <Button
- type="submit"
- colorSchema="primary"
- variant="solid"
- leftIcon={<FontAwesomeIcon icon={faSave} />}
- >
- Save
- </Button>
- </>
- )}
- <Button
- onClick={() => setIsAddIdentityModalOpen(true)}
- colorSchema="primary"
- variant="outline_bg"
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- isDisabled={!isAllowed}
- type="button"
- >
- Add Machine Identity
- </Button>
- </div>
- )}
- </OrgPermissionCan>
- </div>
- {errors.identities && (
- <span className="my-4 text-sm text-danger">{errors.identities.message}</span>
- )}
- {errors.projectManagedIdentities && (
- <span className="my-4 text-sm text-danger">
- {errors.projectManagedIdentities.message}
- </span>
- )}
- <TableContainer>
- <Table>
- <THead>
- <Tr>
- <Th>Identity</Th>
- <Th>Roles</Th>
- <Th>Managed by</Th>
- <Th className="w-16" />
- </Tr>
- </THead>
- <TBody>
- {allIdentitiesForTable.length > 0 ? (
- allIdentitiesForTable.map((item) => (
- <Tr key={item.id}>
- <Td className="w-1/4 max-w-0">
- <p className="truncate">
- <span className="text-sm">{item.name}</span>
- </p>
- </Td>
- <Td>
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <Controller
- control={control}
- name={
- item.type === "org"
- ? `identities.${item.index}.roles`
- : `projectManagedIdentities.${item.index}.roles`
- }
- render={({ field, fieldState: { error } }) => {
- // Include orphaned roles
- const availableRoleSlugs = new Set(availableRoles.map((r) => r.slug));
- const orphanedRoles = field.value
- .filter((slug) => !availableRoleSlugs.has(slug))
- .map((slug) => ({ slug, name: slug }));
- const allOptions = [...availableRoles, ...orphanedRoles];
-
- const selectedValues = allOptions.filter((role) =>
- field.value.includes(role.slug)
- );
-
- return (
- <FormControl
- isError={Boolean(error?.message)}
- errorText={error?.message}
- className="mb-0"
- >
- <FilterableSelect
- isMulti
- isDisabled={!isAllowed}
- options={allOptions}
- value={selectedValues}
- onChange={(selected) => {
- field.onChange(
- (selected as { slug: string; name: string }[]).map(
- (s) => s.slug
- )
- );
- }}
- getOptionValue={(option) => option.slug}
- getOptionLabel={(option) => option.name}
- placeholder="Select roles..."
- menuPosition="fixed"
- />
- </FormControl>
- );
- }}
- />
- )}
- </OrgPermissionCan>
- </Td>
- <Td>
- <Badge variant={item.type === "project" ? "project" : "org"}>
- {item.type === "project" ? (
- <>
- <ProjectIcon />
- Project
- </>
- ) : (
- <>
- <OrgIcon />
- Organization
- </>
- )}
- </Badge>
- </Td>
- <Td>
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <IconButton
- onClick={() => {
- if (item.type === "org") {
- removeIdentity(item.index);
- } else {
- removeProjectManagedIdentity(item.index);
- }
- }}
- colorSchema="danger"
- variant="plain"
- ariaLabel="Remove identity"
- isDisabled={!isAllowed}
- >
- <FontAwesomeIcon icon={faTrash} />
- </IconButton>
- )}
- </OrgPermissionCan>
- </Td>
- </Tr>
- ))
- ) : (
- <Tr>
- <Td colSpan={4}>
- <EmptyState
- title="No machine identities assigned to this template"
- icon={faServer}
- />
- </Td>
- </Tr>
- )}
- </TBody>
- </Table>
- </TableContainer>
- </form>
-
- {/* Add Identity Modal */}
- <Modal isOpen={isAddIdentityModalOpen} onOpenChange={setIsAddIdentityModalOpen}>
- <ModalContent
- bodyClassName="overflow-visible"
- title="Add Machine Identity to Template"
- subTitle="Create a new machine identity or assign an existing one"
- >
- <div className="mb-4 flex items-center justify-center gap-x-2">
- <div className="flex w-3/4 gap-x-0.5 rounded-md border border-border-control bg-surface-raised p-1">
- <Button
- variant="outline_bg"
- onClick={() => {
- setAddMachineIdentityType(AddIdentityType.CreateNew);
- }}
- size="xs"
- className={twMerge(
- "min-w-[2.4rem] flex-1 rounded border-none hover:bg-surface-active",
- addMachineIdentityType === AddIdentityType.CreateNew
- ? "bg-surface-selected"
- : "bg-transparent"
- )}
- >
- Create New
- </Button>
- <Button
- variant="outline_bg"
- onClick={() => {
- setAddMachineIdentityType(AddIdentityType.AssignExisting);
- }}
- size="xs"
- className={twMerge(
- "min-w-[2.4rem] flex-1 rounded border-none hover:bg-surface-active",
- addMachineIdentityType === AddIdentityType.AssignExisting
- ? "bg-surface-selected"
- : "bg-transparent"
- )}
- >
- Assign Existing
- </Button>
- </div>
- <Tooltip
- className="max-w-sm"
- position="right"
- align="start"
- content={
- <>
- <p className="mb-2 text-label">
- You can add machine identities to your template in one of two ways:
- </p>
- <ul className="ml-3.5 flex list-disc flex-col gap-y-4">
- <li className="text-foreground-secondary">
- <strong className="font-medium text-foreground">Create New</strong> - Define a
- new machine identity that will be created when a project is made from this
- template.
- <p className="mt-2">
- This method is recommended for autonomous teams that need to manage machine
- identity authentication at the project level.
- </p>
- </li>
- <li>
- <strong className="font-medium text-foreground">Assign Existing</strong> -
- Assign an existing machine identity from your organization.
- <p className="mt-2">
- This method is recommended for organizations that need to maintain
- centralized control.
- </p>
- </li>
- </ul>
- </>
- }
- >
- <InfoIcon size={16} className="text-muted" />
- </Tooltip>
- </div>
- {addMachineIdentityType === AddIdentityType.CreateNew && (
- <form onSubmit={handleAddProjectIdentitySubmit(handleAddProjectIdentity)}>
- <Controller
- control={addProjectIdentityControl}
- name="name"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Name"
- errorText={error?.message}
- isError={Boolean(error)}
- className="mb-4"
- >
- <Input
- {...field}
- autoFocus
- placeholder="Machine Identity 1"
- autoComplete="off"
- name="project-template-identity-name"
- />
- </FormControl>
- )}
- />
- <Controller
- control={addProjectIdentityControl}
- name="roles"
- render={({ field }) => (
- <FormControl
- label="Select roles"
- isError={Boolean(addProjectIdentityErrors.roles)}
- errorText={addProjectIdentityErrors.roles?.message}
- tooltipText="Select the roles that will be assigned to this identity"
- >
- <FilterableSelect
- isMulti
- options={availableRoles}
- value={field.value}
- onChange={field.onChange}
- getOptionValue={(option) => option.slug}
- getOptionLabel={(option) => option.name}
- placeholder="Select roles..."
- />
- </FormControl>
- )}
- />
- <div className="flex items-center">
- <Button
- className="mr-4"
- size="sm"
- type="submit"
- isDisabled={!projectIdentityName || selectedProjectRolesInModal.length === 0}
- >
- Add to Template
- </Button>
- <Button
- type="button"
- colorSchema="secondary"
- variant="plain"
- onClick={handleCloseAddIdentityModal}
- >
- Cancel
- </Button>
- </div>
- </form>
- )}
- {addMachineIdentityType === AddIdentityType.AssignExisting && (
- <form onSubmit={handleAddOrgIdentitySubmit(handleAddOrgIdentity)}>
- <Controller
- control={addOrgIdentityControl}
- name="selectedIdentity"
- render={({ field: { onChange, value }, fieldState: { error } }) => (
- <FormControl
- label="Machine Identity"
- errorText={error?.message}
- isError={Boolean(error)}
- >
- <FilterableSelect
- value={value}
- onChange={onChange}
- isLoading={isSearchingIdentities}
- placeholder="Select machine identity..."
- autoFocus
- options={availableOrgIdentities}
- getOptionValue={(option) => option.id}
- getOptionLabel={(option) => option.name}
- onInputChange={(newValue) => setIdentitySearchInput(newValue)}
- filterOption={() => true}
- />
- </FormControl>
- )}
- />
- <Controller
- control={addOrgIdentityControl}
- name="roles"
- render={({ field }) => (
- <FormControl
- label="Select roles"
- isError={Boolean(addOrgIdentityErrors.roles)}
- errorText={addOrgIdentityErrors.roles?.message}
- tooltipText="Select the roles that will be assigned to the selected identity"
- >
- <FilterableSelect
- isMulti
- options={availableRoles}
- value={field.value}
- onChange={field.onChange}
- getOptionValue={(option) => option.slug}
- getOptionLabel={(option) => option.name}
- placeholder="Select roles..."
- />
- </FormControl>
- )}
- />
- <div className="flex items-center">
- <Button
- className="mr-4"
- size="sm"
- type="submit"
- isDisabled={!selectedOrgIdentity || selectedOrgRolesInModal.length === 0}
- >
- Assign to Template
- </Button>
- <Button
- type="button"
- colorSchema="secondary"
- variant="plain"
- onClick={handleCloseAddIdentityModal}
- >
- Cancel
- </Button>
- </div>
- </form>
- )}
- </ModalContent>
- </Modal>
- </>
- );
-};
diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateRolesSection.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateRolesSection.tsx
deleted file mode 100644
index e9d3441931..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateRolesSection.tsx
+++ /dev/null
@@ -1,217 +0,0 @@
-import { faPlus, faTrash, faUnlock } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-
-import { createNotification } from "@app/components/notifications";
-import { OrgPermissionCan } from "@app/components/permissions";
-import {
- Button,
- DeleteActionModal,
- EmptyState,
- IconButton,
- Table,
- TableContainer,
- TBody,
- Td,
- Th,
- THead,
- Tr
-} from "@app/components/v2";
-import { OrgPermissionActions, OrgPermissionSubjects, useOrgPermission } from "@app/context";
-import { isCustomProjectRole } from "@app/helpers/roles";
-import { usePopUp } from "@app/hooks";
-import { TProjectTemplate, useUpdateProjectTemplate } from "@app/hooks/api/projectTemplates";
-import { TProjectRole } from "@app/hooks/api/roles/types";
-
-import { ProjectTemplateEditRoleForm } from "./ProjectTemplateEditRoleForm";
-
-type Props = {
- projectTemplate: TProjectTemplate;
- isInfisicalTemplate: boolean;
-};
-
-export const ProjectTemplateRolesSection = ({ projectTemplate, isInfisicalTemplate }: Props) => {
- const { popUp, handlePopUpOpen, handlePopUpToggle, handlePopUpClose } = usePopUp([
- "removeRole",
- "editRole"
- ] as const);
-
- const { permission } = useOrgPermission();
-
- const { roles } = projectTemplate;
-
- const updateProjectTemplate = useUpdateProjectTemplate();
-
- const handleRemoveRole = async (slug: string) => {
- // Check if role is used by users, groups, or identities
- const usersWithRole = projectTemplate.users?.filter((u) => u.roles.includes(slug)) || [];
- const groupsWithRole = projectTemplate.groups?.filter((g) => g.roles.includes(slug)) || [];
- const identitiesWithRole =
- projectTemplate.identities?.filter((i) => i.roles.includes(slug)) || [];
- const projectManagedIdentitiesWithRole =
- projectTemplate.projectManagedIdentities?.filter((i) => i.roles.includes(slug)) || [];
-
- const usageMessages: string[] = [];
-
- if (usersWithRole.length > 0)
- usageMessages.push(`${usersWithRole.length} user${usersWithRole.length === 1 ? "" : "s"}`);
- if (groupsWithRole.length > 0)
- usageMessages.push(`${groupsWithRole.length} group${groupsWithRole.length === 1 ? "" : "s"}`);
- if (identitiesWithRole.length > 0 || projectManagedIdentitiesWithRole.length > 0) {
- const totalIdentities = identitiesWithRole.length + projectManagedIdentitiesWithRole.length;
- usageMessages.push(`${totalIdentities} identit${totalIdentities === 1 ? "y" : "ies"}`);
- }
-
- if (usageMessages.length > 0) {
- createNotification({
- text: `Cannot remove role "${slug}" because it is assigned to ${usageMessages.join(", ")}`,
- type: "error"
- });
- handlePopUpClose("removeRole");
- return;
- }
-
- await updateProjectTemplate.mutateAsync({
- templateId: projectTemplate.id,
- roles: projectTemplate.roles.filter(
- (role) => role.slug !== slug && isCustomProjectRole(role.slug) // filter out default roles as well
- )
- });
-
- createNotification({
- text: "Successfully removed role from template",
- type: "success"
- });
- handlePopUpClose("removeRole");
- };
-
- const editRole = popUp?.editRole?.data as TProjectRole;
- const roleToDelete = popUp?.removeRole?.data as TProjectRole;
-
- return (
- <div className="relative mb-6">
- {popUp?.editRole.isOpen ? (
- <ProjectTemplateEditRoleForm
- onGoBack={() => handlePopUpClose("editRole")}
- projectTemplate={projectTemplate}
- role={editRole}
- isDisabled={
- permission.cannot(OrgPermissionActions.Edit, OrgPermissionSubjects.ProjectTemplates) ||
- (editRole && !isCustomProjectRole(editRole.slug))
- }
- />
- ) : (
- <div className="w-full rounded-lg border border-border-control bg-surface-base p-4">
- <div className="flex items-center justify-between border-b border-border-emphasis pb-4">
- <div>
- <h2 className="text-lg font-normal">Project Roles</h2>
- <p className="text-sm text-muted">
- {isInfisicalTemplate
- ? "Click a role to view the associated permissions"
- : "Add, edit and remove roles for this project template"}
- </p>
- </div>
- {!isInfisicalTemplate && (
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <Button
- onClick={() => {
- handlePopUpOpen("editRole");
- }}
- colorSchema="primary"
- className="ml-auto"
- variant="outline_bg"
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- isDisabled={!isAllowed}
- >
- Add Role
- </Button>
- )}
- </OrgPermissionCan>
- )}
- </div>
- <div className="py-4">
- <TableContainer>
- <Table>
- <THead>
- <Tr>
- <Th>Name</Th>
- <Th>Slug</Th>
- <Th className="w-5" />
- </Tr>
- </THead>
- <TBody>
- {roles.length ? (
- roles.map((role) => {
- return (
- <Tr
- key={role.slug}
- className="group w-full cursor-pointer transition-colors duration-100 hover:bg-surface-hover"
- role="button"
- tabIndex={0}
- onKeyDown={(evt) => {
- if (evt.key === "Enter") {
- handlePopUpOpen("editRole", role);
- }
- }}
- onClick={() => handlePopUpOpen("editRole", role)}
- >
- <Td>{role.name}</Td>
- <Td>{role.slug}</Td>
- <Td>
- {isCustomProjectRole(role.slug) && (
- <div className="flex space-x-2 opacity-0 transition-opacity duration-300 group-hover:opacity-100">
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- renderTooltip
- allowedLabel="Remove Role"
- >
- {(isAllowed) => (
- <IconButton
- colorSchema="danger"
- ariaLabel="delete-icon"
- variant="plain"
- className="group relative"
- isDisabled={!isAllowed}
- onClick={(e) => {
- e.stopPropagation();
- e.preventDefault();
- handlePopUpOpen("removeRole", role);
- }}
- >
- <FontAwesomeIcon icon={faTrash} />
- </IconButton>
- )}
- </OrgPermissionCan>
- </div>
- )}
- </Td>
- </Tr>
- );
- })
- ) : (
- <Tr>
- <Td colSpan={2}>
- <EmptyState title="No roles assigned to template" icon={faUnlock} />
- </Td>
- </Tr>
- )}
- </TBody>
- </Table>
- </TableContainer>
- </div>
- <DeleteActionModal
- isOpen={popUp.removeRole.isOpen}
- deleteKey="remove"
- title={`Are you sure you want to remove the role ${roleToDelete?.slug}?`}
- onChange={(isOpen) => handlePopUpToggle("removeRole", isOpen)}
- onDeleteApproved={() => handleRemoveRole(roleToDelete?.slug)}
- />
- </div>
- )}
- </div>
- );
-};
diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateUsersSection.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateUsersSection.tsx
deleted file mode 100644
index f8ea0fa2a9..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/ProjectTemplateUsersSection.tsx
+++ /dev/null
@@ -1,420 +0,0 @@
-import { useMemo, useState } from "react";
-import { Controller, useFieldArray, useForm } from "react-hook-form";
-import { faPlus, faSave, faTrash, faUsers } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { z } from "zod";
-
-import { createNotification } from "@app/components/notifications";
-import { OrgPermissionCan } from "@app/components/permissions";
-import {
- Button,
- EmptyState,
- FilterableSelect,
- FormControl,
- IconButton,
- Modal,
- ModalContent,
- Table,
- TableContainer,
- TBody,
- Td,
- Th,
- THead,
- Tr
-} from "@app/components/v2";
-import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
-import {
- TProjectTemplate,
- TProjectTemplateUser,
- useUpdateProjectTemplate
-} from "@app/hooks/api/projectTemplates";
-import { useGetOrgUsers } from "@app/hooks/api/users";
-
-type Props = {
- projectTemplate: TProjectTemplate;
-};
-
-const formSchema = z.object({
- users: z
- .object({
- username: z.string().min(1),
- roles: z.array(z.string()).min(1, "At least one role is required")
- })
- .array()
-});
-
-type TFormSchema = z.infer<typeof formSchema>;
-
-const addUserFormSchema = z.object({
- selectedUsers: z
- .array(
- z.object({
- label: z.string(),
- value: z.string()
- })
- )
- .min(1, "Select at least one user"),
- roles: z
- .array(
- z.object({
- slug: z.string(),
- name: z.string()
- })
- )
- .min(1, "Select at least one role")
-});
-
-type TAddUserForm = z.infer<typeof addUserFormSchema>;
-
-export const ProjectTemplateUsersSection = ({ projectTemplate }: Props) => {
- const { currentOrg } = useOrganization();
- const orgId = currentOrg?.id || "";
- const [isAddUserModalOpen, setIsAddUserModalOpen] = useState(false);
-
- const { data: orgUsers } = useGetOrgUsers(orgId);
-
- const {
- control,
- handleSubmit,
- formState: { isDirty, errors },
- reset,
- watch
- } = useForm<TFormSchema>({
- defaultValues: {
- users: (projectTemplate.users || []) as TProjectTemplateUser[]
- },
- resolver: zodResolver(formSchema)
- });
-
- const { fields: users, remove, append } = useFieldArray({ control, name: "users" });
-
- const updateProjectTemplate = useUpdateProjectTemplate();
-
- const onFormSubmit = async (form: TFormSchema) => {
- await updateProjectTemplate.mutateAsync({
- users: form.users.length > 0 ? form.users : null,
- templateId: projectTemplate.id
- });
-
- reset({ users: form.users });
-
- createNotification({
- text: "Project template users updated successfully",
- type: "success"
- });
- };
-
- const handleDiscard = () => {
- reset({ users: (projectTemplate.users || []) as TProjectTemplateUser[] });
- };
-
- // Available roles from template (predefined + custom)
- const availableRoles = useMemo(() => {
- const predefinedRoles = [
- { slug: "admin", name: "Admin" },
- { slug: "member", name: "Member" },
- { slug: "viewer", name: "Viewer" },
- { slug: "no-access", name: "No Access" }
- ];
-
- const customRoles = projectTemplate.roles
- .filter((role) => !["admin", "member", "viewer", "no-access", "custom"].includes(role.slug))
- .map((role) => ({ slug: role.slug, name: role.name }));
-
- return [...predefinedRoles, ...customRoles];
- }, [projectTemplate.roles]);
-
- // Org users for dropdown, excluding already added users
- const currentUsers = watch("users");
- const availableOrgUsers = useMemo(() => {
- const addedUsernames = new Set(currentUsers.map((u) => u.username.toLowerCase()));
- return (orgUsers || [])
- .filter((orgUser) => {
- const username = orgUser.user.username?.toLowerCase();
- return username && !addedUsernames.has(username);
- })
- .map((orgUser) => ({
- value: orgUser.user.username,
- label:
- orgUser.user.firstName && orgUser.user.lastName
- ? `${orgUser.user.firstName} ${orgUser.user.lastName} (${orgUser.user.username})`
- : orgUser.user.email || orgUser.user.username
- }));
- }, [orgUsers, currentUsers]);
-
- // Add user modal form
- const {
- control: addUserControl,
- handleSubmit: handleAddUserSubmit,
- reset: resetAddUserForm,
- watch: watchAddUser,
- formState: { errors: addUserErrors }
- } = useForm<TAddUserForm>({
- resolver: zodResolver(addUserFormSchema),
- defaultValues: {
- selectedUsers: [],
- roles: []
- }
- });
-
- const selectedUsersInModal = watchAddUser("selectedUsers");
- const selectedRolesInModal = watchAddUser("roles");
-
- const handleAddUsers = (form: TAddUserForm) => {
- form.selectedUsers.forEach((user) => {
- append({
- username: user.value,
- roles: form.roles.map((r) => r.slug)
- });
- });
- resetAddUserForm();
- setIsAddUserModalOpen(false);
- };
-
- const handleCloseAddUserModal = () => {
- resetAddUserForm();
- setIsAddUserModalOpen(false);
- };
-
- return (
- <>
- <form
- onSubmit={handleSubmit(onFormSubmit)}
- className="mb-6 rounded-lg border border-border-control bg-surface-base p-4"
- >
- <div className="mb-4 flex items-center justify-between border-b border-border-emphasis pb-4">
- <div>
- <h2 className="text-lg font-normal">Project Members</h2>
- <p className="text-sm text-muted">
- Add users who will be automatically added to projects created from this template
- </p>
- </div>
-
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <div className="flex gap-3">
- {isAllowed && isDirty && (
- <>
- <Button
- onClick={handleDiscard}
- colorSchema="secondary"
- variant="plain"
- type="button"
- >
- Discard
- </Button>
- <Button
- type="submit"
- colorSchema="primary"
- variant="solid"
- leftIcon={<FontAwesomeIcon icon={faSave} />}
- >
- Save
- </Button>
- </>
- )}
- <Button
- onClick={() => setIsAddUserModalOpen(true)}
- colorSchema="primary"
- variant="outline_bg"
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- isDisabled={!isAllowed || availableOrgUsers.length === 0}
- type="button"
- >
- Add User
- </Button>
- </div>
- )}
- </OrgPermissionCan>
- </div>
- {errors.users && <span className="my-4 text-sm text-danger">{errors.users.message}</span>}
- <TableContainer>
- <Table>
- <THead>
- <Tr>
- <Th>Username</Th>
- <Th>Roles</Th>
- <Th className="w-16" />
- </Tr>
- </THead>
- <TBody>
- {users.length > 0 ? (
- users.map(({ id }, pos) => (
- <Tr key={id}>
- <Td className="w-1/4 max-w-0">
- <Controller
- control={control}
- name={`users.${pos}.username`}
- render={({ field }) => (
- <p className="truncate">
- <span className="text-sm">{field.value}</span>
- </p>
- )}
- />
- </Td>
- <Td>
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <Controller
- control={control}
- name={`users.${pos}.roles`}
- render={({ field, fieldState: { error } }) => {
- // Include orphaned roles
- const availableRoleSlugs = new Set(availableRoles.map((r) => r.slug));
- const orphanedRoles = field.value
- .filter((slug) => !availableRoleSlugs.has(slug))
- .map((slug) => ({ slug, name: slug }));
- const allOptions = [...availableRoles, ...orphanedRoles];
-
- const selectedValues = allOptions.filter((role) =>
- field.value.includes(role.slug)
- );
-
- return (
- <FormControl
- isError={Boolean(error?.message)}
- errorText={error?.message}
- className="mb-0"
- >
- <FilterableSelect
- isMulti
- isDisabled={!isAllowed}
- options={allOptions}
- value={selectedValues}
- onChange={(selected) => {
- field.onChange(
- (selected as { slug: string; name: string }[]).map(
- (s) => s.slug
- )
- );
- }}
- getOptionValue={(option) => option.slug}
- getOptionLabel={(option) => option.name}
- placeholder="Select roles..."
- menuPosition="fixed"
- />
- </FormControl>
- );
- }}
- />
- )}
- </OrgPermissionCan>
- </Td>
- <Td>
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <IconButton
- onClick={() => remove(pos)}
- colorSchema="danger"
- variant="plain"
- ariaLabel="Remove user"
- isDisabled={!isAllowed}
- >
- <FontAwesomeIcon icon={faTrash} />
- </IconButton>
- )}
- </OrgPermissionCan>
- </Td>
- </Tr>
- ))
- ) : (
- <Tr>
- <Td colSpan={3}>
- <EmptyState title="No users assigned to this template" icon={faUsers} />
- </Td>
- </Tr>
- )}
- </TBody>
- </Table>
- </TableContainer>
- </form>
-
- {/* Add User Modal */}
- <Modal isOpen={isAddUserModalOpen} onOpenChange={setIsAddUserModalOpen}>
- <ModalContent
- title="Add Users to Template"
- subTitle="Select users and roles to add to this project template"
- bodyClassName="overflow-visible"
- >
- <form onSubmit={handleAddUserSubmit(handleAddUsers)}>
- <div className="flex flex-col gap-4">
- <Controller
- control={addUserControl}
- name="selectedUsers"
- render={({ field }) => (
- <FormControl
- label="Select users"
- isError={Boolean(addUserErrors.selectedUsers)}
- errorText={addUserErrors.selectedUsers?.message}
- >
- <FilterableSelect
- isMulti
- options={availableOrgUsers}
- value={field.value}
- onChange={field.onChange}
- placeholder="Select one or more users..."
- noOptionsMessage={() =>
- availableOrgUsers.length === 0
- ? "All organization members have been added"
- : "No matching users found"
- }
- />
- </FormControl>
- )}
- />
- <Controller
- control={addUserControl}
- name="roles"
- render={({ field }) => (
- <FormControl
- label="Select roles"
- isError={Boolean(addUserErrors.roles)}
- errorText={addUserErrors.roles?.message}
- tooltipText="Select the roles that will be assigned to the selected users"
- >
- <FilterableSelect
- isMulti
- options={availableRoles}
- value={field.value}
- onChange={field.onChange}
- getOptionValue={(option) => option.slug}
- getOptionLabel={(option) => option.name}
- placeholder="Select roles..."
- />
- </FormControl>
- )}
- />
- </div>
- <div className="mt-8 flex items-center gap-4">
- <Button
- type="submit"
- colorSchema="primary"
- isDisabled={selectedUsersInModal.length === 0 || selectedRolesInModal.length === 0}
- >
- Add Users
- </Button>
- <Button
- type="button"
- colorSchema="secondary"
- variant="plain"
- onClick={handleCloseAddUserModal}
- >
- Cancel
- </Button>
- </div>
- </form>
- </ModalContent>
- </Modal>
- </>
- );
-};
diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/index.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/index.tsx
deleted file mode 100644
index 67f2cc9dba..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/components/index.tsx
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./EditProjectTemplate";
-export * from "./ProjectTemplateUsersSection";
diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/index.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/index.tsx
deleted file mode 100644
index cd6925f94c..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/EditProjectTemplateSection/index.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./EditProjectTemplateSection";
diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/ProjectTemplateDetailsModal.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/ProjectTemplateDetailsModal.tsx
deleted file mode 100644
index 281c5ee1f8..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/ProjectTemplateDetailsModal.tsx
+++ /dev/null
@@ -1,205 +0,0 @@
-import { Controller, useForm } from "react-hook-form";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { twMerge } from "tailwind-merge";
-import { z } from "zod";
-
-import { createNotification } from "@app/components/notifications";
-import {
- Button,
- FormControl,
- Input,
- Modal,
- ModalClose,
- ModalContent,
- TextArea
-} from "@app/components/v2";
-import { getProjectLucideIcon } from "@app/helpers/project";
-import { ProjectType } from "@app/hooks/api/projects/types";
-import {
- TProjectTemplate,
- useCreateProjectTemplate,
- useUpdateProjectTemplate
-} from "@app/hooks/api/projectTemplates";
-import { slugSchema } from "@app/lib/schemas";
-
-const formSchema = z.object({
- name: slugSchema({ min: 1, max: 64, field: "Name" }),
- description: z.string().max(500).optional(),
- type: z.nativeEnum(ProjectType)
-});
-
-export type FormData = z.infer<typeof formSchema>;
-
-type Props = {
- isOpen: boolean;
- onOpenChange: (isOpen: boolean) => void;
- onComplete?: (template: TProjectTemplate) => void;
- projectTemplate?: TProjectTemplate;
-};
-
-type FormProps = {
- projectTemplate?: TProjectTemplate;
- onComplete: (template: TProjectTemplate) => void;
-};
-
-const PROJECT_TYPE_MENU_ITEMS = [
- {
- label: "KMS",
- value: ProjectType.KMS
- },
- {
- label: "Secret Scanning",
- value: ProjectType.SecretScanning
- },
- {
- label: "Privileged Access Manager",
- value: ProjectType.PAM
- }
-];
-
-const ProjectTemplateForm = ({ onComplete, projectTemplate }: FormProps) => {
- const createProjectTemplate = useCreateProjectTemplate();
- const updateProjectTemplate = useUpdateProjectTemplate();
-
- const {
- handleSubmit,
- register,
- control,
- formState: { isSubmitting, errors }
- } = useForm<FormData>({
- resolver: zodResolver(formSchema),
- defaultValues: {
- name: projectTemplate?.name,
- description: projectTemplate?.description,
- type: projectTemplate?.type ?? ProjectType.KMS
- }
- });
-
- const onFormSubmit = async (data: FormData) => {
- const mutation = projectTemplate
- ? updateProjectTemplate.mutateAsync({
- templateId: projectTemplate.id,
- name: data.name,
- description: data.description
- })
- : createProjectTemplate.mutateAsync({ ...data });
-
- const template = await mutation;
- createNotification({
- text: `Successfully ${
- projectTemplate ? "updated template details" : "created project template"
- }`,
- type: "success"
- });
-
- onComplete(template);
- };
-
- return (
- <form onSubmit={handleSubmit(onFormSubmit)}>
- <FormControl
- helperText="Name must be slug-friendly"
- errorText={errors.name?.message}
- isError={Boolean(errors.name?.message)}
- label="Name"
- >
- <Input
- autoFocus
- placeholder="my-project-template"
- {...register("name")}
- autoComplete="off"
- />
- </FormControl>
- {!projectTemplate && (
- <Controller
- control={control}
- name="type"
- defaultValue={ProjectType.KMS}
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Project Type"
- isError={Boolean(error)}
- errorText={error?.message}
- className="flex-1"
- >
- <div className="mt-2 grid grid-cols-3 gap-3">
- {PROJECT_TYPE_MENU_ITEMS.map((el) => {
- const ProjectIcon = getProjectLucideIcon(el.value);
- return (
- <div
- key={el.value}
- className={twMerge(
- "flex cursor-pointer flex-col items-center gap-2 rounded-sm border border-border-control px-2 py-4 opacity-75 transition-all hover:border-project hover:bg-surface-active",
- field.value === el.value && "border-project bg-surface-active opacity-100"
- )}
- onClick={() => field.onChange(el.value)}
- role="button"
- tabIndex={0}
- onKeyDown={(e) => {
- if (e.key === "Enter") {
- field.onChange(el.value);
- }
- }}
- >
- <ProjectIcon className="h-8 w-8" />
- <div className="text-center text-xs">{el.label}</div>
- </div>
- );
- })}
- </div>
- </FormControl>
- )}
- />
- )}
- <FormControl
- label="Description (optional)"
- errorText={errors.description?.message}
- isError={Boolean(errors.description?.message)}
- >
- <TextArea
- className="max-h-80 min-h-40 max-w-full min-w-full"
- {...register("description")}
- />
- </FormControl>
- <div className="flex items-center">
- <Button
- className="mr-4"
- size="sm"
- type="submit"
- isLoading={isSubmitting}
- isDisabled={isSubmitting}
- >
- {projectTemplate ? "Update" : "Add"} Template
- </Button>
- <ModalClose asChild>
- <Button colorSchema="secondary" variant="plain">
- Cancel
- </Button>
- </ModalClose>
- </div>
- </form>
- );
-};
-
-export const ProjectTemplateDetailsModal = ({
- isOpen,
- onOpenChange,
- projectTemplate,
- onComplete
-}: Props) => {
- return (
- <Modal isOpen={isOpen} onOpenChange={onOpenChange}>
- <ModalContent
- title={projectTemplate ? "Edit Project Template Details" : "Create Project Template"}
- >
- <ProjectTemplateForm
- projectTemplate={projectTemplate}
- onComplete={(template) => {
- if (onComplete) onComplete(template);
- onOpenChange(false);
- }}
- />
- </ModalContent>
- </Modal>
- );
-};
diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/ProjectTemplatesSection.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/ProjectTemplatesSection.tsx
deleted file mode 100644
index 4f4e8688c1..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/ProjectTemplatesSection.tsx
+++ /dev/null
@@ -1,85 +0,0 @@
-import { useState } from "react";
-import { faPlus } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-
-import { ProjectTemplatesUpgradeIntent, UpgradeGate } from "@app/components/license/UpgradeGate";
-import { OrgPermissionCan } from "@app/components/permissions";
-import { Button } from "@app/components/v2";
-import { DocumentationLinkBadge } from "@app/components/v3";
-import { OrgPermissionActions, OrgPermissionSubjects, useSubscription } from "@app/context";
-import { TProjectTemplate } from "@app/hooks/api/projectTemplates";
-import { usePopUp } from "@app/hooks/usePopUp";
-
-import { EditProjectTemplateSection } from "./EditProjectTemplateSection";
-import { ProjectTemplateDetailsModal } from "./ProjectTemplateDetailsModal";
-import { ProjectTemplatesTable } from "./ProjectTemplatesTable";
-
-export const ProjectTemplatesSection = () => {
- const { subscription } = useSubscription();
- const [editTemplate, setEditTemplate] = useState<TProjectTemplate | null>(null);
-
- const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp([
- "upgradePlan",
- "addTemplate"
- ] as const);
-
- return (
- <div className="relative">
- {editTemplate ? (
- <EditProjectTemplateSection template={editTemplate} onBack={() => setEditTemplate(null)} />
- ) : (
- <div>
- <div className="mb-6 rounded-lg border border-border-control bg-surface-base p-4">
- <div className="mb-4 flex flex-wrap items-center justify-between gap-2">
- <div className="flex items-center gap-x-2">
- <p className="text-xl font-medium text-foreground">Project Templates</p>
- <DocumentationLinkBadge href="https://infisical.com/docs/documentation/platform/project-templates" />
- </div>
- <OrgPermissionCan
- I={OrgPermissionActions.Create}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <Button
- colorSchema="secondary"
- type="submit"
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- onClick={() => {
- if (!subscription?.projectTemplates) {
- handlePopUpOpen("upgradePlan", {
- isEnterpriseFeature: true
- });
- return;
- }
-
- handlePopUpOpen("addTemplate");
- }}
- isDisabled={!isAllowed}
- // className="ml-auto"
- >
- Add Template
- </Button>
- )}
- </OrgPermissionCan>
- </div>
- <ProjectTemplatesTable onEdit={setEditTemplate} />
- <ProjectTemplateDetailsModal
- onComplete={(template) => setEditTemplate(template)}
- isOpen={popUp.addTemplate.isOpen}
- onOpenChange={(isOpen) => handlePopUpToggle("addTemplate", isOpen)}
- />
- <UpgradeGate
- paywallKey="organization.project-templates"
- isOpen={popUp.upgradePlan.isOpen}
- onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
- intent={{
- ...ProjectTemplatesUpgradeIntent,
- isEnterpriseFeature: Boolean(popUp.upgradePlan.data?.isEnterpriseFeature)
- }}
- />
- </div>
- </div>
- )}
- </div>
- );
-};
diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/ProjectTemplatesTable.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/ProjectTemplatesTable.tsx
deleted file mode 100644
index 2445746526..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/ProjectTemplatesTable.tsx
+++ /dev/null
@@ -1,261 +0,0 @@
-import { useMemo, useState } from "react";
-import {
- faCircleInfo,
- faClone,
- faMagnifyingGlass,
- faTrash
-} from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-
-import { OrgPermissionCan } from "@app/components/permissions";
-import {
- EmptyState,
- IconButton,
- Input,
- Table,
- TableContainer,
- TableSkeleton,
- TBody,
- Td,
- Th,
- THead,
- Tooltip,
- Tr
-} from "@app/components/v2";
-import { OrgPermissionActions, OrgPermissionSubjects, useSubscription } from "@app/context";
-import { getProjectTitle } from "@app/helpers/project";
-import { usePopUp } from "@app/hooks";
-import { ProjectType } from "@app/hooks/api/projects/types";
-import { TProjectTemplate, useListProjectTemplates } from "@app/hooks/api/projectTemplates";
-
-import { DeleteProjectTemplateModal } from "./DeleteProjectTemplateModal";
-
-type Props = {
- onEdit: (projectTemplate: TProjectTemplate) => void;
-};
-
-export const ProjectTemplatesTable = ({ onEdit }: Props) => {
- const { subscription } = useSubscription();
-
- const { isPending, data: projectTemplates = [] } = useListProjectTemplates({
- enabled: subscription?.projectTemplates
- });
-
- const [search, setSearch] = useState("");
-
- const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp(["deleteTemplate"] as const);
-
- const filteredTemplates = useMemo(
- () =>
- projectTemplates?.filter(
- (template) =>
- template.type !== ProjectType.SecretManager &&
- template.name.toLowerCase().includes(search.toLowerCase().trim())
- ) ?? [],
- [search, projectTemplates]
- );
-
- const colSpan = 7;
-
- return (
- <div>
- <Input
- value={search}
- onChange={(e) => setSearch(e.target.value)}
- leftIcon={<FontAwesomeIcon icon={faMagnifyingGlass} />}
- placeholder="Search templates..."
- />
- <TableContainer className="mt-4">
- <Table>
- <THead>
- <Tr>
- <Th>Name</Th>
- <Th>Type</Th>
- <Th>Roles</Th>
- <Th>Users</Th>
- <Th>Groups</Th>
- <Th>Machine Identities</Th>
- <Th />
- </Tr>
- </THead>
- <TBody>
- {subscription?.projectTemplates && isPending && (
- <TableSkeleton
- innerKey="project-templates-table"
- columns={colSpan}
- key="project-templates"
- />
- )}
- {filteredTemplates.map((template) => {
- const {
- id,
- name,
- roles,
- description,
- type,
- users,
- groups,
- identities,
- projectManagedIdentities
- } = template;
-
- const totalIdentities =
- (identities?.length || 0) + (projectManagedIdentities?.length || 0);
-
- return (
- <Tr
- onClick={() => onEdit(template)}
- className="cursor-pointer hover:bg-surface-hover"
- key={id}
- >
- <Td>
- {name}
- {description && (
- <Tooltip content={description}>
- <FontAwesomeIcon
- size="sm"
- className="ml-2 text-muted"
- icon={faCircleInfo}
- />
- </Tooltip>
- )}
- </Td>
- <Td>{getProjectTitle(type)}</Td>
- <Td className="pl-8">
- {roles.length}
- {roles.length > 0 && (
- <Tooltip
- content={
- <ul className="ml-2 list-disc">
- {roles.map((role) => (
- <li key={role.name}>{role.name}</li>
- ))}
- </ul>
- }
- >
- <FontAwesomeIcon
- size="sm"
- className="ml-2 text-muted"
- icon={faCircleInfo}
- />
- </Tooltip>
- )}
- </Td>
- <Td className="pl-8">
- {users?.length || 0}
- {users && Boolean(users.length) && (
- <Tooltip
- content={
- <ul className="ml-2 list-disc">
- {users.map((user) => (
- <li key={user.username}>{user.username}</li>
- ))}
- </ul>
- }
- >
- <FontAwesomeIcon
- size="sm"
- className="ml-2 text-muted"
- icon={faCircleInfo}
- />
- </Tooltip>
- )}
- </Td>
- <Td className="pl-8">
- {groups?.length || 0}
- {groups && Boolean(groups.length) && (
- <Tooltip
- content={
- <ul className="ml-2 list-disc">
- {groups.map((group) => (
- <li key={group.groupSlug}>{group.groupSlug}</li>
- ))}
- </ul>
- }
- >
- <FontAwesomeIcon
- size="sm"
- className="ml-2 text-muted"
- icon={faCircleInfo}
- />
- </Tooltip>
- )}
- </Td>
- <Td className="pl-8">
- {totalIdentities}
- {Boolean(totalIdentities) && (
- <Tooltip
- content={
- <ul className="ml-2 list-disc">
- {(projectManagedIdentities || []).map((identity) => (
- <li key={identity.name}>{identity.name}</li>
- ))}
- {identities && Boolean(identities?.length) && (
- <li key="org">
- {identities.length} Organization Identit
- {identities.length === 1 ? "y" : "ies"}
- </li>
- )}
- </ul>
- }
- >
- <FontAwesomeIcon
- size="sm"
- className="ml-2 text-muted"
- icon={faCircleInfo}
- />
- </Tooltip>
- )}
- </Td>
- <Td className="w-5">
- {name !== "default" && (
- <OrgPermissionCan
- I={OrgPermissionActions.Delete}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <IconButton
- onClick={(e) => {
- e.stopPropagation();
- handlePopUpOpen("deleteTemplate", template);
- }}
- variant="plain"
- colorSchema="danger"
- ariaLabel="Delete template"
- isDisabled={!isAllowed}
- >
- <FontAwesomeIcon icon={faTrash} />
- </IconButton>
- )}
- </OrgPermissionCan>
- )}
- </Td>
- </Tr>
- );
- })}
- {(!subscription?.projectTemplates ||
- (!isPending && filteredTemplates?.length === 0)) && (
- <Tr>
- <Td colSpan={colSpan}>
- <EmptyState
- title={
- search.trim()
- ? "No project templates match search"
- : "No project templates found"
- }
- icon={faClone}
- />
- </Td>
- </Tr>
- )}
- </TBody>
- </Table>
- </TableContainer>
- <DeleteProjectTemplateModal
- isOpen={popUp.deleteTemplate.isOpen}
- onOpenChange={(isOpen) => handlePopUpToggle("deleteTemplate", isOpen)}
- template={popUp.deleteTemplate.data}
- />
- </div>
- );
-};
diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/index.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/index.tsx
deleted file mode 100644
index 46db36f022..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/index.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export { ProjectTemplatesSection } from "./ProjectTemplatesSection";
diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/index.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/index.tsx
deleted file mode 100644
index 6fdd12aeed..0000000000
--- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/index.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export { ProjectTemplatesTab } from "./ProjectTemplatesTab";
diff --git a/frontend/src/pages/organization/SettingsPage/route.tsx b/frontend/src/pages/organization/SettingsPage/route.tsx
index 3c03ea7392..f63f5b9ae9 100644
--- a/frontend/src/pages/organization/SettingsPage/route.tsx
+++ b/frontend/src/pages/organization/SettingsPage/route.tsx
@@ -28,7 +28,8 @@ const MOVED_SETTINGS_TABS: Record<string, { to: string; selectedTab: string }> =
selectedTab: "external-migrations"
},
"sso-settings": { to: "/organizations/$orgId/sso", selectedTab: "sso" },
- "provisioning-settings": { to: "/organizations/$orgId/sso", selectedTab: "provisioning" }
+ "provisioning-settings": { to: "/organizations/$orgId/sso", selectedTab: "provisioning" },
+ "project-templates": { to: "/organizations/$orgId/settings", selectedTab: "product-settings" }
};
export const Route = createFileRoute(
diff --git a/frontend/src/routeTree.gen.ts b/frontend/src/routeTree.gen.ts
index c6070b1711..1f0eef6c46 100644
--- a/frontend/src/routeTree.gen.ts
+++ b/frontend/src/routeTree.gen.ts
@@ -152,6 +152,7 @@ import { Route as organizationAppConnectionsOauthCallbackPageRouteImport } from
import { Route as agentVaultAgentVaultAccessBundleDetailPageRouteImport } from './pages/agent-vault/AgentVaultAccessBundleDetailPage/route'
import { Route as organizationSecretSharingPageRouteImport } from './pages/organization/SecretSharingPage/route'
import { Route as organizationProductSettingsPageSecretsManagementRouteImport } from './pages/organization/ProductSettingsPage/SecretsManagement/route'
+import { Route as organizationProductSettingsPageProjectTemplatesRouteImport } from './pages/organization/ProductSettingsPage/ProjectTemplates/route'
import { Route as organizationKmipServersPageRouteImport } from './pages/organization/KmipServersPage/route'
import { Route as pamPamAccountsPageRouteImport } from './pages/pam/PamAccountsPage/route'
import { Route as certManagerPkiSubscribersPageRouteImport } from './pages/cert-manager/PkiSubscribersPage/route'
@@ -179,6 +180,7 @@ import { Route as secretManagerSettingsPageRouteImport } from './pages/secret-ma
import { Route as secretManagerOverviewPageRouteImport } from './pages/secret-manager/OverviewPage/route'
import { Route as secretManagerInsightsPageRouteImport } from './pages/secret-manager/InsightsPage/route'
import { Route as secretManagerSecretApprovalsPageRouteImport } from './pages/secret-manager/SecretApprovalsPage/route'
+import { Route as organizationProductSettingsPageProjectTemplatesProjectTemplatesRouteImport } from './pages/organization/ProductSettingsPage/ProjectTemplates/project-templates/route'
import { Route as kmsSettingsPageRouteImport } from './pages/kms/SettingsPage/route'
import { Route as kmsOverviewPageRouteImport } from './pages/kms/OverviewPage/route'
import { Route as kmsKmipPageRouteImport } from './pages/kms/KmipPage/route'
@@ -344,6 +346,10 @@ const AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManag
createFileRoute(
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/$projectId',
)()
+const AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeImport =
+ createFileRoute(
+ '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type',
+ )()
const AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsKmsKmipServersImport =
createFileRoute(
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/kmip-servers',
@@ -1089,6 +1095,15 @@ const AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManag
} as any,
)
+const AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeRoute =
+ AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeImport.update(
+ {
+ id: '/product-settings/$type',
+ path: '/product-settings/$type',
+ getParentRoute: () => organizationProjectsPageRouteRoute,
+ } as any,
+ )
+
const AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsKmsKmipServersRoute =
AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsKmsKmipServersImport.update(
{
@@ -1678,6 +1693,14 @@ const organizationProductSettingsPageSecretsManagementRouteRoute =
AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManagementProductSettingsRoute,
} as any)
+const organizationProductSettingsPageProjectTemplatesRouteRoute =
+ organizationProductSettingsPageProjectTemplatesRouteImport.update({
+ id: '/',
+ path: '/',
+ getParentRoute: () =>
+ AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeRoute,
+ } as any)
+
const organizationKmipServersPageRouteRoute =
organizationKmipServersPageRouteImport.update({
id: '/',
@@ -1899,6 +1922,16 @@ const secretManagerSecretApprovalsPageRouteRoute =
getParentRoute: () => secretManagerLayoutRoute,
} as any)
+const organizationProductSettingsPageProjectTemplatesProjectTemplatesRouteRoute =
+ organizationProductSettingsPageProjectTemplatesProjectTemplatesRouteImport.update(
+ {
+ id: '/project-templates/$templateId',
+ path: '/project-templates/$templateId',
+ getParentRoute: () =>
+ AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeRoute,
+ } as any,
+ )
+
const kmsSettingsPageRouteRoute = kmsSettingsPageRouteImport.update({
id: '/settings',
path: '/settings',
@@ -3587,6 +3620,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsKmsKmipServersImport
parentRoute: typeof organizationProjectsPageRouteImport
}
+ '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type': {
+ id: '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type'
+ path: '/product-settings/$type'
+ fullPath: '/organizations/$orgId/projects/product-settings/$type'
+ preLoaderRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeImport
+ parentRoute: typeof organizationProjectsPageRouteImport
+ }
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/$projectId': {
id: '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/$projectId'
path: '/secret-management/$projectId'
@@ -3706,6 +3746,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof organizationKmipServersPageRouteImport
parentRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsKmsKmipServersImport
}
+ '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type/': {
+ id: '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type/'
+ path: '/'
+ fullPath: '/organizations/$orgId/projects/product-settings/$type/'
+ preLoaderRoute: typeof organizationProductSettingsPageProjectTemplatesRouteImport
+ parentRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeImport
+ }
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/product-settings/': {
id: '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/product-settings/'
path: '/'
@@ -4000,6 +4047,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof kmsSettingsPageRouteImport
parentRoute: typeof kmsLayoutImport
}
+ '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type/project-templates/$templateId': {
+ id: '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type/project-templates/$templateId'
+ path: '/project-templates/$templateId'
+ fullPath: '/organizations/$orgId/projects/product-settings/$type/project-templates/$templateId'
+ preLoaderRoute: typeof organizationProductSettingsPageProjectTemplatesProjectTemplatesRouteImport
+ parentRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeImport
+ }
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/$projectId/_secret-manager-layout/approval': {
id: '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/$projectId/_secret-manager-layout/approval'
path: '/approval'
@@ -4885,6 +4939,24 @@ const AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsKmsKmipServ
AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsKmsKmipServersRouteChildren,
)
+interface AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeRouteChildren {
+ organizationProductSettingsPageProjectTemplatesRouteRoute: typeof organizationProductSettingsPageProjectTemplatesRouteRoute
+ organizationProductSettingsPageProjectTemplatesProjectTemplatesRouteRoute: typeof organizationProductSettingsPageProjectTemplatesProjectTemplatesRouteRoute
+}
+
+const AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeRouteChildren: AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeRouteChildren =
+ {
+ organizationProductSettingsPageProjectTemplatesRouteRoute:
+ organizationProductSettingsPageProjectTemplatesRouteRoute,
+ organizationProductSettingsPageProjectTemplatesProjectTemplatesRouteRoute:
+ organizationProductSettingsPageProjectTemplatesProjectTemplatesRouteRoute,
+ }
+
+const AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeRouteWithChildren =
+ AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeRoute._addFileChildren(
+ AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeRouteChildren,
+ )
+
interface AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManagementProjectIdSecretManagerLayoutIntegrationsRouteChildren {
secretManagerIntegrationsListPageRouteRoute: typeof secretManagerIntegrationsListPageRouteRoute
secretManagerIntegrationsDetailsByIDPageRouteRoute: typeof secretManagerIntegrationsDetailsByIDPageRouteRoute
@@ -5298,6 +5370,7 @@ interface organizationProjectsPageRouteRouteChildren {
organizationSecretInsightsPageRouteRoute: typeof organizationSecretInsightsPageRouteRoute
AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsKmsProjectIdRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsKmsProjectIdRouteWithChildren
AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsKmsKmipServersRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsKmsKmipServersRouteWithChildren
+ AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeRouteWithChildren
AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManagementProjectIdRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManagementProjectIdRouteWithChildren
AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManagementProductSettingsRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManagementProductSettingsRouteWithChildren
AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManagementSecretSharingRoute: typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManagementSecretSharingRouteWithChildren
@@ -5315,6 +5388,8 @@ const organizationProjectsPageRouteRouteChildren: organizationProjectsPageRouteR
AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsKmsProjectIdRouteWithChildren,
AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsKmsKmipServersRoute:
AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsKmsKmipServersRouteWithChildren,
+ AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeRoute:
+ AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeRouteWithChildren,
AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManagementProjectIdRoute:
AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManagementProjectIdRouteWithChildren,
AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManagementProductSettingsRoute:
@@ -6244,6 +6319,7 @@ export interface FileRoutesByFullPath {
'/organizations/$orgId/pam/audit-logs': typeof projectAuditLogsPageRoutePamRoute
'/organizations/$orgId/projects/kms/$projectId': typeof kmsLayoutRouteWithChildren
'/organizations/$orgId/projects/kms/kmip-servers': typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsKmsKmipServersRouteWithChildren
+ '/organizations/$orgId/projects/product-settings/$type': typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeRouteWithChildren
'/organizations/$orgId/projects/secret-management/$projectId': typeof secretManagerLayoutRouteWithChildren
'/organizations/$orgId/projects/secret-management/product-settings': typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManagementProductSettingsRouteWithChildren
'/organizations/$orgId/projects/secret-management/secret-sharing': typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManagementSecretSharingRouteWithChildren
@@ -6261,6 +6337,7 @@ export interface FileRoutesByFullPath {
'/organizations/$orgId/cert-manager/subscribers/': typeof certManagerPkiSubscribersPageRouteRoute
'/organizations/$orgId/pam/accounts/': typeof pamPamAccountsPageRouteRoute
'/organizations/$orgId/projects/kms/kmip-servers/': typeof organizationKmipServersPageRouteRoute
+ '/organizations/$orgId/projects/product-settings/$type/': typeof organizationProductSettingsPageProjectTemplatesRouteRoute
'/organizations/$orgId/projects/secret-management/product-settings/': typeof organizationProductSettingsPageSecretsManagementRouteRoute
'/organizations/$orgId/projects/secret-management/secret-sharing/': typeof organizationSecretSharingPageRouteRoute
'/organizations/$orgId/agent-vault/access-bundles/$accessBundleId': typeof agentVaultAgentVaultAccessBundleDetailPageRouteRoute
@@ -6300,6 +6377,7 @@ export interface FileRoutesByFullPath {
'/organizations/$orgId/projects/kms/$projectId/kmip': typeof kmsKmipPageRouteRoute
'/organizations/$orgId/projects/kms/$projectId/overview': typeof kmsOverviewPageRouteRoute
'/organizations/$orgId/projects/kms/$projectId/settings': typeof kmsSettingsPageRouteRoute
+ '/organizations/$orgId/projects/product-settings/$type/project-templates/$templateId': typeof organizationProductSettingsPageProjectTemplatesProjectTemplatesRouteRoute
'/organizations/$orgId/projects/secret-management/$projectId/approval': typeof secretManagerSecretApprovalsPageRouteRoute
'/organizations/$orgId/projects/secret-management/$projectId/insights': typeof secretManagerInsightsPageRouteRoute
'/organizations/$orgId/projects/secret-management/$projectId/overview': typeof secretManagerOverviewPageRouteRoute
@@ -6528,6 +6606,7 @@ export interface FileRoutesByTo {
'/organizations/$orgId/cert-manager/subscribers': typeof certManagerPkiSubscribersPageRouteRoute
'/organizations/$orgId/pam/accounts': typeof pamPamAccountsPageRouteRoute
'/organizations/$orgId/projects/kms/kmip-servers': typeof organizationKmipServersPageRouteRoute
+ '/organizations/$orgId/projects/product-settings/$type': typeof organizationProductSettingsPageProjectTemplatesRouteRoute
'/organizations/$orgId/projects/secret-management/product-settings': typeof organizationProductSettingsPageSecretsManagementRouteRoute
'/organizations/$orgId/projects/secret-management/secret-sharing': typeof organizationSecretSharingPageRouteRoute
'/organizations/$orgId/agent-vault/access-bundles/$accessBundleId': typeof agentVaultAgentVaultAccessBundleDetailPageRouteRoute
@@ -6566,6 +6645,7 @@ export interface FileRoutesByTo {
'/organizations/$orgId/projects/kms/$projectId/kmip': typeof kmsKmipPageRouteRoute
'/organizations/$orgId/projects/kms/$projectId/overview': typeof kmsOverviewPageRouteRoute
'/organizations/$orgId/projects/kms/$projectId/settings': typeof kmsSettingsPageRouteRoute
+ '/organizations/$orgId/projects/product-settings/$type/project-templates/$templateId': typeof organizationProductSettingsPageProjectTemplatesProjectTemplatesRouteRoute
'/organizations/$orgId/projects/secret-management/$projectId/approval': typeof secretManagerSecretApprovalsPageRouteRoute
'/organizations/$orgId/projects/secret-management/$projectId/insights': typeof secretManagerInsightsPageRouteRoute
'/organizations/$orgId/projects/secret-management/$projectId/overview': typeof secretManagerOverviewPageRouteRoute
@@ -6808,6 +6888,7 @@ export interface FileRoutesById {
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/pam/_pam-layout/audit-logs': typeof projectAuditLogsPageRoutePamRoute
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/$projectId': typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsKmsProjectIdRouteWithChildren
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/kmip-servers': typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsKmsKmipServersRouteWithChildren
+ '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type': typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsProductSettingsTypeRouteWithChildren
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/$projectId': typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManagementProjectIdRouteWithChildren
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/product-settings': typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManagementProductSettingsRouteWithChildren
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/secret-sharing': typeof AuthenticateInjectOrgDetailsOrgLayoutOrganizationsOrgIdProjectsSecretManagementSecretSharingRouteWithChildren
@@ -6825,6 +6906,7 @@ export interface FileRoutesById {
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/cert-manager/_cert-manager-layout/subscribers/': typeof certManagerPkiSubscribersPageRouteRoute
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/pam/_pam-layout/accounts/': typeof pamPamAccountsPageRouteRoute
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/kmip-servers/': typeof organizationKmipServersPageRouteRoute
+ '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type/': typeof organizationProductSettingsPageProjectTemplatesRouteRoute
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/product-settings/': typeof organizationProductSettingsPageSecretsManagementRouteRoute
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/secret-sharing/': typeof organizationSecretSharingPageRouteRoute
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/agent-vault/_agent-vault-layout/access-bundles/$accessBundleId': typeof agentVaultAgentVaultAccessBundleDetailPageRouteRoute
@@ -6867,6 +6949,7 @@ export interface FileRoutesById {
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/$projectId/_kms-layout/kmip': typeof kmsKmipPageRouteRoute
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/$projectId/_kms-layout/overview': typeof kmsOverviewPageRouteRoute
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/$projectId/_kms-layout/settings': typeof kmsSettingsPageRouteRoute
+ '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type/project-templates/$templateId': typeof organizationProductSettingsPageProjectTemplatesProjectTemplatesRouteRoute
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/$projectId/_secret-manager-layout/approval': typeof secretManagerSecretApprovalsPageRouteRoute
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/$projectId/_secret-manager-layout/insights': typeof secretManagerInsightsPageRouteRoute
'/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/$projectId/_secret-manager-layout/overview': typeof secretManagerOverviewPageRouteRoute
@@ -7104,6 +7187,7 @@ export interface FileRouteTypes {
| '/organizations/$orgId/pam/audit-logs'
| '/organizations/$orgId/projects/kms/$projectId'
| '/organizations/$orgId/projects/kms/kmip-servers'
+ | '/organizations/$orgId/projects/product-settings/$type'
| '/organizations/$orgId/projects/secret-management/$projectId'
| '/organizations/$orgId/projects/secret-management/product-settings'
| '/organizations/$orgId/projects/secret-management/secret-sharing'
@@ -7121,6 +7205,7 @@ export interface FileRouteTypes {
| '/organizations/$orgId/cert-manager/subscribers/'
| '/organizations/$orgId/pam/accounts/'
| '/organizations/$orgId/projects/kms/kmip-servers/'
+ | '/organizations/$orgId/projects/product-settings/$type/'
| '/organizations/$orgId/projects/secret-management/product-settings/'
| '/organizations/$orgId/projects/secret-management/secret-sharing/'
| '/organizations/$orgId/agent-vault/access-bundles/$accessBundleId'
@@ -7160,6 +7245,7 @@ export interface FileRouteTypes {
| '/organizations/$orgId/projects/kms/$projectId/kmip'
| '/organizations/$orgId/projects/kms/$projectId/overview'
| '/organizations/$orgId/projects/kms/$projectId/settings'
+ | '/organizations/$orgId/projects/product-settings/$type/project-templates/$templateId'
| '/organizations/$orgId/projects/secret-management/$projectId/approval'
| '/organizations/$orgId/projects/secret-management/$projectId/insights'
| '/organizations/$orgId/projects/secret-management/$projectId/overview'
@@ -7387,6 +7473,7 @@ export interface FileRouteTypes {
| '/organizations/$orgId/cert-manager/subscribers'
| '/organizations/$orgId/pam/accounts'
| '/organizations/$orgId/projects/kms/kmip-servers'
+ | '/organizations/$orgId/projects/product-settings/$type'
| '/organizations/$orgId/projects/secret-management/product-settings'
| '/organizations/$orgId/projects/secret-management/secret-sharing'
| '/organizations/$orgId/agent-vault/access-bundles/$accessBundleId'
@@ -7425,6 +7512,7 @@ export interface FileRouteTypes {
| '/organizations/$orgId/projects/kms/$projectId/kmip'
| '/organizations/$orgId/projects/kms/$projectId/overview'
| '/organizations/$orgId/projects/kms/$projectId/settings'
+ | '/organizations/$orgId/projects/product-settings/$type/project-templates/$templateId'
| '/organizations/$orgId/projects/secret-management/$projectId/approval'
| '/organizations/$orgId/projects/secret-management/$projectId/insights'
| '/organizations/$orgId/projects/secret-management/$projectId/overview'
@@ -7665,6 +7753,7 @@ export interface FileRouteTypes {
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/pam/_pam-layout/audit-logs'
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/$projectId'
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/kmip-servers'
+ | '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type'
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/$projectId'
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/product-settings'
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/secret-sharing'
@@ -7682,6 +7771,7 @@ export interface FileRouteTypes {
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/cert-manager/_cert-manager-layout/subscribers/'
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/pam/_pam-layout/accounts/'
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/kmip-servers/'
+ | '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type/'
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/product-settings/'
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/secret-sharing/'
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/agent-vault/_agent-vault-layout/access-bundles/$accessBundleId'
@@ -7724,6 +7814,7 @@ export interface FileRouteTypes {
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/$projectId/_kms-layout/kmip'
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/$projectId/_kms-layout/overview'
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/$projectId/_kms-layout/settings'
+ | '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type/project-templates/$templateId'
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/$projectId/_secret-manager-layout/approval'
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/$projectId/_secret-manager-layout/insights'
| '/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/$projectId/_secret-manager-layout/overview'
@@ -8197,6 +8288,7 @@ export const routeTree = rootRoute
"/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/insights",
"/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/$projectId",
"/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/kmip-servers",
+ "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type",
"/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/$projectId",
"/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/product-settings",
"/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/secret-sharing",
@@ -8637,6 +8729,14 @@ export const routeTree = rootRoute
"/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/kmip-servers/$kmipServerId"
]
},
+ "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type": {
+ "filePath": "",
+ "parent": "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects",
+ "children": [
+ "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type/",
+ "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type/project-templates/$templateId"
+ ]
+ },
"/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/$projectId": {
"filePath": "",
"parent": "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects",
@@ -8718,6 +8818,10 @@ export const routeTree = rootRoute
"filePath": "organization/KmipServersPage/route.tsx",
"parent": "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/kmip-servers"
},
+ "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type/": {
+ "filePath": "organization/ProductSettingsPage/ProjectTemplates/route.tsx",
+ "parent": "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type"
+ },
"/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/product-settings/": {
"filePath": "organization/ProductSettingsPage/SecretsManagement/route.tsx",
"parent": "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/product-settings"
@@ -8928,6 +9032,10 @@ export const routeTree = rootRoute
"filePath": "kms/SettingsPage/route.tsx",
"parent": "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/kms/$projectId/_kms-layout"
},
+ "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type/project-templates/$templateId": {
+ "filePath": "organization/ProductSettingsPage/ProjectTemplates/project-templates/route.tsx",
+ "parent": "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/product-settings/$type"
+ },
"/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/$projectId/_secret-manager-layout/approval": {
"filePath": "secret-manager/SecretApprovalsPage/route.tsx",
"parent": "/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/secret-management/$projectId/_secret-manager-layout"
diff --git a/frontend/src/routes.ts b/frontend/src/routes.ts
index ab1855a6c0..2827c06042 100644
--- a/frontend/src/routes.ts
+++ b/frontend/src/routes.ts
@@ -420,6 +420,13 @@ const organizationRoutes = route("/organizations/$orgId", [
"organization/ProductSettingsPage/SecretsManagement/project-templates/route.tsx"
)
]),
+ route("/projects/product-settings/$type", [
+ index("organization/ProductSettingsPage/ProjectTemplates/route.tsx"),
+ route(
+ "/project-templates/$templateId",
+ "organization/ProductSettingsPage/ProjectTemplates/project-templates/route.tsx"
+ )
+ ]),
route("/access-management", "organization/AccessManagementPage/route.tsx"),
route("/audit-logs", "organization/AuditLogsPage/route.tsx"),
route("/billing", "organization/BillingPage/route.tsx"),