From cd570acd3a9aebb9b09e6139263a5ef85d406dc0 Mon Sep 17 00:00:00 2001 From: Bruce Tian Date: Thu, 22 Aug 2024 07:54:52 -0700 Subject: [PATCH] fix(orgAdmins): Billing leaders should not see all teams in the org (#10141) --- .../components/OrgTeamMembers/OrgTeamMembers.tsx | 8 ++------ .../userDashboard/components/OrgTeams/OrgTeams.tsx | 5 ++--- packages/server/graphql/public/types/Organization.ts | 7 +++---- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/packages/client/modules/userDashboard/components/OrgTeamMembers/OrgTeamMembers.tsx b/packages/client/modules/userDashboard/components/OrgTeamMembers/OrgTeamMembers.tsx index 77b85049f3b..395c7833334 100644 --- a/packages/client/modules/userDashboard/components/OrgTeamMembers/OrgTeamMembers.tsx +++ b/packages/client/modules/userDashboard/components/OrgTeamMembers/OrgTeamMembers.tsx @@ -27,9 +27,6 @@ const query = graphql` isViewerLead name orgId - organization { - isBillingLeader - } teamMembers(sortBy: "preferredName") { id isNotRemoved @@ -56,9 +53,8 @@ export const OrgTeamMembers = (props: Props) => { } = useDialogState() if (!team) return null - const {isViewerLead, isOrgAdmin: isViewerOrgAdmin, teamMembers, organization} = team - const {isBillingLeader} = organization - const showMenuButton = isViewerLead || isBillingLeader || isViewerOrgAdmin + const {isViewerLead, isOrgAdmin: isViewerOrgAdmin, teamMembers} = team + const showMenuButton = isViewerLead || isViewerOrgAdmin return (
diff --git a/packages/client/modules/userDashboard/components/OrgTeams/OrgTeams.tsx b/packages/client/modules/userDashboard/components/OrgTeams/OrgTeams.tsx index 8284f82906c..1afe0340e6c 100644 --- a/packages/client/modules/userDashboard/components/OrgTeams/OrgTeams.tsx +++ b/packages/client/modules/userDashboard/components/OrgTeams/OrgTeams.tsx @@ -19,7 +19,6 @@ const OrgTeams = (props: Props) => { fragment OrgTeams_organization on Organization { id isOrgAdmin - isBillingLeader featureFlags { publicTeams } @@ -38,9 +37,9 @@ const OrgTeams = (props: Props) => { isOpen: isAddTeamDialogOpened } = useDialogState() - const {allTeams, isBillingLeader, isOrgAdmin, featureFlags} = organization + const {allTeams, isOrgAdmin, featureFlags} = organization const hasPublicTeamsFlag = featureFlags.publicTeams - const showAllTeams = isBillingLeader || isOrgAdmin || hasPublicTeamsFlag + const showAllTeams = isOrgAdmin || hasPublicTeamsFlag return (
diff --git a/packages/server/graphql/public/types/Organization.ts b/packages/server/graphql/public/types/Organization.ts index 1991fa4790b..216634df8b8 100644 --- a/packages/server/graphql/public/types/Organization.ts +++ b/packages/server/graphql/public/types/Organization.ts @@ -56,15 +56,14 @@ const Organization: OrganizationResolvers = { allTeams: async ({id: orgId}, _args, {dataLoader, authToken}) => { const viewerId = getUserId(authToken) - const [allTeamsOnOrg, organization, isOrgAdmin, isBillingLeader] = await Promise.all([ + const [allTeamsOnOrg, organization, isOrgAdmin] = await Promise.all([ dataLoader.get('teamsByOrgIds').load(orgId), dataLoader.get('organizations').loadNonNull(orgId), - isUserOrgAdmin(viewerId, orgId, dataLoader), - isUserBillingLeader(viewerId, orgId, dataLoader) + isUserOrgAdmin(viewerId, orgId, dataLoader) ]) const sortedTeamsOnOrg = allTeamsOnOrg.sort((a, b) => a.name.localeCompare(b.name)) const hasPublicTeamsFlag = !!organization.featureFlags?.includes('publicTeams') - if (isBillingLeader || isOrgAdmin || isSuperUser(authToken) || hasPublicTeamsFlag) { + if (isOrgAdmin || isSuperUser(authToken) || hasPublicTeamsFlag) { const viewerTeams = sortedTeamsOnOrg.filter((team) => authToken.tms.includes(team.id)) const otherTeams = sortedTeamsOnOrg.filter((team) => !authToken.tms.includes(team.id)) return [...viewerTeams, ...otherTeams]