Skip to content

Commit a06579f

Browse files
committed
feat(people): sync issues page with search and CSV export
The issue list in the Directory sync dialog became unusable past a few dozen issues. Issues now live on their own page at /o/[orgId]/people/sync-issues: one category at a time with counts, search over name, username and email, keyset pagination, and a link to each account in the Okta or Entra admin console. Administrators can export every issue as CSV (capped at 100,000 rows, audited as org_people.sync_issues_exported) to work through them in the identity provider. The dialog keeps a one-line summary that opens the page.
1 parent 2a9ed25 commit a06579f

18 files changed

Lines changed: 723 additions & 379 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { exportPeopleSyncIssuesContract } from '@/lib/api/contracts/people-sync'
2+
import {
3+
defineInternalBinaryRoute,
4+
internalOrchestrationErrorPolicy,
5+
internalRateLimits,
6+
internalSessionAuth,
7+
} from '@/lib/api/server/routes'
8+
import { exportPeopleSyncIssues } from '@/lib/people/application/directory-sync'
9+
10+
export const GET = defineInternalBinaryRoute({
11+
contract: exportPeopleSyncIssuesContract,
12+
operation: exportPeopleSyncIssues.operation,
13+
useCase: exportPeopleSyncIssues,
14+
auth: internalSessionAuth,
15+
errorPolicy: internalOrchestrationErrorPolicy,
16+
rateLimit: internalRateLimits.user({ bucketName: 'people-sync-issues-export' }),
17+
mapInput: ({ params, query }) => ({
18+
organizationId: params.id,
19+
category: query.category,
20+
search: query.search,
21+
}),
22+
present: ({ csv, truncated }) => ({
23+
body: csv,
24+
contentType: 'text/csv; charset=utf-8',
25+
contentDisposition: `attachment; filename="directory-sync-issues-${new Date().toISOString().slice(0, 10)}.csv"`,
26+
headers: { 'Cache-Control': 'no-store', 'X-Export-Truncated': truncated ? '1' : '0' },
27+
}),
28+
})

‎apps/sim/app/api/organizations/[id]/people/sync/issues/route.ts‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ import {
99
import { listPeopleSyncIssues } from '@/lib/people/application/directory-sync'
1010
import { readSortedCursor, writeSortedCursor } from '@/app/api/v2/lib/response'
1111

12-
/** A cursor resumes only the issue list of the organization it came from. */
13-
const cursorScope = (id: string) =>
14-
cursorScopeKey(cursorRoute(listPeopleSyncIssuesContract, { id }))
12+
/** A cursor resumes only the category and search of the organization it came from. */
13+
const cursorScope = (id: string, category: string, search = '') =>
14+
cursorScopeKey(cursorRoute(listPeopleSyncIssuesContract, { id }), {
15+
category,
16+
search: search.trim(),
17+
})
1518

1619
export const GET = defineInternalJsonRoute({
1720
contract: listPeopleSyncIssuesContract,
@@ -23,15 +26,22 @@ export const GET = defineInternalJsonRoute({
2326
rateLimit: internalRateLimits.user({ bucketName: 'people-sync-issues' }),
2427
mapInput: ({ params, query }) => ({
2528
organizationId: params.id,
26-
cursorKeys: readSortedCursor(query.cursor, 'section', 'asc', cursorScope(params.id)),
29+
category: query.category,
30+
search: query.search,
31+
cursorKeys: readSortedCursor(
32+
query.cursor,
33+
'section',
34+
'asc',
35+
cursorScope(params.id, query.category, query.search)
36+
),
2737
}),
2838
present: ({ data, nextCursorKeys }, { input }) => ({
2939
issues: data,
3040
nextCursor: writeSortedCursor(
3141
nextCursorKeys,
3242
'section',
3343
'asc',
34-
cursorScope(input.organizationId)
44+
cursorScope(input.organizationId, input.category, input.search)
3545
),
3646
}),
3747
})

‎apps/sim/app/o/[organizationId]/people/directory-sync-issues.tsx‎

Lines changed: 0 additions & 318 deletions
This file was deleted.

0 commit comments

Comments
 (0)