@stoker-platform/web-app 0.5.99 → 0.5.101

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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.101
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: hide Dashboard menu item when not needed
8
+
9
+ ## 0.5.100
10
+
11
+ ### Patch Changes
12
+
13
+ - feat: add search-all to titles context parameter
14
+ - @stoker-platform/node-client@0.5.57
15
+ - @stoker-platform/utils@0.5.48
16
+ - @stoker-platform/web-client@0.5.57
17
+
3
18
  ## 0.5.99
4
19
 
5
20
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.99",
3
+ "version": "0.5.101",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
@@ -51,9 +51,9 @@
51
51
  "@radix-ui/react-tooltip": "^1.2.8",
52
52
  "@react-google-maps/api": "^2.20.8",
53
53
  "@sentry/react": "^10.50.0",
54
- "@stoker-platform/node-client": "0.5.56",
55
- "@stoker-platform/utils": "0.5.47",
56
- "@stoker-platform/web-client": "0.5.56",
54
+ "@stoker-platform/node-client": "0.5.57",
55
+ "@stoker-platform/utils": "0.5.48",
56
+ "@stoker-platform/web-client": "0.5.57",
57
57
  "@tanstack/react-table": "^8.21.3",
58
58
  "@types/react": "18.3.13",
59
59
  "@types/react-dom": "18.3.1",
package/src/Record.tsx CHANGED
@@ -129,6 +129,7 @@ export const Record = ({ collection }: { collection: CollectionSchema }) => {
129
129
  async (data) => {
130
130
  if (!data) {
131
131
  setRecord(undefined)
132
+ setIsRouteLoading("-", location.pathname)
132
133
  return
133
134
  }
134
135
  if (!recordInitialised.current || liveUpdate || fieldLiveUpdate) {
@@ -160,6 +161,7 @@ export const Record = ({ collection }: { collection: CollectionSchema }) => {
160
161
  })
161
162
  if (!data) {
162
163
  setRecord(undefined)
164
+ setIsRouteLoading("-", location.pathname)
163
165
  return
164
166
  }
165
167
  deserializeTimestamps(data)
@@ -11,6 +11,7 @@ import {
11
11
  getLoadingState,
12
12
  getSome,
13
13
  subscribeMany,
14
+ tryPromise,
14
15
  } from "@stoker-platform/web-client"
15
16
  import { Query } from "./Collection"
16
17
  import { QueryConstraint, where, WhereFilterOp } from "firebase/firestore"
@@ -166,12 +167,7 @@ export function SearchAllResults({ collection, search }: { collection: Collectio
166
167
 
167
168
  useEffect(() => {
168
169
  const initialize = async () => {
169
- const collectionTitles = await getCachedConfigValue(customization, [
170
- "collections",
171
- labels.collection,
172
- "admin",
173
- "titles",
174
- ])
170
+ const collectionTitles = await tryPromise(customization.admin?.titles, ["search-all"])
175
171
  setTitle(collectionTitles?.collection || labels.collection)
176
172
  const icon = await getCachedConfigValue(customization, ["collections", labels.collection, "admin", "icon"])
177
173
  setIcon(icon)
package/src/Tenant.tsx CHANGED
@@ -12,7 +12,14 @@ import "./App.css"
12
12
  import { createElement, Suspense, useMemo, useEffect, useState, useCallback, useRef } from "react"
13
13
  import { Outlet, useNavigate, useLocation } from "react-router"
14
14
  import { collectionAccess, tryFunction } from "@stoker-platform/utils"
15
- import { Background, CollectionSchema, MenuGroup, MetaIcon, StokerCollection } from "@stoker-platform/types"
15
+ import {
16
+ Background,
17
+ CollectionSchema,
18
+ DashboardItem,
19
+ MenuGroup,
20
+ MetaIcon,
21
+ StokerCollection,
22
+ } from "@stoker-platform/types"
16
23
  import { useMode } from "./providers/ModeProvider"
17
24
  import {
18
25
  DropdownMenu,
@@ -107,6 +114,16 @@ function Tenant() {
107
114
  isGlobalCachePendingRef.current = isGlobalCachePending.size
108
115
  }, [isGlobalCachePending.size])
109
116
 
117
+ const dashboard = tryFunction(globalConfig.admin?.dashboard)
118
+ const hasDashboard = dashboard?.some((item: DashboardItem) => {
119
+ const collectionPermissions = permissions?.collections?.[item.collection]
120
+ if (!collectionPermissions) return false
121
+ return (
122
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
123
+ (!item.roles || item.roles?.includes(permissions.Role!)) && collectionAccess("Read", collectionPermissions)
124
+ )
125
+ })
126
+
110
127
  useEffect(() => {
111
128
  const getConfig = async () => {
112
129
  const appName = await getCachedConfigValue(globalConfig, ["global", "appName"])
@@ -166,6 +183,7 @@ function Tenant() {
166
183
  ])
167
184
  if (hidden) continue
168
185
  if (collection.parentCollection) continue
186
+ if (!hasCollectionAccess(collection)) continue
169
187
 
170
188
  sidebarMenu.push({
171
189
  title: collectionName,
@@ -174,7 +192,6 @@ function Tenant() {
174
192
  })
175
193
 
176
194
  if (!collectionsGrouped.includes(collectionName)) {
177
- if (!hasCollectionAccess(collection)) continue
178
195
  navbarMenu.push({
179
196
  title: collectionName,
180
197
  collections: [collectionName],
@@ -636,17 +653,19 @@ function Tenant() {
636
653
  </SheetTrigger>
637
654
  <SheetContent side="left" className="sm:max-w-xs overflow-y-auto">
638
655
  <nav className="grid gap-6 text-lg font-medium pt-12">
639
- <button
640
- className={
641
- window.location.pathname === "/"
642
- ? "flex items-center gap-4 px-2.5 text-foreground"
643
- : "flex items-center gap-4 px-2.5 text-muted-foreground hover:text-foreground"
644
- }
645
- onClick={() => runViewTransition(() => navigate("/"))}
646
- >
647
- <ChartBar className="h-5 w-5" />
648
- Dashboard
649
- </button>
656
+ {hasDashboard && (
657
+ <button
658
+ className={
659
+ window.location.pathname === "/"
660
+ ? "flex items-center gap-4 px-2.5 text-foreground"
661
+ : "flex items-center gap-4 px-2.5 text-muted-foreground hover:text-foreground"
662
+ }
663
+ onClick={() => runViewTransition(() => navigate("/"))}
664
+ >
665
+ <ChartBar className="h-5 w-5" />
666
+ Dashboard
667
+ </button>
668
+ )}
650
669
  {sidebarMenu.map((group) => {
651
670
  if (group.collections.length === 1) {
652
671
  const className = "flex items-center gap-4 px-2.5 text-primary"