Repository navigation
feat(admin): add create-workspace-for-owner flow in admin console - #1532
Merged
realcodesiman merged 4 commits intoOct 23, 2026
Merged
Conversation
Lets a platform admin create a workspace for a given owner email (auto-provisioning a root-tenant user if none exists) and optionally attach team members with shared permissions, all in one transaction so a later failure rolls back owner + members together. - packages/business/admin-workspace: new service orchestrating owner provisioning, workspace creation, and member attachment - workspace/service.create: accepts `members[]` inserted alongside the owner on the same tx; quota-consumption and workspace-member tracking generalized from a single live-increment flag to a count, to support multiple inserts per tx - quota-enforcement/user-quota: `hasRoomForTeamMembers` batch check for the owner + N members case - errors: `ownerAlreadyHasWorkspaceException`, `adminWorkspaceMemberNotFoundException`, `teamMembersLimitReachedException` - platform-admin/service: extract shared root-user provisioning to `user/provision-root-user` - workspace-members: extract shared permission switches to `WorkspaceMemberPermissionFields`, reused by the new admin dialog; generalize `useWorkspaceMemberPermissionsCoupling` over any form shape
realcodesiman
deleted the
realcodesiman/enterprise-workspace-add-owner
branch
October 23, 2026 02:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
teamMemberslive-increment/rollback machinery from a single owner insert to an owner + N members batch, so a later failure (quota, cache) rolls every insert back with the workspace instead of leaving a partially staffed workspace.WorkspaceMemberPermissionFieldscomponent, reused by the new admin dialog, and generalizesuseWorkspaceMemberPermissionsCouplingto any form carrying apermissionsfield.Changes
packages/business/src/admin-workspace/service.ts(new): orchestrates owner lookup/provisioning,teamMembersquota pre-check, andworkspaceService.create({ members })packages/business/src/workspace/service.ts:create/writeWorkspaceacceptmembers[]inserted alongside the owner on the same txpackages/business/src/workspace/quota-consumption.ts,workspace-member/service.ts:teamMembersLiveIncremented(boolean) →teamMembersLiveIncrementedCount(number) to support multiple inserts per txpackages/business/src/quota-enforcement/service.ts: owns thehasRoomForTeamMembersbatch check;packages/business/src/user-quota/service.tsgeneralizesisTeamMemberLimitReached(..., additionalCount)packages/business/src/errors.ts:ownerAlreadyHasWorkspaceException,adminWorkspaceMemberNotFoundException,teamMembersLimitReachedExceptionpackages/business/src/platform-admin/service.ts,user/provision-root-user.ts(new): extracted shared root-user provisioning, de-duplicated fromPlatformAdminServiceapps/builder/src/enterprise/features/admin-workspaces/: newcreate-admin-workspace.action.ts,create-admin-workspace-dialog.tsx,schema.ts, wired into the admin workspaces table behindhasEnterpriseFeatures()apps/builder/src/features/workspace-members/:workspace-member-permission-fields.tsx(new, shared), schema/mutation and coupling hook generalizedfields.*keys for the new dialog added across all locale filesTest plan
pnpm lintpnpm --filter builder check-typespnpm --filter @chatbotx.io/business check-typespackages/business/__tests__/admin-workspace-service.test.ts,apps/builder/__tests__/create-admin-workspace-action.test.ts(new tests added with this change)Invariant 23 exemption: platform administration.