The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update link controls
Tim Wilson89c9b1f6208c
diff --git a/apps/web/ui/links/link-controls.tsx b/apps/web/ui/links/link-controls.tsxindex dfe522b392..71863a6e6e 100644--- a/apps/web/ui/links/link-controls.tsx+++ b/apps/web/ui/links/link-controls.tsx@@ -125,183 +125,163 @@ export function LinkControls({ link }: { link: ResponseLink }) {return (<div className="flex justify-end">- <div- className={cn(- "flex items-center justify-end divide-x divide-gray-200 overflow-hidden rounded-md border border-gray-200",- "divide-transparent border-transparent sm:group-hover/card:divide-gray-200 sm:group-hover/card:border-gray-200", // Only show divider on mobile or when hovered- "w-[30px] transition-[width] duration-300 sm:w-[43px] sm:group-hover/card:w-[124px]",- )}- >- <LinkQRModal />- <AddEditLinkModal />- <DuplicateLinkModal />- <ArchiveLinkModal />- <TransferLinkModal />- <DeleteLinkModal />- <Button- icon={<PenWriting className={cn("h-4 w-4 shrink-0")} />}- variant="outline"- className="h-8 rounded-none border-0 px-3"- onClick={() => setShowAddEditLinkModal(true)}- />- <Button- icon={<QRCode className={cn("h-4 w-4 shrink-0")} />}- variant="outline"- className="h-8 rounded-none border-0 px-3"- onClick={() => setShowLinkQRModal(true)}- />- <Popover- content={- <div className="w-full sm:w-48">- <div className="grid gap-px p-2">- <Button- text="Edit"- variant="outline"- onClick={() => {- setOpenPopover(false);- setShowAddEditLinkModal(true);- }}- icon={<PenWriting className="h-4 w-4" />}- shortcut="E"- className="h-9 px-2 font-medium"- />- <Button- text="QR Code"- variant="outline"- onClick={() => {- setOpenPopover(false);- setShowLinkQRModal(true);- }}- icon={<QRCode className="h-4 w-4" />}- shortcut="Q"- className="h-9 px-2 font-medium"- />- <Button- text="Duplicate"- variant="outline"- onClick={() => {- setOpenPopover(false);- setShowDuplicateLinkModal(true);- }}- icon={<CopyPlus className="h-4 w-4" />}- shortcut="D"- className="h-9 px-2 font-medium"- />- <Button- text="Copy Link ID"- variant="outline"- onClick={() => copyLinkId()}- icon={- copiedLinkId ? (- <CircleCheck className="h-4 w-4" />- ) : (- <Copy className="h-4 w-4" />- )- }- shortcut="I"- className="h-9 px-2 font-medium"- />- </div>- <div className="border-t border-gray-200" />- <div className="grid gap-px p-2">+ <LinkQRModal />+ <AddEditLinkModal />+ <DuplicateLinkModal />+ <ArchiveLinkModal />+ <TransferLinkModal />+ <DeleteLinkModal />+ <Popover+ content={+ <div className="w-full sm:w-48">+ <div className="grid gap-px p-2">+ <Button+ text="Edit"+ variant="outline"+ onClick={() => {+ setOpenPopover(false);+ setShowAddEditLinkModal(true);+ }}+ icon={<PenWriting className="h-4 w-4" />}+ shortcut="E"+ className="h-9 px-2 font-medium"+ />+ <Button+ text="QR Code"+ variant="outline"+ onClick={() => {+ setOpenPopover(false);+ setShowLinkQRModal(true);+ }}+ icon={<QRCode className="h-4 w-4" />}+ shortcut="Q"+ className="h-9 px-2 font-medium"+ />+ <Button+ text="Duplicate"+ variant="outline"+ onClick={() => {+ setOpenPopover(false);+ setShowDuplicateLinkModal(true);+ }}+ icon={<CopyPlus className="h-4 w-4" />}+ shortcut="D"+ className="h-9 px-2 font-medium"+ />+ <Button+ text="Copy Link ID"+ variant="outline"+ onClick={() => copyLinkId()}+ icon={+ copiedLinkId ? (+ <CircleCheck className="h-4 w-4" />+ ) : (+ <Copy className="h-4 w-4" />+ )+ }+ shortcut="I"+ className="h-9 px-2 font-medium"+ />+ </div>+ <div className="border-t border-gray-200" />+ <div className="grid gap-px p-2">+ <Button+ text={link.archived ? "Unarchive" : "Archive"}+ variant="outline"+ onClick={() => {+ setOpenPopover(false);+ setShowArchiveLinkModal(true);+ }}+ icon={<BoxArchive className="h-4 w-4" />}+ shortcut="A"+ className="h-9 px-2 font-medium"+ />+ <Button+ text="Transfer"+ variant="outline"+ onClick={() => {+ setOpenPopover(false);+ setShowTransferLinkModal(true);+ }}+ icon={<FolderInput className="h-4 w-4" />}+ shortcut="T"+ className="h-9 px-2 font-medium"+ {...(!isDubDomain(link.domain) && {+ disabledTooltip: (+ <SimpleTooltipContent+ title="Since this is a custom domain link, you can only transfer it to another workspace if you transfer the domain as well."+ cta="Learn more."+ href="https://dub.co/help/article/how-to-transfer-domains"+ />+ ),+ })}+ />+ {link.key !== "_root" && (<Button- text={link.archived ? "Unarchive" : "Archive"}- variant="outline"+ text="Delete"+ variant="danger-outline"onClick={() => {setOpenPopover(false);- setShowArchiveLinkModal(true);+ setShowDeleteLinkModal(true);}}- icon={<BoxArchive className="h-4 w-4" />}- shortcut="A"+ icon={<Delete className="h-4 w-4" />}+ shortcut="X"className="h-9 px-2 font-medium"/>- <Button- text="Transfer"- variant="outline"+ )}+ {!slug && ( // this is only shown in admin mode (where there's no slug)+ <buttononClick={() => {- setOpenPopover(false);- setShowTransferLinkModal(true);+ window.confirm(+ "Are you sure you want to ban this link? It will blacklist the domain and prevent any links from that domain from being created.",+ ) &&+ (setOpenPopover(false),+ toast.promise(+ fetch(`/api/admin/links/ban?key=${link.key}`, {+ method: "DELETE",+ }).then(async () => {+ await mutate(+ (key) =>+ typeof key === "string" &&+ key.startsWith("/api/admin/links/ban"),+ undefined,+ { revalidate: true },+ );+ }),+ {+ loading: "Banning link...",+ success: "Link banned!",+ error: "Error banning link.",+ },+ ));}}- icon={<FolderInput className="h-4 w-4" />}- shortcut="T"- className="h-9 px-2 font-medium"- {...(!isDubDomain(link.domain) && {- disabledTooltip: (- <SimpleTooltipContent- title="Since this is a custom domain link, you can only transfer it to another workspace if you transfer the domain as well."- cta="Learn more."- href="https://dub.co/help/article/how-to-transfer-domains"- />- ),- })}- />- {link.key !== "_root" && (- <Button- text="Delete"- variant="danger-outline"- onClick={() => {- setOpenPopover(false);- setShowDeleteLinkModal(true);- }}- icon={<Delete className="h-4 w-4" />}- shortcut="X"- className="h-9 px-2 font-medium"- />- )}- {!slug && ( // this is only shown in admin mode (where there's no slug)- <button- onClick={() => {- window.confirm(- "Are you sure you want to ban this link? It will blacklist the domain and prevent any links from that domain from being created.",- ) &&- (setOpenPopover(false),- toast.promise(- fetch(`/api/admin/links/ban?key=${link.key}`, {- method: "DELETE",- }).then(async () => {- await mutate(- (key) =>- typeof key === "string" &&- key.startsWith("/api/admin/links/ban"),- undefined,- { revalidate: true },- );- }),- {- loading: "Banning link...",- success: "Link banned!",- error: "Error banning link.",- },- ));- }}- className="group flex w-full items-center justify-between rounded-md p-2 text-left text-sm font-medium text-red-600 transition-all duration-75 hover:bg-red-600 hover:text-white"- >- <IconMenu- text="Ban"- icon={<Delete className="h-4 w-4" />}- />- <kbd className="hidden rounded bg-red-100 px-2 py-0.5 text-xs font-light text-red-600 transition-all duration-75 group-hover:bg-red-500 group-hover:text-white sm:inline-block">- B- </kbd>- </button>- )}- </div>+ className="group flex w-full items-center justify-between rounded-md p-2 text-left text-sm font-medium text-red-600 transition-all duration-75 hover:bg-red-600 hover:text-white"+ >+ <IconMenu text="Ban" icon={<Delete className="h-4 w-4" />} />+ <kbd className="hidden rounded bg-red-100 px-2 py-0.5 text-xs font-light text-red-600 transition-all duration-75 group-hover:bg-red-500 group-hover:text-white sm:inline-block">+ B+ </kbd>+ </button>+ )}</div>- }- align="end"- openPopover={openPopover}- setOpenPopover={setOpenPopover}- >- <Button- variant="outline"- className="h-8 rounded-none border-0 px-2.5 transition-[border-color] duration-200"- icon={<ThreeDots className="h-5 w-5 shrink-0" />}- onClick={() => {- setOpenPopover(!openPopover);- }}- />- </Popover>- </div>+ </div>+ }+ align="end"+ openPopover={openPopover}+ setOpenPopover={setOpenPopover}+ >+ <Button+ variant="secondary"+ className={cn(+ "h-8 px-1.5 outline-none transition-all duration-200",+ "border-transparent data-[state=open]:border-gray-500 sm:group-hover/card:data-[state=closed]:border-gray-200",+ )}+ icon={<ThreeDots className="h-5 w-5 shrink-0" />}+ onClick={() => {+ setOpenPopover(!openPopover);+ }}+ />+ </Popover></div>);}diff --git a/apps/web/ui/links/link-title-column.tsx b/apps/web/ui/links/link-title-column.tsxindex 497a93d06f..4bf89639ac 100644--- a/apps/web/ui/links/link-title-column.tsx+++ b/apps/web/ui/links/link-title-column.tsx@@ -8,6 +8,7 @@ import {CardList,CopyButton,LinkLogo,+ QRCode,Switch,Tooltip,TooltipContent,@@ -40,6 +41,7 @@ import { Mail } from "lucide-react";import { PropsWithChildren, useContext, useRef } from "react";import useSWR from "swr";import { useAddEditLinkModal } from "../modals/add-edit-link-modal";+import { useLinkQRModal } from "../modals/link-qr-modal";import { ResponseLink } from "./links-container";const quickViewSettings = [@@ -132,6 +134,7 @@ export function LinkTitleColumn({ link }: { link: ResponseLink }) {variant="neutral"className="p-1"/>+ <QRCodeButton link={link} /></motion.div>)}</AnimatePresence>@@ -244,6 +247,25 @@ function CommentsBadge({ comments }: { comments: string }) {);}+function QRCodeButton({ link }: { link: ResponseLink }) {+ const { setShowLinkQRModal, LinkQRModal } = useLinkQRModal({+ props: link,+ });++ return (+ <div className="sm:block">+ <LinkQRModal />+ <button+ type="button"+ onClick={() => setShowLinkQRModal(true)}+ className="rounded-full bg-gray-100 p-[5px] hover:bg-gray-200"+ >+ <QRCode className="h-3 w-3" />+ </button>+ </div>+ );+}+function Details({ link, compact }: { link: ResponseLink; compact?: boolean }) {const { url, user, createdAt } = link;return (