Skip to content

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

better style

Matheus Nogueira95dfa7b8c4ef
diff --git a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/EditProjectTemplate.tsx b/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/EditProjectTemplate.tsx
deleted file mode 100644
index dcd49162ad..0000000000
--- a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/EditProjectTemplate.tsx
+++ /dev/null
@@ -1,130 +0,0 @@
-import { Pencil, Trash2 } from "lucide-react";
-
-import { createNotification } from "@app/components/notifications";
-import { OrgPermissionCan } from "@app/components/permissions";
-import { DeleteActionModal } from "@app/components/v2";
-import { Button } from "@app/components/v3";
-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-9 flex items-start justify-between gap-4">
- <div className="flex-col">
- <h3 className="text-2xl font-semibold tracking-normal">{name}</h3>
- <h2 className="mt-2 text-base text-mineshaft-300">
- {getProjectTitle(type)}
- <span className="px-2 text-mineshaft-500">•</span>
- {description || "Project Template"}
- </h2>
- </div>
- {!isInfisicalTemplate && (
- <div className="flex shrink-0 gap-3 pt-1">
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <Button
- isDisabled={!isAllowed}
- size="lg"
- variant="outline"
- onClick={() => handlePopUpOpen("editDetails")}
- >
- <Pencil className="size-4" />
- Edit Details
- </Button>
- )}
- </OrgPermissionCan>
- <OrgPermissionCan
- I={OrgPermissionActions.Delete}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <Button
- isDisabled={!isAllowed}
- onClick={() => {
- handlePopUpOpen("removeTemplate");
- }}
- size="lg"
- variant="danger"
- className="text-red-200"
- >
- <Trash2 className="size-4" />
- 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/ProductSettingsPage/SecretsManagement/project-templates/ProjectTemplatePage.tsx b/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/ProjectTemplatePage.tsx
index 90d5007cce..6c1d05e930 100644
--- a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/ProjectTemplatePage.tsx
+++ b/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/ProjectTemplatePage.tsx
@@ -1,11 +1,9 @@
-import { Helmet } from "react-helmet";
import { useNavigate } from "@tanstack/react-router";
-import { PageHeader } from "@app/components/v2";
import { useOrganization } from "@app/context";
import { ProjectType } from "@app/hooks/api/projects/types";
-import { EditProjectTemplateSection } from "./EditProjectTemplateSection";
+import { ProjectTemplatePage as ProjectTemplatePageBase } from "../../project-templates/ProjectTemplatePage";
type Props = {
templateId: string;
@@ -27,23 +25,10 @@ export const ProjectTemplatePage = ({ templateId }: Props) => {
};
return (
- <>
- <Helmet>
- <title>Project Template | 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-bunker-800 text-white">
- <PageHeader
- scope={ProjectType.SecretManager}
- title="Project Template"
- description="Configure project template roles, environments, and memberships."
- />
- <div className="pb-8">
- <EditProjectTemplateSection templateId={templateId} onBack={navigateBack} />
- </div>
- </div>
- </div>
- </>
+ <ProjectTemplatePageBase
+ templateId={templateId}
+ projectType={ProjectType.SecretManager}
+ onBack={navigateBack}
+ />
);
};
diff --git a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/ProjectTemplatesSection.tsx b/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/ProjectTemplatesSection.tsx
index eda6a67ff3..9e7925badc 100644
--- a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/ProjectTemplatesSection.tsx
+++ b/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/ProjectTemplatesSection.tsx
@@ -1,38 +1,14 @@
import { useNavigate } from "@tanstack/react-router";
-import { LayoutTemplate } from "lucide-react";
-import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
-import { OrgPermissionCan } from "@app/components/permissions";
-import {
- Button,
- Card,
- CardAction,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle
-} from "@app/components/v3";
-import {
- OrgPermissionActions,
- OrgPermissionSubjects,
- useOrganization,
- useSubscription
-} from "@app/context";
+import { useOrganization } from "@app/context";
+import { ProjectType } from "@app/hooks/api/projects/types";
import { TProjectTemplate } from "@app/hooks/api/projectTemplates";
-import { usePopUp } from "@app/hooks/usePopUp";
-import { ProjectTemplateDetailsModal } from "./ProjectTemplateDetailsModal";
-import { ProjectTemplatesTable } from "./ProjectTemplatesTable";
+import { ProjectTemplatesSection as ProjectTemplatesSectionBase } from "../../project-templates/ProjectTemplatesSection";
export const ProjectTemplatesSection = () => {
const navigate = useNavigate();
const { currentOrg } = useOrganization();
- const { subscription } = useSubscription();
-
- const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp([
- "upgradePlan",
- "addTemplate"
- ] as const);
const navigateToTemplate = (template: TProjectTemplate) => {
if (!currentOrg?.id) return;
@@ -47,58 +23,9 @@ export const ProjectTemplatesSection = () => {
};
return (
- <>
- <Card>
- <CardHeader>
- <CardTitle>
- <LayoutTemplate className="size-4 text-accent" />
- Project Templates
- </CardTitle>
- <CardDescription>
- Create and configure templates with predefined roles and environments to streamline
- project setup.
- </CardDescription>
- <CardAction>
- <OrgPermissionCan
- I={OrgPermissionActions.Create}
- a={OrgPermissionSubjects.ProjectTemplates}
- >
- {(isAllowed) => (
- <Button
- variant="project"
- isDisabled={!isAllowed}
- onClick={() => {
- if (!subscription?.projectTemplates) {
- handlePopUpOpen("upgradePlan", {
- isEnterpriseFeature: true
- });
- return;
- }
-
- handlePopUpOpen("addTemplate");
- }}
- >
- Add Template
- </Button>
- )}
- </OrgPermissionCan>
- </CardAction>
- </CardHeader>
- <CardContent>
- <ProjectTemplatesTable onEdit={navigateToTemplate} />
- </CardContent>
- </Card>
- <ProjectTemplateDetailsModal
- onComplete={navigateToTemplate}
- isOpen={popUp.addTemplate.isOpen}
- onOpenChange={(isOpen) => handlePopUpToggle("addTemplate", isOpen)}
- />
- <UpgradePlanModal
- isOpen={popUp.upgradePlan.isOpen}
- onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
- text="Your current plan does not include access to project templates. To unlock this feature, please upgrade to Infisical Enterprise plan."
- isEnterpriseFeature={popUp.upgradePlan.data?.isEnterpriseFeature}
- />
- </>
+ <ProjectTemplatesSectionBase
+ projectType={ProjectType.SecretManager}
+ onTemplateSelect={navigateToTemplate}
+ />
);
};
diff --git a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/DeleteProjectTemplateModal.tsx b/frontend/src/pages/organization/ProductSettingsPage/project-templates/DeleteProjectTemplateModal.tsx
similarity index 100%
rename from frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/DeleteProjectTemplateModal.tsx
rename to frontend/src/pages/organization/ProductSettingsPage/project-templates/DeleteProjectTemplateModal.tsx
diff --git a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/EditProjectTemplateSection.tsx b/frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/EditProjectTemplateSection.tsx
similarity index 66%
rename from frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/EditProjectTemplateSection.tsx
rename to frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/EditProjectTemplateSection.tsx
index 9ef24e9726..9e5513005f 100644
--- a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/EditProjectTemplateSection.tsx
+++ b/frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/EditProjectTemplateSection.tsx
@@ -1,7 +1,6 @@
import { useMemo } from "react";
-import { ChevronLeft } from "lucide-react";
-import { Button, Empty, EmptyHeader, EmptyTitle, PageLoader } from "@app/components/v3";
+import { Empty, EmptyHeader, EmptyTitle, PageLoader } from "@app/components/v3";
import { ProjectType } from "@app/hooks/api/projects/types";
import { InfisicalProjectTemplate, useListProjectTemplates } from "@app/hooks/api/projectTemplates";
@@ -9,16 +8,14 @@ import { EditProjectTemplate } from "./components";
type Props = {
templateId: string;
- onBack: () => void;
+ projectType: ProjectType;
};
-export const EditProjectTemplateSection = ({ templateId, onBack }: Props) => {
+export const EditProjectTemplateSection = ({ templateId, projectType }: Props) => {
const { data: projectTemplates, isPending } = useListProjectTemplates();
const projectTemplate = useMemo(() => {
- const template = projectTemplates?.find(
- (t) => t.id === templateId && t.type === ProjectType.SecretManager
- );
+ const template = projectTemplates?.find((t) => t.id === templateId && t.type === projectType);
if (!template) return undefined;
return {
@@ -28,7 +25,7 @@ export const EditProjectTemplateSection = ({ templateId, onBack }: Props) => {
permissions: role.permissions.filter((perm) => perm.subject !== "secret-events")
}))
};
- }, [projectTemplates, templateId]);
+ }, [projectTemplates, templateId, projectType]);
const isInfisicalTemplate = Object.values(InfisicalProjectTemplate).includes(
projectTemplate?.name as InfisicalProjectTemplate
@@ -36,15 +33,6 @@ export const EditProjectTemplateSection = ({ templateId, onBack }: Props) => {
return (
<div>
- <Button
- variant="ghost"
- type="button"
- onClick={onBack}
- className="mb-6 px-0 text-mineshaft-300 hover:bg-transparent hover:text-mineshaft-100"
- >
- <ChevronLeft className="size-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">
@@ -54,7 +42,6 @@ export const EditProjectTemplateSection = ({ templateId, onBack }: Props) => {
<EditProjectTemplate
isInfisicalTemplate={isInfisicalTemplate}
projectTemplate={projectTemplate}
- onBack={onBack}
/>
) : (
<Empty className="border border-dashed">
diff --git a/frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/EditProjectTemplate.tsx b/frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/EditProjectTemplate.tsx
new file mode 100644
index 0000000000..34bdab1484
--- /dev/null
+++ b/frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/EditProjectTemplate.tsx
@@ -0,0 +1,39 @@
+import { ProjectType } from "@app/hooks/api/projects/types";
+import { TProjectTemplate } from "@app/hooks/api/projectTemplates";
+
+import { ProjectTemplateEnvironmentsForm } from "./ProjectTemplateEnvironmentsForm";
+import { ProjectTemplateGroupsSection } from "./ProjectTemplateGroupsSection";
+import { ProjectTemplateIdentitiesSection } from "./ProjectTemplateIdentitiesSection";
+import { ProjectTemplateRolesSection } from "./ProjectTemplateRolesSection";
+import { ProjectTemplateUsersSection } from "./ProjectTemplateUsersSection";
+
+type Props = {
+ projectTemplate: TProjectTemplate;
+ isInfisicalTemplate: boolean;
+};
+
+export const EditProjectTemplate = ({ isInfisicalTemplate, projectTemplate }: Props) => {
+ const { type } = projectTemplate;
+
+ return (
+ <>
+ {type === ProjectType.SecretManager && (
+ <ProjectTemplateEnvironmentsForm
+ isInfisicalTemplate={isInfisicalTemplate}
+ projectTemplate={projectTemplate}
+ />
+ )}
+ <ProjectTemplateRolesSection
+ isInfisicalTemplate={isInfisicalTemplate}
+ projectTemplate={projectTemplate}
+ />
+ {!isInfisicalTemplate && (
+ <>
+ <ProjectTemplateUsersSection projectTemplate={projectTemplate} />
+ <ProjectTemplateGroupsSection projectTemplate={projectTemplate} />
+ <ProjectTemplateIdentitiesSection projectTemplate={projectTemplate} />
+ </>
+ )}
+ </>
+ );
+};
diff --git a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/ProjectTemplateEditRoleForm.tsx b/frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/ProjectTemplateEditRoleForm.tsx
similarity index 100%
rename from frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/ProjectTemplateEditRoleForm.tsx
rename to frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/ProjectTemplateEditRoleForm.tsx
diff --git a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/ProjectTemplateEnvironmentsForm.tsx b/frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/ProjectTemplateEnvironmentsForm.tsx
similarity index 95%
rename from frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/ProjectTemplateEnvironmentsForm.tsx
rename to frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/ProjectTemplateEnvironmentsForm.tsx
index 213a70c7db..decfd9aad2 100644
--- a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/ProjectTemplateEnvironmentsForm.tsx
+++ b/frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/ProjectTemplateEnvironmentsForm.tsx
@@ -141,19 +141,18 @@ export const ProjectTemplateEnvironmentsForm = ({
)}
<Table
className="table-fixed"
- containerClassName="rounded-lg border-mineshaft-600 bg-mineshaft-800"
>
<TableHeader>
<TableRow>
- <TableHead className="h-12 px-5 text-sm text-mineshaft-200">Name</TableHead>
- <TableHead className="h-12 px-5 text-sm text-mineshaft-200">Slug</TableHead>
+ <TableHead>Name</TableHead>
+ <TableHead>Slug</TableHead>
{!isInfisicalTemplate && <TableHead className="h-12 w-44 px-5" />}
</TableRow>
</TableHeader>
<TableBody>
{environments.map(({ id, name, slug }, pos) => (
<TableRow key={id} className="hover:bg-transparent">
- <TableCell className="h-[56px] px-5 py-2 text-sm text-mineshaft-100">
+ <TableCell>
{isInfisicalTemplate ? (
name
) : (
@@ -181,7 +180,7 @@ export const ProjectTemplateEnvironmentsForm = ({
</OrgPermissionCan>
)}
</TableCell>
- <TableCell className="h-[56px] px-5 py-2 font-mono text-sm text-mineshaft-100">
+ <TableCell>
{isInfisicalTemplate ? (
slug
) : (
@@ -210,7 +209,7 @@ export const ProjectTemplateEnvironmentsForm = ({
)}
</TableCell>
{!isInfisicalTemplate && (
- <TableCell className="h-[56px] px-5 py-2 align-middle">
+ <TableCell>
<div className="flex items-center justify-end gap-3 text-mineshaft-400">
<OrgPermissionCan
I={OrgPermissionActions.Edit}
diff --git a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/ProjectTemplateGroupsSection.tsx b/frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/ProjectTemplateGroupsSection.tsx
similarity index 100%
rename from frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/ProjectTemplateGroupsSection.tsx
rename to frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/ProjectTemplateGroupsSection.tsx
diff --git a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/ProjectTemplateIdentitiesSection.tsx b/frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/ProjectTemplateIdentitiesSection.tsx
similarity index 97%
rename from frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/ProjectTemplateIdentitiesSection.tsx
rename to frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/ProjectTemplateIdentitiesSection.tsx
index d9ea5d9be3..fe795559b3 100644
--- a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/ProjectTemplateIdentitiesSection.tsx
+++ b/frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/ProjectTemplateIdentitiesSection.tsx
@@ -346,19 +346,18 @@ export const ProjectTemplateIdentitiesSection = ({ projectTemplate }: Props) =>
{allIdentitiesForTable.length > 0 ? (
<Table
className="table-fixed"
- containerClassName="rounded-lg border-mineshaft-600 bg-mineshaft-800"
>
<TableHeader>
<TableRow>
- <TableHead className="h-12 px-5 text-sm text-mineshaft-200">Identity</TableHead>
- <TableHead className="h-12 px-5 text-sm text-mineshaft-200">Roles</TableHead>
- <TableHead className="h-12 w-20 px-5" />
+ <TableHead>Identity</TableHead>
+ <TableHead>Roles</TableHead>
+ <TableHead />
</TableRow>
</TableHeader>
<TableBody>
{allIdentitiesForTable.map((item) => (
- <TableRow key={item.id} className="hover:bg-transparent">
- <TableCell className="h-[58px] w-1/3 max-w-0 px-5 py-2">
+ <TableRow key={item.id}>
+ <TableCell>
<p className="flex items-center gap-3 truncate">
<Tooltip>
<TooltipTrigger asChild>
@@ -377,7 +376,7 @@ export const ProjectTemplateIdentitiesSection = ({ projectTemplate }: Props) =>
</span>
</p>
</TableCell>
- <TableCell className="h-[58px] px-5 py-2">
+ <TableCell>
<OrgPermissionCan
I={OrgPermissionActions.Edit}
a={OrgPermissionSubjects.ProjectTemplates}
@@ -428,7 +427,7 @@ export const ProjectTemplateIdentitiesSection = ({ projectTemplate }: Props) =>
)}
</OrgPermissionCan>
</TableCell>
- <TableCell className="h-[58px] px-5 py-2">
+ <TableCell>
<div className="flex justify-end">
<OrgPermissionCan
I={OrgPermissionActions.Edit}
diff --git a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/ProjectTemplateRolesSection.tsx b/frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/ProjectTemplateRolesSection.tsx
similarity index 92%
rename from frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/ProjectTemplateRolesSection.tsx
rename to frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/ProjectTemplateRolesSection.tsx
index f20e12c52d..42379c1dc9 100644
--- a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/ProjectTemplateRolesSection.tsx
+++ b/frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/ProjectTemplateRolesSection.tsx
@@ -134,13 +134,12 @@ export const ProjectTemplateRolesSection = ({ projectTemplate, isInfisicalTempla
{roles.length ? (
<Table
className="table-fixed"
- containerClassName="rounded-lg border-mineshaft-600 bg-mineshaft-800"
>
<TableHeader>
<TableRow>
- <TableHead className="h-12 px-5 text-sm text-mineshaft-200">Name</TableHead>
- <TableHead className="h-12 px-5 text-sm text-mineshaft-200">Type</TableHead>
- <TableHead className="h-12 w-20 px-5" />
+ <TableHead>Name</TableHead>
+ <TableHead>Type</TableHead>
+ <TableHead />
</TableRow>
</TableHeader>
<TableBody>
@@ -150,7 +149,6 @@ export const ProjectTemplateRolesSection = ({ projectTemplate, isInfisicalTempla
return (
<TableRow
key={role.slug}
- className="group w-full cursor-pointer hover:bg-transparent"
role="button"
tabIndex={0}
onKeyDown={(evt) => {
@@ -160,10 +158,10 @@ export const ProjectTemplateRolesSection = ({ projectTemplate, isInfisicalTempla
}}
onClick={() => handlePopUpOpen("editRole", role)}
>
- <TableCell className="h-[56px] px-5 py-2 text-sm font-medium text-mineshaft-100">
+ <TableCell>
{role.name}
</TableCell>
- <TableCell className="h-[56px] px-5 py-2">
+ <TableCell>
<span className="inline-flex items-center gap-1.5 rounded-md border border-mineshaft-500 bg-mineshaft-700 px-2 py-0.5 text-sm font-medium text-mineshaft-200">
{isCustomRole ? (
<>
@@ -178,7 +176,7 @@ export const ProjectTemplateRolesSection = ({ projectTemplate, isInfisicalTempla
)}
</span>
</TableCell>
- <TableCell className="h-[56px] px-5 py-2">
+ <TableCell>
<div className="flex justify-end">
{isCustomRole && (
<OrgPermissionCan
diff --git a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/ProjectTemplateUsersSection.tsx b/frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/ProjectTemplateUsersSection.tsx
similarity index 95%
rename from frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/ProjectTemplateUsersSection.tsx
rename to frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/ProjectTemplateUsersSection.tsx
index 944673899c..c236b8f8fb 100644
--- a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/ProjectTemplateUsersSection.tsx
+++ b/frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/ProjectTemplateUsersSection.tsx
@@ -228,19 +228,18 @@ export const ProjectTemplateUsersSection = ({ projectTemplate }: Props) => {
{users.length > 0 ? (
<Table
className="table-fixed"
- containerClassName="rounded-lg border-mineshaft-600 bg-mineshaft-800"
>
<TableHeader>
<TableRow>
- <TableHead className="h-12 px-5 text-sm text-mineshaft-200">Username</TableHead>
- <TableHead className="h-12 px-5 text-sm text-mineshaft-200">Roles</TableHead>
- <TableHead className="h-12 w-20 px-5" />
+ <TableHead>Username</TableHead>
+ <TableHead>Roles</TableHead>
+ <TableHead />
</TableRow>
</TableHeader>
<TableBody>
{users.map(({ id }, pos) => (
- <TableRow key={id} className="hover:bg-transparent">
- <TableCell className="h-[58px] w-1/3 max-w-0 px-5 py-2">
+ <TableRow key={id}>
+ <TableCell>
<Controller
control={control}
name={`users.${pos}.username`}
@@ -253,7 +252,7 @@ export const ProjectTemplateUsersSection = ({ projectTemplate }: Props) => {
)}
/>
</TableCell>
- <TableCell className="h-[58px] px-5 py-2">
+ <TableCell>
<OrgPermissionCan
I={OrgPermissionActions.Edit}
a={OrgPermissionSubjects.ProjectTemplates}
@@ -300,7 +299,7 @@ export const ProjectTemplateUsersSection = ({ projectTemplate }: Props) => {
)}
</OrgPermissionCan>
</TableCell>
- <TableCell className="h-[58px] px-5 py-2">
+ <TableCell>
<div className="flex justify-end">
<OrgPermissionCan
I={OrgPermissionActions.Edit}
diff --git a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/index.tsx b/frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/index.tsx
similarity index 100%
rename from frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/components/index.tsx
rename to frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/components/index.tsx
diff --git a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/index.tsx b/frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/index.tsx
similarity index 100%
rename from frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/EditProjectTemplateSection/index.tsx
rename to frontend/src/pages/organization/ProductSettingsPage/project-templates/EditProjectTemplateSection/index.tsx
diff --git a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/ProjectTemplateDetailsModal.tsx b/frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplateDetailsModal.tsx
similarity index 92%
rename from frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/ProjectTemplateDetailsModal.tsx
rename to frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplateDetailsModal.tsx
index 91d98daaa2..23e319cb77 100644
--- a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/ProjectTemplateDetailsModal.tsx
+++ b/frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplateDetailsModal.tsx
@@ -28,7 +28,7 @@ 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).default(ProjectType.SecretManager)
+ type: z.nativeEnum(ProjectType)
});
export type FormData = z.infer<typeof formSchema>;
@@ -38,14 +38,16 @@ type Props = {
onOpenChange: (isOpen: boolean) => void;
onComplete?: (template: TProjectTemplate) => void;
projectTemplate?: TProjectTemplate;
+ projectType: ProjectType;
};
type FormProps = {
projectTemplate?: TProjectTemplate;
onComplete: (template: TProjectTemplate) => void;
+ projectType: ProjectType;
};
-const ProjectTemplateForm = ({ onComplete, projectTemplate }: FormProps) => {
+const ProjectTemplateForm = ({ onComplete, projectTemplate, projectType }: FormProps) => {
const createProjectTemplate = useCreateProjectTemplate();
const updateProjectTemplate = useUpdateProjectTemplate();
@@ -58,7 +60,7 @@ const ProjectTemplateForm = ({ onComplete, projectTemplate }: FormProps) => {
defaultValues: {
name: projectTemplate?.name,
description: projectTemplate?.description,
- type: projectTemplate?.type ?? ProjectType.SecretManager
+ type: projectTemplate?.type ?? projectType
}
});
@@ -120,7 +122,8 @@ export const ProjectTemplateDetailsModal = ({
isOpen,
onOpenChange,
projectTemplate,
- onComplete
+ onComplete,
+ projectType
}: Props) => {
return (
<Dialog open={isOpen} onOpenChange={onOpenChange}>
@@ -131,6 +134,7 @@ export const ProjectTemplateDetailsModal = ({
</DialogTitle>
</DialogHeader>
<ProjectTemplateForm
+ projectType={projectType}
projectTemplate={projectTemplate}
onComplete={(template) => {
if (onComplete) onComplete(template);
diff --git a/frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplatePage.tsx b/frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplatePage.tsx
new file mode 100644
index 0000000000..1efb3c4071
--- /dev/null
+++ b/frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplatePage.tsx
@@ -0,0 +1,146 @@
+import { Helmet } from "react-helmet";
+import { ChevronLeft, Pencil, Trash2 } from "lucide-react";
+
+import { createNotification } from "@app/components/notifications";
+import { OrgPermissionCan } from "@app/components/permissions";
+import { DeleteActionModal, PageHeader } from "@app/components/v2";
+import { Button } from "@app/components/v3";
+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 {
+ InfisicalProjectTemplate,
+ useDeleteProjectTemplate,
+ useGetProjectTemplateById
+} from "@app/hooks/api/projectTemplates";
+
+import { EditProjectTemplateSection } from "./EditProjectTemplateSection";
+import { ProjectTemplateDetailsModal } from "./ProjectTemplateDetailsModal";
+
+type Props = {
+ templateId: string;
+ projectType: ProjectType;
+ onBack: () => void;
+};
+
+export const ProjectTemplatePage = ({ templateId, projectType, onBack }: Props) => {
+ const { data: projectTemplate } = useGetProjectTemplateById(templateId);
+ const deleteProjectTemplate = useDeleteProjectTemplate();
+ const { handlePopUpToggle, popUp, handlePopUpOpen, handlePopUpClose } = usePopUp([
+ "removeTemplate",
+ "editDetails"
+ ] as const);
+
+ const isInfisicalTemplate = Object.values(InfisicalProjectTemplate).includes(
+ projectTemplate?.name as InfisicalProjectTemplate
+ );
+
+ const handleRemoveTemplate = async () => {
+ await deleteProjectTemplate.mutateAsync({ templateId });
+ createNotification({
+ text: "Successfully removed project template",
+ type: "success"
+ });
+ onBack();
+ handlePopUpClose("removeTemplate");
+ };
+
+ return (
+ <>
+ <Helmet>
+ <title>Project Template | 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-bunker-800 text-white">
+ <Button
+ variant="ghost"
+ type="button"
+ onClick={onBack}
+ className="mb-2 px-0 text-mineshaft-300 hover:bg-transparent hover:text-mineshaft-100"
+ >
+ <ChevronLeft className="size-4" />
+ Back to Templates
+ </Button>
+ <PageHeader
+ scope={projectType}
+ title={projectTemplate?.name ?? "Project Template"}
+ description={
+ <>
+ {getProjectTitle(projectType)}
+ {projectTemplate?.description && (
+ <>
+ <span className="px-2 text-mineshaft-500">&bull;</span>
+ {projectTemplate.description}
+ </>
+ )}
+ </>
+ }
+ >
+ {!isInfisicalTemplate && (
+ <>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ a={OrgPermissionSubjects.ProjectTemplates}
+ >
+ {(isAllowed) => (
+ <Button
+ isDisabled={!isAllowed}
+ size="lg"
+ variant="outline"
+ onClick={() => handlePopUpOpen("editDetails")}
+ >
+ <Pencil className="size-4" />
+ Edit Details
+ </Button>
+ )}
+ </OrgPermissionCan>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ a={OrgPermissionSubjects.ProjectTemplates}
+ >
+ {(isAllowed) => (
+ <Button
+ isDisabled={!isAllowed}
+ onClick={() => handlePopUpOpen("removeTemplate")}
+ size="lg"
+ variant="danger"
+ className="text-red-200"
+ >
+ <Trash2 className="size-4" />
+ Delete Template
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </>
+ )}
+ </PageHeader>
+ <div className="pb-8">
+ <EditProjectTemplateSection
+ templateId={templateId}
+ projectType={projectType}
+ />
+ </div>
+ </div>
+ </div>
+ {projectTemplate && (
+ <>
+ <ProjectTemplateDetailsModal
+ projectType={projectType}
+ 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/ProductSettingsPage/project-templates/ProjectTemplatesSection.tsx b/frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplatesSection.tsx
new file mode 100644
index 0000000000..918efc8cd8
--- /dev/null
+++ b/frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplatesSection.tsx
@@ -0,0 +1,91 @@
+import { LayoutTemplate } from "lucide-react";
+
+import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
+import { OrgPermissionCan } from "@app/components/permissions";
+import {
+ Button,
+ Card,
+ CardAction,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle
+} from "@app/components/v3";
+import { OrgPermissionActions, OrgPermissionSubjects, useSubscription } from "@app/context";
+import { ProjectType } from "@app/hooks/api/projects/types";
+import { TProjectTemplate } from "@app/hooks/api/projectTemplates";
+import { usePopUp } from "@app/hooks/usePopUp";
+
+import { ProjectTemplateDetailsModal } from "./ProjectTemplateDetailsModal";
+import { ProjectTemplatesTable } from "./ProjectTemplatesTable";
+
+type Props = {
+ projectType: ProjectType;
+ onTemplateSelect: (template: TProjectTemplate) => void;
+};
+
+export const ProjectTemplatesSection = ({ projectType, onTemplateSelect }: Props) => {
+ const { subscription } = useSubscription();
+
+ const { popUp, handlePopUpOpen, handlePopUpToggle } = usePopUp([
+ "upgradePlan",
+ "addTemplate"
+ ] as const);
+
+ return (
+ <>
+ <Card>
+ <CardHeader>
+ <CardTitle>
+ <LayoutTemplate className="size-4 text-accent" />
+ Project Templates
+ </CardTitle>
+ <CardDescription>
+ Create and configure templates with predefined roles and environments to streamline
+ project setup.
+ </CardDescription>
+ <CardAction>
+ <OrgPermissionCan
+ I={OrgPermissionActions.Create}
+ a={OrgPermissionSubjects.ProjectTemplates}
+ >
+ {(isAllowed) => (
+ <Button
+ variant="project"
+ isDisabled={!isAllowed}
+ onClick={() => {
+ if (!subscription?.projectTemplates) {
+ handlePopUpOpen("upgradePlan", {
+ isEnterpriseFeature: true
+ });
+ return;
+ }
+
+ handlePopUpOpen("addTemplate");
+ }}
+ >
+ Add Template
+ </Button>
+ )}
+ </OrgPermissionCan>
+ </CardAction>
+ </CardHeader>
+ <CardContent>
+ <ProjectTemplatesTable projectType={projectType} onEdit={onTemplateSelect} />
+ </CardContent>
+ </Card>
+ <ProjectTemplateDetailsModal
+ projectType={projectType}
+ onComplete={onTemplateSelect}
+ isOpen={popUp.addTemplate.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("addTemplate", isOpen)}
+ />
+ <UpgradePlanModal
+ isOpen={popUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
+ text="Your current plan does not include access to project templates. To unlock this feature, please upgrade to Infisical Enterprise plan."
+ isEnterpriseFeature={popUp.upgradePlan.data?.isEnterpriseFeature}
+ />
+ </>
+ );
+};
diff --git a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/ProjectTemplatesTable.tsx b/frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplatesTable.tsx
similarity index 97%
rename from frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/ProjectTemplatesTable.tsx
rename to frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplatesTable.tsx
index f8dd42489a..b9bc893f7c 100644
--- a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/project-templates/ProjectTemplatesTable.tsx
+++ b/frontend/src/pages/organization/ProductSettingsPage/project-templates/ProjectTemplatesTable.tsx
@@ -29,6 +29,7 @@ import { TProjectTemplate, useListProjectTemplates } from "@app/hooks/api/projec
import { DeleteProjectTemplateModal } from "./DeleteProjectTemplateModal";
type Props = {
+ projectType: ProjectType;
onEdit: (projectTemplate: TProjectTemplate) => void;
};
@@ -42,7 +43,7 @@ const skeletonRowIds = [
const tableColumnKeys = ["name", "roles", "users", "groups", "identities", "actions"];
-export const ProjectTemplatesTable = ({ onEdit }: Props) => {
+export const ProjectTemplatesTable = ({ projectType, onEdit }: Props) => {
const { subscription } = useSubscription();
const { isPending, data: projectTemplates = [] } = useListProjectTemplates({
@@ -57,10 +58,10 @@ export const ProjectTemplatesTable = ({ onEdit }: Props) => {
() =>
projectTemplates?.filter(
(template) =>
- template.type === ProjectType.SecretManager &&
+ template.type === projectType &&
template.name.toLowerCase().includes(search.toLowerCase().trim())
) ?? [],
- [search, projectTemplates]
+ [search, projectTemplates, projectType]
);
const shouldShowEmptyState =
@@ -128,7 +129,6 @@ export const ProjectTemplatesTable = ({ onEdit }: Props) => {
return (
<TableRow
onClick={() => onEdit(template)}
- className="cursor-pointer hover:bg-mineshaft-700"
key={id}
>
<TableCell>