From a31b42f5b194630e75a4fd8a88580697dfa91c45 Mon Sep 17 00:00:00 2001 From: Nick O'Ferrall Date: Tue, 14 Nov 2023 15:58:46 +0000 Subject: [PATCH 1/2] fix: sort team names alphabetically --- packages/server/graphql/types/Organization.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/server/graphql/types/Organization.ts b/packages/server/graphql/types/Organization.ts index b639731ca31..250f9cabc69 100644 --- a/packages/server/graphql/types/Organization.ts +++ b/packages/server/graphql/types/Organization.ts @@ -86,7 +86,9 @@ const Organization: GraphQLObjectType = new GraphQLObjectType a.name.localeCompare(b.name)) return [...viewerTeams, ...sortedOtherTeams] } else { - 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)) } } }, @@ -95,7 +97,9 @@ const Organization: GraphQLObjectType = new GraphQLObjectType { 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: { From ca7f6f1f065d7233d739e90ae7c363b6e4b9f8b4 Mon Sep 17 00:00:00 2001 From: Nick O'Ferrall Date: Thu, 16 Nov 2023 14:52:19 +0000 Subject: [PATCH 2/2] sort allTeamsOnOrg --- packages/server/graphql/types/Organization.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/server/graphql/types/Organization.ts b/packages/server/graphql/types/Organization.ts index 250f9cabc69..eaf30c16e00 100644 --- a/packages/server/graphql/types/Organization.ts +++ b/packages/server/graphql/types/Organization.ts @@ -78,17 +78,15 @@ const Organization: GraphQLObjectType = new GraphQLObjectType 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)) } } },