Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(web): open the owner's folder in the Cap's organization too

Richie McIlroy5266c6b29ad7
diff --git a/apps/web/__tests__/unit/share-dashboard-destination.test.ts b/apps/web/__tests__/unit/share-dashboard-destination.test.ts
index eab8db143..7feb1d903 100644
--- a/apps/web/__tests__/unit/share-dashboard-destination.test.ts
+++ b/apps/web/__tests__/unit/share-dashboard-destination.test.ts
@@ -199,7 +199,7 @@ describe("pickShareDashboardDestination", () => {
expect(pickShareDashboardDestination(access({}))).toBeNull();
});
- it("switches organization only for an owner's My Caps in another organization", () => {
+ it("switches organization only for an owner's destinations in another organization", () => {
expect(
pickShareDashboardDestination(
access({ isOwner: true, videoOrganizationId: "org-other" }),
@@ -226,11 +226,11 @@ describe("pickShareDashboardDestination", () => {
pickShareDashboardDestination(
access({
isOwner: true,
- videoOrganizationId: "org-other",
+ activeOrganizationId: null,
ownerFolder: { id: "folder-1", name: "Launch" },
}),
)?.switchOrganizationId,
- ).toBeNull();
+ ).toBe("org-active");
expect(
pickShareDashboardDestination(
diff --git a/apps/web/lib/share-dashboard-destination.ts b/apps/web/lib/share-dashboard-destination.ts
index 5788866bc..982725271 100644
--- a/apps/web/lib/share-dashboard-destination.ts
+++ b/apps/web/lib/share-dashboard-destination.ts
@@ -44,26 +44,27 @@ export function pickShareDashboardDestination(
access: ShareDashboardAccess,
): ShareDashboardDestination | null {
if (access.isOwner) {
+ // My Caps lists only the active organization's Caps, and the folder page
+ // 404s without an active organization, so the owner's destinations open
+ // in the Cap's own organization. Space pages load under any of them.
+ const switchOrganizationId =
+ access.ownerIsVideoOrganizationMember &&
+ access.videoOrganizationId !== access.activeOrganizationId
+ ? access.videoOrganizationId
+ : null;
if (access.ownerFolder) {
return {
kind: "folder",
href: `/dashboard/folder/${access.ownerFolder.id}`,
label: access.ownerFolder.name,
- switchOrganizationId: null,
+ switchOrganizationId,
};
}
- // Folder and space pages load whatever the active organization is, but
- // My Caps only lists the active organization's Caps, so it's the one
- // destination that has to switch first.
return {
kind: "caps",
href: "/dashboard/caps",
label: "My Caps",
- switchOrganizationId:
- access.ownerIsVideoOrganizationMember &&
- access.videoOrganizationId !== access.activeOrganizationId
- ? access.videoOrganizationId
- : null,
+ switchOrganizationId,
};
}