Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(web): add back to dashboard link and responsive action bar on share page

Richie McIlroy8e3a9ebd573f
diff --git a/apps/web/app/s/[videoId]/Share.tsx b/apps/web/app/s/[videoId]/Share.tsx
index 23b690293..202ab1d96 100644
--- a/apps/web/app/s/[videoId]/Share.tsx
+++ b/apps/web/app/s/[videoId]/Share.tsx
@@ -26,7 +26,9 @@ import {
} from "@/actions/videos/get-status";
import type { OrganizationSettings } from "@/app/(org)/dashboard/dashboard-data";
import { SignedImageUrl } from "@/components/SignedImageUrl";
+import type { ShareDashboardDestination } from "@/lib/share-dashboard-destination";
import { CaptionProvider } from "./_components/CaptionContext";
+import { DashboardBackLink } from "./_components/DashboardBackLink";
import { PlaybackProvider } from "./_components/playback/PlaybackContext";
import { ShareVideo } from "./_components/ShareVideo";
import { type ShareView, ShareViewToggle } from "./_components/ShareViewToggle";
@@ -216,6 +218,8 @@ interface ShareProps {
* view is active.
*/
header?: React.ReactNode;
+ /** Timeline view's slim bar replaces the header, so it carries its own way back. */
+ dashboardDestination?: ShareDashboardDestination | null;
}
const useVideoStatus = (
@@ -339,6 +343,7 @@ export const Share = ({
canRecordMedia = false,
viewerSignedIn = false,
header,
+ dashboardDestination = null,
}: ShareProps) => {
const isScreenshot = data.isScreenshot === true;
// Memoized: a fresh Date each render would defeat the memoized `data`
@@ -809,6 +814,12 @@ export const Share = ({
// the player instead.
<div className="mx-auto flex h-14 w-full max-w-6xl items-center justify-between gap-3 rounded-t-xl border border-b-0 border-gray-5 bg-white px-5">
<div className="flex min-w-0 items-center gap-3">
+ {dashboardDestination && (
+ <DashboardBackLink
+ destination={dashboardDestination}
+ compact
+ />
+ )}
<SignedImageUrl
image={data.owner.image}
name={data.owner.name ?? "Someone"}
diff --git a/apps/web/app/s/[videoId]/_components/DashboardBackLink.tsx b/apps/web/app/s/[videoId]/_components/DashboardBackLink.tsx
new file mode 100644
index 000000000..37a3c104b
--- /dev/null
+++ b/apps/web/app/s/[videoId]/_components/DashboardBackLink.tsx
@@ -0,0 +1,58 @@
+import clsx from "clsx";
+import { ChevronLeft, Folder, LayoutGrid, Users } from "lucide-react";
+import Link from "next/link";
+import type { ShareDashboardDestination } from "@/lib/share-dashboard-destination";
+
+const DESTINATION_ICONS = {
+ caps: LayoutGrid,
+ folder: Folder,
+ space: Users,
+ organization: Users,
+} satisfies Record<ShareDashboardDestination["kind"], unknown>;
+
+export function DashboardBackLink({
+ destination,
+ compact = false,
+ className,
+}: {
+ destination: ShareDashboardDestination;
+ compact?: boolean;
+ className?: string;
+}) {
+ const Icon = DESTINATION_ICONS[destination.kind];
+ const accessibleLabel = `Back to ${destination.label}`;
+
+ if (compact) {
+ return (
+ <Link
+ href={destination.href}
+ aria-label={accessibleLabel}
+ title={accessibleLabel}
+ className={clsx(
+ "flex size-8 shrink-0 items-center justify-center rounded-full border border-gray-5 bg-gray-2 text-gray-11 transition-colors hover:bg-gray-4 hover:text-gray-12 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-9",
+ className,
+ )}
+ >
+ <ChevronLeft className="size-4" aria-hidden />
+ </Link>
+ );
+ }
+
+ return (
+ <Link
+ href={destination.href}
+ aria-label={accessibleLabel}
+ className={clsx(
+ "group inline-flex h-8 min-w-0 max-w-full items-center gap-1.5 rounded-full py-1 pl-1.5 pr-3 text-[13px] text-gray-11 transition-colors hover:bg-gray-3 hover:text-gray-12 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-9",
+ className,
+ )}
+ >
+ <ChevronLeft
+ className="size-4 shrink-0 transition-transform duration-200 group-hover:-translate-x-0.5"
+ aria-hidden
+ />
+ <Icon className="size-3.5 shrink-0 text-gray-10" aria-hidden />
+ <span className="truncate">{destination.label}</span>
+ </Link>
+ );
+}
diff --git a/apps/web/app/s/[videoId]/_components/ShareHeader.tsx b/apps/web/app/s/[videoId]/_components/ShareHeader.tsx
index bdaee84ae..a9ac06189 100644
--- a/apps/web/app/s/[videoId]/_components/ShareHeader.tsx
+++ b/apps/web/app/s/[videoId]/_components/ShareHeader.tsx
@@ -30,7 +30,6 @@ import {
Copy,
Download,
Globe2,
- LayoutDashboard,
Lock,
MousePointer2,
Pencil,
@@ -54,6 +53,7 @@ import type { Spaces } from "@/app/(org)/dashboard/dashboard-data";
import { useCurrentUser } from "@/app/Layout/AuthContext";
import { SignedImageUrl } from "@/components/SignedImageUrl";
import { Tooltip } from "@/components/Tooltip";
+import type { ShareDashboardDestination } from "@/lib/share-dashboard-destination";
import {
copyRichVideoLink,
videoPreviewImageUrl,
@@ -61,6 +61,7 @@ import {
import { usePublicEnv } from "@/utils/public-env";
import { navigateWithTransition } from "@/utils/view-transition";
import type { SharePageBranding, VideoData } from "../types";
+import { DashboardBackLink } from "./DashboardBackLink";
import { describeShareAudience } from "./share-audience";
import { useVideoDownload } from "./use-video-download";
import { fromNow } from "./utils/from-now";
@@ -139,6 +140,14 @@ const TITLE_TEXT_CLASS =
const TITLE_PLACEHOLDER = "Cap title";
+/**
+ * One shape for every button in the action bar. Phones get a 40px target and
+ * share the row in equal columns; from `sm` up the buttons size to their
+ * labels at the compact header height.
+ */
+const ACTION_BAR_BUTTON_CLASS =
+ "h-10 min-w-0 gap-1.5 rounded-full px-3 text-[13px] sm:h-8 sm:px-2.5 sm:text-xs";
+
export const ShareHeader = ({
data,
customDomain,
@@ -153,6 +162,7 @@ export const ShareHeader = ({
canDownload = false,
hasEdits = false,
views,
+ dashboardDestination = null,
}: {
data: VideoData;
customDomain?: string | null;
@@ -188,6 +198,12 @@ export const ShareHeader = ({
* Resolves late and never blocks the header (see `ViewCount`).
*/
views?: MaybePromise<number | null>;
+ /**
+ * Where "back" goes for a viewer this Cap belongs to or was shared with:
+ * the owner's folder or library, or the space it reached them through.
+ * Null for everyone else, who has nothing on the dashboard to return to.
+ */
+ dashboardDestination?: ShareDashboardDestination | null;
}) => {
const user = useCurrentUser();
const { push, refresh } = useRouter();
@@ -249,7 +265,6 @@ export const ShareHeader = ({
const [isHidingBranding, setIsHidingBranding] = useState(false);
const [isOpeningBrandingSettings, setIsOpeningBrandingSettings] =
useState(false);
- const copyOptionsRef = useRef<HTMLDivElement>(null);
const titleInputRef = useRef<HTMLInputElement>(null);
const titleButtonRef = useRef<HTMLButtonElement>(null);
/**
@@ -269,13 +284,16 @@ export const ShareHeader = ({
useEffect(() => {
if (!showCopyOptions) return;
+ // The control renders twice (full link on desktop, compact button below
+ // it) with only one visible, so "outside" means outside either copy.
const handler = (e: MouseEvent) => {
if (
- copyOptionsRef.current &&
- !copyOptionsRef.current.contains(e.target as Node)
+ e.target instanceof Element &&
+ e.target.closest("[data-copy-link-control]")
) {
- setShowCopyOptions(false);
+ return;
}
+ setShowCopyOptions(false);
};
document.addEventListener("mousedown", handler);
return () => document.removeEventListener("mousedown", handler);
@@ -519,13 +537,10 @@ export const ShareHeader = ({
const renderSharedStatus = () => {
if (!isOwner) {
return (
- <Button
- className="px-3 pointer-events-none w-fit"
- size="xs"
- variant="outline"
- >
+ <span className="inline-flex h-8 shrink-0 items-center gap-1.5 rounded-full border border-gray-4 px-3 text-xs font-medium text-gray-11">
+ <Users className="size-3.5 text-gray-10" aria-hidden />
Shared with you
- </Button>
+ </span>
);
}
@@ -539,16 +554,16 @@ export const ShareHeader = ({
return (
<Tooltip content={audience.tooltip} position="bottom">
<Button
- className="gap-1.5 px-3 w-fit"
+ className="min-w-0 max-w-full gap-1.5 px-3"
size="xs"
variant="outline"
aria-label={`Sharing: ${audience.label}. Click to manage access.`}
onClick={() => setIsSharingDialogOpen(true)}
>
- <AudienceIcon className="size-3.5 text-gray-11" />
- {audience.label}
+ <AudienceIcon className="size-3.5 shrink-0 text-gray-11" />
+ <span className="truncate">{audience.label}</span>
<FontAwesomeIcon
- className="size-2.5 text-gray-10"
+ className="size-2.5 shrink-0 text-gray-10"
icon={faChevronDown}
/>
</Button>
@@ -562,9 +577,9 @@ export const ShareHeader = ({
* Signed-out viewers get it too on a public Cap — passing a link on is the
* one thing they can usefully do here.
*/
- const renderShareButton = () => (
+ const renderShareButton = (className?: string) => (
<Button
- className="gap-1.5 px-3 w-fit"
+ className={clsx("gap-1.5 px-3", className)}
size="xs"
variant="blue"
aria-label="Share this Cap"
@@ -581,6 +596,75 @@ export const ShareHeader = ({
</Button>
);
+ /**
+ * Desktop shows the link itself, since the custom domain in it is worth seeing.
+ * Below `lg` there's no row wide enough for a URL, so the same control
+ * becomes a "Copy link" button in the action bar.
+ */
+ const renderCopyLinkControl = (variant: "link" | "button") => (
+ <div
+ className={clsx("relative", variant === "button" && "min-w-0")}
+ data-copy-link-control
+ >
+ {variant === "link" ? (
+ <Button
+ variant="white"
+ className="max-w-full px-3"
+ onClick={handleCopyClick}
+ >
+ <span className="max-w-96 truncate">{getDisplayLink()}</span>
+ {linkCopied ? (
+ <Check className="ml-2 w-4 h-4 svgpathanimation" />
+ ) : (
+ <Copy className="ml-2 w-4 h-4" />
+ )}
+ </Button>
+ ) : (
+ <Button
+ variant="gray"
+ size="xs"
+ className={clsx(ACTION_BAR_BUTTON_CLASS, "w-full")}
+ aria-label="Copy link"
+ onClick={handleCopyClick}
+ >
+ {linkCopied ? (
+ <Check className="size-3.5 shrink-0 svgpathanimation" />
+ ) : (
+ <Copy className="size-3.5 shrink-0" />
+ )}
+ <span className="truncate">
+ {linkCopied ? "Copied" : "Copy link"}
+ </span>
+ </Button>
+ )}
+ {showCopyOptions && (
+ <div
+ className={clsx(
+ "absolute top-full z-50 mt-1 min-w-full w-max overflow-hidden rounded-lg border border-gray-6 bg-white shadow-lg",
+ variant === "link" ? "right-0" : "left-1/2 -translate-x-1/2",
+ )}
+ >
+ <button
+ type="button"
+ className="flex w-full items-center gap-2 px-3 py-2 text-sm text-gray-12 transition-colors hover:bg-gray-3"
+ onClick={() => handleCopyLink(false)}
+ >
+ <Copy className="w-3.5 h-3.5 shrink-0" />
+ Copy link
+ </button>
+ <button
+ type="button"
+ className="flex w-full items-center gap-2 px-3 py-2 text-sm text-gray-12 transition-colors hover:bg-gray-3"
+ onClick={() => handleCopyLink(true)}
+ >
+ <Clock className="w-3.5 h-3.5 shrink-0" />
+ Copy link at {formatTimestamp(capturedTime)}
+ </button>
+ </div>
+ )}
+ </div>
+ );
+
const userIsOwnerAndNotPro = user?.id === data.owner.id && !data.owner.isPro;
const canEditVideo =
isOwner &&
@@ -841,7 +925,13 @@ export const ShareHeader = ({
)}
{/* Sits in the page bar above both panes, so the spacing is the bar's
own padding rather than a top margin against the video. */}
- <div className="py-4">
+ <div className={clsx("pb-4", dashboardDestination ? "pt-2" : "pt-4")}>
+ {dashboardDestination && (
+ <DashboardBackLink
+ destination={dashboardDestination}
+ className="-ml-1.5 mb-1.5"
+ />
+ )}
<div className="flex flex-col gap-4">
<div className="flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between">
{/* The title takes the row's slack rather than splitting it with
@@ -941,7 +1031,8 @@ export const ShareHeader = ({
{user !== null && (
// Holds its own width so the title, not this, absorbs what the
// row has left over. Its own link label already truncates.
- <div className="lg:shrink-0">
+ // Desktop only: narrower screens copy from the action bar.
+ <div className="hidden lg:block lg:shrink-0">
<div className="flex gap-2 items-center">
{(data.hasPassword || data.hasInheritedPassword) && (
<FontAwesomeIcon
@@ -949,42 +1040,7 @@ export const ShareHeader = ({
icon={faLock}
/>
)}
- <div className="relative" ref={copyOptionsRef}>
- <Button
- variant="white"
- className="max-w-full px-3"
- onClick={handleCopyClick}
- >
- <span className="max-w-[70vw] truncate sm:max-w-96">
- {getDisplayLink()}
- </span>
- {linkCopied ? (
- <Check className="ml-2 w-4 h-4 svgpathanimation" />
- ) : (
- <Copy className="ml-2 w-4 h-4" />
- )}
- </Button>
- {showCopyOptions && (
- <div className="absolute right-0 top-full z-50 mt-1 min-w-full w-max overflow-hidden rounded-lg border border-gray-6 bg-white shadow-lg">
- <button
- type="button"
- className="flex w-full items-center gap-2 px-3 py-2 text-sm text-gray-12 transition-colors hover:bg-gray-3"
- onClick={() => handleCopyLink(false)}
- >
- <Copy className="w-3.5 h-3.5 shrink-0" />
- Copy link
- </button>
- <button
- type="button"
- className="flex w-full items-center gap-2 px-3 py-2 text-sm text-gray-12 transition-colors hover:bg-gray-3"
- onClick={() => handleCopyLink(true)}
- >
- <Clock className="w-3.5 h-3.5 shrink-0" />
- Copy link at {formatTimestamp(capturedTime)}
- </button>
- </div>
- )}
- </div>
+ {renderCopyLinkControl("link")}
</div>
{userIsOwnerAndNotPro && (
<button
@@ -1000,23 +1056,29 @@ export const ShareHeader = ({
)}
{renderSignedOutNav()}
</div>
- {/* One row at every width. On phones the owner's side of it is a
- single "Manage Cap" button, so it sits alongside the byline
- instead of claiming a row of its own. */}
- <div className="flex flex-wrap gap-3 items-center justify-between">
- <div className="flex flex-wrap gap-x-7 gap-y-2 items-center">
- <div className="flex gap-2 items-center">
+ {/*
+ * Below `lg`, the byline shares its row with the audience pill
+ * and every action moves to a bar of its own underneath: on a
+ * phone that bar is equal columns with full-size tap targets, on
+ * a tablet it's the desktop buttons with room to breathe. `lg`
+ * folds both back into the one row.
+ */}
+ <div className="flex flex-col gap-3 lg:flex-row lg:items-center">
+ <div className="flex min-w-0 items-center justify-between gap-3 lg:justify-start lg:gap-5">
+ <div className="flex min-w-0 items-center gap-2">
{data.name && (
<SignedImageUrl
name={data.name}
image={data.owner.image}
- className="size-8"
+ className="size-8 shrink-0"
letterClass="text-base"
/>
)}
- <div className="flex flex-col text-left">
- <p className="text-sm text-gray-12">{data.owner.name}</p>
- <p className="text-xs text-gray-10">
+ <div className="flex min-w-0 flex-col text-left">
+ <p className="truncate text-sm text-gray-12">
+ {data.owner.name}
+ </p>
+ <p className="truncate text-xs text-gray-10">
{fromNow(data.createdAt)}
{views !== undefined && (
<Suspense fallback={null}>
@@ -1026,253 +1088,252 @@ export const ShareHeader = ({
</p>
</div>
</div>
- {/*
- * Share survives every width — it's the point of the page.
- * The audience pill doesn't: on phones its readout moves into
- * the "Sharing & access" row of "Manage Cap", and the viewer's
- * version of it was inert anyway.
- */}
- <div className="flex flex-wrap gap-2 items-center">
- {user && (
- <div className="hidden sm:flex">{renderSharedStatus()}</div>
- )}
- {(user || data.public) && renderShareButton()}
- </div>
+ {user !== null ? (
+ <div className="flex min-w-0 max-w-[60%] justify-end lg:max-w-xs">
+ {renderSharedStatus()}
+ </div>
+ ) : (
+ data.public && renderShareButton("shrink-0")
+ )}
</div>
{user !== null && (
- // `ml-auto` rather than relying on the parent's justify-between:
- // when this wraps onto its own line on a phone, a lone flex item
- // would otherwise sit left, orphaned under the byline.
- <div className="flex flex-wrap items-center gap-2 ml-auto justify-end">
- {isOwner && (
- <>
- {canEditVideo && (
+ <div className="grid auto-cols-fr grid-flow-col gap-2 sm:flex sm:items-center lg:flex-1">
+ {renderShareButton(ACTION_BAR_BUTTON_CLASS)}
+ <div className="min-w-0 lg:hidden">
+ {renderCopyLinkControl("button")}
+ </div>
+ {/* `contents` on phones so these join the equal columns
+ above; from `sm` they group on the right. */}
+ <div className="contents sm:ml-auto sm:flex sm:items-center sm:gap-2">
+ {isOwner && (
+ <>
+ {canEditVideo && (
+ <Button
+ variant="gray"
+ size="xs"
+ className={clsx(
+ ACTION_BAR_BUTTON_CLASS,
+ "hidden sm:flex",
+ )}
+ onClick={handleEditVideo}
+ >
+ <Scissors className="size-3.5 text-gray-12" />
+ Edit video
+ </Button>
+ )}
<Button
variant="gray"
size="xs"
- className="hidden h-8 gap-1.5 rounded-full px-2.5 text-xs sm:flex"
- onClick={handleEditVideo}
+ className={clsx(
+ ACTION_BAR_BUTTON_CLASS,
+ "hidden sm:flex",
+ )}
+ onClick={() => {
+ push(`/dashboard/analytics?capId=${data.id}`);
+ }}
>
- <Scissors className="size-3.5 text-gray-12" />
- Edit video
+ <FontAwesomeIcon
+ className="size-3.5 text-gray-12"
+ icon={faChartSimple}
+ />
+ View analytics
</Button>
- )}
- <Button
- variant="gray"
- size="xs"
- className="hidden h-8 gap-1.5 rounded-full px-2.5 text-xs sm:flex"
- onClick={() => {
- push(`/dashboard/analytics?capId=${data.id}`);
- }}
- >
- <FontAwesomeIcon
- className="size-3.5 text-gray-12"
- icon={faChartSimple}
- />
- View analytics
- </Button>
- <DropdownMenu modal={false}>
- <DropdownMenuTrigger asChild>
- <Button
- variant="dark"
- size="xs"
- className="h-8 gap-1.5 rounded-full px-3 text-xs"
+ <DropdownMenu modal={false}>
+ <DropdownMenuTrigger asChild>
+ <Button
+ variant="dark"
+ size="xs"
+ aria-label="Manage Cap"
+ className={clsx(ACTION_BAR_BUTTON_CLASS, "sm:px-3")}
+ >
+ <FontAwesomeIcon
+ className="size-3.5 shrink-0"
+ icon={faEllipsis}
+ />
+ <span className="truncate sm:hidden">Manage</span>
+ <span className="hidden sm:inline">Manage Cap</span>
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent
+ align="end"
+ sideOffset={6}
+ className="min-w-56"
>
- <FontAwesomeIcon
- className="size-3.5"
- icon={faEllipsis}
- />
- Manage Cap
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end" sideOffset={5}>
- {/* The header buttons phones don't show. Hidden from
- `sm` up so nothing is offered twice. Share isn't
- among them: it keeps its own button at every width. */}
- {canEditVideo && (
+ {/* The header buttons phones don't show. Hidden from
+ `sm` up so nothing is offered twice. Share and copy
+ link keep their own buttons at every width. */}
+ {canEditVideo && (
+ <DropdownMenuItem
+ onClick={handleEditVideo}
+ className="flex items-center gap-2 rounded-lg sm:hidden"
+ >
+ <Scissors className="size-3.5" />
+ <p className="text-sm text-gray-12">Edit video</p>
+ </DropdownMenuItem>
+ )}
<DropdownMenuItem
- onClick={handleEditVideo}
+ onClick={() => {
+ push(`/dashboard/analytics?capId=${data.id}`);
+ }}
className="flex items-center gap-2 rounded-lg sm:hidden"
>
- <Scissors className="size-3.5" />
- <p className="text-sm text-gray-12">Edit video</p>
+ <FontAwesomeIcon
+ className="size-3"
+ icon={faChartSimple}
+ />
+ <p className="text-sm text-gray-12">
+ View analytics
+ </p>
</DropdownMenuItem>
- )}
- <DropdownMenuItem
- onClick={() => {
- push(`/dashboard/analytics?capId=${data.id}`);
- }}
- className="flex items-center gap-2 rounded-lg sm:hidden"
- >
- <FontAwesomeIcon
- className="size-3"
- icon={faChartSimple}
- />
- <p className="text-sm text-gray-12">View analytics</p>
- </DropdownMenuItem>
- <DropdownMenuSeparator className="sm:hidden" />
- <DropdownMenuItem
- onClick={() => setIsSharingDialogOpen(true)}
- className="flex items-center gap-2 rounded-lg"
- >
- <FontAwesomeIcon className="size-3" icon={faShare} />
- <p className="text-sm text-gray-12">
- Sharing & access
- </p>
- {/* The audience pill is desktop-only, so its readout
- has to live here on phones. */}
- <span className="ml-auto max-w-[9rem] truncate pl-3 text-xs text-gray-10 sm:hidden">
- {audience.label}
- </span>
- </DropdownMenuItem>
- <DropdownMenuItem
- onClick={() => setIsSettingsDialogOpen(true)}
- className="flex items-center gap-2 rounded-lg"
- >
- <FontAwesomeIcon className="size-3" icon={faGear} />
- <p className="text-sm text-gray-12">Video settings</p>
- </DropdownMenuItem>
- <DropdownMenuItem
- onClick={() => {
- if (!data.owner.isPro) setUpgradeModalOpen(true);
- else setIsCtaDialogOpen(true);
- }}
- className="flex items-center gap-2 rounded-lg"
- >
- <MousePointer2 className="size-3.5" />
- <p className="text-sm text-gray-12">
- {data.callToAction
- ? "Edit call to action"
- : "Add call to action"}
- </p>
- {!data.owner.isPro ? (
- <span className="ml-auto pl-3 text-xs text-gray-10">
- Pro
- </span>
- ) : data.callToAction ? (
- <span className="ml-auto pl-3 text-xs text-gray-10">
- On
- </span>
- ) : null}
- </DropdownMenuItem>
- <DropdownMenuItem
- onClick={() => {
- if (!user.isPro) setUpgradeModalOpen(true);
- else setIsPasswordDialogOpen(true);
- }}
- className="flex items-center gap-2 rounded-lg"
- >
- <FontAwesomeIcon
- className="size-3"
- icon={
- effectivePasswordProtected ? faLock : faUnlock
- }
+ <DropdownMenuSeparator className="sm:hidden" />
+ <DropdownMenuItem
+ onClick={() => setIsSharingDialogOpen(true)}
+ className="flex items-center gap-2 rounded-lg"
+ >
+ <FontAwesomeIcon
+ className="size-3"
+ icon={faShare}
+ />
+ <p className="text-sm text-gray-12">
+ Sharing & access
+ </p>
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={() => setIsSettingsDialogOpen(true)}
+ className="flex items-center gap-2 rounded-lg"
+ >
+ <FontAwesomeIcon className="size-3" icon={faGear} />
+ <p className="text-sm text-gray-12">
+ Video settings
+ </p>
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={() => {
+ if (!data.owner.isPro) setUpgradeModalOpen(true);
+ else setIsCtaDialogOpen(true);
+ }}
+ className="flex items-center gap-2 rounded-lg"
+ >
+ <MousePointer2 className="size-3.5" />
+ <p className="text-sm text-gray-12">
+ {data.callToAction
+ ? "Edit call to action"
+ : "Add call to action"}
+ </p>
+ {!data.owner.isPro ? (
+ <span className="ml-auto pl-3 text-xs text-gray-10">
+ Pro
+ </span>
+ ) : data.callToAction ? (
+ <span className="ml-auto pl-3 text-xs text-gray-10">
+ On
+ </span>
+ ) : null}
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={() => {
+ if (!user.isPro) setUpgradeModalOpen(true);
+ else setIsPasswordDialogOpen(true);
+ }}
+ className="flex items-center gap-2 rounded-lg"
+ >
+ <FontAwesomeIcon
+ className="size-3"
+ icon={
+ effectivePasswordProtected ? faLock : faUnlock
+ }
+ />
+ <p className="text-sm text-gray-12">
+ {passwordProtected
+ ? "Edit password"
+ : "Add password"}
+ </p>
+ </DropdownMenuItem>
+ <DuplicateCapMenuItem
+ videoId={data.id}
+ disabled={data.hasActiveUpload}
/>
- <p className="text-sm text-gray-12">
- {passwordProtected
- ? "Edit password"
- : "Add password"}
- </p>
- </DropdownMenuItem>
- <DuplicateCapMenuItem
- videoId={data.id}
- disabled={data.hasActiveUpload}
- />
- {/* Downloads used to live behind a second dots button next to
+ {/* Downloads used to live behind a second dots button next to
the link. There is one "everything else about this Cap"
menu, and this is it. */}
- {canDownload && (
- <>
- <DropdownMenuSeparator />
- <DropdownMenuItem
- onClick={() => download("current")}
- disabled={isDownloading}
- className="flex items-center gap-2 rounded-lg"
- >
- <Download className="size-3.5" />
- <p className="text-sm text-gray-12">
- {hasEdits
- ? "Download current video"
- : "Download video"}
- </p>
- </DropdownMenuItem>
- {hasEdits && (
+ {canDownload && (
+ <>
+ <DropdownMenuSeparator />
<DropdownMenuItem
- onClick={() => download("original")}
+ onClick={() => download("current")}
disabled={isDownloading}
className="flex items-center gap-2 rounded-lg"
>
<Download className="size-3.5" />
<p className="text-sm text-gray-12">
- Download original video
+ {hasEdits
+ ? "Download current video"
+ : "Download video"}
</p>
</DropdownMenuItem>
- )}
- </>
- )}
- <DropdownMenuSeparator />
- <DropdownMenuItem
- onClick={() => push("/dashboard/caps?page=1")}
- className="flex items-center gap-2 rounded-lg"
- >
- <LayoutDashboard className="size-3.5" />
- <p className="text-sm text-gray-12">
- Go to dashboard
- </p>
- </DropdownMenuItem>
- <DropdownMenuItem
- onClick={() => setIsDeleteDialogOpen(true)}
- className="flex items-center gap-2 rounded-lg text-red-500 focus:text-red-600"
- >
- <FontAwesomeIcon className="size-3" icon={faTrash} />
- <p className="text-sm text-inherit">Delete Cap</p>
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </>
- )}
- {!isOwner && (
- <>
- {/* Space and org members can download someone else's Cap,
- and they never see "Manage Cap" — so the action has to
- stand on its own for them. */}
- {canDownload &&
- (hasEdits ? (
- <VideoDownloadMenu
- videoId={data.id}
- hasEdits
- triggerLabel="Download"
- triggerClassName="h-8 gap-1.5 rounded-full border border-gray-5 bg-gray-3 px-2.5 text-xs text-gray-12 transition hover:bg-gray-6"
- trigger={
- <>
- <Download className="size-3.5" aria-hidden />
- Download
+ {hasEdits && (
+ <DropdownMenuItem
+ onClick={() => download("original")}
+ disabled={isDownloading}
+ className="flex items-center gap-2 rounded-lg"
+ >
+ <Download className="size-3.5" />
+ <p className="text-sm text-gray-12">
+ Download original video
+ </p>
+ </DropdownMenuItem>
+ )}
</>
- }
- />
- ) : (
- <Button
- variant="gray"
- size="xs"
- className="h-8 gap-1.5 rounded-full px-2.5 text-xs"
- disabled={isDownloading}
- onClick={() => download("current")}
- >
- <Download className="size-3.5 text-gray-12" />
- Download
- </Button>
- ))}
- <Button
- size="xs"
- className="h-8 rounded-full px-2.5 text-xs"
- onClick={() => {
- push("/dashboard/caps?page=1");
- }}
- >
- Go to dashboard
- </Button>
- </>
- )}
+ )}
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ onClick={() => setIsDeleteDialogOpen(true)}
+ className="flex items-center gap-2 rounded-lg text-red-500 focus:text-red-600"
+ >
+ <FontAwesomeIcon
+ className="size-3"
+ icon={faTrash}
+ />
+ <p className="text-sm text-inherit">Delete Cap</p>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </>
+ )}
+ {/* Space and org members can download someone else's
+ Cap, and they never see "Manage Cap", so the action
+ has to stand on its own for them. */}
+ {!isOwner &&
+ canDownload &&
+ (hasEdits ? (
+ <VideoDownloadMenu
+ videoId={data.id}
+ hasEdits
+ triggerLabel="Download"
+ triggerClassName={clsx(
+ ACTION_BAR_BUTTON_CLASS,
+ "flex items-center justify-center border border-gray-5 bg-gray-3 text-gray-12 transition hover:bg-gray-6",
+ )}
+ trigger={
+ <>
+ <Download className="size-3.5" aria-hidden />
+ Download
+ </>
+ }
+ />
+ ) : (
+ <Button
+ variant="gray"
+ size="xs"
+ className={ACTION_BAR_BUTTON_CLASS}
+ disabled={isDownloading}
+ onClick={() => download("current")}
+ >
+ <Download className="size-3.5 text-gray-12" />
+ Download
+ </Button>
+ ))}
+ </div>
</div>
)}
</div>
diff --git a/apps/web/app/s/[videoId]/page.tsx b/apps/web/app/s/[videoId]/page.tsx
index af173516c..d015d6d07 100644
--- a/apps/web/app/s/[videoId]/page.tsx
+++ b/apps/web/app/s/[videoId]/page.tsx
@@ -58,6 +58,7 @@ import * as EffectRuntime from "@/lib/server";
import { runPromise } from "@/lib/server";
import { getSharePageBranding } from "@/lib/share-branding";
import { parseShareCallToAction } from "@/lib/share-call-to-action";
+import { getShareDashboardDestination } from "@/lib/share-dashboard-destination";
import { getSharePlaybackUrl } from "@/lib/share-playback";
import { buildShareVideoMetadata } from "@/lib/share-video-metadata";
import { resolveShareWebUrl } from "@/lib/share-web-url";
@@ -774,6 +775,20 @@ async function AuthorizedContent({
})
: Promise.resolve(false);
+ const dashboardDestinationPromise = getShareDashboardDestination({
+ viewer: user
+ ? { id: user.id, activeOrganizationId: user.activeOrganizationId }
+ : null,
+ videoId,
+ ownerId: video.owner.id,
+ }).catch((error) => {
+ console.error(
+ `[ShareVideoPage] Dashboard destination lookup failed for ${videoId}:`,
+ error,
+ );
+ return null;
+ });
+
const videoHasEditsPromise = canDownloadVideoPromise.then((canDownload) => {
if (!canDownload || video.isScreenshot) return false;
return db()
@@ -804,6 +819,7 @@ async function AuthorizedContent({
videoHasEdits,
ownerIsOverShareLimit,
resolvedImages,
+ dashboardDestination,
] = await Promise.all([
spacesDataPromise,
sharedSpacesPromise,
@@ -818,6 +834,7 @@ async function AuthorizedContent({
videoHasEditsPromise,
overShareLimitPromise,
imagesPromise,
+ dashboardDestinationPromise,
viewNotificationPromise,
]);
@@ -949,8 +966,10 @@ async function AuthorizedContent({
// header renders for everyone, and a failed count is worth
// less than the header it would otherwise take down.
views={viewsPromise.catch(() => null)}
+ dashboardDestination={dashboardDestination}
/>
}
+ dashboardDestination={dashboardDestination}
data={videoWithOrganizationInfo}
initialPlaybackUrl={initialPlaybackUrlPromise}
screenshotImageUrl={screenshotImageUrl}