Skip to content

Open-source status page, incident response and uptime monitoring

Revert "refactor: auth components (#767)" (#784)

Thibault Le Ouaya334c5b3ffec
diff --git a/apps/web/src/app/app/(auth)/_components/oauth-buttons.tsx b/apps/web/src/app/app/(auth)/_components/oauth-buttons.tsx
deleted file mode 100644
index 8cf71337a..000000000
--- a/apps/web/src/app/app/(auth)/_components/oauth-buttons.tsx
+++ /dev/null
@@ -1,74 +0,0 @@
-"use client";
-
-import * as React from "react";
-import { useSearchParams } from "next/navigation";
-import { useSignIn } from "@clerk/nextjs";
-import type { OAuthStrategy } from "@clerk/nextjs/dist/types/server";
-
-import { Button } from "@openstatus/ui";
-
-import { Icons } from "@/components/icons";
-import { LoadingAnimation } from "@/components/loading-animation";
-import { toast } from "@/lib/toast";
-
-export function OauthButtons() {
- const [isLoading, setIsLoading] = React.useState<OAuthStrategy | null>(null);
- const { signIn, isLoaded: signInLoaded } = useSignIn();
- const searchParams = useSearchParams();
-
- const oauthSignIn = async (provider: OAuthStrategy) => {
- if (!signInLoaded) {
- return null;
- }
- try {
- setIsLoading(provider);
-
- const redirectUrl = searchParams.get("redirect_url") || "/app";
-
- await signIn.authenticateWithRedirect({
- strategy: provider,
- redirectUrl,
- redirectUrlComplete: redirectUrl,
- });
- } catch (err) {
- console.error(err);
- setIsLoading(null);
- toast.error((err as Error).message);
- }
- };
-
- return (
- <div className="@container">
- <div className="@md:flex-row flex w-full flex-col gap-2">
- <Button
- onClick={() => oauthSignIn("oauth_github")}
- className="w-full"
- disabled={isLoading === "oauth_github"}
- >
- {isLoading === "oauth_github" ? (
- <LoadingAnimation />
- ) : (
- <>
- <Icons.github className="mr-2 h-4 w-4" />
- GitHub
- </>
- )}
- </Button>
- <Button
- onClick={() => oauthSignIn("oauth_google")}
- className="w-full"
- disabled={isLoading === "oauth_google"}
- >
- {isLoading === "oauth_google" ? (
- <LoadingAnimation />
- ) : (
- <>
- <Icons.google className="mr-2 h-4 w-4" />
- Google
- </>
- )}
- </Button>
- </div>
- </div>
- );
-}
diff --git a/apps/web/src/app/app/(auth)/_components/terms-and-conditions.tsx b/apps/web/src/app/app/(auth)/_components/terms-and-conditions.tsx
deleted file mode 100644
index 6796ac69f..000000000
--- a/apps/web/src/app/app/(auth)/_components/terms-and-conditions.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-import Link from "next/link";
-
-export function TermsAndConditions() {
- return (
- <p className="text-muted-foreground px-8 text-center text-sm">
- By clicking continue, you agree to our{" "}
- <Link
- href="/legal/terms"
- className="hover:text-primary underline underline-offset-4 hover:no-underline"
- >
- Terms of Service
- </Link>{" "}
- and{" "}
- <Link
- href="/legal/privacy"
- className="hover:text-primary underline underline-offset-4 hover:no-underline"
- >
- Privacy Policy
- </Link>
- .
- </p>
- );
-}
diff --git a/apps/web/src/app/app/(auth)/layout.tsx b/apps/web/src/app/app/(auth)/layout.tsx
index e53fe633d..38673dcee 100644
--- a/apps/web/src/app/app/(auth)/layout.tsx
+++ b/apps/web/src/app/app/(auth)/layout.tsx
@@ -1,6 +1,4 @@
import * as React from "react";
-import Image from "next/image";
-import Link from "next/link";
import { redirect } from "next/navigation";
import { auth } from "@clerk/nextjs";
@@ -15,18 +13,9 @@ export default function AuthLayout({
redirect("/app");
}
return (
- <div className="grid min-h-screen grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-5">
- <aside className="border-border col-span-1 flex w-full flex-col gap-4 border p-4 backdrop-blur-[2px] md:p-8 xl:col-span-2">
- <Link href="/" className="relative">
- <Image
- src="/icon.png"
- alt="OpenStatus"
- height={30}
- width={30}
- className="border-border rounded-full border"
- />
- </Link>
- <div className="flex w-full max-w-lg flex-1 flex-col justify-center text-left">
+ <div className="grid min-h-screen grid-cols-1 md:grid-cols-2 xl:grid-cols-3">
+ <aside className="border-border col-span-1 flex w-full items-center justify-center border p-3 backdrop-blur-[2px] md:p-6">
+ <div className="w-full max-w-lg text-left">
<h1 className="font-cal text-foreground mb-3 text-2xl">
Open Source Monitoring Service
</h1>
@@ -45,10 +34,14 @@ export default function AuthLayout({
</a>{" "}
and let us know your use case!
</p>
+ {/* Add Demo tracker here? */}
+ <div className="h-12" />
+ {/* <p className="text-muted-foreground text-right text-sm font-light">
+ *your data is safe
+ </p> */}
</div>
- <div className="md:h-[30px]" />
</aside>
- <main className="container col-span-1 mx-auto flex items-center justify-center md:col-span-1 xl:col-span-3">
+ <main className="container col-span-1 mx-auto flex items-center justify-center md:col-span-1 xl:col-span-2">
{children}
</main>
</div>
diff --git a/apps/web/src/app/app/(auth)/sign-in/[[...sign-in]]/page.tsx b/apps/web/src/app/app/(auth)/sign-in/[[...sign-in]]/page.tsx
index 2ff9994bd..889711c52 100644
--- a/apps/web/src/app/app/(auth)/sign-in/[[...sign-in]]/page.tsx
+++ b/apps/web/src/app/app/(auth)/sign-in/[[...sign-in]]/page.tsx
@@ -1,26 +1,5 @@
-import Link from "next/link";
-
-import { Shell } from "@/components/dashboard/shell";
-import { OauthButtons } from "../../_components/oauth-buttons";
-import { TermsAndConditions } from "../../_components/terms-and-conditions";
+import { SignIn } from "@clerk/nextjs";
export default function Page() {
- return (
- <Shell className="my-4 grid w-full max-w-xl gap-6 md:p-10">
- <div className="flex flex-col gap-2 text-center">
- <h1 className="text-3xl font-semibold tracking-tight">Sign in</h1>
- <p className="text-muted-foreground text-sm">
- Create an account?{" "}
- <Link
- href="/app/sign-up"
- className="text-primary underline underline-offset-4 hover:no-underline"
- >
- Sign up
- </Link>
- </p>
- </div>
- <OauthButtons />
- <TermsAndConditions />
- </Shell>
- );
+ return <SignIn redirectUrl={"/app"} afterSignInUrl={"/app"} />;
}
diff --git a/apps/web/src/app/app/(auth)/sign-up/[[...sign-up]]/page.tsx b/apps/web/src/app/app/(auth)/sign-up/[[...sign-up]]/page.tsx
index c0fff8f56..effaf9b5f 100644
--- a/apps/web/src/app/app/(auth)/sign-up/[[...sign-up]]/page.tsx
+++ b/apps/web/src/app/app/(auth)/sign-up/[[...sign-up]]/page.tsx
@@ -1,28 +1,5 @@
-import Link from "next/link";
-
-import { Shell } from "@/components/dashboard/shell";
-import { OauthButtons } from "../../_components/oauth-buttons";
-import { TermsAndConditions } from "../../_components/terms-and-conditions";
+import { SignUp } from "@clerk/nextjs";
export default function Page() {
- return (
- <Shell className="my-4 grid w-full max-w-xl gap-6 md:p-10">
- <div className="flex flex-col gap-2 text-center">
- <h1 className="text-3xl font-semibold tracking-tight">
- Create an account
- </h1>
- <p className="text-muted-foreground text-sm">
- Already have an account?{" "}
- <Link
- href="/app/sign-in"
- className="text-primary underline underline-offset-4 hover:no-underline"
- >
- Sign in
- </Link>
- </p>
- </div>
- <OauthButtons />
- <TermsAndConditions />
- </Shell>
- );
+ return <SignUp redirectUrl={"/app"} afterSignUpUrl={"/app"} />;
}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/user/layout.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/user/layout.tsx
deleted file mode 100644
index 3f66cdd00..000000000
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/user/layout.tsx
+++ /dev/null
@@ -1,13 +0,0 @@
-import { Header } from "@/components/dashboard/header";
-import { getPageBySegment } from "@/config/pages";
-
-const page = getPageBySegment(["settings", "user"]);
-
-export default function Layout({ children }: { children: React.ReactNode }) {
- return (
- <>
- <Header title={page?.title} description={page?.description} />
- {children}
- </>
- );
-}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/user/loading.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/user/loading.tsx
deleted file mode 100644
index 5eb7326c5..000000000
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/user/loading.tsx
+++ /dev/null
@@ -1,7 +0,0 @@
-import { Skeleton } from "@openstatus/ui";
-
-// TODO: can be improved...
-
-export default function Loading() {
- return <Skeleton className="h-72 w-full" />;
-}
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/user/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/user/page.tsx
deleted file mode 100644
index ec2109cd1..000000000
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/settings/user/page.tsx
+++ /dev/null
@@ -1,73 +0,0 @@
-"use client";
-
-import { UserButton, useUser } from "@clerk/nextjs";
-
-import {
- Alert,
- AlertDescription,
- AlertTitle,
- Avatar,
- AvatarFallback,
- AvatarImage,
- Input,
- Label,
- Separator,
-} from "@openstatus/ui";
-
-import { Icons } from "@/components/icons";
-import Loading from "./loading";
-
-export default function UserPage() {
- const { user } = useUser();
-
- if (!user) {
- return <Loading />;
- }
-
- return (
- <div className="flex flex-col gap-8">
- <div className="grid max-w-sm gap-3">
- <div className="grid w-full items-center gap-1.5">
- <Label htmlFor="fullname">Full name</Label>
- <Input id="fullname" value={`${user.fullName}`} disabled />
- </div>
- <div className="grid w-full items-center gap-1.5">
- <Label htmlFor="email">Email</Label>
- <Input
- id="email"
- type="email"
- value={`${user.emailAddresses?.[0].emailAddress}`}
- disabled
- />
- </div>
- <div className="flex flex-wrap items-end gap-2">
- <div className="grid items-center gap-1.5">
- <Label htmlFor="avatar">Image</Label>
- <Input id="avatar" type="file" className="w-56" disabled />
- </div>
- <Avatar className="h-10 w-10">
- <AvatarImage src={user.imageUrl} alt={`${user.fullName}`} />
- <AvatarFallback></AvatarFallback>
- </Avatar>
- </div>
- </div>
- <Separator />
- <Alert className="max-w-2xl">
- <Icons.user className="h-4 w-4" />
- <AlertTitle>Manage User</AlertTitle>
- <AlertDescription className="flex gap-4">
- <p>
- We are using Clerk as our authentication provider. You can manage
- your profile via the user portal. Click on your avatar on the right
- to access it.
- </p>
- <div>
- <div className="border-primary rounded-full border p-0.5">
- <UserButton />
- </div>
- </div>
- </AlertDescription>
- </Alert>
- </div>
- );
-}
diff --git a/apps/web/src/components/icons.tsx b/apps/web/src/components/icons.tsx
index 11bd1b3db..a58de3c05 100644
--- a/apps/web/src/components/icons.tsx
+++ b/apps/web/src/components/icons.tsx
@@ -44,7 +44,6 @@ import {
ToyBrick,
Trash,
TwitterIcon,
- UserCircle,
Users,
Webhook,
Youtube,
@@ -103,7 +102,6 @@ export const Icons = {
book: Book,
newspaper: Newspaper,
youtube: Youtube,
- user: UserCircle,
"hour-glass": Hourglass,
"candlestick-chart": CandlestickChart,
discord: ({ ...props }: LucideProps) => (
@@ -119,15 +117,7 @@ export const Icons = {
<path
fill="currentColor"
d="M409.132 114.573c-19.608-33.596-46.205-60.194-79.798-79.8-33.598-19.607-70.277-29.408-110.063-29.408-39.781 0-76.472 9.804-110.063 29.408-33.596 19.605-60.192 46.204-79.8 79.8C9.803 148.168 0 184.854 0 224.63c0 47.78 13.94 90.745 41.827 128.906 27.884 38.164 63.906 64.572 108.063 79.227 5.14.954 8.945.283 11.419-1.996 2.475-2.282 3.711-5.14 3.711-8.562 0-.571-.049-5.708-.144-15.417a2549.81 2549.81 0 01-.144-25.406l-6.567 1.136c-4.187.767-9.469 1.092-15.846 1-6.374-.089-12.991-.757-19.842-1.999-6.854-1.231-13.229-4.086-19.13-8.559-5.898-4.473-10.085-10.328-12.56-17.556l-2.855-6.57c-1.903-4.374-4.899-9.233-8.992-14.559-4.093-5.331-8.232-8.945-12.419-10.848l-1.999-1.431c-1.332-.951-2.568-2.098-3.711-3.429-1.142-1.331-1.997-2.663-2.568-3.997-.572-1.335-.098-2.43 1.427-3.289 1.525-.859 4.281-1.276 8.28-1.276l5.708.853c3.807.763 8.516 3.042 14.133 6.851 5.614 3.806 10.229 8.754 13.846 14.842 4.38 7.806 9.657 13.754 15.846 17.847 6.184 4.093 12.419 6.136 18.699 6.136 6.28 0 11.704-.476 16.274-1.423 4.565-.952 8.848-2.383 12.847-4.285 1.713-12.758 6.377-22.559 13.988-29.41-10.848-1.14-20.601-2.857-29.264-5.14-8.658-2.286-17.605-5.996-26.835-11.14-9.235-5.137-16.896-11.516-22.985-19.126-6.09-7.614-11.088-17.61-14.987-29.979-3.901-12.374-5.852-26.648-5.852-42.826 0-23.035 7.52-42.637 22.557-58.817-7.044-17.318-6.379-36.732 1.997-58.24 5.52-1.715 13.706-.428 24.554 3.853 10.85 4.283 18.794 7.952 23.84 10.994 5.046 3.041 9.089 5.618 12.135 7.708 17.705-4.947 35.976-7.421 54.818-7.421s37.117 2.474 54.823 7.421l10.849-6.849c7.419-4.57 16.18-8.758 26.262-12.565 10.088-3.805 17.802-4.853 23.134-3.138 8.562 21.509 9.325 40.922 2.279 58.24 15.036 16.18 22.559 35.787 22.559 58.817 0 16.178-1.958 30.497-5.853 42.966-3.9 12.471-8.941 22.457-15.125 29.979-6.191 7.521-13.901 13.85-23.131 18.986-9.232 5.14-18.182 8.85-26.84 11.136-8.662 2.286-18.415 4.004-29.263 5.146 9.894 8.562 14.842 22.077 14.842 40.539v60.237c0 3.422 1.19 6.279 3.572 8.562 2.379 2.279 6.136 2.95 11.276 1.995 44.163-14.653 80.185-41.062 108.068-79.226 27.88-38.161 41.825-81.126 41.825-128.906-.01-39.771-9.818-76.454-29.414-110.049z"
- />
- </svg>
- ),
- google: (props: LucideProps) => (
- <svg viewBox="0 0 24 24" {...props}>
- <path
- fill="currentColor"
- d="M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z"
- />
+ ></path>
</svg>
),
} as const;
diff --git a/apps/web/src/components/layout/header/app-header.tsx b/apps/web/src/components/layout/header/app-header.tsx
index e7baec0a6..9f8e23362 100644
--- a/apps/web/src/components/layout/header/app-header.tsx
+++ b/apps/web/src/components/layout/header/app-header.tsx
@@ -1,16 +1,16 @@
"use client";
import Link from "next/link";
+import { UserButton, useUser } from "@clerk/nextjs";
import { allChangelogs } from "contentlayer/generated";
import { ArrowUpRight } from "lucide-react";
-import { Button } from "@openstatus/ui";
+import { Button, Skeleton } from "@openstatus/ui";
import { Shell } from "@/components/dashboard/shell";
import { useCookieState } from "@/hooks/use-cookie-state";
import { AppTabs } from "./app-tabs";
import { Breadcrumbs } from "./breadcrumbs";
-import { UserNav } from "./user-nav";
const lastChangelog = allChangelogs
.sort(
@@ -20,6 +20,7 @@ const lastChangelog = allChangelogs
.pop();
export function AppHeader() {
+ const { isLoaded, isSignedIn } = useUser();
const [lastViewed, setLastViewed] = useCookieState(
"last-viewed-changelog",
new Date(0).toISOString(),
@@ -63,7 +64,12 @@ export function AppHeader() {
</Button>
</li>
</ul>
- <UserNav />
+ <div className="relative">
+ <Skeleton className="h-8 w-8 rounded-full" />
+ <div className="absolute inset-0">
+ {isLoaded && isSignedIn && <UserButton />}
+ </div>
+ </div>
</div>
</div>
<AppTabs />
diff --git a/apps/web/src/components/layout/header/user-nav.tsx b/apps/web/src/components/layout/header/user-nav.tsx
deleted file mode 100644
index 72063429b..000000000
--- a/apps/web/src/components/layout/header/user-nav.tsx
+++ /dev/null
@@ -1,64 +0,0 @@
-import Link from "next/link";
-import { useParams } from "next/navigation";
-import { useAuth, useUser } from "@clerk/nextjs";
-
-import {
- Avatar,
- AvatarFallback,
- AvatarImage,
- Button,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuGroup,
- DropdownMenuItem,
- DropdownMenuLabel,
- DropdownMenuSeparator,
- DropdownMenuTrigger,
- Skeleton,
-} from "@openstatus/ui";
-
-export function UserNav() {
- const { isLoaded, isSignedIn, user } = useUser();
- const { signOut } = useAuth();
- const { workspaceSlug } = useParams<{ workspaceSlug: string }>();
-
- if (!isLoaded || !isSignedIn) {
- return <Skeleton className="h-8 w-8 rounded-full" />;
- }
-
- return (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="ghost" className="relative h-8 w-8 rounded-full">
- <Avatar className="h-8 w-8">
- <AvatarImage src={user.imageUrl} alt={`${user.fullName}`} />
- <AvatarFallback></AvatarFallback>
- </Avatar>
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent className="w-56" align="end" forceMount>
- <DropdownMenuLabel className="font-normal">
- <div className="flex flex-col space-y-1">
- <p className="truncate text-sm font-medium leading-none">
- {user.fullName}
- </p>
- <p className="text-muted-foreground truncate text-xs leading-none">
- {user.emailAddresses?.[0].emailAddress}
- </p>
- </div>
- </DropdownMenuLabel>
- <DropdownMenuSeparator />
- <DropdownMenuGroup>
- <DropdownMenuItem asChild>
- <Link href={`/app/${workspaceSlug}/settings/billing`}>Billing</Link>
- </DropdownMenuItem>
- <DropdownMenuItem asChild>
- <Link href={`/app/${workspaceSlug}/settings/user`}>Profile</Link>
- </DropdownMenuItem>
- </DropdownMenuGroup>
- <DropdownMenuSeparator />
- <DropdownMenuItem onClick={() => signOut()}>Log out</DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- );
-}
diff --git a/apps/web/src/config/pages.ts b/apps/web/src/config/pages.ts
index 7c4b4f80f..a50c809c7 100644
--- a/apps/web/src/config/pages.ts
+++ b/apps/web/src/config/pages.ts
@@ -46,13 +46,6 @@ export const settingsPagesConfig: Page[] = [
icon: "sun",
segment: "appearance",
},
- {
- title: "User",
- description: "Profile settings for the user.",
- href: "/settings/user",
- icon: "user",
- segment: "user",
- },
];
export const monitorPagesConfig: Page[] = [