fix: update create org to properly handle tx (super admin), remove sub org incidents, remove clipping animation container for project templates ui

This commit is contained in:
Scott Wilson
2025-10-20 16:36:46 -07:00
parent 339e00dedf
commit 0b5c823390
6 changed files with 185 additions and 235 deletions
@@ -284,7 +284,7 @@ export const licenseServiceFactory = ({
}; };
const updateSubscriptionOrgMemberCount = async (orgId: string, tx?: Knex) => { 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` }); if (!org) throw new NotFoundError({ message: `Organization with ID '${orgId}' not found` });
const rootOrgId = org.id; const rootOrgId = org.id;
+2 -3
View File
@@ -705,10 +705,9 @@ export const orgDALFactory = (db: TDbClient) => {
} }
}; };
const findRootOrgDetails = async (orgId: string): Promise<TOrganizations | undefined> => { const findRootOrgDetails = async (orgId: string, tx?: Knex): Promise<TOrganizations | undefined> => {
try { try {
const org = await db const org = await (tx ?? db.replicaNode())(TableName.Organization)
.replicaNode()(TableName.Organization)
.select(selectAllTableCols(TableName.Organization)) .select(selectAllTableCols(TableName.Organization))
.where( .where(
"id", "id",
+1 -1
View File
@@ -679,7 +679,7 @@ export const orgServiceFactory = ({
const organization = await (trx ? createOrg(trx) : orgDAL.transaction(createOrg)); const organization = await (trx ? createOrg(trx) : orgDAL.transaction(createOrg));
await licenseService.updateSubscriptionOrgMemberCount(organization.id); await licenseService.updateSubscriptionOrgMemberCount(organization.id, trx);
return organization; return organization;
}; };
@@ -11,7 +11,7 @@ export const OrgGeneralTab = () => {
return ( return (
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-6"> <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-6">
{isSubOrganization ? <SubOrgNameChangeSection /> : <OrgNameChangeSection />} {isSubOrganization ? <SubOrgNameChangeSection /> : <OrgNameChangeSection />}
<OrgIncidentContactsSection /> {!isSubOrganization && <OrgIncidentContactsSection />}
{hasOrgRole(OrgMembershipRole.Admin) && <OrgDeleteSection />} {hasOrgRole(OrgMembershipRole.Admin) && <OrgDeleteSection />}
</div> </div>
); );
@@ -70,39 +70,17 @@ export const ProjectTemplateRolesSection = ({ projectTemplate, isInfisicalTempla
return ( return (
<div className="relative"> <div className="relative">
<AnimatePresence>
{popUp?.editRole.isOpen ? ( {popUp?.editRole.isOpen ? (
<motion.div
key="edit-role"
transition={{ duration: 0.3 }}
initial={{ opacity: 0, translateX: 30 }}
animate={{ opacity: 1, translateX: 0 }}
exit={{ opacity: 0, translateX: 30 }}
className="absolute min-h-40 w-full"
>
<ProjectTemplateEditRoleForm <ProjectTemplateEditRoleForm
onGoBack={() => handlePopUpClose("editRole")} onGoBack={() => handlePopUpClose("editRole")}
projectTemplate={projectTemplate} projectTemplate={projectTemplate}
role={editRole} role={editRole}
isDisabled={ isDisabled={
permission.cannot( permission.cannot(OrgPermissionActions.Edit, OrgPermissionSubjects.ProjectTemplates) ||
OrgPermissionActions.Edit,
OrgPermissionSubjects.ProjectTemplates
) ||
(editRole && !isCustomProjectRole(editRole.slug)) (editRole && !isCustomProjectRole(editRole.slug))
} }
/> />
<div className="h-4 w-full" />
</motion.div>
) : ( ) : (
<motion.div
key="role-list"
transition={{ duration: 0.3 }}
initial={{ opacity: 0, translateX: 0 }}
animate={{ opacity: 1, translateX: 0 }}
exit={{ opacity: 0, translateX: -30 }}
className="absolute w-full"
>
<div className="w-full rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4"> <div className="w-full rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
<div className="flex items-center justify-between border-b border-mineshaft-400 pb-4"> <div className="flex items-center justify-between border-b border-mineshaft-400 pb-4">
<div> <div>
@@ -214,10 +192,7 @@ export const ProjectTemplateRolesSection = ({ projectTemplate, isInfisicalTempla
onDeleteApproved={() => handleRemoveRole(roleToDelete?.slug)} onDeleteApproved={() => handleRemoveRole(roleToDelete?.slug)}
/> />
</div> </div>
<div className="h-4 w-full" />
</motion.div>
)} )}
</AnimatePresence>
</div> </div>
); );
}; };
@@ -1,7 +1,6 @@
import { useState } from "react"; import { useState } from "react";
import { faArrowUpRightFromSquare, faBookOpen, faPlus } from "@fortawesome/free-solid-svg-icons"; import { faArrowUpRightFromSquare, faBookOpen, faPlus } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { AnimatePresence, motion } from "framer-motion";
import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal"; import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
import { OrgPermissionCan } from "@app/components/permissions"; import { OrgPermissionCan } from "@app/components/permissions";
@@ -25,30 +24,9 @@ export const ProjectTemplatesSection = () => {
return ( return (
<div className="relative"> <div className="relative">
<AnimatePresence>
{editTemplate ? ( {editTemplate ? (
<motion.div <EditProjectTemplateSection template={editTemplate} onBack={() => setEditTemplate(null)} />
key="edit-project-template"
transition={{ duration: 0.3 }}
initial={{ opacity: 0, translateX: 30 }}
animate={{ opacity: 1, translateX: 0 }}
exit={{ opacity: 0, translateX: 30 }}
className="absolute min-h-40 w-full"
>
<EditProjectTemplateSection
template={editTemplate}
onBack={() => setEditTemplate(null)}
/>
</motion.div>
) : ( ) : (
<motion.div
key="project-templates-list"
transition={{ duration: 0.3 }}
initial={{ opacity: 0, translateX: 30 }}
animate={{ opacity: 1, translateX: 0 }}
exit={{ opacity: 0, translateX: 30 }}
className="absolute min-h-40 w-full"
>
<div> <div>
<p className="mb-6 font-inter text-bunker-300"> <p className="mb-6 font-inter text-bunker-300">
Create and configure templates with predefined roles and environments to streamline Create and configure templates with predefined roles and environments to streamline
@@ -109,9 +87,7 @@ export const ProjectTemplatesSection = () => {
/> />
</div> </div>
</div> </div>
</motion.div>
)} )}
</AnimatePresence>
</div> </div>
); );
}; };