-
-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Change the admin page to be tabbed similar to that of the setti…
…ngs page
- Loading branch information
1 parent
aff4e60
commit 179f00b
Showing
18 changed files
with
156 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import AdminActions from "@/components/admin/AdminActions"; | ||
|
||
export default function AdminActionsPage() { | ||
return <AdminActions />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { redirect } from "next/navigation"; | ||
import { AdminCard } from "@/components/admin/AdminCard"; | ||
import { AdminNotices } from "@/components/admin/AdminNotices"; | ||
import MobileAdminSidebar from "@/components/admin/sidebar/MobileSidebar"; | ||
import AdminSidebar from "@/components/admin/sidebar/Sidebar"; | ||
import Header from "@/components/dashboard/header/Header"; | ||
import { Separator } from "@/components/ui/separator"; | ||
import { getServerAuthSession } from "@/server/auth"; | ||
|
||
export default async function AdminLayout({ | ||
children, | ||
}: Readonly<{ | ||
children: React.ReactNode; | ||
}>) { | ||
const session = await getServerAuthSession(); | ||
if (!session || session.user.role !== "admin") { | ||
redirect("/"); | ||
} | ||
|
||
return ( | ||
<div> | ||
<Header /> | ||
<div className="flex min-h-[calc(100vh-64px)] w-screen flex-col sm:h-[calc(100vh-64px)] sm:flex-row"> | ||
<div className="hidden flex-none sm:flex"> | ||
<AdminSidebar /> | ||
</div> | ||
<main className="flex-1 bg-muted sm:overflow-y-auto"> | ||
<div className="block w-full sm:hidden"> | ||
<MobileAdminSidebar /> | ||
<Separator /> | ||
</div> | ||
<div className="min-h-30 container flex flex-col gap-1 p-4"> | ||
<AdminNotices /> | ||
<AdminCard>{children}</AdminCard> | ||
</div> | ||
</main> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import ServerStats from "@/components/admin/ServerStats"; | ||
|
||
export default function AdminOverviewPage() { | ||
return <ServerStats />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { redirect } from "next/navigation"; | ||
|
||
export default function AdminHomepage() { | ||
redirect("/admin/overview"); | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import UserList from "@/components/admin/UserList"; | ||
|
||
export default function AdminUsersPage() { | ||
return <UserList />; | ||
} |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import MobileSidebarItem from "@/components/shared/sidebar/ModileSidebarItem"; | ||
import { useTranslation } from "@/lib/i18n/server"; | ||
|
||
import { adminSidebarItems } from "./items"; | ||
|
||
export default async function MobileSidebar() { | ||
const { t } = await useTranslation(); | ||
return ( | ||
<aside className="w-full"> | ||
<ul className="flex justify-between space-x-2 border-b-black px-5 py-2 pt-5"> | ||
{adminSidebarItems(t).map((item) => ( | ||
<MobileSidebarItem | ||
key={item.name} | ||
logo={item.icon} | ||
path={item.path} | ||
/> | ||
))} | ||
</ul> | ||
</aside> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { redirect } from "next/navigation"; | ||
import SidebarItem from "@/components/shared/sidebar/SidebarItem"; | ||
import { useTranslation } from "@/lib/i18n/server"; | ||
import { getServerAuthSession } from "@/server/auth"; | ||
|
||
import serverConfig from "@hoarder/shared/config"; | ||
|
||
import { adminSidebarItems } from "./items"; | ||
|
||
export default async function Sidebar() { | ||
const { t } = await useTranslation(); | ||
const session = await getServerAuthSession(); | ||
if (!session) { | ||
redirect("/"); | ||
} | ||
|
||
return ( | ||
<aside className="flex h-[calc(100vh-64px)] w-60 flex-col gap-5 border-r p-4 "> | ||
<div> | ||
<ul className="space-y-2 text-sm font-medium"> | ||
{adminSidebarItems(t).map((item) => ( | ||
<SidebarItem | ||
key={item.name} | ||
logo={item.icon} | ||
name={item.name} | ||
path={item.path} | ||
/> | ||
))} | ||
</ul> | ||
</div> | ||
<div className="mt-auto flex items-center border-t pt-2 text-sm text-gray-400"> | ||
Hoarder v{serverConfig.serverVersion} | ||
</div> | ||
</aside> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { TFunction } from "i18next"; | ||
import { Activity, ArrowLeft, Settings, Users } from "lucide-react"; | ||
|
||
export const adminSidebarItems = ( | ||
t: TFunction, | ||
): { | ||
name: string; | ||
icon: JSX.Element; | ||
path: string; | ||
}[] => [ | ||
{ | ||
name: t("settings.back_to_app"), | ||
icon: <ArrowLeft size={18} />, | ||
path: "/dashboard/bookmarks", | ||
}, | ||
{ | ||
name: t("admin.server_stats.server_stats"), | ||
icon: <Activity size={18} />, | ||
path: "/admin/overview", | ||
}, | ||
{ | ||
name: t("admin.users_list.users_list"), | ||
icon: <Users size={18} />, | ||
path: "/admin/users", | ||
}, | ||
{ | ||
name: t("common.actions"), | ||
icon: <Settings size={18} />, | ||
path: "/admin/actions", | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters