Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

showArchived fixes

Steven Tey930b2a107a75
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tags/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tags/page-client.tsx
index f793d5d0d6..0c071b24f3 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tags/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/tags/page-client.tsx
@@ -28,6 +28,7 @@ export default function WorkspaceTagsClient() {
const { tags, loading } = useTags();
const { data: tagsCount } = useLinksCount({
groupBy: "tagId",
+ showArchived: true,
});
const [openMenuTagId, setOpenMenuTagId] = useState<string | null>(null);
diff --git a/apps/web/ui/links/archived-links-hint.tsx b/apps/web/ui/links/archived-links-hint.tsx
index 392a3b95da..55bfb24da3 100644
--- a/apps/web/ui/links/archived-links-hint.tsx
+++ b/apps/web/ui/links/archived-links-hint.tsx
@@ -29,6 +29,7 @@ function ArchivedLinksHintHelper() {
<div className="px-3 py-2 text-sm text-gray-500">
<div className="flex items-center gap-4">
<span>
+ You have{" "}
<span className="font-medium text-gray-950">
{archivedCount}
</span>{" "}
diff --git a/apps/web/ui/links/links-container.tsx b/apps/web/ui/links/links-container.tsx
index a86d47ca04..db6ee93660 100644
--- a/apps/web/ui/links/links-container.tsx
+++ b/apps/web/ui/links/links-container.tsx
@@ -4,6 +4,7 @@ import useLinks from "@/lib/swr/use-links";
import useLinksCount from "@/lib/swr/use-links-count";
import { LinkWithTagsProps, UserProps } from "@/lib/types";
import { CardList, MaxWidthWrapper, useRouterStuff } from "@dub/ui";
+import { LoadingSpinner } from "@dub/ui/src/icons";
import { useSearchParams } from "next/navigation";
import {
Dispatch,
@@ -31,7 +32,7 @@ export default function LinksContainer({
const { viewMode, sort, showArchived } = useContext(LinksDisplayContext);
const { links, isValidating } = useLinks({ sort, showArchived });
- const { data: count } = useLinksCount();
+ const { data: count } = useLinksCount({ showArchived });
return (
<MaxWidthWrapper className="grid gap-y-2">
@@ -81,51 +82,59 @@ function LinksList({
"showArchived",
].some((param) => searchParams.has(param));
- return !links || links.length ? (
- <LinksListContext.Provider value={{ openMenuLinkId, setOpenMenuLinkId }}>
- {/* Cards */}
- <CardList variant={compact ? "compact" : "loose"} loading={loading}>
- {links?.length
- ? // Link cards
- links.map((link) => <LinkCard link={link} />)
- : // Loading placeholder cards
- Array.from({ length: 12 }).map((_, idx) => (
- <CardList.Card
- key={idx}
- outerClassName="pointer-events-none"
- innerClassName="flex items-center gap-4"
- >
- <LinkCardPlaceholder />
- </CardList.Card>
- ))}
- </CardList>
+ return (
+ <>
+ {!links || links.length ? (
+ <LinksListContext.Provider
+ value={{ openMenuLinkId, setOpenMenuLinkId }}
+ >
+ {/* Cards */}
+ <CardList variant={compact ? "compact" : "loose"} loading={loading}>
+ {links?.length
+ ? // Link cards
+ links.map((link) => <LinkCard link={link} />)
+ : // Loading placeholder cards
+ Array.from({ length: 12 }).map((_, idx) => (
+ <CardList.Card
+ key={idx}
+ outerClassName="pointer-events-none"
+ innerClassName="flex items-center gap-4"
+ >
+ <LinkCardPlaceholder />
+ </CardList.Card>
+ ))}
+ </CardList>
+ </LinksListContext.Provider>
+ ) : isFiltered ? (
+ <LinkNotFound />
+ ) : (
+ <NoLinksPlaceholder AddEditLinkButton={AddEditLinkButton} />
+ )}
{/* Pagination */}
- {!!links?.length && (
- <CardList.Pagination
- page={page}
- onPageChange={(p) => {
- const newPage = p(page);
- queryParams(
- newPage === 0
- ? { del: "page" }
- : {
- set: {
- page: (newPage + 1).toString(),
- },
+ <CardList.Pagination
+ page={page}
+ onPageChange={(p) => {
+ const newPage = p(page);
+ queryParams(
+ newPage === 0
+ ? { del: "page" }
+ : {
+ set: {
+ page: (newPage + 1).toString(),
},
- );
- }}
- totalCount={count ?? links.length}
- resourceName={(plural) => `${plural ? "links" : "link"}`}
- >
+ },
+ );
+ }}
+ totalCount={count ?? links?.length ?? 0}
+ resourceName={(plural) => `${plural ? "links" : "link"}`}
+ >
+ {loading ? (
+ <LoadingSpinner className="size-3.5" />
+ ) : (
<ArchivedLinksHint />
- </CardList.Pagination>
- )}
- </LinksListContext.Provider>
- ) : isFiltered ? (
- <LinkNotFound />
- ) : (
- <NoLinksPlaceholder AddEditLinkButton={AddEditLinkButton} />
+ )}
+ </CardList.Pagination>
+ </>
);
}
diff --git a/packages/ui/src/card-list/card-list-pagination.tsx b/packages/ui/src/card-list/card-list-pagination.tsx
index ba0aa7e91e..41fdc37bea 100644
--- a/packages/ui/src/card-list/card-list-pagination.tsx
+++ b/packages/ui/src/card-list/card-list-pagination.tsx
@@ -22,18 +22,18 @@ export function CardListPagination({
<div className="h-[90px]" />
<div className="fixed bottom-4 left-1/2 w-full max-w-[768px] -translate-x-1/2 px-2.5 max-[920px]:bottom-5 max-[920px]:pr-20">
<nav className="flex w-full items-center justify-between rounded-xl border border-gray-200 bg-white px-4 py-3.5 text-sm leading-6 text-gray-600 [filter:drop-shadow(0_5px_8px_#222A351d)]">
- <div className="flex items-center gap-4">
+ <div className="flex items-center gap-2">
<div>
<span className="hidden sm:inline-block">Viewing</span>{" "}
<span className="font-medium">
- {page * pageSize + 1}-
+ {page * pageSize + (totalCount ? 1 : 0)}-
{Math.min(page * pageSize + pageSize, totalCount)}
</span>{" "}
of{" "}
<span className="font-medium">{totalCount.toLocaleString()}</span>{" "}
{resourceName?.(totalCount !== 1) || "items"}
</div>
- {children && <div>{children}</div>}
+ {children}
</div>
<div className="flex items-center gap-2">
<Button