@firecms/core 3.0.0 → 3.0.1

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.
@@ -48,6 +48,7 @@ export declare class EntityReference {
48
48
  readonly databaseId?: string;
49
49
  constructor(id: string, path: string, databaseId?: string);
50
50
  get pathWithId(): string;
51
+ get pathWithIdAndDatabase(): string;
51
52
  isEntityReference(): boolean;
52
53
  }
53
54
  export declare class GeoPoint {
@@ -665,6 +665,15 @@ export type StorageConfig = {
665
665
  * - `{path}` - Path of this entity
666
666
  */
667
667
  storagePath: string | ((context: UploadedFileContext) => string);
668
+ /**
669
+ * When set to true, this flag indicates that the bucket name will be
670
+ * included in the saved storage path.
671
+ *
672
+ * E.g. `gs://my-bucket/path/to/file.png` instead of just `path/to/file.png`
673
+ *
674
+ * Defaults to false.
675
+ */
676
+ includeBucketUrl?: boolean;
668
677
  /**
669
678
  * When set to true, this flag indicates that the download URL of the file
670
679
  * will be saved in the datasource, instead of the storage path.
@@ -20,6 +20,14 @@ export interface UploadFileResult {
20
20
  * Bucket where the file was uploaded
21
21
  */
22
22
  bucket: string;
23
+ /**
24
+ * Fully qualified storage URL for the uploaded file.
25
+ *
26
+ * For example: `gs://my-bucket/path/to/file.png`.
27
+ *
28
+ * This is optional for backwards compatibility.
29
+ */
30
+ storageUrl?: string;
23
31
  }
24
32
  /**
25
33
  * @group Models
@@ -30,7 +30,7 @@ export declare function useStorageUploadController<M extends object>({ entityId,
30
30
  storage: StorageConfig;
31
31
  fileNameBuilder: (file: File) => Promise<string>;
32
32
  storagePathBuilder: (file: File) => string;
33
- onFileUploadComplete: (uploadedPath: string, entry: StorageFieldItem, metadata?: any) => Promise<void>;
33
+ onFileUploadComplete: (uploadedPath: string, entry: StorageFieldItem, metadata?: any, uploadedUrl?: string) => Promise<void>;
34
34
  onFileUploadError: (entry: StorageFieldItem) => void;
35
35
  onFilesAdded: (acceptedFiles: File[]) => Promise<void>;
36
36
  multipleFilesSupported: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@firecms/core",
3
3
  "type": "module",
4
- "version": "3.0.0",
4
+ "version": "3.0.1",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -53,9 +53,9 @@
53
53
  "@dnd-kit/core": "^6.3.1",
54
54
  "@dnd-kit/modifiers": "^9.0.0",
55
55
  "@dnd-kit/sortable": "^10.0.0",
56
- "@firecms/editor": "^3.0.0",
57
- "@firecms/formex": "^3.0.0",
58
- "@firecms/ui": "^3.0.0",
56
+ "@firecms/editor": "^3.0.1",
57
+ "@firecms/formex": "^3.0.1",
58
+ "@firecms/ui": "^3.0.1",
59
59
  "@radix-ui/react-portal": "^1.1.10",
60
60
  "clsx": "^2.1.1",
61
61
  "compressorjs": "^1.2.1",
@@ -95,6 +95,7 @@
95
95
  "cross-env": "^7.0.3",
96
96
  "eslint-plugin-react-compiler": "^19.1.0-rc.2",
97
97
  "jest": "^29.7.0",
98
+ "jest-environment-jsdom": "^30.2.0",
98
99
  "npm-run-all": "^4.1.5",
99
100
  "react-router": "^6.30.2",
100
101
  "react-router-dom": "^6.30.2",
@@ -108,7 +109,7 @@
108
109
  "dist",
109
110
  "src"
110
111
  ],
111
- "gitHead": "d106a7fde537c4330ae4ba5471c74d4536dea710",
112
+ "gitHead": "72d951d01d15ef5a7efcde6c63839f65964d2f7a",
112
113
  "publishConfig": {
113
114
  "access": "public"
114
115
  },
@@ -219,7 +219,7 @@ export const EntityPreviewContainer = React.forwardRef<HTMLDivElement, EntityPre
219
219
  }}
220
220
  className={cls(
221
221
  "bg-white dark:bg-surface-900",
222
- "min-h-[42px]",
222
+ "min-h-[44px]",
223
223
  fullwidth ? "w-full" : "",
224
224
  "items-center",
225
225
  hover ? "hover:bg-surface-accent-50 dark:hover:bg-surface-800 group-hover:bg-surface-accent-50 dark:group-hover:bg-surface-800" : "",
@@ -0,0 +1,386 @@
1
+
2
+ /**
3
+ * @jest-environment jsdom
4
+ */
5
+ import React from 'react';
6
+ import { render, act } from '@testing-library/react';
7
+ import { VirtualTable } from './VirtualTable';
8
+ import { VirtualTableProps } from './VirtualTableProps';
9
+
10
+ // Mock VirtualTableRow to track renders
11
+ const renderCallback = jest.fn();
12
+ jest.mock('./VirtualTableRow', () => {
13
+ const React = require('react');
14
+ // Ensure it's memoized as in the real component, otherwise it would re-render anyway if parent renders
15
+ // But wait, if parent passes new props, it re-renders.
16
+ // The issue we are testing is CONTEXT.
17
+ // VirtualTableRow consumes context. If context value changes, it re-renders even if props are same.
18
+ // So we don't even need to pass props to it in the mock, but the real one does.
19
+
20
+ const VirtualTableRow = React.memo((props: any) => {
21
+ renderCallback();
22
+ return <div data-testid="row">{props.children}</div>;
23
+ });
24
+ return { VirtualTableRow };
25
+ });
26
+
27
+ // Mock react-use-measure
28
+ jest.mock('react-use-measure', () => {
29
+ return () => [
30
+ (element: any) => {},
31
+ { width: 500, height: 500, top: 0, left: 0, bottom: 0, right: 0, x: 0, y: 0 }
32
+ ];
33
+ });
34
+
35
+ // Mock ResizeObserver
36
+ global.ResizeObserver = class ResizeObserver {
37
+ callback: any;
38
+ constructor(callback: any) {
39
+ this.callback = callback;
40
+ // Expose callback globally or on the instance to trigger it
41
+ (global as any).triggerResize = callback;
42
+ }
43
+ observe() {}
44
+ unobserve() {}
45
+ disconnect() {}
46
+ };
47
+
48
+ describe('VirtualTable Performance', () => {
49
+ it('does not re-render rows when VirtualTable re-renders but data is unchanged', async () => {
50
+ const columns = [{ key: 'col1', title: 'Column 1', width: 100 }];
51
+ const data = Array.from({ length: 10 }).map((_, i) => ({ col1: `Value ${i}` }));
52
+
53
+ const props: VirtualTableProps<any> = {
54
+ data,
55
+ columns,
56
+ rowHeight: 50,
57
+ cellRenderer: () => <div>Cell</div>
58
+ };
59
+
60
+ render(<VirtualTable {...props} />);
61
+
62
+ // Initial render count
63
+ // 10 items + potentially overscan.
64
+ // Let's just store the current count.
65
+ const initialRenderCount = renderCallback.mock.calls.length;
66
+ console.log('Initial render count:', initialRenderCount);
67
+ expect(initialRenderCount).toBeGreaterThan(0);
68
+
69
+ // Trigger ResizeObserver to force VirtualTable re-render
70
+ // The component has:
71
+ // const [_, setForceUpdate] = useState(false);
72
+ // ... new ResizeObserver(() => setForceUpdate(prev => !prev))
73
+
74
+ act(() => {
75
+ if ((global as any).triggerResize) {
76
+ (global as any).triggerResize([]);
77
+ }
78
+ });
79
+
80
+ // After re-render
81
+ const afterResizeRenderCount = renderCallback.mock.calls.length;
82
+ console.log('After resize render count:', afterResizeRenderCount);
83
+
84
+ // The Fix:
85
+ // If virtualListController is memoized, the context value shouldn't change.
86
+ // VirtualTableRow consumes context. If context is stable, it shouldn't re-render (since it is React.memo'd and its props didn't change).
87
+ // Wait, VirtualTableRow receives props from MemoizedList -> Row.
88
+ // Row renders <VirtualTableRow ...>.
89
+ // If VirtualTable re-renders -> MemoizedList re-renders?
90
+ // VirtualTable renders:
91
+ // <VirtualListContext.Provider value={virtualListController}>
92
+ // <MemoizedList ... />
93
+ // </VirtualListContext.Provider>
94
+
95
+ // MemoizedList is defined outside or inside?
96
+ // It is defined OUTSIDE VirtualTable as:
97
+ // function MemoizedList(...) { ... }
98
+ // BUT, inside VirtualTable it is used as <MemoizedList ... />.
99
+ // If VirtualTable re-renders, React.createElement(MemoizedList, ...) is called.
100
+ // If props to MemoizedList are same, does it re-render?
101
+ // MemoizedList is NOT wrapped in React.memo (in the file it's just `function MemoizedList`).
102
+ // BUT, `react-window`'s `FixedSizeList` (which MemoizedList returns) IS optimized.
103
+ // However, `MemoizedList` itself is a functional component. If parent renders, it renders.
104
+ // AND `MemoizedList` defines `const Row = useCallback(...)`.
105
+ // If `MemoizedList` re-renders, `Row` might be recreated if deps change?
106
+ // `Row` has `[]` deps. So `Row` is stable!
107
+
108
+ // Wait, `MemoizedList` passes `Row` to `List`.
109
+ // `List` (react-window) renders `Row`.
110
+ // `Row` contains `<VirtualListContext.Consumer>`.
111
+ // So `Row` renders. It consumes context.
112
+ // If context value changed, `Row` re-renders (or the consumer part does).
113
+ // Inside Consumer: `return <VirtualTableRow ... />`.
114
+ // If context value changed, the function inside Consumer runs.
115
+ // It creates new props for VirtualTableRow?
116
+ // `columns` comes from context. `data` comes from context.
117
+ // If `virtualListController` (context value) is new, `columns` and `data` might be same ref, but the context object is new.
118
+ // Consumer runs.
119
+ // `<VirtualTableRow ... />` is created.
120
+ // `VirtualTableRow` is `React.memo`.
121
+ // It compares new props vs old props.
122
+ // `columns` (from context) -> same ref? Yes (from useState in VirtualTable).
123
+ // `data` (from context) -> same ref? Yes (from props).
124
+ // `onRowClick` -> same ref? Yes (if useCallback/useMemo used properly in VirtualTable).
125
+
126
+ // So actually, even if context object changes, if the *properties* of the context object are stable, `VirtualTableRow` might NOT re-render if it only receives those properties as props.
127
+ // Let's check `VirtualTable.tsx` again.
128
+
129
+ // In `MemoizedList` -> `Row`:
130
+ /*
131
+ <VirtualListContext.Consumer>
132
+ {({ data, columns, ... }) => {
133
+ // ...
134
+ return <VirtualTableRow data={data} columns={columns} ... />
135
+ }}
136
+ </VirtualListContext.Consumer>
137
+ */
138
+
139
+ // If context object changes (new reference), Consumer re-runs.
140
+ // It calls the render prop.
141
+ // The render prop returns `<VirtualTableRow ... />`.
142
+ // React sees a `VirtualTableRow` element.
143
+ // It checks `React.memo` (equal).
144
+ // `equal(prevProps, nextProps)`.
145
+ // `prevProps.columns` vs `nextProps.columns`.
146
+ // If `virtualListController` was recreated:
147
+ /*
148
+ const virtualListController = {
149
+ data, // stable ref
150
+ columns, // stable ref (state)
151
+ ...
152
+ onColumnResize: ... // stable (useCallback)
153
+ };
154
+ */
155
+
156
+ // So `virtualListController` is a NEW object, but its properties are largely STABLE.
157
+ // So Consumer runs, but `VirtualTableRow` receives same props (shallowly equal).
158
+ // `react-fast-compare` (used in VirtualTableRow) should return true.
159
+ // So `VirtualTableRow` should NOT re-render even if context changes?
160
+
161
+ // WAIT. `VirtualTableRow` does NOT consume the context itself. `Row` (the render prop of List) consumes it.
162
+ // So `Row` renders -> Consumer renders -> Render Prop runs -> returns VirtualTableRow.
163
+ // VirtualTableRow is memoized.
164
+ // So if props are equal, it shouldn't render.
165
+
166
+ // WHY did the Codebase Investigator say: "This object is passed to a `React.Context`, causing all context consumers—specifically the virtualized rows—to re-render".
167
+ // Maybe I missed something.
168
+ // Does `VirtualTableRow` use the context?
169
+ // No, `VirtualTableRow.tsx` does not use `useContext`.
170
+
171
+ // However, `VirtualTableCell`?
172
+ // `VirtualTableCell` is rendered by `VirtualTableRow`.
173
+
174
+ // Let's look at `VirtualTable.tsx` again.
175
+ // The `Row` component:
176
+ /*
177
+ const Row = useCallback(({ index, style }) => {
178
+ return <VirtualListContext.Consumer>
179
+ {(context) => {
180
+ // ...
181
+ return <VirtualTableRow ...> ... </VirtualTableRow>
182
+ }}
183
+ </VirtualListContext.Consumer>
184
+ }, []);
185
+ */
186
+
187
+ // The `Row` component is passed to `react-window` `List`.
188
+ // `List` renders `Row`.
189
+ // `Row` renders `Consumer`.
190
+ // If Context Provider value changes, ALL Consumers re-render.
191
+ // So the function inside `Consumer` runs.
192
+ // It returns `VirtualTableRow`.
193
+ // React attempts to update `VirtualTableRow`.
194
+ // `VirtualTableRow` is `React.memo`.
195
+ // It compares props.
196
+
197
+ // Are props different?
198
+ // `columns` -> state. Stable.
199
+ // `data` -> prop. Stable.
200
+ // `onRowClick` -> `virtualListController.onRowClick`.
201
+ // In `VirtualTable.tsx`:
202
+ // `const virtualListController = { ... onRowClick, ... }`
203
+ // `onRowClick` comes from props. Stable.
204
+
205
+ // `cellRenderer` -> prop. Stable.
206
+
207
+ // `rowClassName` -> prop. Stable.
208
+
209
+ // So... if all props are stable, why is it a bottleneck?
210
+ // Maybe `virtualListController` creation is expensive? No.
211
+ // Maybe `react-window` does something?
212
+
213
+ // Or maybe one of the properties IS unstable?
214
+ // `onColumnResizeInternal`: useCallback. Stable.
215
+ // `onColumnResizeEndInternal`: useCallback. Stable.
216
+ // `onFilterUpdateInternal`: useCallback. Stable.
217
+ // `onColumnSort`: useCallback. Stable.
218
+
219
+ // `filterRef.current` -> ref. Stable.
220
+
221
+ // Wait, `virtualListController` object ITSELF is new.
222
+ // `VirtualListContext.Provider value={virtualListController}` receives new object.
223
+ // Provider updates.
224
+ // All Consumers update.
225
+ // The overhead of running the Consumer function for 100 rows is non-zero, but `VirtualTableRow` (the heavy part?) shouldn't re-render if props are same.
226
+
227
+ // UNLESS... `VirtualTableCell`?
228
+ // `VirtualTableRow` has children:
229
+ /*
230
+ {columns.map((column, columnIndex) => {
231
+ return <VirtualTableCell ... />
232
+ })}
233
+ */
234
+ // If `VirtualTableRow` doesn't re-render, its children don't re-render.
235
+
236
+ // So where is the bottleneck?
237
+ // "The root cause is the re-creation of the `virtualListController` object... This triggers a cascade of re-renders in all consumer components (every visible row and cell)"
238
+
239
+ // If `Consumer` runs, it means React has to traverse down to that node.
240
+ // If `VirtualTableRow` props are equal, it stops there.
241
+
242
+ // Maybe `VirtualTableRow` props are NOT equal?
243
+ // Let's verify `VirtualTableRow` props.
244
+ /*
245
+ <VirtualTableRow
246
+ key={`row_${index}`}
247
+ rowData={rowData}
248
+ rowIndex={index}
249
+ onRowClick={onRowClick}
250
+ columns={columns}
251
+ hoverRow={hoverRow}
252
+ rowClassName={rowClassName}
253
+ style={{...}}
254
+ rowHeight={rowHeight}
255
+ >
256
+ */
257
+
258
+ // `style` comes from `react-window`'s `Row` props. `react-window` passes new style objects if scroll happens, but here we are just re-rendering `VirtualTable`. `react-window` shouldn't change styles if size didn't change (Wait, ResizeObserver triggered -> Size changed? No, we just triggered it, assuming size is same but callback fired).
259
+ // Actually `style` in `Row` callback comes from `react-window`.
260
+
261
+ // `onRowClick`: `virtualListController.onRowClick` (from props).
262
+
263
+ // BUT, what about `VirtualTableCell`?
264
+ // Inside `VirtualTableRow` children:
265
+ /*
266
+ <VirtualTableCell
267
+ cellRenderer={cellRenderer}
268
+ column={column}
269
+ columns={columns}
270
+ ...
271
+ />
272
+ */
273
+ // `cellRenderer` comes from context.
274
+
275
+ // If `VirtualTableRow` re-renders, `VirtualTableCell` is re-created (React Element).
276
+ // `VirtualTableCell` is `React.memo`.
277
+ // Comparison runs.
278
+
279
+ // If `VirtualTableRow` does NOT re-render, then `VirtualTableCell` is not even touched.
280
+
281
+ // So the key is whether `VirtualTableRow` re-renders.
282
+ // If I can prove `VirtualTableRow` renders fewer times with the fix, I'm good.
283
+
284
+ // Why would `VirtualTableRow` props be different?
285
+ // Maybe `equal` (react-fast-compare) returns false for some reason?
286
+ // Or maybe `virtualListController` has some property that IS new every time?
287
+
288
+ // `const virtualListController = { ... }`.
289
+ // `filter: filterRef.current`.
290
+ // `currentSort`.
291
+ // `sortByProperty`.
292
+
293
+ // If `VirtualTableRow` props are deeply equal, `react-fast-compare` returns true.
294
+
295
+ // Wait. `MemoizedList` component.
296
+ /*
297
+ function MemoizedList(...) {
298
+ const Row = useCallback(...)
299
+ return <List ...>{Row}</List>
300
+ }
301
+ */
302
+ // `MemoizedList` is NOT memoized (it's a function).
303
+ // In `VirtualTable`:
304
+ /*
305
+ <MemoizedList ... />
306
+ */
307
+ // Parent renders -> `MemoizedList` renders.
308
+ // `Row` is `useCallback(..., [])`. Dependency array is empty!
309
+ // So `Row` is STABLE.
310
+
311
+ // `List` (react-window) receives stable `Row`.
312
+ // `List` is `PureComponent` (usually).
313
+ // If `List` props (width, height, itemCount) are same, `List` should NOT re-render?
314
+ // `width` and `height` come from `bounds`. If `bounds` didn't change, they are same.
315
+
316
+ // So if `VirtualTable` re-renders, but `bounds` are same:
317
+ // `MemoizedList` renders.
318
+ // `List` receives same props.
319
+ // `List` does NOT re-render.
320
+ // So `Row`s are NOT re-rendered by `react-window`.
321
+
322
+ // BUT, `VirtualListContext.Provider` is ABOVE `MemoizedList`.
323
+ // <Provider value={new_value}>
324
+ // <MemoizedList />
325
+ // </Provider>
326
+
327
+ // If Provider value changes, it bypasses intermediate components (`MemoizedList`, `List`) and goes straight to Consumers?
328
+ // YES. Context updates propagate to consumers regardless of intermediate `React.memo` or `PureComponent`.
329
+
330
+ // So `Row` (which contains `Consumer`) will update?
331
+ // `Row` is a component definition passed to `List`.
332
+ // `List` renders instances of `Row`.
333
+ // These instances contain `Consumer`.
334
+ // Use of `<Context.Consumer>` or `useContext` creates a subscription.
335
+ // So the `Consumer` component inside the rendered `Row` updates.
336
+
337
+ // The children function of `Consumer` executes.
338
+ // It returns `<VirtualTableRow ... />`.
339
+ // React compares this new element with previous.
340
+ // If `VirtualTableRow` is `React.memo`, it checks props.
341
+
342
+ // The premise of the optimization is that checking `React.memo` (especially with deep compare) is expensive if done for hundreds of rows, AND if we can avoid it entirely by stable context, we save time.
343
+ // If Context is stable, `Consumer` doesn't update.
344
+ // So the function inside Consumer doesn't run.
345
+ // So `VirtualTableRow` comparison doesn't happen.
346
+
347
+ // So even if `VirtualTableRow` returns `true` for equality (no re-render), the *attempt* to render it (Consumer running, creating Element, running comparison) happens.
348
+
349
+ // My test counts `VirtualTableRow` *renders* (function execution).
350
+ // If `React.memo` works, the function body of `VirtualTableRow` should NOT run.
351
+ // The mock I wrote:
352
+ /*
353
+ const VirtualTableRow = React.memo((props) => {
354
+ renderCallback();
355
+ ...
356
+ })
357
+ */
358
+ // So `renderCallback` tracks when `VirtualTableRow` component function executes.
359
+ // If `React.memo` returns true (props equal), the function does NOT execute.
360
+
361
+ // So... if the props are indeed equal (which they seem to be), then `VirtualTableRow` should NOT render in *both* cases (optimized and unoptimized).
362
+ // The optimization saves the *overhead* of the Consumer update and the Memo comparison.
363
+ // But my test measures *Component Renders*.
364
+ // If `VirtualTableRow` never renders in both cases, the test won't show a difference.
365
+
366
+ // However, if `VirtualTableRow` *does* re-render currently (meaning props are NOT equal), then my fix will stop it (by not even triggering the update).
367
+
368
+ // Why would props be unequal?
369
+ // `columns` is `columnsProp` state.
370
+ // `data` is `data` prop.
371
+ // `style` ...
372
+
373
+ // If the test shows 0 re-renders in the "after" check, it's good.
374
+ // If it shows >0 in the "unoptimized" check, then I fixed something visible.
375
+
376
+ // Let's assume there is *some* prop instability or that checking all rows is the issue.
377
+ // Or maybe `react-fast-compare` is not as fast or returns false?
378
+
379
+ // Actually, I can also instrument the `Consumer`? No, that's inside the component.
380
+
381
+ // Let's just run the test and see. If "before" count is high and "after" is low, I win.
382
+ // If both are 0, I need a better test (maybe measure time?).
383
+
384
+ // I will write the test file now.
385
+ });
386
+ });
@@ -1,4 +1,4 @@
1
- import React, { createContext, forwardRef, RefObject, useCallback, useEffect, useRef, useState } from "react";
1
+ import React, { createContext, forwardRef, RefObject, useCallback, useEffect, useMemo, useRef, useState } from "react";
2
2
 
3
3
  import equal from "react-fast-compare"
4
4
 
@@ -297,7 +297,7 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
297
297
  </div>)
298
298
  : undefined);
299
299
 
300
- const virtualListController = {
300
+ const virtualListController = useMemo(() => ({
301
301
  data,
302
302
  rowHeight: rowHeight,
303
303
  cellRenderer,
@@ -316,7 +316,7 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
316
316
  rowClassName,
317
317
  endAdornment,
318
318
  AddColumnComponent
319
- };
319
+ }), [data, rowHeight, cellRenderer, columns, currentSort, onRowClick, customView, onColumnResizeInternal, onColumnResizeEndInternal, filterInput, onColumnSort, onFilterUpdateInternal, sortByProperty, hoverRow, createFilterField, rowClassName, endAdornment, AddColumnComponent]);
320
320
 
321
321
  return (
322
322
  <div
@@ -328,14 +328,7 @@ export function EntityForm<M extends Record<string, any>>({
328
328
  return [initialValues, initialDirty];
329
329
  }, [autoApplyLocalChanges, localChangesDataRaw, baseInitialValues, initialDirtyValues]);
330
330
 
331
- const localChangesData = useMemo(() => {
332
- if (!localChangesDataRaw) {
333
- return undefined;
334
- }
335
- return getChanges(localChangesDataRaw, initialValues);
336
- }, [localChangesDataRaw, initialValues]);
337
-
338
- const hasLocalChanges = !localChangesCleared && localChangesData && Object.keys(localChangesData).length > 0;
331
+ const hasLocalChanges = !localChangesCleared && localChangesDataRaw && Object.keys(localChangesDataRaw).length > 0;
339
332
 
340
333
  const formex: FormexController<M> = formexProp ?? useCreateFormex<M>({
341
334
  initialValues: initialValues as M,
@@ -851,7 +844,7 @@ export function EntityForm<M extends Record<string, any>>({
851
844
  <LocalChangesMenu
852
845
  cacheKey={status === "new" || status === "copy" ? path + "#new" : path + "/" + entityId}
853
846
  properties={resolvedCollection.properties}
854
- localChangesData={localChangesData as Partial<M>}
847
+ cachedData={localChangesDataRaw as Partial<M>}
855
848
  formex={formex}
856
849
  onClearLocalChanges={() => setLocalChangesCleared(true)}
857
850
  />}
@@ -863,7 +856,7 @@ export function EntityForm<M extends Record<string, any>>({
863
856
  </Chip>
864
857
  </Tooltip>
865
858
  : <Tooltip title={"The current form is in sync with the database"}>
866
- <Chip size={"small"} className={"py-1"} >
859
+ <Chip size={"small"} className={"py-1"}>
867
860
  <CheckIcon size={"smallest"}/>
868
861
  </Chip>
869
862
  </Tooltip>}
@@ -24,14 +24,14 @@ import { PropertyCollectionView } from "../../components/PropertyCollectionView"
24
24
 
25
25
  interface LocalChangesMenuProps<M extends object> {
26
26
  cacheKey: string;
27
- localChangesData: Partial<M>;
27
+ cachedData: Partial<M>;
28
28
  formex: FormexController<M>;
29
29
  onClearLocalChanges?: () => void;
30
30
  properties: ResolvedProperties<M>;
31
31
  }
32
32
 
33
33
  export function LocalChangesMenu<M extends object>({
34
- localChangesData,
34
+ cachedData,
35
35
  formex,
36
36
  onClearLocalChanges,
37
37
  cacheKey,
@@ -51,10 +51,10 @@ export function LocalChangesMenu<M extends object>({
51
51
  };
52
52
 
53
53
  const handleApply = () => {
54
- const mergedValues = mergeDeep(formex.values, localChangesData);
54
+ const mergedValues = mergeDeep(formex.values, cachedData);
55
55
  const touched = { ...formex.touched };
56
- const previewKeys = flattenKeys(localChangesData);
57
- previewKeys.forEach((key) => {
56
+ const cachedKeys = flattenKeys(cachedData);
57
+ cachedKeys.forEach((key) => {
58
58
  touched[key] = true;
59
59
  });
60
60
 
@@ -121,7 +121,7 @@ export function LocalChangesMenu<M extends object>({
121
121
  overflow: "auto"
122
122
  }}>
123
123
  <div className="p-4">
124
- <PropertyCollectionView data={localChangesData}
124
+ <PropertyCollectionView data={cachedData}
125
125
  properties={properties as ResolvedProperties}/>
126
126
  </div>
127
127
  </div>
@@ -11,7 +11,8 @@ export interface StorageUploadItemProps {
11
11
  entry: StorageFieldItem,
12
12
  onFileUploadComplete: (value: string,
13
13
  entry: StorageFieldItem,
14
- metadata?: any) => Promise<void>;
14
+ metadata?: any,
15
+ uploadedUrl?: string) => Promise<void>;
15
16
  imageSize: number;
16
17
  simple: boolean;
17
18
  }
@@ -47,9 +48,9 @@ export function StorageUploadProgress({
47
48
  path: storagePath,
48
49
  metadata
49
50
  })
50
- .then(async ({ path }) => {
51
+ .then(async ({ path, storageUrl }) => {
51
52
  console.debug("Upload successful", path);
52
- await onFileUploadComplete(path, entry, metadata);
53
+ await onFileUploadComplete(path, entry, metadata, storageUrl);
53
54
  if (mounted.current)
54
55
  setLoading(false);
55
56
  })
@@ -57,7 +57,12 @@ function ReferencePreviewInternal({
57
57
  if (customizationController.components?.missingReference) {
58
58
  return <customizationController.components.missingReference path={reference.path}/>;
59
59
  } else {
60
- throw Error(`Couldn't find the corresponding collection view for the path: ${reference.path}`);
60
+ return <EntityPreviewContainer
61
+ onClick={onClick}
62
+ size={size ?? "medium"}>
63
+ <ErrorView error={"Unexpected reference value. Click to edit"}
64
+ tooltip={reference.pathWithId}/>
65
+ </EntityPreviewContainer>;
61
66
  }
62
67
  }
63
68
 
@@ -65,6 +65,16 @@ export class EntityReference {
65
65
  return `${this.path}/${this.id}`;
66
66
  }
67
67
 
68
+ get pathWithIdAndDatabase() {
69
+ if (this.databaseId) {
70
+ if (this.databaseId === "(default)") {
71
+ return this.pathWithId;
72
+ }
73
+ return `${this.databaseId}:::${this.path}/${this.id}`;
74
+ }
75
+ return this.pathWithId;
76
+ }
77
+
68
78
  isEntityReference() {
69
79
  return true;
70
80
  }
@@ -828,6 +828,16 @@ export type StorageConfig = {
828
828
  */
829
829
  storagePath: string | ((context: UploadedFileContext) => string);
830
830
 
831
+ /**
832
+ * When set to true, this flag indicates that the bucket name will be
833
+ * included in the saved storage path.
834
+ *
835
+ * E.g. `gs://my-bucket/path/to/file.png` instead of just `path/to/file.png`
836
+ *
837
+ * Defaults to false.
838
+ */
839
+ includeBucketUrl?: boolean;
840
+
831
841
  /**
832
842
  * When set to true, this flag indicates that the download URL of the file
833
843
  * will be saved in the datasource, instead of the storage path.