From 65f40d0897b7cb716f2da170a886d2ea793f72e8 Mon Sep 17 00:00:00 2001 From: LandaMm Date: Tue, 24 Jun 2025 19:04:01 +0200 Subject: [PATCH] feat: app permissions admin page --- web/src/App.tsx | 7 + web/src/pages/Admin/AppPermissions/index.tsx | 130 +++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 web/src/pages/Admin/AppPermissions/index.tsx diff --git a/web/src/App.tsx b/web/src/App.tsx index fd0ca70..e17c501 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -27,6 +27,7 @@ import VerifyAvatarPage from "./pages/Verify/Avatar"; import VerifyReviewPage from "./pages/Verify/Review"; import AdminUserSessionsPage from "./pages/Admin/UserSessions"; import AdminServiceSessionsPage from "./pages/Admin/ServiceSessions"; +import AdminAppPermissionsPage from "./pages/Admin/AppPermissions"; const router = createBrowserRouter([ { @@ -93,6 +94,12 @@ const router = createBrowserRouter([ { index: true, element: }, ], }, + { + path: "app-permissions", + children: [ + { index: true, element: }, + ], + }, ], }, ], diff --git a/web/src/pages/Admin/AppPermissions/index.tsx b/web/src/pages/Admin/AppPermissions/index.tsx new file mode 100644 index 0000000..d2b08f9 --- /dev/null +++ b/web/src/pages/Admin/AppPermissions/index.tsx @@ -0,0 +1,130 @@ +import { useEffect, type FC } from "react"; +import Breadcrumbs from "@/components/ui/breadcrumbs"; +import { usePermissions } from "@/store/admin/permissions"; + +interface DisplayPermission { + name: string; + description: string; +} + +interface IPermissionGroupProps { + scope: string; + permissions?: DisplayPermission[] | null | undefined; + generatedPermissions?: DisplayPermission[] | null | undefined; +} + +const PermissionGroup: FC = ({ + scope, + permissions, + generatedPermissions, +}) => { + return ( +
+

+ {scope} +

+ + {(generatedPermissions?.length ?? 0) > 0 && ( + <> +

Generated by Guard

+ +
    0 ? "6" : "2"}`} + > + {generatedPermissions!.map(({ name, description }) => ( +
  1. +
    + +

    + {description} +

    +
    +
  2. + ))} +
+ + )} + + {(permissions?.length ?? 0) > 0 && ( + <> +

Manually Created

+ +
    + {permissions!.map(({ name, description }) => ( +
  1. +
    + +

    + {description} +

    +
    +
  2. + ))} +
+ + )} +
+ ); +}; + +const AdminAppPermissionsPage: FC = () => { + const permissions = usePermissions((s) => s.permissions); + const fetch = usePermissions((s) => s.fetch); + + useEffect(() => { + fetch(); + }, [fetch]); + + return ( +
+
+ +
+
+ {Object.keys(permissions).map((scope) => ( + ({ + name: p.name + .split("_") + .map((s) => s[0].toUpperCase() + s.slice(1)) + .join(" "), + description: p.description, + }))} + /> + ))} + {/* ({ + name, + description: `You can ${name.toLowerCase()}`, + }))} + permissions={[ + "Receive Messages", + "Send Messages", + "View Status", + "Post Status", + "Use Ghost Mode", + "Send Large Media", + ].map((name) => ({ + name, + description: `You can ${name.toLowerCase()}`, + }))} + /> */} +
+
+ ); +}; + +export default AdminAppPermissionsPage;