⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
Start reordering dropdown
Isaac8ecd35acfe53
diff --git a/apps/web/components.json b/apps/web/components.jsonindex dcbb1abf..471a71b7 100644--- a/apps/web/components.json+++ b/apps/web/components.json@@ -18,4 +18,4 @@"hooks": "@/hooks"},"iconLibrary": "lucide"-}\ No newline at end of file+}diff --git a/apps/web/components/DashboardViewDropdown.tsx b/apps/web/components/DashboardViewDropdown.tsxnew file mode 100644index 00000000..c57f3518--- /dev/null+++ b/apps/web/components/DashboardViewDropdown.tsx@@ -0,0 +1,86 @@+import * as React from "react";+import {+ DropdownMenu,+ DropdownMenuTrigger,+ DropdownMenuContent,+} from "@/components/ui/dropdown-menu";+import { useTranslation } from "next-i18next";+import { Button } from "@/components/ui/button";+import TextInput from "./TextInput";+import { useCollections } from "@linkwarden/router/collections";++export default function DashboardViewDropdown() {+ const { t } = useTranslation();+ const { data: collections = [], isLoading } = useCollections();+ const [searchTerm, setSearchTerm] = React.useState("");++ const filteredCollections = React.useMemo(() => {+ if (!searchTerm.trim()) {+ return collections;+ }++ return collections.filter((collection) =>+ collection.name.toLowerCase().includes(searchTerm.toLowerCase())+ );+ }, [collections, searchTerm]);++ const handleSearchChange = (value: string) => {+ setSearchTerm(value);+ };++ return (+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button variant="ghost" size="icon">+ <i className="bi-sliders2-vertical text-neutral"></i>+ </Button>+ </DropdownMenuTrigger>++ <DropdownMenuContent className="min-w-72 py-2" align="end">+ <div className="px-1 flex flex-col gap-1">+ <p className="text-sm text-neutral">{t("display_on_dashboard")}</p>+ <TextInput+ value={searchTerm}+ onChange={(e) => handleSearchChange(e.target.value)}+ className="py-0"+ placeholder={t("search")}+ />+ <ul className="max-h-60 overflow-y-auto">+ {!isLoading &&+ filteredCollections.length > 0 &&+ filteredCollections.map((collection) => (+ <li+ key={collection.id}+ className="py-1 px-2 flex items-center justify-between cursor-pointer"+ >+ <div className="flex items-center gap-2">+ <input+ className="checkbox checkbox-primary"+ type="checkbox"+ checked={false}+ onChange={() => {+ /* Handle checkbox change */+ }}+ />+ <label+ htmlFor={`collection-${collection.id}`}+ className="text-sm"+ >+ {collection.name}+ </label>+ </div>++ <i className="bi-grip-vertical text-neutral"></i>+ </li>+ ))}+ {!isLoading && filteredCollections.length === 0 && searchTerm && (+ <li className="py-2 px-2 text-sm text-neutral text-center">+ {t("you_have_no_collections")}+ </li>+ )}+ </ul>+ </div>+ </DropdownMenuContent>+ </DropdownMenu>+ );+}diff --git a/apps/web/lib/api/controllers/dashboard/getDashboardDataV2.ts b/apps/web/lib/api/controllers/dashboard/getDashboardDataV2.tsindex 524c5bbb..3d435c5f 100644--- a/apps/web/lib/api/controllers/dashboard/getDashboardDataV2.ts+++ b/apps/web/lib/api/controllers/dashboard/getDashboardDataV2.ts@@ -1,18 +1,6 @@import { prisma } from "@linkwarden/prisma";import { LinkRequestQuery, Order, Sort } from "@linkwarden/types";-type Response<D> =- | {- data: D;- message: string;- status: number;- }- | {- data: D;- message: string;- status: number;- };-export default async function getDashboardData(userId: number,query: LinkRequestQuery,@@ -135,7 +123,6 @@ export default async function getDashboardData(orderBy: order || { id: "desc" },});}-const links = [...recentlyAddedLinks, ...pinnedLinks].sort((a, b) => new Date(b.id).getTime() - new Date(a.id).getTime());diff --git a/apps/web/pages/dashboard.tsx b/apps/web/pages/dashboard.tsxindex 5232f3c4..b5f46237 100644--- a/apps/web/pages/dashboard.tsx+++ b/apps/web/pages/dashboard.tsx@@ -19,6 +19,7 @@ import { useUpdateUser, useUser } from "@linkwarden/router/user";import SurveyModal from "@/components/ModalContent/SurveyModal";import ImportDropdown from "@/components/ImportDropdown";import { Button } from "@/components/ui/button";+import DashboardViewDropdown from "@/components/DashboardViewDropdown";export default function Dashboard() {const { t } = useTranslation();@@ -129,7 +130,10 @@ export default function Dashboard() {title={t("dashboard")}description={t("dashboard_desc")}/>- <ViewDropdown viewMode={viewMode} setViewMode={setViewMode} />+ <div className="flex items-center gap-3">+ <DashboardViewDropdown />+ <ViewDropdown viewMode={viewMode} setViewMode={setViewMode} />+ </div></div><div className="xl:flex flex flex-col sm:grid grid-cols-2 gap-3 xl:flex-row xl:justify-evenly xl:w-full">diff --git a/apps/web/pages/settings/preference.tsx b/apps/web/pages/settings/preference.tsxindex aaa9ca7d..cc2d71ab 100644--- a/apps/web/pages/settings/preference.tsx+++ b/apps/web/pages/settings/preference.tsx@@ -380,27 +380,6 @@ export default function Preference() {</div>)}- <div>- <p className="capitalize text-3xl font-thin inline">- {t("dashboard_settings")}- </p>- <div className="divider my-3"></div>- <p>{t("choose_whats_displayed_dashboard")}</p>- <div className="p-3">- <Checkbox- label={t("pinned_links")}- state={dashboardPinnedLinks}- onClick={() => setDashboardPinnedLinks(!dashboardPinnedLinks)}- />-- <Checkbox- label={t("recent_links")}- state={dashboardRecentLinks}- onClick={() => setDashboardRecentLinks(!dashboardRecentLinks)}- />- </div>- </div>-<div><p className="capitalize text-3xl font-thin inline">{t("archive_settings")}diff --git a/apps/web/public/locales/en/common.json b/apps/web/public/locales/en/common.jsonindex e8671cb9..faa7101d 100644--- a/apps/web/public/locales/en/common.json+++ b/apps/web/public/locales/en/common.json@@ -450,8 +450,6 @@"rss_subscription_deleted": "RSS Subscription deleted!","create_rss_subscription": "Create RSS Subscription","rss_feed": "RSS Feed",- "dashboard_settings": "Dashboard Settings",- "choose_whats_displayed_dashboard": "Choose what's displayed on your Dashboard:","pinned_links": "Pinned Links","recent_links": "Recent Links","search_results": "Search Results",@@ -475,5 +473,6 @@"links_are_being_represerved": "Links are being re-preserved...","cancel": "Cancel","preservation_rules": "Preservation rules:",- "links_being_archived": "Links are being archived..."+ "links_being_archived": "Links are being archived...",+ "display_on_dashboard": "Display on Dashboard"}diff --git a/apps/web/public/locales/ja/common.json b/apps/web/public/locales/ja/common.jsonindex 10d2598e..d5a70103 100644--- a/apps/web/public/locales/ja/common.json+++ b/apps/web/public/locales/ja/common.json@@ -447,8 +447,6 @@"rss_subscription_deleted": "RSSサブスクリプションを削除しました!","create_rss_subscription": "RSSサブスクリプションを作成","rss_feed": "RSSフィード",- "dashboard_settings": "ダッシュボード設定",- "choose_whats_displayed_dashboard": "ダッシュボードに表示する内容:","pinned_links": "ピン止めしたリンク","recent_links": "最近追加したリンク","search_results": "検索結果",diff --git a/apps/web/public/locales/ru/common.json b/apps/web/public/locales/ru/common.jsonindex 52d76b6d..1961595e 100644--- a/apps/web/public/locales/ru/common.json+++ b/apps/web/public/locales/ru/common.json@@ -447,8 +447,6 @@"rss_subscription_deleted": "Подписка RSS удалена!","create_rss_subscription": "Создать подписку RSS","rss_feed": "Лента RSS",- "dashboard_settings": "Настройки Инфопанели",- "choose_whats_displayed_dashboard": "Выберите, что будет отображаться на вашей Инфопанели:","pinned_links": "Закреплённые ссылки","recent_links": "Недавние ссылки","search_results": "Результаты поиска",diff --git a/apps/web/public/locales/zh-TW/common.json b/apps/web/public/locales/zh-TW/common.jsonindex 1607c826..0085863a 100644--- a/apps/web/public/locales/zh-TW/common.json+++ b/apps/web/public/locales/zh-TW/common.json@@ -450,8 +450,6 @@"rss_subscription_deleted": "RSS 訂閱已刪除!","create_rss_subscription": "建立 RSS 訂閱","rss_feed": "RSS Feed",- "dashboard_settings": "儀表板設定",- "choose_whats_displayed_dashboard": "選擇要在儀表板上顯示的內容:","pinned_links": "已釘選的連結","recent_links": "最近的連結","search_results": "搜尋結果",