Skip to content

Commit

Permalink
sort allTeamsOnOrg
Browse files Browse the repository at this point in the history
  • Loading branch information
nickoferrall committed Nov 16, 2023
1 parent a31b42f commit ca7f6f1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/server/graphql/types/Organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,15 @@ const Organization: GraphQLObjectType<any, GQLContext> = new GraphQLObjectType<a
dataLoader.get('teamsByOrgIds').load(orgId),
dataLoader.get('organizations').load(orgId)
])
const sortedTeamsOnOrg = allTeamsOnOrg.sort((a, b) => a.name.localeCompare(b.name))
const hasPublicTeamsFlag = !!organization.featureFlags?.includes('publicTeams')
const isBillingLeader = await isUserBillingLeader(viewerId, orgId, dataLoader)
if (isBillingLeader || isSuperUser(authToken) || hasPublicTeamsFlag) {
const viewerTeams = allTeamsOnOrg.filter((team) => authToken.tms.includes(team.id))
const otherTeams = allTeamsOnOrg.filter((team) => !authToken.tms.includes(team.id))
const sortedOtherTeams = otherTeams.sort((a, b) => a.name.localeCompare(b.name))
return [...viewerTeams, ...sortedOtherTeams]
const viewerTeams = sortedTeamsOnOrg.filter((team) => authToken.tms.includes(team.id))
const otherTeams = sortedTeamsOnOrg.filter((team) => !authToken.tms.includes(team.id))
return [...viewerTeams, ...otherTeams]
} else {
return allTeamsOnOrg
.filter((team) => authToken.tms.includes(team.id))
.sort((a, b) => a.name.localeCompare(b.name))
return sortedTeamsOnOrg.filter((team) => authToken.tms.includes(team.id))
}
}
},
Expand Down

0 comments on commit ca7f6f1

Please sign in to comment.