Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion apps/web/src/components/editor/panels/timeline/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ import {
ContextMenuItem,
ContextMenuTrigger,
} from "@/components/ui/context-menu";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { useTimelineZoom } from "@/hooks/timeline/use-timeline-zoom";
import {
useCallback,
Expand Down Expand Up @@ -675,6 +685,7 @@ function TimelineTrackRows({
const timeline = useEditor((e) => e.timeline);
const tracks = useEditor((e) => e.timeline.getTracks());
const { selectedElements } = useElementSelection();
const [trackToDelete, setTrackToDelete] = useState<TimelineTrack | null>(null);
const tracksWithSelection = useMemo(
() => new Set(selectedElements.map((el) => el.trackId)),
[selectedElements],
Expand Down Expand Up @@ -773,7 +784,7 @@ function TimelineTrackRows({
icon={<HugeiconsIcon icon={Delete02Icon} />}
onClick={(event: React.MouseEvent) => {
event.stopPropagation();
timeline.removeTrack({ trackId: track.id });
setTrackToDelete(track);
}}
variant="destructive"
>
Expand All @@ -783,6 +794,30 @@ function TimelineTrackRows({
</ContextMenuContent>
</ContextMenu>
))}
{trackToDelete && (
<AlertDialog open onOpenChange={(open) => !open && setTrackToDelete(null)}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete track?</AlertDialogTitle>
<AlertDialogDescription>
This will remove {trackToDelete.elements.length} element{trackToDelete.elements.length === 1 ? "" : "s"}.
This action cannot be undone.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
onClick={() => {
timeline.removeTrack({ trackId: trackToDelete.id });
setTrackToDelete(null);
}}
>
Delete
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
)}
</>
);
}
Expand Down