Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(web): prefill the Loom importer from url and mode params

Richie McIlroy326ae8deb448
diff --git a/apps/web/app/(org)/dashboard/import/loom/ImportLoomPage.tsx b/apps/web/app/(org)/dashboard/import/loom/ImportLoomPage.tsx
index bab2aaba6..ebca80798 100644
--- a/apps/web/app/(org)/dashboard/import/loom/ImportLoomPage.tsx
+++ b/apps/web/app/(org)/dashboard/import/loom/ImportLoomPage.tsx
@@ -36,7 +36,7 @@ import { useQuery } from "@tanstack/react-query";
import clsx from "clsx";
import { motion } from "framer-motion";
import Link from "next/link";
-import { useRouter } from "next/navigation";
+import { useRouter, useSearchParams } from "next/navigation";
import {
type ChangeEvent,
type DragEvent,
@@ -256,6 +256,10 @@ export const ImportLoomPage = ({
}) => {
const { user, activeOrganization, spacesData } = useDashboardContext();
const router = useRouter();
+ const searchParams = useSearchParams();
+ const prefilledLoomUrl = searchParams?.get("url")?.trim() ?? "";
+ const prefilledMode: Mode =
+ searchParams?.get("mode") === "csv" ? "csv" : "single";
const currentMember = activeOrganization?.members.find(
(member) => member.userId === user?.id,
@@ -267,7 +271,7 @@ export const ImportLoomPage = ({
});
const canUseCsvImport = canManageOrganizationSettings(currentRole);
- const [mode, setMode] = useState<Mode>("single");
+ const [mode, setMode] = useState<Mode>(prefilledMode);
const activeMode = canUseCsvImport ? mode : "single";
const [upgradeModalOpen, setUpgradeModalOpen] = useState(!user?.isPro);
@@ -310,7 +314,7 @@ export const ImportLoomPage = ({
: rootLabel;
const importPageHref = loomImportPageHref(destination);
- const [loomUrl, setLoomUrl] = useState("");
+ const [loomUrl, setLoomUrl] = useState(prefilledLoomUrl);
const [isImporting, setIsImporting] = useState(false);
const inputRef = useRef<HTMLInputElement>(null);