…rg-wide (#2046)
Switching a project's owning team to "Org-wide" left sharedWithTeamIds
intact, so getProjectTeamIds() still returned those teams and the project
stayed team-restricted even though the Sharing Select, overview header and
projects table all reported "Org-wide". The orphaned shares were also
unreachable from the UI (the "Also shared with" control is hidden without
an owning team).
A shared-with team is always additional to an owning team, so a project
with no owning team cannot retain shares. Fix on both layers:
- Server: add normalizeSharing() and apply it in updateProjectSharing so
an effective owning team of null clears sharedWithTeamIds. This is the
authoritative backstop regardless of caller.
- Client: handleOwningTeamChange clears the shared list when the owning
team becomes "Org-wide" instead of filtering by a null id (which never
matched), keeping the optimistic UI consistent.
Now "Org-wide" genuinely means org-wide and effective access matches the
displayed visibility.
Closes #2046
Summary
Fixes #2046. Switching a project's owning team to Org-wide used to leave
sharedWithTeamIdsintact, sogetProjectTeamIds()still returned those teams: the project stayed restricted to them while the Sharing Select, overview header, and projects table all displayed "Org-wide". The orphaned shares were also unreachable from the UI (the "Also shared with" control is hidden when there's no owning team).A shared-with team is always additional to an owning team, so a project with no owning team cannot retain shares.
Changes
convex/projects/access.ts,mutations.ts): new purenormalizeSharing()helper, applied inupdateProjectSharingso an effective owning team ofnullclearssharedWithTeamIds. Authoritative backstop regardless of caller (also cleans legacy orphaned rows on next save).project-sharing-section.tsx):handleOwningTeamChangenow clears the shared list when the owning team becomes Org-wide, instead offilter(id => id !== null)which never matched.access.test.ts): unit coverage fornormalizeSharing, including that the result is genuinely org-wide perisOrgWideProject/getProjectTeamIds.Verification
vitest --project server convex/projects/— 38 passedtsc --noEmit— exit 0oxlint --type-awareon changed files — 0 warnings/errorsCloses #2046