@protobase/ui 0.45.11 → 0.45.12

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.
package/dist/app/app.js CHANGED
@@ -47,6 +47,7 @@ import { OrganizationPage } from "../organizations/organization-page.js";
47
47
  import { OrganizationsPage } from "../organizations/organizations-page.js";
48
48
  import { actingUser } from "../roles/acting-user.js";
49
49
  import { useActiveRole } from "../roles/use-active-role.js";
50
+ import { startAddress } from "./start-address.js";
50
51
  import { ProjectLogo } from "./project-logo.js";
51
52
  import { PluginGate, usePluginsOff } from "../plugins/plugin-gate.js";
52
53
  import { PluginNotice } from "../plugins/plugin-notice.js";
@@ -59,7 +60,7 @@ import { NewVersionToast } from "./new-version/new-version-toast.js";
59
60
  import { RuntimeUpdateButton } from "./runtime/runtime-update.js";
60
61
  import { StaffBanner } from "./staff-banner.js";
61
62
  import { useNavRecent } from "./use-nav-recent.js";
62
- import { useCallback, useEffect, useState } from "react";
63
+ import { useCallback, useEffect, useMemo, useState } from "react";
63
64
  import { viewOfList } from "@protobase/schema/internal";
64
65
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
65
66
  import { connectRoute } from "@protobase/schema";
@@ -93,23 +94,13 @@ const Routes = ({ workspace, sidebarMode, assistant, runtime }) => {
93
94
  });
94
95
  useLiveUpdates(meta);
95
96
  const groups = navFromMeta(meta, basePath, recent);
96
- const firstPage = Object.keys(meta.pages)[0];
97
- const firstResource = Object.keys(meta.resources)[0];
97
+ const start = useMemo(() => startAddress(meta), [meta]);
98
98
  const page = address?.kind === "page" ? meta.pages[address.page] : void 0;
99
99
  useEffect(() => {
100
- if (path !== "/") return;
101
- if (firstPage) go({
102
- kind: "page",
103
- page: firstPage
104
- }, { replace: true });
105
- else if (firstResource) go({
106
- kind: "list",
107
- resource: firstResource
108
- }, { replace: true });
100
+ if (path === "/" && start) go(start, { replace: true });
109
101
  }, [
110
102
  path,
111
- firstPage,
112
- firstResource,
103
+ start,
113
104
  go
114
105
  ]);
115
106
  const resource = address?.kind === "page" ? void 0 : address?.resource;
@@ -0,0 +1,33 @@
1
+ import { navFromMeta } from "./nav-from-meta.js";
2
+ //#region src/app/start-address.ts
3
+ /**
4
+ * Where the app opens at `/`: the first sidebar entry the caller sees that opens what it names; with none, the first
5
+ * page, else the first resource's list.
6
+ */
7
+ const startAddress = (meta) => {
8
+ const first = navFromMeta(meta).flatMap((group) => group.items).find((item) => !item.problem);
9
+ if (first && meta.pages[first.id]) return {
10
+ kind: "page",
11
+ page: first.id
12
+ };
13
+ if (first) {
14
+ const [resource, list] = first.id.split("/");
15
+ return {
16
+ kind: "list",
17
+ resource,
18
+ ...list !== void 0 && { list }
19
+ };
20
+ }
21
+ const firstPage = Object.keys(meta.pages)[0];
22
+ if (firstPage) return {
23
+ kind: "page",
24
+ page: firstPage
25
+ };
26
+ const firstResource = Object.keys(meta.resources)[0];
27
+ return firstResource ? {
28
+ kind: "list",
29
+ resource: firstResource
30
+ } : void 0;
31
+ };
32
+ //#endregion
33
+ export { startAddress };
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.45.11";
2
+ var version = "0.45.12";
3
3
  var protobase = { "pluginApi": 1 };
4
4
  //#endregion
5
5
  export { protobase, version };