@firecms/core 3.0.0-beta.12 → 3.0.0-beta.13
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/dist/app/Scaffold.d.ts +4 -0
- package/dist/components/ArrayContainer.d.ts +12 -5
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +4 -0
- package/dist/components/EntityJsonPreview.d.ts +3 -0
- package/dist/core/DefaultAppBar.d.ts +8 -2
- package/dist/core/EntityEditView.d.ts +8 -1
- package/dist/core/FireCMS.d.ts +2 -2
- package/dist/form/EntityForm.d.ts +5 -1
- package/dist/form/PropertyFieldBinding.d.ts +1 -1
- package/dist/hooks/data/save.d.ts +1 -1
- package/dist/index.es.js +8630 -8578
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +8663 -8612
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/useBuildDataSource.d.ts +3 -2
- package/dist/internal/useBuildSideEntityController.d.ts +3 -3
- package/dist/types/collections.d.ts +6 -0
- package/dist/types/fields.d.ts +4 -1
- package/dist/types/firecms.d.ts +1 -1
- package/dist/types/navigation.d.ts +4 -0
- package/dist/types/plugins.d.ts +1 -0
- package/dist/types/properties.d.ts +22 -1
- package/dist/util/createFormexStub.d.ts +2 -0
- package/dist/util/navigation_utils.d.ts +2 -1
- package/dist/util/objects.d.ts +1 -1
- package/dist/util/property_utils.d.ts +2 -2
- package/dist/util/references.d.ts +2 -2
- package/dist/util/resolutions.d.ts +11 -6
- package/package.json +6 -5
- package/src/app/Scaffold.tsx +13 -3
- package/src/components/ArrayContainer.tsx +40 -23
- package/src/components/DeleteEntityDialog.tsx +4 -2
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +8 -6
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +5 -2
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +22 -6
- package/src/components/EntityJsonPreview.tsx +66 -0
- package/src/components/EntityPreview.tsx +10 -3
- package/src/components/EntityView.tsx +4 -1
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +3 -1
- package/src/components/VirtualTable/VirtualTable.tsx +29 -1
- package/src/components/common/default_entity_actions.tsx +15 -4
- package/src/core/DefaultAppBar.tsx +17 -5
- package/src/core/EntityEditView.tsx +111 -35
- package/src/core/FireCMS.tsx +13 -12
- package/src/form/EntityForm.tsx +31 -23
- package/src/form/PropertyFieldBinding.tsx +8 -5
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +4 -1
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +1 -0
- package/src/form/field_bindings/BlockFieldBinding.tsx +1 -1
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +1 -1
- package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +6 -2
- package/src/form/field_bindings/MultiSelectFieldBinding.tsx +2 -2
- package/src/form/field_bindings/RepeatFieldBinding.tsx +8 -2
- package/src/form/field_bindings/SelectFieldBinding.tsx +1 -1
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +5 -2
- package/src/hooks/data/save.ts +24 -29
- package/src/hooks/useBuildNavigationController.tsx +12 -1
- package/src/hooks/useFireCMSContext.tsx +0 -30
- package/src/internal/useBuildDataSource.ts +9 -5
- package/src/internal/useBuildSideEntityController.tsx +26 -20
- package/src/preview/PropertyPreview.tsx +4 -2
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +4 -3
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +4 -3
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +4 -2
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +4 -3
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +4 -2
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +4 -2
- package/src/routes/FireCMSRoute.tsx +15 -4
- package/src/types/collections.ts +7 -0
- package/src/types/fields.tsx +5 -1
- package/src/types/firecms.tsx +1 -1
- package/src/types/navigation.ts +5 -0
- package/src/types/plugins.tsx +1 -0
- package/src/types/properties.ts +27 -1
- package/src/types/side_entity_controller.tsx +5 -0
- package/src/util/createFormexStub.tsx +62 -0
- package/src/util/join_collections.ts +3 -1
- package/src/util/navigation_from_path.ts +5 -1
- package/src/util/navigation_utils.ts +64 -15
- package/src/util/objects.ts +5 -1
- package/src/util/property_utils.tsx +7 -3
- package/src/util/references.ts +8 -6
- package/src/util/resolutions.ts +17 -9
- package/src/util/useStorageUploadController.tsx +21 -2
package/src/util/resolutions.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ArrayProperty,
|
|
3
|
+
AuthController,
|
|
3
4
|
CMSType,
|
|
4
5
|
CustomizationController,
|
|
5
6
|
EntityCollection,
|
|
@@ -27,9 +28,7 @@ import { getDefaultValuesFor, isPropertyBuilder } from "./entities";
|
|
|
27
28
|
import { DEFAULT_ONE_OF_TYPE } from "./common";
|
|
28
29
|
import { getIn } from "@firecms/formex";
|
|
29
30
|
import { enumToObjectEntries } from "./enums";
|
|
30
|
-
import { isDefaultFieldConfigId } from "../core
|
|
31
|
-
|
|
32
|
-
// import util from "util";
|
|
31
|
+
import { isDefaultFieldConfigId } from "../core";
|
|
33
32
|
|
|
34
33
|
export const resolveCollection = <M extends Record<string, any>, >
|
|
35
34
|
({
|
|
@@ -40,7 +39,8 @@ export const resolveCollection = <M extends Record<string, any>, >
|
|
|
40
39
|
previousValues,
|
|
41
40
|
userConfigPersistence,
|
|
42
41
|
propertyConfigs,
|
|
43
|
-
ignoreMissingFields = false
|
|
42
|
+
ignoreMissingFields = false,
|
|
43
|
+
authController
|
|
44
44
|
}: {
|
|
45
45
|
collection: EntityCollection<M> | ResolvedEntityCollection<M>;
|
|
46
46
|
path: string,
|
|
@@ -50,6 +50,7 @@ export const resolveCollection = <M extends Record<string, any>, >
|
|
|
50
50
|
userConfigPersistence?: UserConfigurationPersistence;
|
|
51
51
|
propertyConfigs?: Record<string, PropertyConfig>;
|
|
52
52
|
ignoreMissingFields?: boolean;
|
|
53
|
+
authController: AuthController;
|
|
53
54
|
}): ResolvedEntityCollection<M> => {
|
|
54
55
|
|
|
55
56
|
const collectionOverride = userConfigPersistence?.getCollectionConfig<M>(path);
|
|
@@ -69,7 +70,8 @@ export const resolveCollection = <M extends Record<string, any>, >
|
|
|
69
70
|
path,
|
|
70
71
|
entityId,
|
|
71
72
|
propertyConfigs: propertyConfigs,
|
|
72
|
-
ignoreMissingFields
|
|
73
|
+
ignoreMissingFields,
|
|
74
|
+
authController
|
|
73
75
|
});
|
|
74
76
|
if (!childResolvedProperty) return {};
|
|
75
77
|
return ({
|
|
@@ -114,6 +116,7 @@ export function resolveProperty<T extends CMSType = CMSType, M extends Record<st
|
|
|
114
116
|
fromBuilder?: boolean;
|
|
115
117
|
propertyConfigs?: Record<string, PropertyConfig<any>>;
|
|
116
118
|
ignoreMissingFields?: boolean;
|
|
119
|
+
authController: AuthController;
|
|
117
120
|
}): ResolvedProperty<T> | null {
|
|
118
121
|
|
|
119
122
|
if (typeof propertyOrBuilder === "object" && "resolved" in propertyOrBuilder) {
|
|
@@ -234,7 +237,8 @@ export function getArrayResolvedProperties<M>({
|
|
|
234
237
|
entityId?: string;
|
|
235
238
|
index?: number;
|
|
236
239
|
fromBuilder?: boolean;
|
|
237
|
-
propertyConfigs?: Record<string, PropertyConfig
|
|
240
|
+
propertyConfigs?: Record<string, PropertyConfig>;
|
|
241
|
+
authController: AuthController;
|
|
238
242
|
}) {
|
|
239
243
|
|
|
240
244
|
const of = property.of;
|
|
@@ -266,6 +270,7 @@ export function resolveArrayProperty<T extends any[], M>({
|
|
|
266
270
|
fromBuilder?: boolean;
|
|
267
271
|
propertyConfigs?: Record<string, PropertyConfig>;
|
|
268
272
|
ignoreMissingFields?: boolean;
|
|
273
|
+
authController: AuthController;
|
|
269
274
|
}): ResolvedArrayProperty {
|
|
270
275
|
const propertyValue = propertyKey ? getIn(props.values, propertyKey) : undefined;
|
|
271
276
|
|
|
@@ -281,7 +286,7 @@ export function resolveArrayProperty<T extends any[], M>({
|
|
|
281
286
|
propertyOrBuilder: p as Property<any>,
|
|
282
287
|
ignoreMissingFields,
|
|
283
288
|
...props,
|
|
284
|
-
index
|
|
289
|
+
index,
|
|
285
290
|
});
|
|
286
291
|
})
|
|
287
292
|
} as ResolvedArrayProperty;
|
|
@@ -373,6 +378,7 @@ export function resolveProperties<M extends Record<string, any>>({
|
|
|
373
378
|
fromBuilder?: boolean;
|
|
374
379
|
propertyConfigs?: Record<string, PropertyConfig>;
|
|
375
380
|
ignoreMissingFields?: boolean;
|
|
381
|
+
authController: AuthController;
|
|
376
382
|
}): ResolvedProperties<M> {
|
|
377
383
|
return Object.entries<PropertyOrBuilder>(properties as Record<string, PropertyOrBuilder>)
|
|
378
384
|
.map(([key, property]) => {
|
|
@@ -435,11 +441,13 @@ export function resolveEntityView(entityView: string | EntityCustomView<any>, co
|
|
|
435
441
|
export function resolvedSelectedEntityView<M extends Record<string, any>>(
|
|
436
442
|
customViews: (string | EntityCustomView<M>)[] | undefined,
|
|
437
443
|
customizationController: CustomizationController,
|
|
438
|
-
selectedTab?: string
|
|
444
|
+
selectedTab?: string,
|
|
445
|
+
canEdit?: boolean,
|
|
439
446
|
) {
|
|
440
447
|
const resolvedEntityViews = customViews ? customViews
|
|
441
448
|
.map(e => resolveEntityView(e, customizationController.entityViews))
|
|
442
|
-
.filter(
|
|
449
|
+
.filter((e): e is EntityCustomView<M> => Boolean(e))
|
|
450
|
+
// .filter((e) => canEdit || !e.includeActions)
|
|
443
451
|
: [];
|
|
444
452
|
|
|
445
453
|
const selectedEntityView = resolvedEntityViews.find(e => e.key === selectedTab);
|
|
@@ -18,6 +18,7 @@ import { PreviewSize } from "../preview";
|
|
|
18
18
|
import { randomString } from "./strings";
|
|
19
19
|
import { resolveStorageFilenameString, resolveStoragePathString } from "./storage";
|
|
20
20
|
import { resolveProperty } from "./resolutions";
|
|
21
|
+
import { useAuthController } from "../hooks";
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Internal representation of an item in the storage
|
|
@@ -34,7 +35,6 @@ export interface StorageFieldItem {
|
|
|
34
35
|
size: PreviewSize
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
|
|
38
38
|
export function useStorageUploadController<M extends object>({
|
|
39
39
|
entityId,
|
|
40
40
|
entityValues,
|
|
@@ -58,6 +58,7 @@ export function useStorageUploadController<M extends object>({
|
|
|
58
58
|
onChange: (value: string | string[] | null) => void
|
|
59
59
|
}) {
|
|
60
60
|
|
|
61
|
+
const authController = useAuthController();
|
|
61
62
|
const storage: StorageConfig | undefined = property.dataType === "string"
|
|
62
63
|
? property.storage
|
|
63
64
|
: property.dataType === "array" &&
|
|
@@ -70,6 +71,8 @@ export function useStorageUploadController<M extends object>({
|
|
|
70
71
|
if (!storage)
|
|
71
72
|
throw Error("Storage meta must be specified");
|
|
72
73
|
|
|
74
|
+
const processFile = storage?.processFile;
|
|
75
|
+
|
|
73
76
|
const metadata: Record<string, any> | undefined = storage?.metadata;
|
|
74
77
|
const size = multipleFilesSupported ? "medium" : "large";
|
|
75
78
|
|
|
@@ -90,7 +93,8 @@ export function useStorageUploadController<M extends object>({
|
|
|
90
93
|
|
|
91
94
|
const resolvedProperty = resolveProperty({
|
|
92
95
|
propertyOrBuilder: property as PropertyOrBuilder,
|
|
93
|
-
values: entityValues
|
|
96
|
+
values: entityValues,
|
|
97
|
+
authController
|
|
94
98
|
}) as ResolvedStringProperty | ResolvedArrayProperty<string[]>;
|
|
95
99
|
|
|
96
100
|
const fileNameBuilder = useCallback(async (file: File) => {
|
|
@@ -170,7 +174,22 @@ export function useStorageUploadController<M extends object>({
|
|
|
170
174
|
if (!acceptedFiles.length || disabled)
|
|
171
175
|
return;
|
|
172
176
|
|
|
177
|
+
if (processFile) {
|
|
178
|
+
try {
|
|
179
|
+
acceptedFiles = await Promise.all(acceptedFiles.map(async file => {
|
|
180
|
+
const processedFile = await processFile(file);
|
|
181
|
+
if (!processedFile) {
|
|
182
|
+
return file;
|
|
183
|
+
}
|
|
184
|
+
return processedFile;
|
|
185
|
+
}));
|
|
186
|
+
} catch (e) {
|
|
187
|
+
console.error("Error processing file with custom code. Attempting to continue uploading.", e);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
173
191
|
let newInternalValue: StorageFieldItem[];
|
|
192
|
+
|
|
174
193
|
if (multipleFilesSupported) {
|
|
175
194
|
newInternalValue = [...internalValue,
|
|
176
195
|
...(await Promise.all(acceptedFiles.map(async file => {
|