From 7894bd8ae126e9981197ad90a920516589003065 Mon Sep 17 00:00:00 2001 From: Carlos Monastyrski Date: Thu, 28 Aug 2025 09:49:38 -0300 Subject: [PATCH] Improve messaging --- .../ee/routes/v1/github-org-sync-router.ts | 2 -- .../github-org-sync-service.ts | 11 +++----- .../github-org-sync/github-org-sync-types.ts | 1 - .../api/githubOrgSyncConfig/mutations.tsx | 1 - .../OrgGithubSyncSection.tsx | 26 +++++++------------ 5 files changed, 13 insertions(+), 28 deletions(-) diff --git a/backend/src/ee/routes/v1/github-org-sync-router.ts b/backend/src/ee/routes/v1/github-org-sync-router.ts index 1d7c85c4d..dcfc5778b 100644 --- a/backend/src/ee/routes/v1/github-org-sync-router.ts +++ b/backend/src/ee/routes/v1/github-org-sync-router.ts @@ -141,7 +141,6 @@ export const registerGithubOrgSyncRouter = async (server: FastifyZodProvider) => response: { 200: z.object({ syncedUsersCount: z.number(), - skippedUsersCount: z.number(), totalUsers: z.number(), errors: z.array(z.string()), createdTeams: z.array(z.string()), @@ -159,7 +158,6 @@ export const registerGithubOrgSyncRouter = async (server: FastifyZodProvider) => return { syncedUsersCount: result.syncedUsersCount, - skippedUsersCount: result.skippedUsersCount, totalUsers: result.totalUsers, errors: result.errors, createdTeams: result.createdTeams, diff --git a/backend/src/ee/services/github-org-sync/github-org-sync-service.ts b/backend/src/ee/services/github-org-sync/github-org-sync-service.ts index 141c243f9..e430b87c6 100644 --- a/backend/src/ee/services/github-org-sync/github-org-sync-service.ts +++ b/backend/src/ee/services/github-org-sync/github-org-sync-service.ts @@ -417,7 +417,9 @@ export const githubOrgSyncServiceFactory = ({ } }); - await octokitGraphQL.graphql(`query { organization(login: $org) { id name } }`, { org: config.githubOrgName }); + await octokitGraphQL.graphql(`query($org: String!) { organization(login: $org) { id name } }`, { + org: config.githubOrgName + }); return { valid: true, @@ -550,7 +552,6 @@ export const githubOrgSyncServiceFactory = ({ const startTime = Date.now(); let syncedUsersCount = 0; - let skippedUsersCount = 0; const syncErrors: string[] = []; const createdTeams = new Set(); const updatedTeams = new Set(); @@ -765,8 +766,6 @@ export const githubOrgSyncServiceFactory = ({ for (const member of activeMembers) { try { if (!member.userId) { - skippedUsersCount += 1; - syncErrors.push("Member without userId found, skipping"); // eslint-disable-next-line no-continue continue; } @@ -774,8 +773,6 @@ export const githubOrgSyncServiceFactory = ({ const githubUsername = githubUsernameMap.get(member.userId); if (!githubUsername) { - skippedUsersCount += 1; - syncErrors.push(`User ${member.userId}: No GitHub username found. User needs to log in at least once.`); // eslint-disable-next-line no-continue continue; } @@ -811,7 +808,6 @@ export const githubOrgSyncServiceFactory = ({ { orgId: orgPermission.orgId, syncedUsersCount, - skippedUsersCount, totalUsers: activeMembers.length, createdTeams: createdTeams.size, updatedTeams: updatedTeams.size, @@ -824,7 +820,6 @@ export const githubOrgSyncServiceFactory = ({ return { syncedUsersCount, - skippedUsersCount, totalUsers: activeMembers.length, errors: syncErrors, createdTeams: Array.from(createdTeams), diff --git a/backend/src/ee/services/github-org-sync/github-org-sync-types.ts b/backend/src/ee/services/github-org-sync/github-org-sync-types.ts index 9da41d6d8..02ef07180 100644 --- a/backend/src/ee/services/github-org-sync/github-org-sync-types.ts +++ b/backend/src/ee/services/github-org-sync/github-org-sync-types.ts @@ -29,7 +29,6 @@ export interface TSyncAllTeamsDTO { export interface TSyncResult { syncedUsersCount: number; - skippedUsersCount: number; totalUsers: number; errors: string[]; createdTeams: string[]; diff --git a/frontend/src/hooks/api/githubOrgSyncConfig/mutations.tsx b/frontend/src/hooks/api/githubOrgSyncConfig/mutations.tsx index e3082fec2..273b64a31 100644 --- a/frontend/src/hooks/api/githubOrgSyncConfig/mutations.tsx +++ b/frontend/src/hooks/api/githubOrgSyncConfig/mutations.tsx @@ -49,7 +49,6 @@ export const useSyncAllGithubTeams = () => { githubOrgAccessToken?: string; } = {}): Promise<{ syncedUsersCount: number; - skippedUsersCount: number; totalUsers: number; errors: string[]; createdTeams: string[]; diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgProvisioningTab/OrgGithubSyncSection.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgProvisioningTab/OrgGithubSyncSection.tsx index 61eb6fb06..ca4e48472 100644 --- a/frontend/src/pages/organization/SettingsPage/components/OrgProvisioningTab/OrgGithubSyncSection.tsx +++ b/frontend/src/pages/organization/SettingsPage/components/OrgProvisioningTab/OrgGithubSyncSection.tsx @@ -65,20 +65,23 @@ export const OrgGithubSyncSection = () => { const result = await syncAllTeamsMutation.mutateAsync({ githubOrgAccessToken: token }); - let message = `Successfully synced teams for ${result.syncedUsersCount} out of ${result.totalUsers} users`; + let message = `Successfully synced teams for ${result.syncedUsersCount} user${result.syncedUsersCount === 1 ? "" : "s"}`; const details = []; if (result.createdTeams.length > 0) { - details.push(`${result.createdTeams.length} new teams created`); + details.push( + `${result.createdTeams.length} new team${result.createdTeams.length === 1 ? "" : "s"} created` + ); } if (result.updatedTeams.length > 0) { - details.push(`${result.updatedTeams.length} teams updated`); + details.push( + `${result.updatedTeams.length} team${result.updatedTeams.length === 1 ? "" : "s"} updated` + ); } if (result.removedMemberships > 0) { - details.push(`${result.removedMemberships} memberships removed`); - } - if (result.skippedUsersCount > 0) { - details.push(`${result.skippedUsersCount} users skipped`); + details.push( + `${result.removedMemberships} membership${result.removedMemberships === 1 ? "" : "s"} removed` + ); } if (details.length > 0) { @@ -326,15 +329,6 @@ export const OrgGithubSyncSection = () => { {tokenValidationResult.valid && tokenValidationResult.organizationInfo ? (
✓ Token Valid
-
- Organization: {tokenValidationResult.organizationInfo.name} ( - {tokenValidationResult.organizationInfo.login}) -
- {tokenValidationResult.organizationInfo.publicRepos !== undefined && ( -
- Public repos: {tokenValidationResult.organizationInfo.publicRepos} -
- )}
) : (
✗ Token Invalid