From 0b5c82339031d83f36db64558e2e6eb214d23135 Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Mon, 20 Oct 2025 16:36:46 -0700 Subject: [PATCH] fix: update create org to properly handle tx (super admin), remove sub org incidents, remove clipping animation container for project templates ui --- .../ee/services/license/license-service.ts | 2 +- backend/src/services/org/org-dal.ts | 5 +- backend/src/services/org/org-service.ts | 2 +- .../OrgGeneralTab/OrgGeneralTab.tsx | 2 +- .../ProjectTemplateRolesSection.tsx | 261 ++++++++---------- .../components/ProjectTemplatesSection.tsx | 148 +++++----- 6 files changed, 185 insertions(+), 235 deletions(-) diff --git a/backend/src/ee/services/license/license-service.ts b/backend/src/ee/services/license/license-service.ts index 835c80dd5..5a53f924c 100644 --- a/backend/src/ee/services/license/license-service.ts +++ b/backend/src/ee/services/license/license-service.ts @@ -284,7 +284,7 @@ export const licenseServiceFactory = ({ }; const updateSubscriptionOrgMemberCount = async (orgId: string, tx?: Knex) => { - const org = await orgDAL.findRootOrgDetails(orgId); + const org = await orgDAL.findRootOrgDetails(orgId, tx); if (!org) throw new NotFoundError({ message: `Organization with ID '${orgId}' not found` }); const rootOrgId = org.id; diff --git a/backend/src/services/org/org-dal.ts b/backend/src/services/org/org-dal.ts index ff625875a..114ff3790 100644 --- a/backend/src/services/org/org-dal.ts +++ b/backend/src/services/org/org-dal.ts @@ -705,10 +705,9 @@ export const orgDALFactory = (db: TDbClient) => { } }; - const findRootOrgDetails = async (orgId: string): Promise => { + const findRootOrgDetails = async (orgId: string, tx?: Knex): Promise => { try { - const org = await db - .replicaNode()(TableName.Organization) + const org = await (tx ?? db.replicaNode())(TableName.Organization) .select(selectAllTableCols(TableName.Organization)) .where( "id", diff --git a/backend/src/services/org/org-service.ts b/backend/src/services/org/org-service.ts index c56354e11..20ed37a06 100644 --- a/backend/src/services/org/org-service.ts +++ b/backend/src/services/org/org-service.ts @@ -679,7 +679,7 @@ export const orgServiceFactory = ({ const organization = await (trx ? createOrg(trx) : orgDAL.transaction(createOrg)); - await licenseService.updateSubscriptionOrgMemberCount(organization.id); + await licenseService.updateSubscriptionOrgMemberCount(organization.id, trx); return organization; }; diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgGeneralTab/OrgGeneralTab.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgGeneralTab/OrgGeneralTab.tsx index 917153089..44f075dc1 100644 --- a/frontend/src/pages/organization/SettingsPage/components/OrgGeneralTab/OrgGeneralTab.tsx +++ b/frontend/src/pages/organization/SettingsPage/components/OrgGeneralTab/OrgGeneralTab.tsx @@ -11,7 +11,7 @@ export const OrgGeneralTab = () => { return (
{isSubOrganization ? : } - + {!isSubOrganization && } {hasOrgRole(OrgMembershipRole.Admin) && }
); 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 index 85580da07..1df8128f4 100644 --- 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 @@ -70,154 +70,129 @@ export const ProjectTemplateRolesSection = ({ projectTemplate, isInfisicalTempla return (
- - {popUp?.editRole.isOpen ? ( - - handlePopUpClose("editRole")} - projectTemplate={projectTemplate} - role={editRole} - isDisabled={ - permission.cannot( - OrgPermissionActions.Edit, - OrgPermissionSubjects.ProjectTemplates - ) || - (editRole && !isCustomProjectRole(editRole.slug)) - } - /> -
- - ) : ( - -
-
-
-

Project Roles

-

- {isInfisicalTemplate - ? "Click a role to view the associated permissions" - : "Add, edit and remove roles for this project template"} -

-
- {!isInfisicalTemplate && ( - handlePopUpClose("editRole")} + projectTemplate={projectTemplate} + role={editRole} + isDisabled={ + permission.cannot(OrgPermissionActions.Edit, OrgPermissionSubjects.ProjectTemplates) || + (editRole && !isCustomProjectRole(editRole.slug)) + } + /> + ) : ( +
+
+
+

Project Roles

+

+ {isInfisicalTemplate + ? "Click a role to view the associated permissions" + : "Add, edit and remove roles for this project template"} +

+
+ {!isInfisicalTemplate && ( + + {(isAllowed) => ( + - )} - + Add Role + )} -
-
- - - - - - - - - - {roles.length ? ( - roles.map((role) => { - return ( - { - if (evt.key === "Enter") { - handlePopUpOpen("editRole", role); - } - }} - onClick={() => handlePopUpOpen("editRole", role)} - > - - - + + + )} + +
NameSlug -
{role.name}{role.slug} - {isCustomProjectRole(role.slug) && ( -
- + )} +
+
+ + + + + + + + + + {roles.length ? ( + roles.map((role) => { + return ( + { + if (evt.key === "Enter") { + handlePopUpOpen("editRole", role); + } + }} + onClick={() => handlePopUpOpen("editRole", role)} + > + + + - - ); - }) - ) : ( - - - )} - -
NameSlug +
{role.name}{role.slug} + {isCustomProjectRole(role.slug) && ( +
+ + {(isAllowed) => ( + { + e.stopPropagation(); + e.preventDefault(); + handlePopUpOpen("removeRole", role); + }} > - {(isAllowed) => ( - { - e.stopPropagation(); - e.preventDefault(); - handlePopUpOpen("removeRole", role); - }} - > - - - )} - -
- )} -
- + + + )} + + + )}
-
-
- handlePopUpToggle("removeRole", isOpen)} - onDeleteApproved={() => handleRemoveRole(roleToDelete?.slug)} - /> - -
- - )} - + ); + }) + ) : ( +
+ +
+
+
+ handlePopUpToggle("removeRole", isOpen)} + onDeleteApproved={() => handleRemoveRole(roleToDelete?.slug)} + /> +
+ )}
); }; diff --git a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/ProjectTemplatesSection.tsx b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/ProjectTemplatesSection.tsx index c542410bd..8d524c41c 100644 --- a/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/ProjectTemplatesSection.tsx +++ b/frontend/src/pages/organization/SettingsPage/components/ProjectTemplatesTab/components/ProjectTemplatesSection.tsx @@ -1,7 +1,6 @@ import { useState } from "react"; import { faArrowUpRightFromSquare, faBookOpen, faPlus } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { AnimatePresence, motion } from "framer-motion"; import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal"; import { OrgPermissionCan } from "@app/components/permissions"; @@ -25,93 +24,70 @@ export const ProjectTemplatesSection = () => { return (
- - {editTemplate ? ( - - setEditTemplate(null)} - /> - - ) : ( - -
-

- Create and configure templates with predefined roles and environments to streamline - project setup -

-
-
-

Project Templates

- -
- - Docs - -
-
- - {(isAllowed) => ( - - )} - + {editTemplate ? ( + setEditTemplate(null)} /> + ) : ( +
+

+ Create and configure templates with predefined roles and environments to streamline + project setup +

+
+ + + + {(isAllowed) => ( + + )} +
- - )} - + + setEditTemplate(template)} + isOpen={popUp.addTemplate.isOpen} + onOpenChange={(isOpen) => handlePopUpToggle("addTemplate", isOpen)} + /> + handlePopUpToggle("upgradePlan", isOpen)} + text="You can create project templates if you switch to Infisical's Enterprise plan." + /> +
+
+ )}
); };