Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
chore: last used login provider (#2081)
Maximilian Kaskeabde3967787e
diff --git a/apps/dashboard/src/app/(dashboard)/not-found.tsx b/apps/dashboard/src/app/(dashboard)/not-found.tsxindex 0ea7a7ffb..9ab3f9c60 100644--- a/apps/dashboard/src/app/(dashboard)/not-found.tsx+++ b/apps/dashboard/src/app/(dashboard)/not-found.tsx@@ -28,12 +28,12 @@ export default function NotFound() {className="rounded-md border border-border bg-background"side="bottom"/>- <div className="grid sm:grid-cols-2 gap-2">+ <div className="grid gap-2 sm:grid-cols-2">{quickLinks.map((link) => (<Linkkey={link.href}href={link.href}- className="flex items-center gap-2 rounded-md border border-border bg-background px-4 py-2 text-muted-foreground text-sm transition-colors hover:bg-accent hover:text-accent-foreground font-commit-mono"+ className="flex items-center gap-2 rounded-md border border-border bg-background px-4 py-2 font-commit-mono text-muted-foreground text-sm transition-colors hover:bg-accent hover:text-accent-foreground"><link.icon className="h-4 w-4" />{link.name}diff --git a/apps/dashboard/src/app/login/_components/login-button.tsx b/apps/dashboard/src/app/login/_components/login-button.tsxnew file mode 100644index 000000000..4ada8b5b0--- /dev/null+++ b/apps/dashboard/src/app/login/_components/login-button.tsx@@ -0,0 +1,53 @@+"use client";++import { Badge } from "@openstatus/ui/components/ui/badge";+import { Button } from "@openstatus/ui/components/ui/button";+import { cn } from "@openstatus/ui/lib/utils";+import { useEffect, useState } from "react";++const STORAGE_KEY = "openstatus:last-login-provider";++type Provider = "github" | "google" | "email";++export function LoginButton({+ provider,+ children,+ onClick,+ className,+ ...props+}: {+ provider: Provider;+} & React.ComponentProps<typeof Button>) {+ const [isLastUsed, setIsLastUsed] = useState(false);++ useEffect(() => {+ const lastUsed = localStorage.getItem(STORAGE_KEY);+ setIsLastUsed(lastUsed === provider);+ }, [provider]);++ return (+ <Button+ variant="secondary"+ className={cn(+ "relative w-full",+ isLastUsed && "border border-primary",+ className,+ )}+ onClick={(e) => {+ localStorage.setItem(STORAGE_KEY, provider);+ onClick?.(e);+ }}+ {...props}+ >+ {children}+ {isLastUsed ? (+ <Badge+ variant="secondary"+ className="-top-2.5 -right-2.5 absolute border border-primary bg-background text-[10px]"+ >+ Last used+ </Badge>+ ) : null}+ </Button>+ );+}diff --git a/apps/dashboard/src/app/login/_components/magic-link-form.tsx b/apps/dashboard/src/app/login/_components/magic-link-form.tsxindex c79075779..29388fe14 100644--- a/apps/dashboard/src/app/login/_components/magic-link-form.tsx+++ b/apps/dashboard/src/app/login/_components/magic-link-form.tsx@@ -2,11 +2,11 @@import { useFormStatus } from "react-dom";-import { Button } from "@openstatus/ui/components/ui/button";import { Input } from "@openstatus/ui/components/ui/input";import { Label } from "@openstatus/ui/components/ui/label";import { toast } from "sonner";import { signInWithResendAction } from "./actions";+import { LoginButton } from "./login-button";/*** @deprecated - only to be used in development mode@@ -31,9 +31,9 @@ export default function MagicLinkForm() {<Label htmlFor="email">Email</Label><Input id="email" name="email" type="email" required /></div>- <Button variant="secondary" className="w-full">+ <LoginButton provider="email">{pending ? "Logging..." : "Log Magic Link"}- </Button>+ </LoginButton></form>);}diff --git a/apps/dashboard/src/app/login/page.tsx b/apps/dashboard/src/app/login/page.tsxindex da6b8b721..f20c35100 100644--- a/apps/dashboard/src/app/login/page.tsx+++ b/apps/dashboard/src/app/login/page.tsx@@ -4,9 +4,9 @@ import Link from "next/link";import { signIn } from "@/lib/auth";import { GitHubIcon } from "@openstatus/icons";import { GoogleIcon } from "@openstatus/icons";-import { Button } from "@openstatus/ui/components/ui/button";import { Separator } from "@openstatus/ui/components/ui/separator";import type { SearchParams } from "nuqs/server";+import { LoginButton } from "./_components/login-button";import MagicLinkForm from "./_components/magic-link-form";import { searchParamsCache } from "./search-params";@@ -37,10 +37,10 @@ export default async function Page(props: {Get started now. No credit card required.</p></div>- <div className="grid gap-3 p-4">+ <div className="grid gap-4 p-4">{process.env.NODE_ENV === "development" ||process.env.SELF_HOST === "true" ? (- <div className="grid gap-3">+ <div className="grid gap-4"><MagicLinkForm /><Separator /></div>@@ -52,9 +52,9 @@ export default async function Page(props: {}}className="w-full">- <Button type="submit" className="w-full">+ <LoginButton type="submit" provider="github">Sign in with GitHub <GitHubIcon className="ml-2 h-4 w-4" />- </Button>+ </LoginButton></form><formaction={async () => {@@ -63,9 +63,9 @@ export default async function Page(props: {}}className="w-full">- <Button type="submit" className="w-full" variant="outline">+ <LoginButton type="submit" provider="google">Sign in with Google <GoogleIcon className="ml-2 h-4 w-4" />- </Button>+ </LoginButton></form></div><p className="px-8 text-center text-muted-foreground text-sm">