@stoker-platform/web-app 0.5.79 → 0.5.81

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,24 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.81
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: use single args object for hooks
8
+ - feat: add relation list constraints option
9
+ - Updated dependencies
10
+ - @stoker-platform/node-client@0.5.46
11
+ - @stoker-platform/utils@0.5.38
12
+ - @stoker-platform/web-client@0.5.45
13
+
14
+ ## 0.5.80
15
+
16
+ ### Patch Changes
17
+
18
+ - fix: improve board card header padding
19
+ - fix: account for excluded status values
20
+ - fix: fix photo upload closure issue
21
+
3
22
  ## 0.5.79
4
23
 
5
24
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.79",
3
+ "version": "0.5.81",
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.47.0",
54
- "@stoker-platform/node-client": "0.5.45",
55
- "@stoker-platform/utils": "0.5.37",
56
- "@stoker-platform/web-client": "0.5.44",
54
+ "@stoker-platform/node-client": "0.5.46",
55
+ "@stoker-platform/utils": "0.5.38",
56
+ "@stoker-platform/web-client": "0.5.45",
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/Cards.tsx CHANGED
@@ -218,7 +218,13 @@ function CardItem({ index, style, data }: CardItemProps) {
218
218
  )}
219
219
  onClick={() => goToRecord(collection, record)}
220
220
  >
221
- <div id={`${statusValue}-${record.id}-header`} className="grid gap-0.5 p-6">
221
+ <div
222
+ id={`${statusValue}-${record.id}-header`}
223
+ className={cn(
224
+ "grid gap-0.5 p-6",
225
+ ((!isPending && !isDisabled && hasUpdateAccess) || isPending) && "pr-0",
226
+ )}
227
+ >
222
228
  <button
223
229
  className={cn(
224
230
  titleClass,
@@ -255,7 +261,7 @@ function CardItem({ index, style, data }: CardItemProps) {
255
261
  </div>
256
262
  )
257
263
  ) : (
258
- <div className="ml-auto relative bottom-1.5 p-6">
264
+ <div className="ml-auto relative bottom-1.5 p-6 pl-4">
259
265
  <LoadingSpinner size={7} />
260
266
  </div>
261
267
  )}
@@ -424,7 +424,7 @@ function Collection({
424
424
  const getKeysLength = useCallback(() => {
425
425
  let length = 1
426
426
  if (tab === "cards") {
427
- length = statusValues.current?.length || 1
427
+ length = (statusValues.current?.length || 1) - (cardsConfig?.excludeValues?.length || 0)
428
428
  if (!isPreloadCacheEnabled && !isServerReadOnly) {
429
429
  length++
430
430
  }
package/src/Files.tsx CHANGED
@@ -268,16 +268,16 @@ export const RecordFiles = ({ collection, record }: FilesProps) => {
268
268
  }
269
269
 
270
270
  try {
271
- await runHooks("preFileAdd", globalConfig, customization, [
271
+ await runHooks("preFileAdd", globalConfig, customization, {
272
272
  record,
273
- filePath,
273
+ fullPath: filePath,
274
274
  filename,
275
- {
275
+ permissions: {
276
276
  read: metadata.customMetadata.read,
277
277
  update: metadata.customMetadata.update,
278
278
  delete: metadata.customMetadata.delete,
279
279
  },
280
- ])
280
+ })
281
281
  } catch {
282
282
  setUploadProgress((prev) =>
283
283
  prev.map((item) => (item.file === file ? { ...item, status: "error" } : item)),
@@ -320,16 +320,16 @@ export const RecordFiles = ({ collection, record }: FilesProps) => {
320
320
  })
321
321
 
322
322
  try {
323
- await runHooks("postFileAdd", globalConfig, customization, [
323
+ await runHooks("postFileAdd", globalConfig, customization, {
324
324
  record,
325
- filePath,
325
+ fullPath: filePath,
326
326
  filename,
327
- {
327
+ permissions: {
328
328
  read: metadata.customMetadata.read,
329
329
  update: metadata.customMetadata.update,
330
330
  delete: metadata.customMetadata.delete,
331
331
  },
332
- ])
332
+ })
333
333
  } catch {
334
334
  return
335
335
  }
@@ -483,9 +483,9 @@ export const RecordFiles = ({ collection, record }: FilesProps) => {
483
483
  }
484
484
 
485
485
  try {
486
- await runHooks("preFileUpdate", globalConfig, customization, [
486
+ await runHooks("preFileUpdate", globalConfig, customization, {
487
487
  record,
488
- {
488
+ update: {
489
489
  type: "permissions",
490
490
  path: selectedFileForPermissions.fullPath,
491
491
  originalPermissions: {
@@ -499,7 +499,7 @@ export const RecordFiles = ({ collection, record }: FilesProps) => {
499
499
  delete: updatedMetadata.customMetadata.delete,
500
500
  },
501
501
  },
502
- ])
502
+ })
503
503
  } catch {
504
504
  return
505
505
  }
@@ -512,9 +512,9 @@ export const RecordFiles = ({ collection, record }: FilesProps) => {
512
512
  })
513
513
 
514
514
  try {
515
- await runHooks("postFileUpdate", globalConfig, customization, [
515
+ await runHooks("postFileUpdate", globalConfig, customization, {
516
516
  record,
517
- {
517
+ update: {
518
518
  type: "permissions",
519
519
  path: selectedFileForPermissions.fullPath,
520
520
  originalPermissions: {
@@ -528,7 +528,7 @@ export const RecordFiles = ({ collection, record }: FilesProps) => {
528
528
  delete: updatedMetadata.customMetadata.delete,
529
529
  },
530
530
  },
531
- ])
531
+ })
532
532
  } catch {
533
533
  return
534
534
  }
@@ -690,10 +690,10 @@ export const RecordFiles = ({ collection, record }: FilesProps) => {
690
690
  const metadata = await getMetadata(originalRef)
691
691
 
692
692
  try {
693
- await runHooks("preFileUpdate", globalConfig, customization, [
693
+ await runHooks("preFileUpdate", globalConfig, customization, {
694
694
  record,
695
- { type: "rename", oldPath: item.fullPath, newPath },
696
- ])
695
+ update: { type: "rename", oldPath: item.fullPath, newPath },
696
+ })
697
697
  } catch {
698
698
  return
699
699
  }
@@ -712,10 +712,10 @@ export const RecordFiles = ({ collection, record }: FilesProps) => {
712
712
  })
713
713
 
714
714
  try {
715
- await runHooks("postFileUpdate", globalConfig, customization, [
715
+ await runHooks("postFileUpdate", globalConfig, customization, {
716
716
  record,
717
- { type: "rename", oldPath: item.fullPath, newPath },
718
- ])
717
+ update: { type: "rename", oldPath: item.fullPath, newPath },
718
+ })
719
719
  } catch {
720
720
  return
721
721
  }
package/src/Form.tsx CHANGED
@@ -2541,16 +2541,16 @@ function RecordForm({
2541
2541
  }
2542
2542
 
2543
2543
  try {
2544
- await runHooks("preFileAdd", globalConfig, customization, [
2545
- targetRecord,
2546
- filePath,
2544
+ await runHooks("preFileAdd", globalConfig, customization, {
2545
+ record: targetRecord,
2546
+ fullPath: filePath,
2547
2547
  filename,
2548
- {
2548
+ permissions: {
2549
2549
  read: metadata.customMetadata.read,
2550
2550
  update: metadata.customMetadata.update,
2551
2551
  delete: metadata.customMetadata.delete,
2552
2552
  },
2553
- ])
2553
+ })
2554
2554
  } catch {
2555
2555
  continue
2556
2556
  }
@@ -2572,16 +2572,16 @@ function RecordForm({
2572
2572
  toast({ title: "Upload successful", description: `${filename} uploaded successfully` })
2573
2573
 
2574
2574
  try {
2575
- await runHooks("postFileAdd", globalConfig, customization, [
2576
- targetRecord,
2577
- filePath,
2575
+ await runHooks("postFileAdd", globalConfig, customization, {
2576
+ record: targetRecord,
2577
+ fullPath: filePath,
2578
2578
  filename,
2579
- {
2579
+ permissions: {
2580
2580
  read: metadata.customMetadata.read,
2581
2581
  update: metadata.customMetadata.update,
2582
2582
  delete: metadata.customMetadata.delete,
2583
2583
  },
2584
- ])
2584
+ })
2585
2585
  } catch {
2586
2586
  return
2587
2587
  }
@@ -2596,8 +2596,13 @@ function RecordForm({
2596
2596
  )
2597
2597
 
2598
2598
  const handlePermissionsConfirm = useCallback(
2599
- async (selectedPermissions: FilePermissions) => {
2600
- if (permissionsContext === "files") {
2599
+ async (
2600
+ selectedPermissions: FilePermissions,
2601
+ contextOverride?: "files" | "image-create" | "image-update",
2602
+ imageUpdateOverrides?: { pendingImage: { fieldName: string; file: File }; resolver: () => void },
2603
+ ) => {
2604
+ const context = contextOverride ?? permissionsContext
2605
+ if (context === "files") {
2601
2606
  if (isMultipleFileUpload) {
2602
2607
  if (pendingUploadFiles.length > 0) {
2603
2608
  setQueuedUploads((prev) => [
@@ -2627,7 +2632,7 @@ function RecordForm({
2627
2632
  return
2628
2633
  }
2629
2634
 
2630
- if (permissionsContext === "image-create") {
2635
+ if (context === "image-create") {
2631
2636
  if (!pendingUploadFile || !pendingImageFieldName) return
2632
2637
  setQueuedImageUploads((prev) => ({
2633
2638
  ...prev,
@@ -2642,9 +2647,11 @@ function RecordForm({
2642
2647
  return
2643
2648
  }
2644
2649
 
2645
- if (permissionsContext === "image-update") {
2646
- if (!pendingImageForUpdate || !id || !currentUser) return
2647
- const { fieldName, file } = pendingImageForUpdate
2650
+ if (context === "image-update") {
2651
+ const effectivePendingImage = imageUpdateOverrides?.pendingImage ?? pendingImageForUpdate
2652
+ const effectiveResolver = imageUpdateOverrides?.resolver ?? imageUpdateResolver
2653
+ if (!effectivePendingImage || !id || !currentUser) return
2654
+ const { fieldName, file } = effectivePendingImage
2648
2655
  const basePath = computeBasePath(id)
2649
2656
  const filename = file.name.trim()
2650
2657
  const validationError = validateStorageName(filename)
@@ -2653,9 +2660,9 @@ function RecordForm({
2653
2660
  setShowPermissionsDialog(false)
2654
2661
  setPendingImageForUpdate(null)
2655
2662
  setPermissionsContext("files")
2656
- if (imageUpdateResolver) {
2663
+ if (effectiveResolver) {
2657
2664
  setIsUploading((prev) => ({ ...prev, [fieldName]: false }))
2658
- imageUpdateResolver()
2665
+ effectiveResolver()
2659
2666
  }
2660
2667
  return
2661
2668
  }
@@ -2675,23 +2682,23 @@ function RecordForm({
2675
2682
  ...record,
2676
2683
  } as StokerRecord
2677
2684
  try {
2678
- await runHooks("preFileAdd", globalConfig, customization, [
2679
- targetRecord,
2680
- filePath,
2685
+ await runHooks("preFileAdd", globalConfig, customization, {
2686
+ record: targetRecord,
2687
+ fullPath: filePath,
2681
2688
  filename,
2682
- {
2689
+ permissions: {
2683
2690
  read: metadata.customMetadata.read,
2684
2691
  update: metadata.customMetadata.update,
2685
2692
  delete: metadata.customMetadata.delete,
2686
2693
  },
2687
- ])
2694
+ })
2688
2695
  } catch {
2689
2696
  setShowPermissionsDialog(false)
2690
2697
  setPendingImageForUpdate(null)
2691
2698
  setPermissionsContext("files")
2692
- if (imageUpdateResolver) {
2699
+ if (effectiveResolver) {
2693
2700
  setIsUploading((prev) => ({ ...prev, [fieldName]: false }))
2694
- imageUpdateResolver()
2701
+ effectiveResolver()
2695
2702
  }
2696
2703
  return
2697
2704
  }
@@ -2710,16 +2717,16 @@ function RecordForm({
2710
2717
  },
2711
2718
  async () => {
2712
2719
  try {
2713
- await runHooks("postFileAdd", globalConfig, customization, [
2714
- targetRecord,
2715
- filePath,
2720
+ await runHooks("postFileAdd", globalConfig, customization, {
2721
+ record: targetRecord,
2722
+ fullPath: filePath,
2716
2723
  filename,
2717
- {
2724
+ permissions: {
2718
2725
  read: metadata.customMetadata.read,
2719
2726
  update: metadata.customMetadata.update,
2720
2727
  delete: metadata.customMetadata.delete,
2721
2728
  },
2722
- ])
2729
+ })
2723
2730
  } catch {
2724
2731
  resolve()
2725
2732
  return
@@ -2733,9 +2740,9 @@ function RecordForm({
2733
2740
  setShowPermissionsDialog(false)
2734
2741
  setPendingImageForUpdate(null)
2735
2742
  setPermissionsContext("files")
2736
- if (imageUpdateResolver) {
2743
+ if (effectiveResolver) {
2737
2744
  setIsUploading((prev) => ({ ...prev, [fieldName]: false }))
2738
- imageUpdateResolver()
2745
+ effectiveResolver()
2739
2746
  }
2740
2747
  return
2741
2748
  }
@@ -2786,7 +2793,10 @@ function RecordForm({
2786
2793
  setIsMultipleFileUpload(false)
2787
2794
  setImageUpdateResolver(() => resolve)
2788
2795
  if (shouldSkipPermissionsDialog()) {
2789
- setTimeout(() => handlePermissionsConfirm(getDefaultPermissions()), 0)
2796
+ handlePermissionsConfirm(getDefaultPermissions(), "image-update", {
2797
+ pendingImage: { fieldName, file },
2798
+ resolver: resolve,
2799
+ })
2790
2800
  } else {
2791
2801
  setShowPermissionsDialog(true)
2792
2802
  }
@@ -4358,7 +4368,7 @@ function RecordForm({
4358
4368
  if (!formValues) return
4359
4369
  const record = cloneDeep(originalRecord) as Partial<StokerRecord>
4360
4370
  const globalConfig = getGlobalConfigModule()
4361
- await runHooks("preDuplicate", globalConfig, customization, [record])
4371
+ await runHooks("preDuplicate", globalConfig, customization, { data: record })
4362
4372
  const recordToDuplicate: Partial<StokerRecord> = {}
4363
4373
  for (const field of fields) {
4364
4374
  const fieldCustomization = getFieldCustomization(field, customization)
@@ -5302,6 +5312,7 @@ function RecordForm({
5302
5312
  field: formList.sortField || relationCollection.recordTitleField,
5303
5313
  direction: formList.sortDirection,
5304
5314
  }}
5315
+ additionalConstraints={relationList.constraints}
5305
5316
  />
5306
5317
  </FiltersProvider>
5307
5318
  </div>
package/src/Record.tsx CHANGED
@@ -277,6 +277,7 @@ export const Record = ({ collection }: { collection: CollectionSchema }) => {
277
277
  item.collection === relationList.collection,
278
278
  )}
279
279
  hasBreadcrumbs={!!breadcrumbs}
280
+ additionalConstraints={relationList.constraints}
280
281
  />
281
282
  </FiltersProvider>
282
283
  </main>