Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

web: render all folder lists through FoldersSection

Richie McIlroye12bf74ef409
diff --git a/apps/web/app/(org)/dashboard/caps/Caps.tsx b/apps/web/app/(org)/dashboard/caps/Caps.tsx
index 4774bb586..c3fd088ff 100644
--- a/apps/web/app/(org)/dashboard/caps/Caps.tsx
+++ b/apps/web/app/(org)/dashboard/caps/Caps.tsx
@@ -27,7 +27,7 @@ import { CapCard } from "./components/CapCard/CapCard";
import { CapPagination } from "./components/CapPagination";
import { EmptyCapState } from "./components/EmptyCapState";
import type { FolderDataType } from "./components/Folder";
-import Folder from "./components/Folder";
+import { FoldersSection } from "./components/FoldersSection";
import { useUploadingStatus } from "./UploadingContext";
export type VideoData = {
@@ -271,23 +271,13 @@ export const Caps = ({
className={`${CHROME_EXTENSION_BUTTON_CLASS} font-medium`}
/>
</div>
- {folders.length > 0 && (
- <>
- <div className="flex gap-3 items-center mb-6 w-full">
- <h1 className="text-2xl font-medium text-gray-12">Folders</h1>
- </div>
- <div className="grid grid-cols-[repeat(auto-fill,minmax(250px,1fr))] gap-4 mb-10">
- {folders.map((folder) => (
- <Folder
- key={folder.id}
- {...folder}
- canMove
- moveRootLabel="My Caps"
- />
- ))}
- </div>
- </>
- )}
+ <FoldersSection
+ title="Folders"
+ scope="personal"
+ folders={folders}
+ canMove
+ moveRootLabel="My Caps"
+ />
{visibleVideos.length > 0 && (
<>
<div className="flex justify-between items-center mb-6 w-full">
diff --git a/apps/web/app/(org)/dashboard/folder/[id]/page.tsx b/apps/web/app/(org)/dashboard/folder/[id]/page.tsx
index b8292fc6a..703aed3df 100644
--- a/apps/web/app/(org)/dashboard/folder/[id]/page.tsx
+++ b/apps/web/app/(org)/dashboard/folder/[id]/page.tsx
@@ -15,7 +15,7 @@ import { runPromise } from "@/lib/server";
import { CollectionShareControl } from "../../_components/CollectionShareControl";
import { UploadCapButton } from "../../caps/components";
-import FolderCard from "../../caps/components/Folder";
+import { FoldersSection } from "../../caps/components/FoldersSection";
import { WebRecorderDialog } from "../../caps/components/web-recorder-dialog/web-recorder-dialog";
import {
BreadcrumbItem,
@@ -94,29 +94,22 @@ const FolderPage = async (props: PageProps<"/dashboard/folder/[id]">) => {
</div>
</div>
- {/* Display Child Folders */}
- {childFolders.length > 0 && (
- <>
- <h1 className="mb-6 text-xl font-medium text-gray-12">
- Subfolders
- </h1>
- <div className="grid grid-cols-[repeat(auto-fill,minmax(250px,1fr))] gap-4 mb-10">
- {childFolders.map((folder) => (
- <FolderCard
- key={folder.id}
- name={folder.name}
- color={folder.color}
- public={folder.public}
- id={folder.id}
- parentId={folder.parentId}
- videoCount={folder.videoCount}
- canMove={share.canManage}
- moveRootLabel="My Caps"
- />
- ))}
- </div>
- </>
- )}
+ <FoldersSection
+ title="Subfolders"
+ scope="personal"
+ headingSize="md"
+ folders={childFolders.map((folder) => ({
+ id: folder.id,
+ name: folder.name,
+ color: folder.color,
+ public: folder.public,
+ parentId: folder.parentId,
+ videoCount: folder.videoCount,
+ createdAt: folder.createdAt,
+ }))}
+ canMove={share.canManage}
+ moveRootLabel="My Caps"
+ />
{/* Display Videos */}
<FolderVideosSection
diff --git a/apps/web/app/(org)/dashboard/spaces/[spaceId]/SharedCaps.tsx b/apps/web/app/(org)/dashboard/spaces/[spaceId]/SharedCaps.tsx
index 2eb70f336..b2079583b 100644
--- a/apps/web/app/(org)/dashboard/spaces/[spaceId]/SharedCaps.tsx
+++ b/apps/web/app/(org)/dashboard/spaces/[spaceId]/SharedCaps.tsx
@@ -30,7 +30,8 @@ import { CollectionShareControl } from "../../_components/CollectionShareControl
import SpaceDialog from "../../_components/Navbar/SpaceDialog";
import { useDashboardContext } from "../../Contexts";
import { CapPagination } from "../../caps/components/CapPagination";
-import Folder, { type FolderDataType } from "../../caps/components/Folder";
+import type { FolderDataType } from "../../caps/components/Folder";
+import { FoldersSection } from "../../caps/components/FoldersSection";
import { NewFolderDialog } from "../../caps/components/NewFolderDialog";
import { SelectedCapsBar } from "../../caps/components/SelectedCapsBar";
import { AddVideosDialog } from "./components/AddVideosDialog";
@@ -418,20 +419,14 @@ export const SharedCaps = ({
</Button>
)}
</div>
- {folders && folders.length > 0 && (
- <>
- <h1 className="mb-6 text-2xl font-medium text-gray-12">Folders</h1>
- <div className="grid grid-cols-[repeat(auto-fill,minmax(250px,1fr))] gap-4 mb-10">
- {folders.map((folder) => (
- <Folder
- key={folder.id}
- {...folder}
- canMove={canManageCurrentSharedCollection}
- moveRootLabel={moveRootLabel}
- />
- ))}
- </div>
- </>
+ {folders && (
+ <FoldersSection
+ title="Folders"
+ scope={`space:${spaceId}`}
+ folders={folders}
+ canMove={canManageCurrentSharedCollection}
+ moveRootLabel={moveRootLabel}
+ />
)}
{data.length > 0 && (
diff --git a/apps/web/app/(org)/dashboard/spaces/[spaceId]/folder/[folderId]/page.tsx b/apps/web/app/(org)/dashboard/spaces/[spaceId]/folder/[folderId]/page.tsx
index 10dcaea3d..6327f1f71 100644
--- a/apps/web/app/(org)/dashboard/spaces/[spaceId]/folder/[folderId]/page.tsx
+++ b/apps/web/app/(org)/dashboard/spaces/[spaceId]/folder/[folderId]/page.tsx
@@ -7,7 +7,7 @@ import { notFound } from "next/navigation";
import { getOrganizationAccess } from "@/actions/organization/authorization";
import { getSpaceAccess } from "@/actions/organization/space-authorization";
import { CollectionShareControl } from "@/app/(org)/dashboard/_components/CollectionShareControl";
-import FolderCard from "@/app/(org)/dashboard/caps/components/Folder";
+import { FoldersSection } from "@/app/(org)/dashboard/caps/components/FoldersSection";
import {
getChildFolders,
getFolderBreadcrumb,
@@ -150,29 +150,23 @@ const FolderPage = async (props: {
))}
</div>
</div>
- {childFolders.length > 0 && (
- <>
- <h1 className="mb-6 text-xl font-medium text-gray-12">
- Subfolders
- </h1>
- <div className="grid grid-cols-[repeat(auto-fill,minmax(250px,1fr))] gap-4 mb-10">
- {childFolders.map((folder) => (
- <FolderCard
- key={folder.id}
- name={folder.name}
- color={folder.color}
- public={folder.public}
- spaceId={params.spaceId}
- id={folder.id}
- parentId={folder.parentId}
- videoCount={folder.videoCount}
- canMove={canManageCollection}
- moveRootLabel={moveRootLabel}
- />
- ))}
- </div>
- </>
- )}
+ <FoldersSection
+ title="Subfolders"
+ scope={`space:${params.spaceId}`}
+ headingSize="md"
+ folders={childFolders.map((folder) => ({
+ id: folder.id,
+ name: folder.name,
+ color: folder.color,
+ public: folder.public,
+ spaceId: params.spaceId,
+ parentId: folder.parentId,
+ videoCount: folder.videoCount,
+ createdAt: folder.createdAt,
+ }))}
+ canMove={canManageCollection}
+ moveRootLabel={moveRootLabel}
+ />
<FolderVideosSection
initialVideos={videosData}
location={moveLocation}