@stoker-platform/web-app 0.5.57 → 0.5.59

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,19 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.59
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: improve permissions change logic
8
+ - Updated dependencies
9
+ - @stoker-platform/web-client@0.5.36
10
+
11
+ ## 0.5.58
12
+
13
+ ### Patch Changes
14
+
15
+ - feat: improve list metrics layout
16
+
3
17
  ## 0.5.57
4
18
 
5
19
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.57",
3
+ "version": "0.5.59",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
@@ -53,7 +53,7 @@
53
53
  "@sentry/react": "^10.47.0",
54
54
  "@stoker-platform/node-client": "0.5.38",
55
55
  "@stoker-platform/utils": "0.5.32",
56
- "@stoker-platform/web-client": "0.5.35",
56
+ "@stoker-platform/web-client": "0.5.36",
57
57
  "@tanstack/react-table": "^8.21.3",
58
58
  "@types/react": "18.3.13",
59
59
  "@types/react-dom": "18.3.1",
@@ -14,6 +14,7 @@ import {
14
14
  RelationField,
15
15
  RelationList,
16
16
  StokerCollection,
17
+ StokerPermissions,
17
18
  StokerRecord,
18
19
  StokerRole,
19
20
  } from "@stoker-platform/types"
@@ -30,6 +31,7 @@ import {
30
31
  GetSomeOptions,
31
32
  getTimezone,
32
33
  keepTimezone,
34
+ onStokerPermissionsChange,
33
35
  onStokerSignOut,
34
36
  subscribeMany,
35
37
  SubscribeManyOptions,
@@ -153,7 +155,7 @@ function Collection({
153
155
  const schema = getSchema()
154
156
  const customization = getCollectionConfigModule(labels.collection)
155
157
  const timezone = getTimezone()
156
- const permissions = getCurrentUserPermissions()
158
+ const [permissions, setPermissions] = useState<StokerPermissions | null>(() => getCurrentUserPermissions())
157
159
  if (!permissions?.Role) throw new Error("PERMISSION_DENIED")
158
160
  const { toast } = useToast()
159
161
 
@@ -236,6 +238,13 @@ function Collection({
236
238
 
237
239
  const preventChange = isRouteLoadingImmediate.has(location.pathname)
238
240
 
241
+ useEffect(() => {
242
+ const unsubscribe = onStokerPermissionsChange(() => {
243
+ setPermissions(getCurrentUserPermissions())
244
+ })
245
+ return unsubscribe
246
+ }, [])
247
+
239
248
  const onTabChange = useCallback((value: string) => {
240
249
  Object.values(unsubscribe.current).forEach((unsubscribe) => unsubscribe.forEach((unsubscribe) => unsubscribe()))
241
250
  unsubscribe.current = {}
@@ -1333,7 +1342,7 @@ function Collection({
1333
1342
  }, [calendarConfig, schema])
1334
1343
 
1335
1344
  const canAddRecords =
1336
- permissions.collections?.[labels.collection].operations.includes("Create") &&
1345
+ permissions.collections?.[labels.collection]?.operations.includes("Create") &&
1337
1346
  !hasEntityRestrictions.some((entityRestriction) => entityRestriction.type === "Individual") &&
1338
1347
  !disableCreate
1339
1348
  const isCreateDisabled = getConnectionStatus() === "Offline" && (isOfflineDisabled || serverWriteOnly)
@@ -1641,6 +1650,8 @@ function Collection({
1641
1650
  [recordTitle],
1642
1651
  )
1643
1652
 
1653
+ if (!permissions.collections?.[labels.collection]) return null
1654
+
1644
1655
  return (
1645
1656
  !collection.singleton && (
1646
1657
  <>
@@ -1895,7 +1906,7 @@ function Collection({
1895
1906
  (action) => !action.condition || action.condition(),
1896
1907
  ) ? (
1897
1908
  <DropdownMenu>
1898
- <DropdownMenuTrigger>
1909
+ <DropdownMenuTrigger asChild>
1899
1910
  <Button
1900
1911
  type="button"
1901
1912
  size="sm"
package/src/List.tsx CHANGED
@@ -1320,8 +1320,9 @@ export function List({
1320
1320
  >
1321
1321
  <CardContent>
1322
1322
  {metrics && hasMetrics && !relationList && (
1323
- <div className="hidden lg:flex flex-row gap-4 mb-4 mt-4">
1323
+ <div className="hidden lg:flex flex-row gap-4 mb-4 mt-4 max-w-[calc(100vw-96px)]">
1324
1324
  {metrics.map((metric: Metric | Chart, index: number) => {
1325
+ const hideThirdMetric = index >= 2 ? "hidden xl:grid" : undefined
1325
1326
  if (
1326
1327
  permissions?.Role &&
1327
1328
  (!metric.roles || metric.roles.includes(permissions?.Role))
@@ -1337,7 +1338,7 @@ export function List({
1337
1338
  return (
1338
1339
  <div
1339
1340
  key={`metric-${index}`}
1340
- className="grid gap-3 place-content-center"
1341
+ className={cn("grid gap-3 place-content-center", hideThirdMetric)}
1341
1342
  >
1342
1343
  <Card className="p-4 pt-6 pb-6 h-[175px] min-w-[175px] flex flex-col place-content-center items-center bg-blue-500 dark:bg-blue-500/50 text-primary-foreground dark:text-primary">
1343
1344
  <div className="relative bottom-2">
@@ -2,12 +2,17 @@ import { flushSync } from "react-dom"
2
2
 
3
3
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
4
  export const runViewTransition = (callback: () => any) => {
5
- if (document.startViewTransition) {
6
- document.startViewTransition(() => {
7
- flushSync(() => {
8
- callback()
5
+ if (document.startViewTransition && document.visibilityState === "visible") {
6
+ try {
7
+ const transition = document.startViewTransition(() => {
8
+ flushSync(() => {
9
+ callback()
10
+ })
9
11
  })
10
- })
12
+ transition.finished.catch(() => {})
13
+ } catch {
14
+ callback()
15
+ }
11
16
  } else {
12
17
  callback()
13
18
  }