Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Add isOwner prop for analytics and UI controls
Richie McIlroyc89451b18210
diff --git a/apps/web/app/(org)/dashboard/caps/components/CapCard/CapCardAnalytics.tsx b/apps/web/app/(org)/dashboard/caps/components/CapCard/CapCardAnalytics.tsxindex 230eac01c..6139a4a21 100644--- a/apps/web/app/(org)/dashboard/caps/components/CapCard/CapCardAnalytics.tsx+++ b/apps/web/app/(org)/dashboard/caps/components/CapCard/CapCardAnalytics.tsx@@ -18,6 +18,7 @@ interface CapCardAnalyticsProps {totalComments: number;isLoadingAnalytics: boolean;totalReactions: number;+ isOwner?: boolean;}export const CapCardAnalytics = Object.assign(@@ -27,53 +28,66 @@ export const CapCardAnalytics = Object.assign(totalComments,totalReactions,isLoadingAnalytics,+ isOwner = true,}: CapCardAnalyticsProps) =>isLoadingAnalytics ? (<CapCardAnalytics.Skeleton />) : (<Shell>- <Tooltip- content="View analytics"- className="bg-gray-12 text-gray-1 border-gray-11 shadow-lg"- delayDuration={100}- >- <Link- href={`/dashboard/analytics?capId=${capId}`}- className="inline-flex cursor-pointer"+ <div className="flex flex-wrap gap-4 items-center">+ <Tooltip+ content="View analytics"+ className="bg-gray-12 text-gray-1 border-gray-11 shadow-lg"+ delayDuration={100}>- <IconItem icon={faEye}>- <span className="text-sm text-gray-12">{displayCount}</span>- </IconItem>- </Link>- </Tooltip>- <Tooltip- content="View analytics"- className="bg-gray-12 text-gray-1 border-gray-11 shadow-lg"- delayDuration={100}- >- <Link- href={`/dashboard/analytics?capId=${capId}`}- className="inline-flex cursor-pointer"+ <Link+ href={`/dashboard/analytics?capId=${capId}`}+ className="inline-flex cursor-pointer"+ >+ <IconItem icon={faEye}>+ <span className="text-sm text-gray-12">{displayCount}</span>+ </IconItem>+ </Link>+ </Tooltip>+ <Tooltip+ content="View analytics"+ className="bg-gray-12 text-gray-1 border-gray-11 shadow-lg"+ delayDuration={100}>- <IconItem icon={faComment}>- <span className="text-sm text-gray-12">{totalComments}</span>- </IconItem>- </Link>- </Tooltip>- <Tooltip- content="View analytics"- className="bg-gray-12 text-gray-1 border-gray-11 shadow-lg"- delayDuration={100}- >+ <Link+ href={`/dashboard/analytics?capId=${capId}`}+ className="inline-flex cursor-pointer"+ >+ <IconItem icon={faComment}>+ <span className="text-sm text-gray-12">{totalComments}</span>+ </IconItem>+ </Link>+ </Tooltip>+ <Tooltip+ content="View analytics"+ className="bg-gray-12 text-gray-1 border-gray-11 shadow-lg"+ delayDuration={100}+ >+ <Link+ href={`/dashboard/analytics?capId=${capId}`}+ className="inline-flex cursor-pointer"+ >+ <IconItem icon={faSmile}>+ <span className="text-sm text-gray-12">{totalReactions}</span>+ </IconItem>+ </Link>+ </Tooltip>+ </div>+ {isOwner && (<Linkhref={`/dashboard/analytics?capId=${capId}`}- className="inline-flex cursor-pointer"+ target="_blank"+ rel="noopener noreferrer"+ className="text-xs text-blue-600 hover:underline">- <IconItem icon={faSmile}>- <span className="text-sm text-gray-12">{totalReactions}</span>- </IconItem>+ View analytics</Link>- </Tooltip>+ )}</Shell>),{@@ -88,7 +102,7 @@ export const CapCardAnalytics = Object.assign();const Shell = (props: PropsWithChildren) => (- <div className="flex flex-wrap gap-4 items-center text-sm text-gray-60">+ <div className="flex flex-wrap gap-4 items-center justify-between text-sm text-gray-60">{props.children}</div>);diff --git a/apps/web/app/s/[videoId]/_components/ShareHeader.tsx b/apps/web/app/s/[videoId]/_components/ShareHeader.tsxindex 14e7f2c86..74662a06b 100644--- a/apps/web/app/s/[videoId]/_components/ShareHeader.tsx+++ b/apps/web/app/s/[videoId]/_components/ShareHeader.tsx@@ -4,7 +4,11 @@ import type { videos } from "@cap/database/schema";import { buildEnv, NODE_ENV } from "@cap/env";import { Button } from "@cap/ui";import { type ImageUpload, User } from "@cap/web-domain";-import { faChevronDown, faLock } from "@fortawesome/free-solid-svg-icons";+import {+ faChartSimple,+ faChevronDown,+ faLock,+} from "@fortawesome/free-solid-svg-icons";import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { Check, Copy, Globe2 } from "lucide-react";import moment from "moment";@@ -17,6 +21,7 @@ import { SharingDialog } from "@/app/(org)/dashboard/caps/components/SharingDialimport 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 { UpgradeModal } from "@/components/UpgradeModal";import { usePublicEnv } from "@/utils/public-env";import type { VideoData } from "../types";@@ -292,7 +297,27 @@ export const ShareHeader = ({)}</div>{user !== null && (- <div className="hidden md:flex">+ <div className="hidden md:flex gap-2">+ {isOwner && (+ <Tooltip+ content="View analytics"+ className="bg-gray-12 text-gray-1 border-gray-11 shadow-lg"+ delayDuration={100}+ >+ <Button+ variant="gray"+ className="rounded-full flex items-center justify-center"+ onClick={() => {+ push(`/dashboard/analytics?capId=${data.id}`);+ }}+ >+ <FontAwesomeIcon+ className="size-4 text-gray-12"+ icon={faChartSimple}+ />+ </Button>+ </Tooltip>+ )}<ButtononClick={() => {push("/dashboard/caps?page=1");diff --git a/apps/web/app/s/[videoId]/_components/Sidebar.tsx b/apps/web/app/s/[videoId]/_components/Sidebar.tsxindex 3310e5631..c9302d037 100644--- a/apps/web/app/s/[videoId]/_components/Sidebar.tsx+++ b/apps/web/app/s/[videoId]/_components/Sidebar.tsx@@ -83,9 +83,9 @@ export const Sidebar = forwardRef<{ scrollToBottom: () => void }, SidebarProps>() => {const user = useCurrentUser();+ const isOwner = Boolean(user?.id === data.owner.id);const isOwnerOrMember = Boolean(- user?.id === data.owner.id ||- (user && data.organizationMembers?.includes(user.id)),+ isOwner || (user && data.organizationMembers?.includes(user.id)),);const defaultTab = !(@@ -156,6 +156,7 @@ export const Sidebar = forwardRef<{ scrollToBottom: () => void }, SidebarProps>(setOptimisticComments={setOptimisticComments}handleCommentSuccess={handleCommentSuccess}isOwnerOrMember={isOwnerOrMember}+ isOwner={isOwner}onSeek={onSeek}videoId={data.id}/>diff --git a/apps/web/app/s/[videoId]/_components/tabs/Activity/Analytics.tsx b/apps/web/app/s/[videoId]/_components/tabs/Activity/Analytics.tsxindex 436714a48..d4e8c5dde 100644--- a/apps/web/app/s/[videoId]/_components/tabs/Activity/Analytics.tsx+++ b/apps/web/app/s/[videoId]/_components/tabs/Activity/Analytics.tsx@@ -10,6 +10,7 @@ const Analytics = (props: {views: MaybePromise<number>;comments: CommentType[];isLoadingAnalytics: boolean;+ isOwner: boolean;}) => {const [views, setViews] = useState(props.views instanceof Promise ? use(props.views) : props.views,@@ -46,6 +47,7 @@ const Analytics = (props: {displayCount={views}totalComments={totalComments}totalReactions={totalReactions}+ isOwner={props.isOwner}/>);};diff --git a/apps/web/app/s/[videoId]/_components/tabs/Activity/index.tsx b/apps/web/app/s/[videoId]/_components/tabs/Activity/index.tsxindex c5534c8a1..9e4b3e322 100644--- a/apps/web/app/s/[videoId]/_components/tabs/Activity/index.tsx+++ b/apps/web/app/s/[videoId]/_components/tabs/Activity/index.tsx@@ -20,6 +20,7 @@ interface ActivityProps {optimisticComments: CommentType[];setOptimisticComments: (newComment: CommentType) => void;isOwnerOrMember: boolean;+ isOwner: boolean;commentsDisabled: boolean;}@@ -29,6 +30,7 @@ export const Activity = Object.assign({videoId,isOwnerOrMember,+ isOwner,comments,handleCommentSuccess,optimisticComments,@@ -48,6 +50,7 @@ export const Activity = Object.assign(views={props.views}comments={comments}isLoadingAnalytics={false}+ isOwner={isOwner}/></Suspense>}