@protobase/ui 0.63.1 → 0.63.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -148,7 +148,10 @@ const useAuthPage = (workspace, children) => {
148
148
  children: text("tryAgain")
149
149
  })]
150
150
  });
151
- case "needs-admin": return /* @__PURE__ */ jsx(FirstRunPage, { onCheckAgain: recheck });
151
+ case "needs-admin": return /* @__PURE__ */ jsx(FirstRunPage, {
152
+ firstAdminUrl: state.firstAdminUrl,
153
+ onCheckAgain: recheck
154
+ });
152
155
  }
153
156
  if (state.kind === "signed-in" && address) return /* @__PURE__ */ jsx(Redirect, { to: next ?? "/" });
154
157
  if (page.kind === "reset-password") return /* @__PURE__ */ jsx(ResetPasswordPage, {
@@ -125,7 +125,10 @@ const AuthProvider = ({ session: given, origin, nativeBridge, children }) => {
125
125
  setAnonymous(Boolean(status.anonymous));
126
126
  setBeforeSignIn(status.plugins ?? []);
127
127
  setLocale(status.locale);
128
- if (status.needsAdmin) return setState({ kind: "needs-admin" });
128
+ if (status.needsAdmin) return setState({
129
+ kind: "needs-admin",
130
+ ...status.firstAdminUrl && { firstAdminUrl: status.firstAdminUrl }
131
+ });
129
132
  const user = await session.session();
130
133
  return user ? enter(user) : setState({ kind: status.anonymous ? "visitor" : "signed-out" });
131
134
  }).catch((error) => setState({
@@ -1,52 +1,61 @@
1
1
  import { text } from "./messages.js";
2
- import { Button } from "../primitives/button.js";
2
+ import { cn } from "../lib/cn.js";
3
+ import { Button, buttonClass } from "../primitives/button.js";
3
4
  import { AuthLayout } from "./auth-layout.js";
4
5
  import { useState } from "react";
5
- import { Check, Copy } from "lucide-react";
6
- import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { Check, Copy, ExternalLink } from "lucide-react";
7
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
8
  //#region src/auth/first-run-page.tsx
8
9
  const createAdminCommand = "protobase users create you@example.com";
9
10
  /**
10
11
  * Shown while the admin store has no user. Accounts are not created over the web (a fresh URL must not be claimable
11
- * by whoever reaches it first), so this says how to create the first admin on the host.
12
+ * by whoever reaches it first), so this says how to create the first admin on the host, or, with `firstAdminUrl`,
13
+ * links to the platform's page where it is added, since nobody hosted there can run the command.
12
14
  */
13
- const FirstRunPage = ({ command = createAdminCommand, onCheckAgain, busy }) => {
15
+ const FirstRunPage = ({ command = createAdminCommand, firstAdminUrl, onCheckAgain, busy }) => /* @__PURE__ */ jsxs(AuthLayout, {
16
+ title: text("noAdminTitle"),
17
+ description: text("noAdminDescription"),
18
+ children: [firstAdminUrl ? /* @__PURE__ */ jsx(ConsoleLink, { url: firstAdminUrl }) : /* @__PURE__ */ jsx(CommandBox, { command }), /* @__PURE__ */ jsx(Button, {
19
+ variant: firstAdminUrl ? "secondary" : "primary",
20
+ className: "mt-4 min-h-10 w-full",
21
+ loading: busy,
22
+ onClick: onCheckAgain,
23
+ children: text("reload")
24
+ })]
25
+ });
26
+ const ConsoleLink = ({ url }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("p", {
27
+ className: "text-muted-foreground",
28
+ children: text("firstAdminExplanation")
29
+ }), /* @__PURE__ */ jsxs("a", {
30
+ href: url,
31
+ target: "_blank",
32
+ rel: "noopener noreferrer",
33
+ className: cn(buttonClass({ variant: "primary" }), "mt-4 min-h-10 w-full"),
34
+ children: [text("firstAdminLink"), /* @__PURE__ */ jsx(ExternalLink, { className: "size-4" })]
35
+ })] });
36
+ const CommandBox = ({ command }) => {
14
37
  const [copied, setCopied] = useState(false);
15
- return /* @__PURE__ */ jsxs(AuthLayout, {
16
- title: text("noAdminTitle"),
17
- description: text("noAdminDescription"),
18
- children: [
19
- /* @__PURE__ */ jsx("p", {
20
- className: "text-muted-foreground",
21
- children: text("noAdminExplanation")
22
- }),
23
- /* @__PURE__ */ jsxs("div", {
24
- className: "mt-4 flex items-center gap-2 rounded-md border bg-surface py-1.5 pl-3 pr-1.5",
25
- children: [/* @__PURE__ */ jsx("code", {
26
- className: "min-w-0 flex-1 break-all font-mono text-xs",
27
- children: command
28
- }), /* @__PURE__ */ jsx("button", {
29
- type: "button",
30
- "aria-label": text("copyCommand"),
31
- onClick: () => {
32
- navigator.clipboard.writeText(command).then(() => {
33
- setCopied(true);
34
- setTimeout(() => setCopied(false), 2e3);
35
- });
36
- },
37
- className: "inline-flex size-8 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted pointer-coarse:size-11",
38
- children: copied ? /* @__PURE__ */ jsx(Check, { className: "size-4 text-success" }) : /* @__PURE__ */ jsx(Copy, { className: "size-4" })
39
- })]
40
- }),
41
- /* @__PURE__ */ jsx(Button, {
42
- variant: "primary",
43
- className: "mt-4 min-h-10 w-full",
44
- loading: busy,
45
- onClick: onCheckAgain,
46
- children: text("reload")
47
- })
48
- ]
49
- });
38
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("p", {
39
+ className: "text-muted-foreground",
40
+ children: text("noAdminExplanation")
41
+ }), /* @__PURE__ */ jsxs("div", {
42
+ className: "mt-4 flex items-center gap-2 rounded-md border bg-surface py-1.5 pl-3 pr-1.5",
43
+ children: [/* @__PURE__ */ jsx("code", {
44
+ className: "min-w-0 flex-1 break-all font-mono text-xs",
45
+ children: command
46
+ }), /* @__PURE__ */ jsx("button", {
47
+ type: "button",
48
+ "aria-label": text("copyCommand"),
49
+ onClick: () => {
50
+ navigator.clipboard.writeText(command).then(() => {
51
+ setCopied(true);
52
+ setTimeout(() => setCopied(false), 2e3);
53
+ });
54
+ },
55
+ className: "inline-flex size-8 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted pointer-coarse:size-11",
56
+ children: copied ? /* @__PURE__ */ jsx(Check, { className: "size-4 text-success" }) : /* @__PURE__ */ jsx(Copy, { className: "size-4" })
57
+ })]
58
+ })] });
50
59
  };
51
60
  //#endregion
52
61
  export { FirstRunPage, createAdminCommand };
@@ -29,6 +29,8 @@ const text = defineMessages({
29
29
  noAdminDescription: "This Protobase has no users to sign in with.",
30
30
  noAdminExplanation: "Run this in the terminal where Protobase runs, then reload. The first admin is created on the server, not in the browser, so nobody else can claim a fresh URL.",
31
31
  copyCommand: "Copy command",
32
+ firstAdminExplanation: "The first user is added in the Protobase Cloud console, not in the browser, so nobody else can claim a fresh URL. Add yourself there, then reload.",
33
+ firstAdminLink: "Add your first user in the Protobase Cloud console",
32
34
  reload: "Reload",
33
35
  tooManyRequests: "Too many requests. Wait a minute and try again.",
34
36
  tooManyAttempts: "Too many attempts. Wait a minute and try again.",
@@ -127,6 +129,8 @@ const text = defineMessages({
127
129
  noAdminDescription: "Deze Protobase heeft geen gebruikers om mee in te loggen.",
128
130
  noAdminExplanation: "Voer dit uit in de terminal waar Protobase draait en laad de pagina daarna opnieuw. De eerste beheerder wordt op de server gemaakt, niet in de browser, zodat niemand anders een nieuwe URL kan opeisen.",
129
131
  copyCommand: "Opdracht kopiëren",
132
+ firstAdminExplanation: "De eerste gebruiker wordt in de Protobase Cloud-console toegevoegd, niet in de browser, zodat niemand anders een nieuwe URL kan opeisen. Voeg jezelf daar toe en laad de pagina daarna opnieuw.",
133
+ firstAdminLink: "Voeg je eerste gebruiker toe in de Protobase Cloud-console",
130
134
  reload: "Opnieuw laden",
131
135
  tooManyRequests: "Te veel verzoeken. Wacht een minuut en probeer het opnieuw.",
132
136
  tooManyAttempts: "Te veel pogingen. Wacht een minuut en probeer het opnieuw.",
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.63.1";
2
+ var version = "0.63.3";
3
3
  var protobase = { "pluginApi": 1 };
4
4
  //#endregion
5
5
  export { protobase, version };