Skip to content

refactor(login): organize login routes and components by forge#3030

Merged
afonsojramos merged 2 commits into
mainfrom
gitify-issue-2866
Jul 10, 2026
Merged

refactor(login): organize login routes and components by forge#3030
afonsojramos merged 2 commits into
mainfrom
gitify-issue-2866

Conversation

@afonsojramos

Copy link
Copy Markdown
Member

Summary

The PAT login route comingled GitHub and Gitea logic through isGitea conditionals. Now that forge adapters exist, this organizes the login components and routes the same way: forge-specific knowledge lives in forge-specific modules, and shared code stays free of forge branching.

  • Extract the shared PAT form shell into components/login/LoginWithPersonalAccessTokenForm, which owns form state, validation, and submission. Forge-specific copy is supplied via props, and the GitHub-only recommended-scopes hint renders through a children slot, so the shared form contains zero forge conditionals.
  • Add forge-specific login route components organized like utils/forges/<forge>/:
    • routes/github/LoginWithPersonalAccessToken and routes/gitea/LoginWithPersonalAccessToken supply their own copy to the shared form.
    • routes/github/LoginWithDeviceFlow and routes/github/LoginWithOAuthApp move under routes/github/ since GitHub is the only forge with those capability bundles; they no longer read the forge from router state.
  • Register forge-specific paths: /login/github/device-flow, /login/github/personal-access-token, /login/github/oauth-app, /login/gitea/personal-access-token.
  • LoginMethodDescriptor gains a required authMethod and drops the router state field (LoginRouteState is deleted). With routes being forge-specific, no forge needs to travel through navigation state anymore; re-auth still passes the account.
  • Accounts is now fully adapter-driven: the "Add new account" menu renders from listAdapters() × loginMethods (existing testids preserved), and re-authentication resolves its destination via the account's adapter descriptor instead of a hardcoded switch. An unmatched auth method now logs an error instead of silently doing nothing.

Adding a new forge (e.g. Bitbucket) no longer touches any shared login component: register the adapter, add its route components, and the login screen, add-account menu, and re-auth flow pick it up.

User-visible changes

  • Add-account menu labels are now consistently Login with <forge> (<method>), so the GitHub PAT and OAuth App entries read "Login with GitHub (Personal Access Token)" and "Login with GitHub (OAuth App)". Reproducing the old inconsistent labels would have required reintroducing a forge conditional.
  • The Gitea menu entry now shows the key icon from its login-method descriptor (matching the login screen) instead of the server icon.

Testing

  • PAT route tests split per forge with new Gitea coverage (token format validation, token settings URL, login payload including forge: 'gitea').
  • New re-authentication tests covering all auth methods across both forges, previously untested.
  • Add-account menu tests now also lock the menu labels.
  • Full suite: 145 files / 1082 tests passing, lint, format, and typecheck clean.

Closes #2866

@afonsojramos afonsojramos requested a review from setchy as a code owner July 10, 2026 14:50
@github-actions github-actions Bot added the refactor Refactoring of existing feature label Jul 10, 2026
@sonarqubecloud

Copy link
Copy Markdown

@afonsojramos afonsojramos merged commit 5edabc1 into main Jul 10, 2026
17 checks passed
@afonsojramos afonsojramos deleted the gitify-issue-2866 branch July 10, 2026 17:08
@github-actions github-actions Bot added this to the Release 7.0.0 milestone Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Refactoring of existing feature

Development

Successfully merging this pull request may close these issues.

refactor: login routes and components to be forge specific

2 participants