@protobase/ui 0.62.4 → 0.62.5

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.
@@ -18,11 +18,13 @@ const useAccountPage = () => {
18
18
  const auth = useAuth();
19
19
  const { mcp, accountDeletion } = auth;
20
20
  const linkable = linkableProviders(auth).length > 0;
21
+ const mailboxes = auth.personalMail.length > 0;
21
22
  return useMemo(() => {
22
23
  if (!account) return void 0;
23
24
  const hidden = /* @__PURE__ */ new Set([
24
25
  ...mcp ? [] : ["ConnectedApps"],
25
26
  ...linkable ? [] : ["ConnectedAccounts"],
27
+ ...mailboxes ? [] : ["PersonalMail"],
26
28
  ...accountDeletion ? [] : ["DeleteAccount"]
27
29
  ]);
28
30
  return {
@@ -33,6 +35,7 @@ const useAccountPage = () => {
33
35
  account,
34
36
  mcp,
35
37
  linkable,
38
+ mailboxes,
36
39
  accountDeletion
37
40
  ]);
38
41
  };
@@ -34,4 +34,4 @@ const ConnectedAccountsBlock = () => {
34
34
  return linkable.length > 0 ? /* @__PURE__ */ jsx(Linked, { providers: linkable }) : null;
35
35
  };
36
36
  //#endregion
37
- export { ConnectedAccountsBlock, linkableProviders };
37
+ export { ConnectedAccountsBlock, linkableProviders, takeLinkError };
@@ -0,0 +1,36 @@
1
+ import { text } from "../messages.js";
2
+ import { useAuth } from "../../auth/auth-provider.js";
3
+ import { providerMessage } from "../../auth/auth-messages.js";
4
+ import { SignInProvidersSection } from "../sign-in-providers-section.js";
5
+ import { AccountLoading } from "./account-loading.js";
6
+ import { useAccountData } from "./use-account-data.js";
7
+ import { takeLinkError } from "./connected-accounts-block.js";
8
+ import { useCallback, useState } from "react";
9
+ import { jsx } from "react/jsx-runtime";
10
+ //#region src/account/blocks/personal-mail-block.tsx
11
+ const Mailboxes = ({ links }) => {
12
+ const { session, linkPersonalMail } = useAuth();
13
+ const { account } = session;
14
+ const [linkError] = useState(takeLinkError);
15
+ const { data: linked, error } = useAccountData(useCallback(() => account.linkedPersonalMail(links), [account, links]), text("couldNotReadMethods"));
16
+ if (!linked) return /* @__PURE__ */ jsx(AccountLoading, { error });
17
+ const connect = (id) => linkPersonalMail(links.find((link) => link.id === id));
18
+ return /* @__PURE__ */ jsx(SignInProvidersSection, {
19
+ title: text("mailbox"),
20
+ description: text("mailboxDescription"),
21
+ providers: links.map(({ id, name }) => ({
22
+ id,
23
+ name
24
+ })),
25
+ linked,
26
+ onConnect: connect,
27
+ error: linkError && providerMessage(linkError, links.length === 1 ? links[0].name : text("theProvider"))
28
+ });
29
+ };
30
+ /** The `PersonalMail` block: the mailboxes the signed-in person can link for the app to send mail from, hidden when the app has none. */
31
+ const PersonalMailBlock = () => {
32
+ const { personalMail } = useAuth();
33
+ return personalMail.length > 0 ? /* @__PURE__ */ jsx(Mailboxes, { links: personalMail }) : null;
34
+ };
35
+ //#endregion
36
+ export { PersonalMailBlock };
@@ -71,6 +71,8 @@ const text = defineMessages({
71
71
  connectedAccountsDescription: "Sign in with these instead of your password. Connecting one asks you to sign in there; its address may differ from yours here.",
72
72
  connected: "Connected",
73
73
  connect: (name) => `Connect ${name}`,
74
+ mailbox: "Mailbox",
75
+ mailboxDescription: "Mail this app sends for you goes out from your own mailbox. Connecting one asks you to sign in there and allow sending mail; it cannot read your mail.",
74
76
  stopped: (time) => `Stopped ${time}`,
75
77
  ended: (time) => `Ended ${time}`,
76
78
  signedInUntil: (time) => `Signed in until ${time}`,
@@ -234,6 +236,8 @@ const text = defineMessages({
234
236
  connectedAccountsDescription: "Log hiermee in in plaats van met je wachtwoord. Koppelen vraagt je daar in te loggen; het adres daar kan anders zijn dan hier.",
235
237
  connected: "Gekoppeld",
236
238
  connect: (name) => `${name} koppelen`,
239
+ mailbox: "Mailbox",
240
+ mailboxDescription: "Mail die deze app voor je verstuurt, gaat uit vanuit je eigen mailbox. Koppelen vraagt je daar in te loggen en het versturen van mail toe te staan; je mail lezen kan de app niet.",
237
241
  stopped: (time) => `Gestopt ${time}`,
238
242
  ended: (time) => `Afgelopen ${time}`,
239
243
  signedInUntil: (time) => `Ingelogd tot ${time}`,
@@ -9,7 +9,7 @@ import { AuthError } from "@protobase/client";
9
9
  import { jsx, jsxs } from "react/jsx-runtime";
10
10
  //#region src/account/sign-in-providers-section.tsx
11
11
  /** The providers someone can sign in with besides a password, and a way to connect one whatever address it has. */
12
- const SignInProvidersSection = ({ providers, linked, onConnect, error: returned }) => {
12
+ const SignInProvidersSection = ({ providers, linked, onConnect, error: returned, title = text("connectedAccounts"), description = text("connectedAccountsDescription") }) => {
13
13
  const [busy, setBusy] = useState();
14
14
  const [error, setError] = useState(returned);
15
15
  const connect = async (provider) => {
@@ -24,8 +24,8 @@ const SignInProvidersSection = ({ providers, linked, onConnect, error: returned
24
24
  }
25
25
  };
26
26
  return /* @__PURE__ */ jsxs(AccountSection, {
27
- title: text("connectedAccounts"),
28
- description: text("connectedAccountsDescription"),
27
+ title,
28
+ description,
29
29
  children: [/* @__PURE__ */ jsx(SectionError, { message: error }), /* @__PURE__ */ jsx("ul", {
30
30
  className: "divide-y rounded-md border",
31
31
  children: providers.map((provider) => /* @__PURE__ */ jsxs("li", {
@@ -23,6 +23,7 @@ import { TableBlock } from "./blocks/table.js";
23
23
  import { TabBlock, TabsBlock } from "./blocks/tabs.js";
24
24
  import { UsersBlock } from "../../users/users-block.js";
25
25
  import { ConnectedAccountsBlock } from "../../account/blocks/connected-accounts-block.js";
26
+ import { PersonalMailBlock } from "../../account/blocks/personal-mail-block.js";
26
27
  import { ConnectedAppsBlock } from "../../account/blocks/connected-apps-block.js";
27
28
  import { DeleteAccountBlock } from "../../account/blocks/delete-account-block.js";
28
29
  import { DevicesBlock } from "../../account/blocks/devices-block.js";
@@ -61,6 +62,7 @@ const blocks = {
61
62
  Passkeys: PasskeysBlock,
62
63
  TwoFactor: TwoFactorBlock,
63
64
  ConnectedAccounts: ConnectedAccountsBlock,
65
+ PersonalMail: PersonalMailBlock,
64
66
  Devices: DevicesBlock,
65
67
  ConnectedApps: ConnectedAppsBlock,
66
68
  DeleteAccount: DeleteAccountBlock
@@ -31,6 +31,7 @@ const AuthProvider = ({ session: given, origin, nativeBridge, children }) => {
31
31
  const [passkeyDomains, setPasskeyDomains] = useState([]);
32
32
  const [socialProviders, setSocialProviders] = useState([]);
33
33
  const [platformSignIn, setPlatformSignIn] = useState();
34
+ const [personalMail, setPersonalMail] = useState([]);
34
35
  const [samlProviders, setSamlProviders] = useState([]);
35
36
  const [staffSignIn, setStaffSignIn] = useState();
36
37
  const [organizations, setOrganizations] = useState();
@@ -117,6 +118,7 @@ const AuthProvider = ({ session: given, origin, nativeBridge, children }) => {
117
118
  setPasskeyDomains(status.passkeyDomains ?? []);
118
119
  setSocialProviders(status.socialProviders);
119
120
  setPlatformSignIn(status.platformSignIn);
121
+ setPersonalMail(status.personalMail ?? []);
120
122
  setSamlProviders(status.samlProviders);
121
123
  setStaffSignIn(status.staffSignIn);
122
124
  setOrganizations(status.organizations);
@@ -183,6 +185,10 @@ const AuthProvider = ({ session: given, origin, nativeBridge, children }) => {
183
185
  linkProvider: async (provider) => {
184
186
  window.location.assign(await session.account.linkProvider(provider, new URL(withoutSignInLink(window.location.href), window.location.href).href));
185
187
  },
188
+ personalMail,
189
+ linkPersonalMail: async (link) => {
190
+ window.location.assign(await session.account.linkPersonalMail(link, new URL(withoutSignInLink(window.location.href), window.location.href).href));
191
+ },
186
192
  stopStaffSession: async () => {
187
193
  await push.forget();
188
194
  await session.staff.stop();
@@ -213,6 +219,7 @@ const AuthProvider = ({ session: given, origin, nativeBridge, children }) => {
213
219
  passkeyDomains,
214
220
  socialProviders,
215
221
  platformSignIn,
222
+ personalMail,
216
223
  samlProviders,
217
224
  staffSignIn,
218
225
  organizations,
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.62.4";
2
+ var version = "0.62.5";
3
3
  var protobase = { "pluginApi": 1 };
4
4
  //#endregion
5
5
  export { protobase, version };