Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

Merge branch 'dev' of https://github.com/IsaacWise06/linkwarden into dashboard-layout

Isaac8718b1acfef6
diff --cc apps/web/pages/dashboard.tsx
index 5f1b8907,8d392c53..f6de3268
--- a/apps/web/pages/dashboard.tsx
+++ b/apps/web/pages/dashboard.tsx
@@@ -52,12 -47,12 +52,12 @@@ export default function Dashboard()
useEffect(() => {
if (
process.env.NEXT_PUBLIC_STRIPE === "true" &&
- account &&
- account.id &&
- account.referredBy === null &&
+ user &&
+ user.id &&
+ user.referredBy === null &&
// if user is using Linkwarden for more than 3 days
- new Date().getTime() - new Date(account.createdAt).getTime() >
- 3 * 24 * 60 * 60 * 1000
+ new Date().getTime() - new Date(user.createdAt).getTime() >
- 3 * 24 * 60 * 60 * 1000
++ 3 * 24 * 60 * 60 * 1000
) {
setTimeout(() => {
setShowsSurveyModal(true);
@@@ -145,260 -120,185 +145,260 @@@
);
};
- return (
- <MainLayout>
- <div style={{ flex: "1 1 auto" }} className="p-5 flex flex-col gap-5">
- <div className="flex items-center justify-between">
+ const renderStatsSection = () => (
+ <div className="xl:flex flex flex-col sm:grid grid-cols-2 gap-3 xl:flex-row xl:justify-evenly xl:w-full">
+ <DashboardItem
+ name={numberOfLinks === 1 ? t("link") : t("links")}
+ value={numberOfLinks}
+ icon={"bi-link-45deg"}
+ />
+
+ <DashboardItem
+ name={collections.length === 1 ? t("collection") : t("collections")}
+ value={collections.length}
+ icon={"bi-folder"}
+ />
+
+ <DashboardItem
+ name={tags.length === 1 ? t("tag") : t("tags")}
+ value={tags.length}
+ icon={"bi-hash"}
+ />
+
+ <DashboardItem
+ name={t("pinned")}
+ value={numberOfPinnedLinks}
+ icon={"bi-pin-angle"}
+ />
+ </div>
+ );
+
+ const renderRecentLinksSection = () => (
+ <>
+ <div className="flex justify-between items-center mb-4">
+ <div className="flex gap-2 items-center">
<PageHeader
- icon={"bi-house "}
- title={t("dashboard")}
- description={t("dashboard_desc")}
+ icon={"bi-clock-history"}
+ title={t("recent")}
+ description={t("recent_links_desc")}
/>
- <ViewDropdown viewMode={viewMode} setViewMode={setViewMode} />
</div>
+ <Link
+ href="/links"
+ className="flex items-center text-sm text-black/75 dark:text-white/75 gap-2 cursor-pointer"
+ >
+ {t("view_all")}
+ <i className="bi-chevron-right text-sm"></i>
+ </Link>
+ </div>
- <div className="xl:flex flex flex-col sm:grid grid-cols-2 gap-3 xl:flex-row xl:justify-evenly xl:w-full">
- <DashboardItem
- name={numberOfLinks === 1 ? t("link") : t("links")}
- value={numberOfLinks}
- icon={"bi-link-45deg"}
- />
+ <div
+ style={{
+ flex: links || dashboardData.isLoading ? "0 1 auto" : "1 1 auto",
+ }}
+ className="flex flex-col 2xl:flex-row items-start 2xl:gap-2"
+ >
+ {dashboardData.isLoading ? (
+ <div className="w-full">
+ <Links
+ layout={viewMode}
+ placeholderCount={settings.columns || 1}
+ useData={dashboardData}
+ />
+ </div>
+ ) : links && links[0] && !dashboardData.isLoading ? (
+ <div className="w-full">
+ <Links
+ links={links.slice(
+ 0,
+ settings.columns && showRecentLinks && showPinnedLinks
+ ? settings.columns * 2
+ : numberOfLinksToShow
+ )}
+ layout={viewMode}
+ />
+ </div>
+ ) : (
+ <div className="flex flex-col gap-2 justify-center h-full border border-solid border-neutral-content w-full mx-auto p-10 rounded-xl bg-base-200 bg-gradient-to-tr from-neutral-content/70 to-50% to-base-200">
+ <p className="text-center text-xl">{t("view_added_links_here")}</p>
+ <p className="text-center mx-auto max-w-96 w-fit text-neutral text-sm mt-2">
+ {t("view_added_links_here_desc")}
+ </p>
- <DashboardItem
- name={collections.length === 1 ? t("collection") : t("collections")}
- value={collections.length}
- icon={"bi-folder"}
- />
+ <div className="text-center w-full mt-4 flex flex-wrap gap-4 justify-center">
+ <Button
+ onClick={() => {
+ setNewLinkModal(true);
+ }}
+ variant="accent"
+ >
+ <i className="bi-plus-lg text-xl"></i>
+ {t("add_link")}
+ </Button>
- <DashboardItem
- name={tags.length === 1 ? t("tag") : t("tags")}
- value={tags.length}
- icon={"bi-hash"}
- />
+ <ImportDropdown />
+ </div>
+ </div>
+ )}
+ </div>
+ </>
+ );
- <DashboardItem
- name={t("pinned")}
- value={numberOfPinnedLinks}
+ const renderPinnedLinksSection = () => (
+ <>
+ <div className="flex justify-between items-center mb-4">
+ <div className="flex gap-2 items-center">
+ <PageHeader
icon={"bi-pin-angle"}
+ title={t("pinned")}
+ description={t("pinned_links_desc")}
/>
</div>
+ <Link
+ href="/links/pinned"
+ className="flex items-center text-sm text-black/75 dark:text-white/75 gap-2 cursor-pointer"
+ >
+ {t("view_all")}
+ <i className="bi-chevron-right text-sm "></i>
+ </Link>
+ </div>
- {account?.dashboardRecentLinks && (
- <>
- <div className="flex justify-between items-center">
- <div className="flex gap-2 items-center">
- <PageHeader
- icon={"bi-clock-history"}
- title={t("recent")}
- description={t("recent_links_desc")}
- />
- </div>
- <Link
- href="/links"
- className="flex items-center text-sm text-black/75 dark:text-white/75 gap-2 cursor-pointer"
- >
- {t("view_all")}
- <i className="bi-chevron-right text-sm"></i>
- </Link>
- </div>
-
- <div
- style={{
- flex:
- links || dashboardData.isLoading ? "0 1 auto" : "1 1 auto",
- }}
- className="flex flex-col 2xl:flex-row items-start 2xl:gap-2"
- >
- {dashboardData.isLoading ? (
- <div className="w-full">
- <Links
- layout={viewMode}
- placeholderCount={settings.columns || 1}
- useData={dashboardData}
- />
- </div>
- ) : links && links[0] && !dashboardData.isLoading ? (
- <div className="w-full">
- <Links
- links={links.slice(
- 0,
- settings.columns &&
- account.dashboardRecentLinks &&
- account.dashboardPinnedLinks
- ? settings.columns * 2
- : numberOfLinksToShow
- )}
- layout={viewMode}
- />
- </div>
- ) : (
- <div className="flex flex-col justify-center h-full border border-solid border-neutral-content w-full mx-auto p-10 rounded-xl bg-base-200 bg-gradient-to-tr from-neutral-content/70 to-50% to-base-200">
- <p className="text-center text-xl">
- {t("view_added_links_here")}
- </p>
- <p className="text-center mx-auto max-w-96 w-fit text-neutral text-sm mt-2">
- {t("view_added_links_here_desc")}
- </p>
-
- <div className="text-center w-full mt-4 flex flex-wrap gap-4 justify-center">
- <Button
- onClick={() => {
- setNewLinkModal(true);
- }}
- variant="accent"
- >
- <i className="bi-plus-lg text-xl"></i>
- {t("add_link")}
- </Button>
-
- <ImportDropdown />
- </div>
- </div>
- )}
- </div>
- </>
+ <div
+ style={{ flex: "1 1 auto" }}
+ className="flex flex-col 2xl:flex-row items-start 2xl:gap-2"
+ >
+ {dashboardData.isLoading ? (
+ <div className="w-full">
+ <Links
+ layout={viewMode}
+ placeholderCount={settings.columns || 1}
+ useData={dashboardData}
+ />
+ </div>
+ ) : links?.some((e: any) => e.pinnedBy && e.pinnedBy[0]) ? (
+ <div className="w-full">
+ <Links
+ links={links
+ .filter((e: any) => e.pinnedBy && e.pinnedBy[0])
+ .slice(
+ 0,
+ settings.columns && showRecentLinks && showPinnedLinks
+ ? settings.columns * 2
+ : numberOfLinksToShow
+ )}
+ layout={viewMode}
+ />
+ </div>
+ ) : (
+ <div
+ style={{ flex: "1 1 auto" }}
+ className="flex flex-col gap-2 justify-center h-full border border-solid border-neutral-content w-full mx-auto p-10 rounded-xl bg-base-200 bg-gradient-to-tr from-neutral-content/70 to-50% to-base-200"
+ >
+ <i className="bi-pin mx-auto text-6xl text-primary"></i>
+ <p className="text-center text-xl">
+ {t("pin_favorite_links_here")}
+ </p>
+ <p className="text-center mx-auto max-w-96 w-fit text-neutral text-sm">
+ {t("pin_favorite_links_here_desc")}
+ </p>
+ </div>
)}
+ </div>
+ </>
+ );
- {account?.dashboardPinnedLinks && (
- <>
- <div className="flex justify-between items-center">
- <div className="flex gap-2 items-center">
- <PageHeader
- icon={"bi-pin-angle"}
- title={t("pinned")}
- description={t("pinned_links_desc")}
- />
- </div>
- <Link
- href="/links/pinned"
- className="flex items-center text-sm text-black/75 dark:text-white/75 gap-2 cursor-pointer"
- >
- {t("view_all")}
- <i className="bi-chevron-right text-sm "></i>
- </Link>
- </div>
+ const renderCollectionSection = (section: DashboardSection) => {
+ const collection = collections.find((c) => c.id === section.collectionId);
+ if (!collection) return null;
- <div
- style={{ flex: "1 1 auto" }}
- className="flex flex-col 2xl:flex-row items-start 2xl:gap-2"
- >
- {dashboardData.isLoading ? (
- <div className="w-full">
- <Links
- layout={viewMode}
- placeholderCount={settings.columns || 1}
- useData={dashboardData}
- />
- </div>
- ) : links?.some((e: any) => e.pinnedBy && e.pinnedBy[0]) ? (
- <div className="w-full">
- <Links
- links={links
- .filter((e: any) => e.pinnedBy && e.pinnedBy[0])
- .slice(
- 0,
- settings.columns &&
- account.dashboardRecentLinks &&
- account.dashboardPinnedLinks
- ? settings.columns * 2
- : numberOfLinksToShow
- )}
- layout={viewMode}
- />
- </div>
- ) : (
- <div
- style={{ flex: "1 1 auto" }}
- className="flex flex-col gap-2 justify-center h-full border border-solid border-neutral-content w-full mx-auto p-10 rounded-xl bg-base-200 bg-gradient-to-tr from-neutral-content/70 to-50% to-base-200"
- >
- <i className="bi-pin mx-auto text-6xl text-primary"></i>
- <p className="text-center text-xl">
- {t("pin_favorite_links_here")}
- </p>
- <p className="text-center mx-auto max-w-96 w-fit text-neutral text-sm">
- {t("pin_favorite_links_here_desc")}
- </p>
- </div>
- )}
+ return (
+ <>
+ <div className="flex justify-between items-center mb-4">
+ <div className="flex gap-2 items-center">
+ <PageHeader
+ icon={"bi-folder"}
+ title={collection.name}
+ description={`${collection._count?.links || 0} ${t("links")}`}
+ />
+ </div>
+ <Link
+ href={`/collections/${collection.id}`}
+ className="flex items-center text-sm text-black/75 dark:text-white/75 gap-2 cursor-pointer"
+ >
+ {t("view_all")}
+ <i className="bi-chevron-right text-sm"></i>
+ </Link>
+ </div>
+
+ <div className="flex flex-col 2xl:flex-row items-start 2xl:gap-2">
+ {dashboardData.isLoading ? (
+ <div className="w-full">
+ <Links
+ layout={viewMode}
+ placeholderCount={settings.columns || 1}
+ useData={dashboardData}
+ />
</div>
- </>
- )}
+ ) : links?.filter((link: any) => link.collection.id === collection.id)
- .length > 0 ? (
++ .length > 0 ? (
+ <div className="w-full">
+ <Links
+ links={links
+ .filter((link: any) => link.collection.id === collection.id)
+ .slice(0, numberOfLinksToShow)}
+ layout={viewMode}
+ />
+ </div>
+ ) : (
+ <div className="flex flex-col gap-2 justify-center h-full border border-solid border-neutral-content w-full mx-auto p-10 rounded-xl bg-base-200 bg-gradient-to-tr from-neutral-content/70 to-50% to-base-200">
+ <i className="bi-folder mx-auto text-6xl text-primary"></i>
+ <p className="text-center text-xl">
+ {t("no_links_in_collection")}
+ </p>
+ </div>
+ )}
+ </div>
+ </>
+ );
+ };
+
+ const renderSection = (section: DashboardSection) => {
+ switch (section.type) {
+ case DashboardSectionType.STATS:
+ return renderStatsSection();
+ case DashboardSectionType.RECENT_LINKS:
+ return renderRecentLinksSection();
+ case DashboardSectionType.PINNED_LINKS:
+ return renderPinnedLinksSection();
+ case DashboardSectionType.COLLECTION:
+ return renderCollectionSection(section);
+ default:
+ return null;
+ }
+ };
+
+ return (
+ <MainLayout>
+ <div style={{ flex: "1 1 auto" }} className="p-5 flex flex-col gap-4">
+ <div className="flex items-center justify-between">
+ <PageHeader
+ icon={"bi-house "}
+ title={t("dashboard")}
+ description={t("dashboard_desc")}
+ />
+ <div className="flex items-center gap-3">
+ <DashboardLayoutDropdown />
+ <ViewDropdown viewMode={viewMode} setViewMode={setViewMode} />
+ </div>
+ </div>
+
+ {orderedSections.map((section) => (
+ <div key={`${section.type}-${section.collectionId || "default"}`}>
+ {renderSection(section)}
+ </div>
+ ))}
</div>
+
{showSurveyModal && (
<SurveyModal
submit={submitSurvey}
diff --cc apps/web/public/locales/en/common.json
index ca3ca855,326dc048..a9e92243
--- a/apps/web/public/locales/en/common.json
+++ b/apps/web/public/locales/en/common.json
@@@ -474,8 -477,12 +475,16 @@@
"cancel": "Cancel",
"preservation_rules": "Preservation rules:",
"links_being_archived": "Links are being archived...",
+ "display_on_dashboard": "Display on Dashboard",
+ "dashboard_stats": "Dashboard Stats",
+ "no_results_found": "No results found.",
- "no_links_in_collection": "No Links in this Collection."
- }
++ "no_links_in_collection": "No Links in this Collection.",
+ "theme": "Theme",
+ "font_family": "Font Family",
+ "font_size": "Font Size",
+ "line_height": "Line Height",
+ "line_width": "Line Width",
+ "notes_highlights": "Notes & Highlights",
+ "no_notes_highlights": "No notes or highlights found for this link.",
+ "save": "Save"
-}
++}
diff --cc packages/lib/schemaValidation.ts
index 6d130a9d,2b7cdaba..7a3d22bd
--- a/packages/lib/schemaValidation.ts
+++ b/packages/lib/schemaValidation.ts
@@@ -1,7 -1,10 +1,11 @@@
import { ArchivedFormat, TokenExpiry } from "@linkwarden/types";
- import { AiTaggingMethod, LinksRouteTo, DashboardSectionType } from "@linkwarden/prisma/client";
+ import {
+ AiTaggingMethod,
+ LinksRouteTo,
++ DashboardSectionType,
+ Theme,
+ } from "@linkwarden/prisma/client";
import { z } from "zod";
- import collection from "@/pages/api/v1/public/collections/[id]";
// const stringField = z.string({
// errorMap: (e) => ({
@@@ -253,18 -280,9 +279,20 @@@ export type PostHighlightSchemaType = z
export const LinkArchiveActionSchema = z.object({
action: z.enum(["allAndRePreserve", "allAndIgnore", "allBroken"]).optional(),
- linkIds: z.array(z.number()).optional()
+ linkIds: z.array(z.number()).optional(),
});
- export type LinkArchiveActionSchemaType = z.infer<typeof LinkArchiveActionSchema>;
+ export type LinkArchiveActionSchemaType = z.infer<
+ typeof LinkArchiveActionSchema
+ >;
+
+export const UpdateDashboardLayoutSchema = z.array(
+ z.object({
+ type: z.nativeEnum(DashboardSectionType),
+ collectionId: z.number().optional(),
+ enabled: z.boolean(),
+ order: z.number().optional(),
+ })
+)
+
- export type UpdateDashboardLayoutSchemaType = z.infer<typeof UpdateDashboardLayoutSchema>;
++export type UpdateDashboardLayoutSchemaType = z.infer<typeof UpdateDashboardLayoutSchema>;
diff --cc packages/prisma/schema.prisma
index 94d7a6d0,764722f0..c8762a95
--- a/packages/prisma/schema.prisma
+++ b/packages/prisma/schema.prisma
@@@ -51,8 -51,15 +51,13 @@@ model User
subscriptions Subscription?
linksRouteTo LinksRouteTo @default(ORIGINAL)
aiTaggingMethod AiTaggingMethod @default(DISABLED)
- aiPredefinedTags String[] @default([])
+ aiPredefinedTags String[] @default([])
aiTagExistingLinks Boolean @default(false)
+ theme Theme @default(dark)
+ readableFontFamily String?
+ readableFontSize String?
+ readableLineHeight String?
+ readableLineWidth String?
- dashboardRecentLinks Boolean @default(true)
- dashboardPinnedLinks Boolean @default(true)
preventDuplicateLinks Boolean @default(false)
archiveAsScreenshot Boolean @default(true)
archiveAsMonolith Boolean @default(true)