From 04572a8e5081b1e4871e273cde9dbaaa44c52fe0 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Wed, 13 Mar 2024 21:43:44 +0000 Subject: structure: Create apps dir and copy tooling dir from t3-turbo repo --- packages/web/app/dashboard/admin/page.tsx | 203 --------------------- packages/web/app/dashboard/archive/page.tsx | 9 - packages/web/app/dashboard/bookmarks/layout.tsx | 23 --- packages/web/app/dashboard/bookmarks/loading.tsx | 11 -- packages/web/app/dashboard/bookmarks/page.tsx | 5 - packages/web/app/dashboard/error.tsx | 9 - packages/web/app/dashboard/favourites/page.tsx | 14 -- packages/web/app/dashboard/layout.tsx | 24 --- packages/web/app/dashboard/lists/[listId]/page.tsx | 44 ----- packages/web/app/dashboard/lists/page.tsx | 14 -- packages/web/app/dashboard/not-found.tsx | 7 - .../app/dashboard/preview/[bookmarkId]/page.tsx | 14 -- packages/web/app/dashboard/search/page.tsx | 41 ----- packages/web/app/dashboard/settings/page.tsx | 9 - packages/web/app/dashboard/tags/[tagName]/page.tsx | 55 ------ packages/web/app/dashboard/tags/page.tsx | 56 ------ 16 files changed, 538 deletions(-) delete mode 100644 packages/web/app/dashboard/admin/page.tsx delete mode 100644 packages/web/app/dashboard/archive/page.tsx delete mode 100644 packages/web/app/dashboard/bookmarks/layout.tsx delete mode 100644 packages/web/app/dashboard/bookmarks/loading.tsx delete mode 100644 packages/web/app/dashboard/bookmarks/page.tsx delete mode 100644 packages/web/app/dashboard/error.tsx delete mode 100644 packages/web/app/dashboard/favourites/page.tsx delete mode 100644 packages/web/app/dashboard/layout.tsx delete mode 100644 packages/web/app/dashboard/lists/[listId]/page.tsx delete mode 100644 packages/web/app/dashboard/lists/page.tsx delete mode 100644 packages/web/app/dashboard/not-found.tsx delete mode 100644 packages/web/app/dashboard/preview/[bookmarkId]/page.tsx delete mode 100644 packages/web/app/dashboard/search/page.tsx delete mode 100644 packages/web/app/dashboard/settings/page.tsx delete mode 100644 packages/web/app/dashboard/tags/[tagName]/page.tsx delete mode 100644 packages/web/app/dashboard/tags/page.tsx (limited to 'packages/web/app/dashboard') diff --git a/packages/web/app/dashboard/admin/page.tsx b/packages/web/app/dashboard/admin/page.tsx deleted file mode 100644 index 6babdd79..00000000 --- a/packages/web/app/dashboard/admin/page.tsx +++ /dev/null @@ -1,203 +0,0 @@ -"use client"; - -import { ActionButton } from "@/components/ui/action-button"; -import LoadingSpinner from "@/components/ui/spinner"; -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; -import { toast } from "@/components/ui/use-toast"; -import { api } from "@/lib/trpc"; -import { keepPreviousData } from "@tanstack/react-query"; -import { Trash } from "lucide-react"; -import { useSession } from "next-auth/react"; -import { useRouter } from "next/navigation"; - -function ActionsSection() { - const { mutate: recrawlLinks, isPending: isRecrawlPending } = - api.admin.recrawlAllLinks.useMutation({ - onSuccess: () => { - toast({ - description: "Recrawl enqueued", - }); - }, - onError: (e) => { - toast({ - variant: "destructive", - description: e.message, - }); - }, - }); - - const { mutate: reindexBookmarks, isPending: isReindexPending } = - api.admin.reindexAllBookmarks.useMutation({ - onSuccess: () => { - toast({ - description: "Reindex enqueued", - }); - }, - onError: (e) => { - toast({ - variant: "destructive", - description: e.message, - }); - }, - }); - - return ( - <> -

Actions

- recrawlLinks()} - > - Recrawl All Links - - reindexBookmarks()} - > - Reindex All Bookmarks - - - ); -} - -function ServerStatsSection() { - const { data: serverStats } = api.admin.stats.useQuery(undefined, { - refetchInterval: 1000, - placeholderData: keepPreviousData, - }); - - if (!serverStats) { - return ; - } - - return ( - <> -

Server Stats

- - - - Num Users - {serverStats.numUsers} - - - Num Bookmarks - {serverStats.numBookmarks} - - -
-
-

Background Jobs

- - - - Pending Crawling Jobs - {serverStats.pendingCrawls} - - - Pending Indexing Jobs - {serverStats.pendingIndexing} - - - Pending OpenAI Jobs - {serverStats.pendingOpenai} - - -
- - ); -} - -function UsersSection() { - const { data: session } = useSession(); - const invalidateUserList = api.useUtils().users.list.invalidate; - const { data: users } = api.users.list.useQuery(); - const { mutate: deleteUser, isPending: isDeletionPending } = - api.users.delete.useMutation({ - onSuccess: () => { - toast({ - description: "User deleted", - }); - invalidateUserList(); - }, - onError: (e) => { - toast({ - variant: "destructive", - description: `Something went wrong: ${e.message}`, - }); - }, - }); - - if (!users) { - return ; - } - - return ( - <> -

Users

- - - Name - Email - Role - Action - - - {users.users.map((u) => ( - - {u.name} - {u.email} - {u.role} - - deleteUser({ userId: u.id })} - loading={isDeletionPending} - disabled={session!.user.id == u.id} - > - - - - - ))} - -
- - ); -} - -export default function AdminPage() { - const router = useRouter(); - const { data: session, status } = useSession(); - - if (status == "loading") { - return ; - } - - if (!session || session.user.role != "admin") { - router.push("/"); - return; - } - - return ( -
-

Admin

-
- -
- -
- -
- ); -} diff --git a/packages/web/app/dashboard/archive/page.tsx b/packages/web/app/dashboard/archive/page.tsx deleted file mode 100644 index 69559185..00000000 --- a/packages/web/app/dashboard/archive/page.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import Bookmarks from "@/components/dashboard/bookmarks/Bookmarks"; - -export default async function ArchivedBookmarkPage() { - return ( -
- -
- ); -} diff --git a/packages/web/app/dashboard/bookmarks/layout.tsx b/packages/web/app/dashboard/bookmarks/layout.tsx deleted file mode 100644 index 71ee143b..00000000 --- a/packages/web/app/dashboard/bookmarks/layout.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React from "react"; -import TopNav from "@/components/dashboard/bookmarks/TopNav"; -import type { Metadata } from "next"; - -export const metadata: Metadata = { - title: "Hoarder - Bookmarks", -}; - -export default function BookmarksLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( -
-
- -
-
-
{children}
-
- ); -} diff --git a/packages/web/app/dashboard/bookmarks/loading.tsx b/packages/web/app/dashboard/bookmarks/loading.tsx deleted file mode 100644 index 4e56c3c4..00000000 --- a/packages/web/app/dashboard/bookmarks/loading.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import Spinner from "@/components/ui/spinner"; - -export default function Loading() { - return ( -
-
- -
-
- ); -} diff --git a/packages/web/app/dashboard/bookmarks/page.tsx b/packages/web/app/dashboard/bookmarks/page.tsx deleted file mode 100644 index c9391d85..00000000 --- a/packages/web/app/dashboard/bookmarks/page.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import Bookmarks from "@/components/dashboard/bookmarks/Bookmarks"; - -export default async function BookmarksPage() { - return ; -} diff --git a/packages/web/app/dashboard/error.tsx b/packages/web/app/dashboard/error.tsx deleted file mode 100644 index 556e59a3..00000000 --- a/packages/web/app/dashboard/error.tsx +++ /dev/null @@ -1,9 +0,0 @@ -"use client"; - -export default function Error() { - return ( -
-
Something went wrong
-
- ); -} diff --git a/packages/web/app/dashboard/favourites/page.tsx b/packages/web/app/dashboard/favourites/page.tsx deleted file mode 100644 index de17461d..00000000 --- a/packages/web/app/dashboard/favourites/page.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import Bookmarks from "@/components/dashboard/bookmarks/Bookmarks"; - -export default async function FavouritesBookmarkPage() { - return ( -
- -
- ); -} diff --git a/packages/web/app/dashboard/layout.tsx b/packages/web/app/dashboard/layout.tsx deleted file mode 100644 index 31d592fb..00000000 --- a/packages/web/app/dashboard/layout.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { Separator } from "@/components/ui/separator"; -import MobileSidebar from "@/components/dashboard/sidebar/ModileSidebar"; -import Sidebar from "@/components/dashboard/sidebar/Sidebar"; - -export default async function Dashboard({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( -
-
- -
-
-
- - -
- {children} -
-
- ); -} diff --git a/packages/web/app/dashboard/lists/[listId]/page.tsx b/packages/web/app/dashboard/lists/[listId]/page.tsx deleted file mode 100644 index 006fd3ad..00000000 --- a/packages/web/app/dashboard/lists/[listId]/page.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import { api } from "@/server/api/client"; -import { getServerAuthSession } from "@/server/auth"; -import { TRPCError } from "@trpc/server"; -import { notFound, redirect } from "next/navigation"; -import ListView from "@/components/dashboard/lists/ListView"; -import DeleteListButton from "@/components/dashboard/lists/DeleteListButton"; - -export default async function ListPage({ - params, -}: { - params: { listId: string }; -}) { - const session = await getServerAuthSession(); - if (!session) { - redirect("/"); - } - - let list; - try { - list = await api.lists.get({ listId: params.listId }); - } catch (e) { - if (e instanceof TRPCError) { - if (e.code == "NOT_FOUND") { - notFound(); - } - } - throw e; - } - - const bookmarks = await api.bookmarks.getBookmarks({ ids: list.bookmarks }); - - return ( -
-
- - {list.icon} {list.name} - - -
-
- -
- ); -} diff --git a/packages/web/app/dashboard/lists/page.tsx b/packages/web/app/dashboard/lists/page.tsx deleted file mode 100644 index 88eeda47..00000000 --- a/packages/web/app/dashboard/lists/page.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { api } from "@/server/api/client"; -import AllListsView from "@/components/dashboard/lists/AllListsView"; - -export default async function ListsPage() { - const lists = await api.lists.list(); - - return ( -
-

📋 All Lists

-
- -
- ); -} diff --git a/packages/web/app/dashboard/not-found.tsx b/packages/web/app/dashboard/not-found.tsx deleted file mode 100644 index 64df220c..00000000 --- a/packages/web/app/dashboard/not-found.tsx +++ /dev/null @@ -1,7 +0,0 @@ -export default function NotFound() { - return ( -
-
Not Found :(
-
- ); -} diff --git a/packages/web/app/dashboard/preview/[bookmarkId]/page.tsx b/packages/web/app/dashboard/preview/[bookmarkId]/page.tsx deleted file mode 100644 index 707d2b69..00000000 --- a/packages/web/app/dashboard/preview/[bookmarkId]/page.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { api } from "@/server/api/client"; -import BookmarkPreview from "@/components/dashboard/bookmarks/BookmarkPreview"; - -export default async function BookmarkPreviewPage({ - params, -}: { - params: { bookmarkId: string }; -}) { - const bookmark = await api.bookmarks.getBookmark({ - bookmarkId: params.bookmarkId, - }); - - return ; -} diff --git a/packages/web/app/dashboard/search/page.tsx b/packages/web/app/dashboard/search/page.tsx deleted file mode 100644 index 602f6aa0..00000000 --- a/packages/web/app/dashboard/search/page.tsx +++ /dev/null @@ -1,41 +0,0 @@ -"use client"; - -import BookmarksGrid from "@/components/dashboard/bookmarks/BookmarksGrid"; -import Loading from "../bookmarks/loading"; -import { Suspense, useRef } from "react"; -import { SearchInput } from "@/components/dashboard/search/SearchInput"; -import { useBookmarkSearch } from "@/lib/hooks/bookmark-search"; - -function SearchComp() { - const { data, isPending, isPlaceholderData } = useBookmarkSearch(); - - const inputRef: React.MutableRefObject = - useRef(null); - - return ( -
- -
- {data ? ( - b.id) }} - bookmarks={data.bookmarks} - /> - ) : ( - - )} -
- ); -} - -export default function SearchPage() { - return ( - - - - ); -} diff --git a/packages/web/app/dashboard/settings/page.tsx b/packages/web/app/dashboard/settings/page.tsx deleted file mode 100644 index 38091e6c..00000000 --- a/packages/web/app/dashboard/settings/page.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import ApiKeySettings from "@/components/dashboard/settings/ApiKeySettings"; -export default async function Settings() { - return ( -
-

Settings

- -
- ); -} diff --git a/packages/web/app/dashboard/tags/[tagName]/page.tsx b/packages/web/app/dashboard/tags/[tagName]/page.tsx deleted file mode 100644 index c978b86a..00000000 --- a/packages/web/app/dashboard/tags/[tagName]/page.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { getServerAuthSession } from "@/server/auth"; -import { db } from "@hoarder/db"; -import { notFound, redirect } from "next/navigation"; -import BookmarksGrid from "@/components/dashboard/bookmarks/BookmarksGrid"; -import { api } from "@/server/api/client"; -import { bookmarkTags, tagsOnBookmarks } from "@hoarder/db/schema"; -import { and, eq } from "drizzle-orm"; - -export default async function TagPage({ - params, -}: { - params: { tagName: string }; -}) { - const session = await getServerAuthSession(); - if (!session) { - redirect("/"); - } - const tagName = decodeURIComponent(params.tagName); - const tag = await db.query.bookmarkTags.findFirst({ - where: and( - eq(bookmarkTags.userId, session.user.id), - eq(bookmarkTags.name, tagName), - ), - columns: { - id: true, - }, - }); - - if (!tag) { - // TODO: Better error message when the tag is not there - notFound(); - } - - const bookmarkIds = await db.query.tagsOnBookmarks.findMany({ - where: eq(tagsOnBookmarks.tagId, tag.id), - columns: { - bookmarkId: true, - }, - }); - - const query = { - ids: bookmarkIds.map((b) => b.bookmarkId), - archived: false, - }; - - const bookmarks = await api.bookmarks.getBookmarks(query); - - return ( -
- {tagName} -
- -
- ); -} diff --git a/packages/web/app/dashboard/tags/page.tsx b/packages/web/app/dashboard/tags/page.tsx deleted file mode 100644 index 44c164e1..00000000 --- a/packages/web/app/dashboard/tags/page.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { Separator } from "@/components/ui/separator"; -import { getServerAuthSession } from "@/server/auth"; -import { db } from "@hoarder/db"; -import { bookmarkTags, tagsOnBookmarks } from "@hoarder/db/schema"; -import { count, eq } from "drizzle-orm"; -import Link from "next/link"; -import { redirect } from "next/navigation"; - -function TagPill({ name, count }: { name: string; count: number }) { - return ( - - {name} {count} - - ); -} - -export default async function TagsPage() { - const session = await getServerAuthSession(); - if (!session) { - redirect("/"); - } - - let tags = await db - .select({ - id: tagsOnBookmarks.tagId, - name: bookmarkTags.name, - count: count(), - }) - .from(tagsOnBookmarks) - .where(eq(bookmarkTags.userId, session.user.id)) - .groupBy(tagsOnBookmarks.tagId) - .innerJoin(bookmarkTags, eq(bookmarkTags.id, tagsOnBookmarks.tagId)); - - // Sort tags by usage desc - tags = tags.sort((a, b) => b.count - a.count); - - let tagPill; - if (tags.length) { - tagPill = tags.map((t) => ( - - )); - } else { - tagPill = "No Tags"; - } - - return ( -
- All Tags -
-
{tagPill}
-
- ); -} -- cgit v1.2.3-70-g09d2