Skip to content

Commit db2dc3d

Browse files
cojiclaude
andcommitted
feat(ui): multi-installation aware settings UI (#283 PR 4/7)
integration page (settings/integration): - loader returns githubAppLinks[] array with installation status - action refactored to discriminated union + parseWithZod + match (CLAUDE.md 規約) - new INTENTS: disconnectGithubAppLink, confirmDisconnectGithubAppLink - per-installation disconnect with assertInstallationBelongsToOrg validation GitHub App section UI: - InstallationCard renders one card per active installation - per-installation fetcher + ConfirmDialog (preserves installationId) - "Add another GitHub account" button when at least one link exists - buildInstallationSettingsUrl branches by github_account_type (User → /settings/installations/<id>, Organization → /organizations/<login>/settings/installations) repositories.add page: - installation selector via shared <InstallationSelect> when 2+ active links - per-installation fetchAllInstallationRepos cache key - loader/action share resolveInstallationIdForApp helper for installation resolution - assertInstallationBelongsToOrg server-side validation - addRepository mutation accepts githubInstallationId + upsertRepositoryMembership github-users page: - loader returns installationOptions via shared getActiveInstallationOptions - searchGithubUsers accepts installationId, validates via assertInstallationBelongsToOrg - toolbar uses shared <InstallationSelect>; selection persisted in URL searchParams - Add button disabled when 2+ installations and none selected (UX feedback) shared helpers added: - app/libs/github-account.ts: formatGithubAccountLabel, isPersonalAccount, buildInstallationSettingsUrl - app/components/installation-select.tsx: <InstallationSelect> reusable component - app/services/github-integration-queries.server.ts: getActiveInstallationOptions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e573408 commit db2dc3d

File tree

13 files changed

+754
-407
lines changed

13 files changed

+754
-407
lines changed

app/libs/github-account.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Shared formatting / URL helpers for GitHub App installation links.
3+
*/
4+
5+
export type GithubAccountLike = {
6+
installationId: number
7+
githubOrg: string
8+
githubAccountType: string | null
9+
}
10+
11+
export const isPersonalAccount = (link: GithubAccountLike): boolean =>
12+
link.githubAccountType === 'User'
13+
14+
/**
15+
* UI label for an installation account. Personal accounts get an `@` prefix
16+
* (matching GitHub's own convention) while organizations show their bare login.
17+
*/
18+
export const formatGithubAccountLabel = (link: GithubAccountLike): string =>
19+
isPersonalAccount(link) ? `@${link.githubOrg}` : link.githubOrg
20+
21+
/**
22+
* GitHub-side settings URL for managing this installation.
23+
*
24+
* - Personal: `https://github.com/settings/installations/<id>`
25+
* - Organization: `https://github.com/organizations/<login>/settings/installations`
26+
*/
27+
export const buildInstallationSettingsUrl = (
28+
link: GithubAccountLike,
29+
): string =>
30+
isPersonalAccount(link)
31+
? `https://github.com/settings/installations/${link.installationId}`
32+
: `https://github.com/organizations/${encodeURIComponent(link.githubOrg)}/settings/installations`

0 commit comments

Comments
 (0)