feat: add Move Team to Organization admin migration page#25067
feat: add Move Team to Organization admin migration page#25067hariombalhara merged 27 commits intomainfrom
Conversation
- Add moveTeamToOrg and removeTeamFromOrg functions to orgMigration.ts - Restore API endpoint at /api/orgMigration/moveTeamToOrg - Restore admin UI page at /settings/admin/orgMigrations/moveTeamToOrg - Add helper functions for team redirect management - Support moving team members along with the team This endpoint allows admins to migrate teams to organizations after org creation, which is needed as a temporary solution until proper org admin permissions are implemented. Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
- Move moveTeamToOrg and removeTeamFromOrg functions from playwright/lib to lib/orgMigration.ts - Update API endpoint to import from lib/orgMigration instead of playwright/lib - Fix redirect URL format: use / instead of /team/ - Fix import path: use ../playwright/lib/orgMigration instead of ./playwright/lib/orgMigration - Rename unused _dbRemoveTeamFromOrg in playwright file to satisfy linter - Remove duplicate functions from playwright/lib/orgMigration.ts This fixes the Vercel deployment failure caused by importing from test-only directories in production API routes, and corrects the redirect URL format to match the original implementation. Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
- Remove custom orgMigration.ts implementation - Update API endpoint to call existing createTeamsHandler with org owner impersonation - Remove moveMembers option from UI (always moves members by design) - Fix Vercel deployment by removing playwright import from production code - Use OrganizationRepository.adminFindById to fetch org owner Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
|
This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active. |
|
This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active. |
No Conflicts DetectedThis PR does not have any merge conflicts with the base branch. The If you believe this PR should have conflicts, please check the PR status and try again. |
…ore-move-team-to-org-endpoint
- Move admin page from pages/settings/admin/orgMigrations to app/(use-page-wrapper)/settings/(admin-layout)/admin/orgMigrations - Convert API route from pages/api/orgMigration/moveTeamToOrg.ts to app/api/orgMigration/moveTeamToOrg/route.ts - Create client view component in modules/settings/admin/org-migrations/ - Remove old pages directory files and getServerSideProps Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
- Fix @calcom/lib/server to @calcom/lib/server/i18n for getTranslation - Fix @calcom/ui barrel import to specific component paths Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
Devin AI is addressing Cubic AI's review feedbackNew feedback has been sent to the existing Devin session. ✅ Pushed commit |
Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
c34da01 to
1b3df61
Compare
E2E results are ready! |
Devin AI is resolving merge conflictsThis PR has merge conflicts with the Devin will:
If you prefer to resolve conflicts manually, you can close the Devin session and handle it yourself. |
…ore-move-team-to-org-endpoint Co-Authored-By: bot_apk <apk@cognition.ai>
Devin AI is completing this stale PRThis PR by @hariombalhara has been marked as stale. A Devin session has been created to complete the remaining work. Devin will review the PR, address any feedback, and push updates to complete this PR. |
…d English string Co-Authored-By: bot_apk <apk@cognition.ai>
Separates the try-catch for prisma.team.update (slug conflict) from creditService.moveCreditsFromTeamToOrg to avoid misattributing credit service P2002 errors as slug conflicts. Co-Authored-By: bot_apk <apk@cognition.ai>
Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
joeauyeung
left a comment
There was a problem hiding this comment.
Great work @hariombalhara. Reuses currently logic and endpoint is protected by the authedAdminProcedure. Tested manually and working as expected
…ore-move-team-to-org-endpoint Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
What does this PR do?
Adds an admin-only "Move Team to Organization" migration page under Settings → Admin → Migrations. This provides a UI for instance admins to move an existing standalone team into an organization.
Key changes:
/settings/admin/migrations/move-team-to-orgwith a form to enter Team ID, new slug, and target Org IDmoveTeamToOrg.handler.ts) that delegates to the existingcreateTeamsHandlerby impersonating the org ownerinstanceof Prisma.PrismaClientKnownRequestErrorinmoveTeam()and surfaces a user-friendly CONFLICT error using an i18n keycreateTeams.handler.test.tsLink to Devin run: https://app.devin.ai/sessions/d313feb45bcd45949d0e49914ed99419
Requested by: bot_apk (apk@cognition.ai)
Original author: @hariombalhara
Updates since last revision
Slug "xyz" is already in use within this organization) to an i18n keyslug_already_in_use_in_org, addressing this review comment. Updated the unit test accordingly.prisma.team.updatefromcreditService.moveCreditsFromTeamToOrgso that a P2002 from the credit service is not misattributed as a slug conflict. Each now has its own try-catch with appropriate error logging. Addresses this review comment.Important Review Points
{ user: { id: orgOwner.id, organizationId: targetOrgId } }and passes it tocreateTeamsHandler. Is this the correct and safe way to perform admin actions on behalf of the org owner?org.members[0].userfromorganizationRepository.adminFindByIdto get the first OWNER-role member. Verify this reliably returns the actual org owner.Prismaimport in handler:createTeams.handler.tschangedimport type { Prisma }to a runtimeimport { Prisma }from@calcom/prisma/clientto support theinstanceofcheck. This is a known deviation from the "no@calcom/prisma/clientin handlers" guideline — confirm this tradeoff is acceptable.creditService.moveCreditsFromTeamToOrgerrors are logged and re-thrown as raw errors (not wrapped in TRPCError). Verify this is acceptable — the team update will have already succeeded at this point.dbRemoveTeamFromOrgfromplaywright/lib/orgMigration.ts— verify nothing else depends on this function (hariombalhara confirmed it was unused).SettingsLayoutAppDirClient.tsxare auto-formatter output — review alongside the actual nav item addition to ensure no unintended changes.How should this be tested?
Prerequisites:
Happy path:
/settings/admin/migrations/move-team-to-orgparentIdis updated, members are invited to the org, redirect is created, success message is displayedSlug conflict:
slug_already_in_use_in_orgEdge cases:
cannot_move_subteam_already_in_orgerrorteam_not_founderrororganization_not_founderrorMandatory Tasks (DO NOT REMOVE)