Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(web): add bulk move to shared caps and spaces
Richie McIlroy87745e8a0f71
diff --git a/apps/web/app/(org)/dashboard/spaces/[spaceId]/SharedCaps.tsx b/apps/web/app/(org)/dashboard/spaces/[spaceId]/SharedCaps.tsxindex f5d7aaa01..2eb70f336 100644--- a/apps/web/app/(org)/dashboard/spaces/[spaceId]/SharedCaps.tsx+++ b/apps/web/app/(org)/dashboard/spaces/[spaceId]/SharedCaps.tsx@@ -32,6 +32,7 @@ import { useDashboardContext } from "../../Contexts";import { CapPagination } from "../../caps/components/CapPagination";import Folder, { type FolderDataType } from "../../caps/components/Folder";import { NewFolderDialog } from "../../caps/components/NewFolderDialog";+import { SelectedCapsBar } from "../../caps/components/SelectedCapsBar";import { AddVideosDialog } from "./components/AddVideosDialog";import { AddVideosToOrganizationDialog } from "./components/AddVideosToOrganizationDialog";import { EmptySharedCapState } from "./components/EmptySharedCapState";@@ -122,10 +123,8 @@ export const SharedCaps = ({const limit = 15;const [openNewFolderDialog, setOpenNewFolderDialog] = useState(false);const totalPages = Math.ceil(count / limit);- const [isDraggingCap, setIsDraggingCap] = useState({- isOwner: false,- isDragging: false,- });+ const [isDraggingCap, setIsDraggingCap] = useState(false);+ const [selectedCaps, setSelectedCaps] = useState<Video.VideoId[]>([]);const [isAddVideosDialogOpen, setIsAddVideosDialogOpen] = useState(false);const [isSpaceSettingsOpen, setIsSpaceSettingsOpen] = useState(false);const [@@ -160,6 +159,21 @@ export const SharedCaps = ({const canManageCurrentSharedCollection = spaceData? canManageCurrentSpace: canManageCurrentOrganization;+ const moveLocation = spaceData+ ? ({ type: "space", spaceId } as const)+ : ({ type: "organization" } as const);+ const moveRootLabel =+ spaceData?.name ??+ organizationData?.name ??+ activeOrganization?.organization.name ??+ "All organization";+ const handleCapSelection = (capId: Video.VideoId) => {+ setSelectedCaps((current) =>+ current.includes(capId)+ ? current.filter((id) => id !== capId)+ : [...current, capId],+ );+ };const spaceMemberCount = spaceMembers?.length || 0;@@ -312,7 +326,7 @@ export const SharedCaps = ({return (<div className="flex relative flex-col w-full h-full">{spaceSettingsDialog}- {isDraggingCap.isDragging && (+ {isDraggingCap && (<div className="fixed inset-0 z-50 pointer-events-none"><div className="flex justify-center items-center w-full h-full"><div className="flex gap-2 items-center px-5 py-3 text-sm font-medium text-white rounded-xl bg-blue-12">@@ -320,11 +334,7 @@ export const SharedCaps = ({className="size-3.5 text-white opacity-50"icon={faInfoCircle}/>- <p className="text-white">- {isDraggingCap.isOwner- ? " Drag to a space to share or folder to move"- : "Only the video owner can drag and move the video"}- </p>+ <p className="text-white">Drag to a folder to move</p></div></div></div>@@ -413,7 +423,12 @@ export const SharedCaps = ({<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} />+ <Folder+ key={folder.id}+ {...folder}+ canMove={canManageCurrentSharedCollection}+ moveRootLabel={moveRootLabel}+ />))}</div></>@@ -426,7 +441,6 @@ export const SharedCaps = ({</h1><div className="grid grid-cols-1 gap-4 sm:gap-6 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5">{data.map((cap) => {- const isOwner = cap.ownerId === currentUserId;return (<SharedCapCardkey={cap.id}@@ -437,12 +451,23 @@ export const SharedCaps = ({organizationName={activeOrganization?.organization.name || ""}spaceName={spaceData?.name || ""}userId={currentUserId}- onDragStart={() =>- setIsDraggingCap({ isOwner, isDragging: true })+ canMove={canManageCurrentSharedCollection}+ moveLocation={moveLocation}+ moveRootLabel={moveRootLabel}+ isSelected={+ canManageCurrentSharedCollection &&+ selectedCaps.includes(cap.id)}- onDragEnd={() =>- setIsDraggingCap({ isOwner, isDragging: false })+ anyCapSelected={+ canManageCurrentSharedCollection && selectedCaps.length > 0}+ onSelectToggle={+ canManageCurrentSharedCollection+ ? () => handleCapSelection(cap.id)+ : undefined+ }+ onDragStart={() => setIsDraggingCap(true)}+ onDragEnd={() => setIsDraggingCap(false)}/>);})}@@ -460,6 +485,14 @@ export const SharedCaps = ({)}</>)}+ {canManageCurrentSharedCollection && (+ <SelectedCapsBar+ selectedCaps={selectedCaps}+ setSelectedCaps={setSelectedCaps}+ moveLocation={moveLocation}+ moveRootLabel={moveRootLabel}+ />+ )}</div>);};diff --git a/apps/web/app/(org)/dashboard/spaces/[spaceId]/components/SharedCapCard.tsx b/apps/web/app/(org)/dashboard/spaces/[spaceId]/components/SharedCapCard.tsxindex 2e7651a50..473c9d2ef 100644--- a/apps/web/app/(org)/dashboard/spaces/[spaceId]/components/SharedCapCard.tsx+++ b/apps/web/app/(org)/dashboard/spaces/[spaceId]/components/SharedCapCard.tsx@@ -2,9 +2,10 @@import type { VideoMetadata } from "@cap/database/types";import type { SpaceRuleSource, ViewerSettingKey } from "@cap/web-backend";-import type { ImageUpload, Video } from "@cap/web-domain";+import type { Folder, ImageUpload, Video } from "@cap/web-domain";import { faBuilding, faUser } from "@fortawesome/free-solid-svg-icons";import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";+import type { MoveLocation } from "@/lib/move-items";import { CapCard } from "../../../caps/components/CapCard/CapCard";interface SharedCapCardProps {@@ -45,6 +46,13 @@ interface SharedCapCardProps {spaceName?: string;onDragStart?: () => void;onDragEnd?: () => void;+ canMove?: boolean;+ moveLocation?: MoveLocation;+ moveRootLabel?: string;+ currentFolderId?: Folder.FolderId | null;+ isSelected?: boolean;+ anyCapSelected?: boolean;+ onSelectToggle?: () => void;}export const SharedCapCard: React.FC<SharedCapCardProps> = ({@@ -57,6 +65,13 @@ export const SharedCapCard: React.FC<SharedCapCardProps> = ({spaceName,onDragStart,onDragEnd,+ canMove,+ moveLocation,+ moveRootLabel,+ currentFolderId,+ isSelected,+ anyCapSelected,+ onSelectToggle,}) => {const displayCount =analytics === 0@@ -72,6 +87,13 @@ export const SharedCapCard: React.FC<SharedCapCardProps> = ({cap={cap}analytics={displayCount}userId={userId}+ canMove={canMove}+ moveLocation={moveLocation}+ moveRootLabel={moveRootLabel}+ currentFolderId={currentFolderId}+ isSelected={isSelected}+ anyCapSelected={anyCapSelected}+ onSelectToggle={onSelectToggle}><div className="mb-2 space-y-1">{cap.ownerName && (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.tsxindex 0cbf2b245..10dcaea3d 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@@ -102,6 +102,14 @@ const FolderPage = async (props: {organizationRole: orgAccess?.role,spaceRole: null,}));+ const moveLocation =+ spaceOrOrg.variant === "space"+ ? ({ type: "space", spaceId: spaceOrOrg.space.id } as const)+ : ({ type: "organization" } as const);+ const moveRootLabel =+ spaceOrOrg.variant === "space"+ ? spaceOrOrg.space.name+ : spaceOrOrg.organization.name;return (<div>@@ -158,6 +166,8 @@ const FolderPage = async (props: {id={folder.id}parentId={folder.parentId}videoCount={folder.videoCount}+ canMove={canManageCollection}+ moveRootLabel={moveRootLabel}/>))}</div>@@ -165,6 +175,10 @@ const FolderPage = async (props: {)}<FolderVideosSectioninitialVideos={videosData}+ location={moveLocation}+ rootLabel={moveRootLabel}+ currentFolderId={params.folderId}+ canMove={canManageCollection}analyticsEnabled={Boolean(serverEnv().TINYBIRD_TOKEN && serverEnv().TINYBIRD_HOST,)}