Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(web): wire bulk cap move in dashboard caps views
Richie McIlroy4af12f86aa1e
diff --git a/apps/web/app/(org)/dashboard/caps/Caps.tsx b/apps/web/app/(org)/dashboard/caps/Caps.tsxindex 6e7f6b916..4774bb586 100644--- a/apps/web/app/(org)/dashboard/caps/Caps.tsx+++ b/apps/web/app/(org)/dashboard/caps/Caps.tsx@@ -86,6 +86,7 @@ export const Caps = ({const previousCountRef = useRef<number>(0);const [selectedCaps, setSelectedCaps] = useState<Video.VideoId[]>([]);const [isDraggingCap, setIsDraggingCap] = useState(false);+ const moveLocation = { type: "personal" } as const;const anyCapSelected = selectedCaps.length > 0;@@ -277,7 +278,12 @@ export const Caps = ({</div><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+ moveRootLabel="My Caps"+ />))}</div></>@@ -313,6 +319,9 @@ export const Caps = ({isSelected={selectedCaps.includes(video.id)}anyCapSelected={anyCapSelected}onSelectToggle={() => handleCapSelection(video.id)}+ canMove+ moveLocation={moveLocation}+ moveRootLabel="My Caps"/>);})}@@ -329,6 +338,8 @@ export const Caps = ({setSelectedCaps={setSelectedCaps}deleteSelectedCaps={() => deleteCaps(selectedCaps)}isDeleting={isDeletingCaps || isDeletingCap}+ moveLocation={moveLocation}+ moveRootLabel="My Caps"/>{isDraggingCap && (<div className="fixed inset-0 z-50 pointer-events-none">diff --git a/apps/web/app/(org)/dashboard/caps/components/SelectedCapsBar.tsx b/apps/web/app/(org)/dashboard/caps/components/SelectedCapsBar.tsxindex 8f82e8c6d..69e79d01f 100644--- a/apps/web/app/(org)/dashboard/caps/components/SelectedCapsBar.tsx+++ b/apps/web/app/(org)/dashboard/caps/components/SelectedCapsBar.tsx@@ -1,97 +1,140 @@"use client";import { Button } from "@cap/ui";+import type { Folder, Video } from "@cap/web-domain";import { faFilm, faTrash } from "@fortawesome/free-solid-svg-icons";import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import NumberFlow from "@number-flow/react";import { AnimatePresence, motion } from "framer-motion";+import { FolderInput } from "lucide-react";+import { useState } from "react";import { ConfirmationDialog } from "@/app/(org)/dashboard/_components/ConfirmationDialog";+import type { MoveLocation } from "@/lib/move-items";+import { MoveItemsDialog } from "./MoveItemsDialog";interface SelectedCapsBarProps {- selectedCaps: string[];+ selectedCaps: Video.VideoId[];setSelectedCaps: (caps: Video.VideoId[]) => void;- deleteSelectedCaps: () => void;- isDeleting: boolean;+ deleteSelectedCaps?: () => void;+ isDeleting?: boolean;+ moveLocation?: MoveLocation;+ moveRootLabel?: string;+ currentFolderId?: Folder.FolderId | null;}-import type { Video } from "@cap/web-domain";-import { useState } from "react";-export const SelectedCapsBar = ({selectedCaps,setSelectedCaps,deleteSelectedCaps,- isDeleting,+ isDeleting = false,+ moveLocation,+ moveRootLabel,+ currentFolderId = null,}: SelectedCapsBarProps) => {const [confirmOpen, setConfirmOpen] = useState(false);+ const [moveOpen, setMoveOpen] = useState(false);const handleConfirmDelete = () => {- deleteSelectedCaps();+ deleteSelectedCaps?.();setConfirmOpen(false);};return (<AnimatePresence>{selectedCaps.length > 0 && (- <motion.div- className="flex fixed right-0 left-0 bottom-12 z-50 justify-between items-center p-3 mx-auto w-full max-w-xl rounded-xl border shadow-lg border-gray-2 bg-gray-1"- initial={{ opacity: 0, y: 10, scale: 0.9 }}- animate={{ opacity: 1, y: 0, scale: 1 }}- exit={{- opacity: 0,- y: 10,- scale: 0.9,- transition: { duration: 0.2 },- }}- transition={{- opacity: { duration: 0.2, ease: "easeOut" },- y: { type: "spring", damping: 15, stiffness: 300 },- scale: { type: "spring", damping: 15, stiffness: 300 },- }}- >- <div className="flex gap-1 text-sm font-medium text-gray-10">- <NumberFlow- value={selectedCaps.length}- className="tabular-nums text-md text-gray-12"- />- cap{selectedCaps.length !== 1 ? "s" : ""} selected- </div>- <div className="flex gap-2 ml-4">- <Button- variant="dark"- onClick={() => setSelectedCaps([])}- className="text-sm"- size="sm"- >- Cancel- </Button>- <Button- variant="destructive"- onClick={() => setConfirmOpen(true)}- disabled={isDeleting}- className="size-[40px] min-w-[unset] p-0"- size="sm"- >- <FontAwesomeIcon className="w-3.5 text-white" icon={faTrash} />- </Button>- <ConfirmationDialog- open={confirmOpen}- icon={<FontAwesomeIcon icon={faFilm} />}- title="Delete selected Caps"- description={`Are you sure you want to delete ${- selectedCaps.length- } cap${- selectedCaps.length === 1 ? "" : "s"- }? This action cannot be undone.`}- confirmLabel={isDeleting ? "Deleting..." : "Delete"}- cancelLabel="Cancel"- confirmVariant="dark"- loading={isDeleting}- onConfirm={handleConfirmDelete}- onCancel={() => setConfirmOpen(false)}+ <>+ <motion.div+ className="flex fixed right-0 left-0 bottom-12 z-50 justify-between items-center p-3 mx-auto w-full max-w-xl rounded-xl border shadow-lg border-gray-2 bg-gray-1"+ initial={{ opacity: 0, y: 10, scale: 0.9 }}+ animate={{ opacity: 1, y: 0, scale: 1 }}+ exit={{+ opacity: 0,+ y: 10,+ scale: 0.9,+ transition: { duration: 0.2 },+ }}+ transition={{+ opacity: { duration: 0.2, ease: "easeOut" },+ y: { type: "spring", damping: 15, stiffness: 300 },+ scale: { type: "spring", damping: 15, stiffness: 300 },+ }}+ >+ <div className="flex gap-1 text-sm font-medium text-gray-10">+ <NumberFlow+ value={selectedCaps.length}+ className="tabular-nums text-md text-gray-12"+ />+ cap{selectedCaps.length !== 1 ? "s" : ""} selected+ </div>+ <div className="flex gap-2 ml-4">+ {moveLocation && moveRootLabel && (+ <Button+ variant="gray"+ onClick={() => setMoveOpen(true)}+ className="flex gap-2 items-center text-sm"+ size="sm"+ >+ <FolderInput className="size-4" />+ Move+ </Button>+ )}+ <Button+ variant="dark"+ onClick={() => setSelectedCaps([])}+ className="text-sm"+ size="sm"+ >+ Cancel+ </Button>+ {deleteSelectedCaps && (+ <>+ <Button+ variant="destructive"+ onClick={() => setConfirmOpen(true)}+ disabled={isDeleting}+ className="size-[40px] min-w-[unset] p-0"+ size="sm"+ >+ <FontAwesomeIcon+ className="w-3.5 text-white"+ icon={faTrash}+ />+ </Button>+ <ConfirmationDialog+ open={confirmOpen}+ icon={<FontAwesomeIcon icon={faFilm} />}+ title="Delete selected Caps"+ description={`Are you sure you want to delete ${+ selectedCaps.length+ } cap${+ selectedCaps.length === 1 ? "" : "s"+ }? This action cannot be undone.`}+ confirmLabel={isDeleting ? "Deleting..." : "Delete"}+ cancelLabel="Cancel"+ confirmVariant="dark"+ loading={isDeleting}+ onConfirm={handleConfirmDelete}+ onCancel={() => setConfirmOpen(false)}+ />+ </>+ )}+ </div>+ </motion.div>+ {moveLocation && moveRootLabel && (+ <MoveItemsDialog+ open={moveOpen}+ onOpenChange={setMoveOpen}+ location={moveLocation}+ rootLabel={moveRootLabel}+ item={{+ type: "videos",+ videoIds: selectedCaps,+ currentFolderId,+ }}+ onMoved={() => setSelectedCaps([])}/>- </div>- </motion.div>+ )}+ </>)}</AnimatePresence>);diff --git a/apps/web/app/(org)/dashboard/folder/[id]/components/FolderVideosSection.tsx b/apps/web/app/(org)/dashboard/folder/[id]/components/FolderVideosSection.tsxindex f6ab57a62..1e93b50d0 100644--- a/apps/web/app/(org)/dashboard/folder/[id]/components/FolderVideosSection.tsx+++ b/apps/web/app/(org)/dashboard/folder/[id]/components/FolderVideosSection.tsx@@ -1,12 +1,13 @@"use client";-import type { Video } from "@cap/web-domain";+import type { Folder, Video } from "@cap/web-domain";import { Effect, Exit } from "effect";import { useRouter } from "next/navigation";import { useMemo, useRef, useState } from "react";import { toast } from "sonner";import { useDashboardContext } from "@/app/(org)/dashboard/Contexts";import { useEffectMutation, useRpcClient } from "@/lib/EffectRuntime";+import type { MoveLocation } from "@/lib/move-items";import { useVideosAnalyticsQuery } from "@/lib/Queries/Analytics";import type { VideoData } from "../../../caps/Caps";import { CapCard } from "../../../caps/components/CapCard/CapCard";@@ -17,11 +18,21 @@ import { useUploadingStatus } from "../../../caps/UploadingContext";interface FolderVideosSectionProps {initialVideos: VideoData;analyticsEnabled: boolean;+ location: MoveLocation;+ rootLabel: string;+ currentFolderId: Folder.FolderId;+ canMove: boolean;+ allowBulkDelete?: boolean;}export default function FolderVideosSection({initialVideos,analyticsEnabled,+ location,+ rootLabel,+ currentFolderId,+ canMove,+ allowBulkDelete = false,}: FolderVideosSectionProps) {const router = useRouter();const { user } = useDashboardContext();@@ -151,7 +162,15 @@ export default function FolderVideosSection({isSelected={selectedCaps.includes(video.id)}anyCapSelected={selectedCaps.length > 0}isDeleting={isDeletingCaps || isDeletingCap}- onSelectToggle={() => handleCapSelection(video.id)}+ onSelectToggle={+ canMove || allowBulkDelete+ ? () => handleCapSelection(video.id)+ : undefined+ }+ canMove={canMove}+ moveLocation={location}+ moveRootLabel={rootLabel}+ currentFolderId={currentFolderId}onDelete={() => {if (selectedCaps.length > 0) {deleteCaps(selectedCaps);@@ -167,8 +186,13 @@ export default function FolderVideosSection({<SelectedCapsBarselectedCaps={selectedCaps}setSelectedCaps={setSelectedCaps}- deleteSelectedCaps={() => deleteCaps(selectedCaps)}+ deleteSelectedCaps={+ allowBulkDelete ? () => deleteCaps(selectedCaps) : undefined+ }isDeleting={isDeletingCaps || isDeletingCap}+ moveLocation={canMove ? location : undefined}+ moveRootLabel={canMove ? rootLabel : undefined}+ currentFolderId={currentFolderId}/></>);diff --git a/apps/web/app/(org)/dashboard/folder/[id]/page.tsx b/apps/web/app/(org)/dashboard/folder/[id]/page.tsxindex 249507304..b8292fc6a 100644--- a/apps/web/app/(org)/dashboard/folder/[id]/page.tsx+++ b/apps/web/app/(org)/dashboard/folder/[id]/page.tsx@@ -110,6 +110,8 @@ const FolderPage = async (props: PageProps<"/dashboard/folder/[id]">) => {id={folder.id}parentId={folder.parentId}videoCount={folder.videoCount}+ canMove={share.canManage}+ moveRootLabel="My Caps"/>))}</div>@@ -119,6 +121,11 @@ const FolderPage = async (props: PageProps<"/dashboard/folder/[id]">) => {{/* Display Videos */}<FolderVideosSectioninitialVideos={videosData}+ location={{ type: "personal" }}+ rootLabel="My Caps"+ currentFolderId={folderId}+ canMove={share.canManage}+ allowBulkDeleteanalyticsEnabled={Boolean(serverEnv().TINYBIRD_TOKEN && serverEnv().TINYBIRD_HOST,)}