From 86d93d94fe2199792422d70c3ff8ccc244ab90e5 Mon Sep 17 00:00:00 2001 From: Abhimanyu Saharan Date: Sun, 8 Feb 2026 23:30:24 +0530 Subject: [PATCH] feat: refactor authentication panels and add AdminOnlyNotice component --- .../app/gateways/[gatewayId]/edit/page.tsx | 24 ++++++----------- .../src/app/gateways/[gatewayId]/page.tsx | 23 ++++++---------- frontend/src/app/gateways/new/page.tsx | 23 ++++++---------- frontend/src/app/gateways/page.tsx | 20 ++++++-------- .../src/components/auth/AdminOnlyNotice.tsx | 11 ++++++++ .../src/components/auth/SignedOutPanel.tsx | 26 +++++++++++++++++++ 6 files changed, 69 insertions(+), 58 deletions(-) create mode 100644 frontend/src/components/auth/AdminOnlyNotice.tsx create mode 100644 frontend/src/components/auth/SignedOutPanel.tsx diff --git a/frontend/src/app/gateways/[gatewayId]/edit/page.tsx b/frontend/src/app/gateways/[gatewayId]/edit/page.tsx index 8fe99251..bb51515c 100644 --- a/frontend/src/app/gateways/[gatewayId]/edit/page.tsx +++ b/frontend/src/app/gateways/[gatewayId]/edit/page.tsx @@ -5,7 +5,7 @@ export const dynamic = "force-dynamic"; import { useState } from "react"; import { useParams, useRouter } from "next/navigation"; -import { SignInButton, SignedIn, SignedOut, useAuth } from "@/auth/clerk"; +import { SignedIn, SignedOut, useAuth } from "@/auth/clerk"; import { ApiError } from "@/api/mutator"; import { @@ -18,10 +18,11 @@ import { useGetMyMembershipApiV1OrganizationsMeMemberGet, } from "@/api/generated/organizations/organizations"; import type { GatewayUpdate } from "@/api/generated/model"; +import { AdminOnlyNotice } from "@/components/auth/AdminOnlyNotice"; +import { SignedOutPanel } from "@/components/auth/SignedOutPanel"; import { GatewayForm } from "@/components/gateways/GatewayForm"; import { DashboardSidebar } from "@/components/organisms/DashboardSidebar"; import { DashboardShell } from "@/components/templates/DashboardShell"; -import { Button } from "@/components/ui/button"; import { DEFAULT_MAIN_SESSION_KEY, DEFAULT_WORKSPACE_ROOT, @@ -180,17 +181,10 @@ export default function EditGatewayPage() { return ( -
-
-

Sign in to edit a gateway.

- - - -
-
+
@@ -210,9 +204,7 @@ export default function EditGatewayPage() {
{!isAdmin ? ( -
- Only organization owners and admins can edit gateways. -
+ ) : ( -
-
-

Sign in to view a gateway.

- - - -
-
+
@@ -173,9 +168,7 @@ export default function GatewayDetailPage() {
{!isAdmin ? ( -
- Only organization owners and admins can access gateways. -
+ ) : gatewayQuery.isLoading ? (
Loading gateway… diff --git a/frontend/src/app/gateways/new/page.tsx b/frontend/src/app/gateways/new/page.tsx index 5d339ec2..c1326488 100644 --- a/frontend/src/app/gateways/new/page.tsx +++ b/frontend/src/app/gateways/new/page.tsx @@ -5,7 +5,7 @@ export const dynamic = "force-dynamic"; import { useState } from "react"; import { useRouter } from "next/navigation"; -import { SignInButton, SignedIn, SignedOut, useAuth } from "@/auth/clerk"; +import { SignedIn, SignedOut, useAuth } from "@/auth/clerk"; import { ApiError } from "@/api/mutator"; import { useCreateGatewayApiV1GatewaysPost } from "@/api/generated/gateways/gateways"; @@ -13,10 +13,11 @@ import { type getMyMembershipApiV1OrganizationsMeMemberGetResponse, useGetMyMembershipApiV1OrganizationsMeMemberGet, } from "@/api/generated/organizations/organizations"; +import { AdminOnlyNotice } from "@/components/auth/AdminOnlyNotice"; +import { SignedOutPanel } from "@/components/auth/SignedOutPanel"; import { GatewayForm } from "@/components/gateways/GatewayForm"; import { DashboardSidebar } from "@/components/organisms/DashboardSidebar"; import { DashboardShell } from "@/components/templates/DashboardShell"; -import { Button } from "@/components/ui/button"; import { DEFAULT_MAIN_SESSION_KEY, DEFAULT_WORKSPACE_ROOT, @@ -141,16 +142,10 @@ export default function NewGatewayPage() { return ( -
-
-

- Sign in to create a gateway. -

- - - -
-
+
@@ -168,9 +163,7 @@ export default function NewGatewayPage() {
{!isAdmin ? ( -
- Only organization owners and admins can create gateways. -
+ ) : ( { if (!value) return "—"; @@ -235,14 +237,10 @@ export default function GatewaysPage() { return ( -
-
-

Sign in to view gateways.

- - - -
-
+
@@ -275,9 +273,7 @@ export default function GatewaysPage() {
{!isAdmin ? ( -
- Only organization owners and admins can access gateways. -
+ ) : ( <>
diff --git a/frontend/src/components/auth/AdminOnlyNotice.tsx b/frontend/src/components/auth/AdminOnlyNotice.tsx new file mode 100644 index 00000000..26a73b72 --- /dev/null +++ b/frontend/src/components/auth/AdminOnlyNotice.tsx @@ -0,0 +1,11 @@ +type AdminOnlyNoticeProps = { + message: string; +}; + +export function AdminOnlyNotice({ message }: AdminOnlyNoticeProps) { + return ( +
+ {message} +
+ ); +} diff --git a/frontend/src/components/auth/SignedOutPanel.tsx b/frontend/src/components/auth/SignedOutPanel.tsx new file mode 100644 index 00000000..062073d6 --- /dev/null +++ b/frontend/src/components/auth/SignedOutPanel.tsx @@ -0,0 +1,26 @@ +import { SignInButton } from "@/auth/clerk"; + +import { Button } from "@/components/ui/button"; + +type SignedOutPanelProps = { + message: string; + forceRedirectUrl: string; + buttonLabel?: string; +}; + +export function SignedOutPanel({ + message, + forceRedirectUrl, + buttonLabel = "Sign in", +}: SignedOutPanelProps) { + return ( +
+
+

{message}

+ + + +
+
+ ); +}