Skip to content

Commit

Permalink
fix(orgAdmins): Billing leaders should not see all teams in the org (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tianrunhe authored Aug 22, 2024
1 parent c70b87a commit cd570ac
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ const query = graphql`
isViewerLead
name
orgId
organization {
isBillingLeader
}
teamMembers(sortBy: "preferredName") {
id
isNotRemoved
Expand All @@ -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 (
<div className='max-w-4xl pb-4'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const OrgTeams = (props: Props) => {
fragment OrgTeams_organization on Organization {
id
isOrgAdmin
isBillingLeader
featureFlags {
publicTeams
}
Expand All @@ -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 (
<div className='max-w-4xl pb-4'>
<div className='flex items-center justify-center py-1'>
Expand Down
7 changes: 3 additions & 4 deletions packages/server/graphql/public/types/Organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit cd570ac

Please sign in to comment.