@stoker-platform/web-app 0.5.89 → 0.5.91

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,10 +1,24 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.91
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: minor fixes to Dashboard and Form
8
+
9
+ ## 0.5.90
10
+
11
+ ### Patch Changes
12
+
13
+ - fix: provide form values to filterValues
14
+ - fix: show title field in relation field
15
+ - feat: use list label for CSV column name
16
+
3
17
  ## 0.5.89
4
18
 
5
19
  ### Patch Changes
6
20
 
7
- - feat: keep all list metrics when chart present
21
+ - feat: keep all list metrics when no chart present
8
22
 
9
23
  ## 0.5.88
10
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.89",
3
+ "version": "0.5.91",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
package/src/Dashboard.tsx CHANGED
@@ -15,7 +15,7 @@ import { preloadCacheEnabled } from "./utils/preloadCacheEnabled"
15
15
  import { DashboardReminder } from "./DashboardReminder"
16
16
  import { cn } from "./lib/utils"
17
17
  import { Helmet } from "react-helmet"
18
- import { getField } from "@stoker-platform/utils"
18
+ import { collectionAccess, getField } from "@stoker-platform/utils"
19
19
 
20
20
  export const Dashboard = () => {
21
21
  const globalConfig = getGlobalConfigModule()
@@ -43,7 +43,13 @@ export const Dashboard = () => {
43
43
  setCollectionTitles((prev) => ({ ...prev, [labels.collection]: titles?.collection }))
44
44
  }
45
45
  const metrics = await getCachedConfigValue(globalConfig, ["global", "admin", "dashboard"])
46
- setMetrics(metrics)
46
+ setMetrics(
47
+ metrics.filter((metric: DashboardItem) => {
48
+ const collectionPermissions = permissions?.collections?.[metric.collection]
49
+ if (!collectionPermissions) return false
50
+ return collectionAccess("Read", collectionPermissions)
51
+ }),
52
+ )
47
53
  }
48
54
  initialize()
49
55
  }, [])
package/src/Form.tsx CHANGED
@@ -578,7 +578,11 @@ function StringField({
578
578
  ?.filter(
579
579
  (option) =>
580
580
  !fieldCustomization.admin?.filterValues ||
581
- fieldCustomization.admin?.filterValues?.(option, collection, record),
581
+ fieldCustomization.admin?.filterValues?.(
582
+ option,
583
+ collection,
584
+ record || (form.getValues() as StokerRecord),
585
+ ),
582
586
  )
583
587
  .map((option) => (
584
588
  <div key={option} className="flex items-center space-x-2">
@@ -630,7 +634,11 @@ function StringField({
630
634
  ?.filter(
631
635
  (option) =>
632
636
  !fieldCustomization.admin?.filterValues ||
633
- fieldCustomization.admin?.filterValues?.(option, collection, record),
637
+ fieldCustomization.admin?.filterValues?.(
638
+ option,
639
+ collection,
640
+ record || (form.getValues() as StokerRecord),
641
+ ),
634
642
  )
635
643
  .map((option) => {
636
644
  return (
@@ -688,7 +696,11 @@ function StringField({
688
696
  ?.filter(
689
697
  (option) =>
690
698
  !fieldCustomization.admin?.filterValues ||
691
- fieldCustomization.admin?.filterValues?.(option, collection, record),
699
+ fieldCustomization.admin?.filterValues?.(
700
+ option,
701
+ collection,
702
+ record || (form.getValues() as StokerRecord),
703
+ ),
692
704
  )
693
705
  .map((option) => (
694
706
  <SelectItem key={option} value={option}>
@@ -1041,7 +1053,11 @@ function NumberField({
1041
1053
  ?.filter(
1042
1054
  (option) =>
1043
1055
  !fieldCustomization.admin?.filterValues ||
1044
- fieldCustomization.admin?.filterValues?.(option, collection, record),
1056
+ fieldCustomization.admin?.filterValues?.(
1057
+ option,
1058
+ collection,
1059
+ record || (form.getValues() as StokerRecord),
1060
+ ),
1045
1061
  )
1046
1062
  .map((option) => (
1047
1063
  <SelectItem key={option} value={option.toString()}>
@@ -1816,7 +1832,10 @@ function RelationField({
1816
1832
  if (fieldCustomization.admin?.modifyResultTitle) {
1817
1833
  setDisplay(fieldCustomization.admin.modifyResultTitle(relationRecord, collection, record))
1818
1834
  } else {
1819
- setDisplay(relationRecord[relationCollection.recordTitleField || "id"] || relationId)
1835
+ setDisplay(
1836
+ relationRecord[field.titleField || relationCollection.recordTitleField || "id"] ||
1837
+ relationId,
1838
+ )
1820
1839
  }
1821
1840
  } else {
1822
1841
  setDisplay(relationId)
@@ -2247,7 +2266,11 @@ function RelationField({
2247
2266
  collection,
2248
2267
  record,
2249
2268
  )
2250
- : relation[relationCollection.recordTitleField || "id"]}
2269
+ : relation[
2270
+ (field as RelationFieldType).titleField ||
2271
+ relationCollection.recordTitleField ||
2272
+ "id"
2273
+ ]}
2251
2274
  </span>
2252
2275
  </Button>
2253
2276
  <Button
@@ -3193,7 +3216,7 @@ function RecordForm({
3193
3216
  (restriction) => restriction.userRole === permissions.Role && restriction.recordRole.includes(role),
3194
3217
  )
3195
3218
  )
3196
- }, [permissions, record])
3219
+ }, [permissions, record, form.watch("Role")])
3197
3220
 
3198
3221
  useEffect(() => {
3199
3222
  const load = async () => {
@@ -38,7 +38,10 @@ export const prepareCSVData = (collection: CollectionSchema, data: any[]) => {
38
38
  if (field.name === softDelete?.timestampField) continue
39
39
  if (collection.auth && field.name === "User_ID") continue
40
40
  const fieldCustomization = getFieldCustomization(field, customization)
41
- const label = tryFunction(fieldCustomization.admin?.label) || field.name
41
+ const label =
42
+ tryFunction(fieldCustomization.admin?.listLabel) ||
43
+ tryFunction(fieldCustomization.admin?.label) ||
44
+ field.name
42
45
  const noExport = tryFunction(fieldCustomization.admin?.noExport) || false
43
46
  if (noExport) continue
44
47
  CSVData.headers.push({ label: escapeCSVField(label), key: field.name })