Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sort team names alphabetically #9187

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions packages/server/graphql/types/Organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +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))
return sortedTeamsOnOrg.filter((team) => authToken.tms.includes(team.id))
}
}
},
Expand All @@ -95,7 +95,9 @@ const Organization: GraphQLObjectType<any, GQLContext> = new GraphQLObjectType<a
description: 'all the teams the viewer is on in the organization',
resolve: async ({id: orgId}, _args: unknown, {dataLoader, authToken}) => {
const allTeamsOnOrg = await dataLoader.get('teamsByOrgIds').load(orgId)
return allTeamsOnOrg.filter((team) => authToken.tms.includes(team.id))
return allTeamsOnOrg
.filter((team) => authToken.tms.includes(team.id))
.sort((a, b) => a.name.localeCompare(b.name))
}
},
tier: {
Expand Down
Loading