The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
add optionPermalink
Steven Tey6fa389567330
diff --git a/apps/web/ui/analytics/toggle.tsx b/apps/web/ui/analytics/toggle.tsxindex 3e4224cb0e..d0308680d5 100644--- a/apps/web/ui/analytics/toggle.tsx+++ b/apps/web/ui/analytics/toggle.tsx@@ -381,6 +381,10 @@ export default function Toggle({label: linkConstructor({ domain, key, pretty: true }),right: nFormatter(count, { full: true }),data: { url },+ permalink:+ slug && !partnerPage+ ? `/${slug}/links/${linkConstructor({ domain, key, pretty: true })}`+ : undefined,}),) ?? null,};@@ -403,21 +407,27 @@ export default function Toggle({/>) : null;},- options: customers?.map(({ id, email, name, avatar }) => {- return {- value: id,- label: email ?? name,- icon: (- <img- src={avatar || `${OG_AVATAR_URL}${id}`}- alt={`${email} avatar`}- className="size-4 rounded-full"- />- ),- };- }) ?? [- { value: selectedCustomerId, label: selectedCustomerId, icon: User },- ],+ getOptionPermalink: () => {+ return programSlug+ ? `/programs/${programSlug}/customers/${selectedCustomerId}`+ : slug+ ? `/${slug}/customers/${selectedCustomerId}`+ : undefined;+ },+ options:+ customers?.map(({ id, email, name, avatar }) => {+ return {+ value: id,+ label: email ?? name,+ icon: (+ <img+ src={avatar || `${OG_AVATAR_URL}${id}`}+ alt={`${email} avatar`}+ className="size-4 rounded-full"+ />+ ),+ };+ }) ?? null,};const filters: ComponentProps<typeof Filter.Select>["filters"] = useMemo(diff --git a/packages/ui/src/filter/filter-list.tsx b/packages/ui/src/filter/filter-list.tsxindex 05d7b23034..9b8eb45677 100644--- a/packages/ui/src/filter/filter-list.tsx+++ b/packages/ui/src/filter/filter-list.tsx@@ -2,7 +2,6 @@ import { cn, truncate } from "@dub/utils";import { AnimatePresence, motion } from "framer-motion";import { X } from "lucide-react";import Link from "next/link";-import { useParams } from "next/navigation";import { ReactNode, isValidElement } from "react";import { AnimatedSizeContainer } from "../animated-size-container";import { useKeyboardShortcut } from "../hooks";@@ -26,7 +25,6 @@ export function FilterList({onRemoveAll,className,}: FilterListProps) {- const { slug } = useParams();useKeyboardShortcut("Escape", onRemoveAll, { priority: 1 });return (<AnimatedSizeContainer@@ -62,11 +60,6 @@ export function FilterList({return null;}- const linkPageHref =- slug && key === "link"- ? `/${slug}/links/${filterValue}`- : undefined;-return (filter.multiple && Array.isArray(filterValue)? filterValue@@ -91,6 +84,11 @@ export function FilterList({filter.getOptionLabel?.(value, { key: filter.key, option }) ??value;+ const optionPermalink =+ option?.permalink ??+ filter.getOptionPermalink?.(value) ??+ null;+return (<motion.divkey={`${key}-${value}`}@@ -124,9 +122,9 @@ export function FilterList({<OptionIcon className="h-4 w-4" />)}</span>- {linkPageHref ? (+ {optionPermalink ? (<Link- href={linkPageHref}+ href={optionPermalink}target="_blank"className="cursor-alias decoration-dotted underline-offset-2 hover:underline">diff --git a/packages/ui/src/filter/types.ts b/packages/ui/src/filter/types.tsindex 309d9646df..fce15750ba 100644--- a/packages/ui/src/filter/types.ts+++ b/packages/ui/src/filter/types.ts@@ -23,6 +23,7 @@ export type Filter = {value: FilterOption["value"],props: { key: Filter["key"]; option?: FilterOption },) => string | null;+ getOptionPermalink?: (value: FilterOption["value"]) => string | null;};export type FilterOption = {@@ -32,4 +33,5 @@ export type FilterOption = {icon?: FilterIcon;hideDuringSearch?: boolean;data?: Record<string, any>;+ permalink?: string;};