@firecms/core 3.0.0-canary.211 → 3.0.0-canary.213
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/components/ArrayContainer.d.ts +12 -5
- package/dist/hooks/data/save.d.ts +1 -1
- package/dist/index.es.js +10571 -10708
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +10441 -10578
- 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 +2 -0
- package/dist/types/properties.d.ts +16 -1
- package/dist/util/property_utils.d.ts +2 -2
- package/dist/util/references.d.ts +2 -2
- package/dist/util/resolutions.d.ts +7 -2
- package/package.json +5 -5
- package/src/components/ArrayContainer.tsx +40 -23
- package/src/components/DeleteEntityDialog.tsx +4 -2
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +4 -2
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +4 -2
- package/src/components/EntityPreview.tsx +10 -3
- package/src/components/EntityView.tsx +4 -1
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +3 -1
- package/src/core/FireCMS.tsx +12 -11
- package/src/form/EntityForm.tsx +11 -6
- package/src/form/PropertyFieldBinding.tsx +6 -3
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +4 -1
- 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/StorageUploadFieldBinding.tsx +4 -1
- package/src/hooks/data/save.ts +24 -29
- package/src/hooks/useFireCMSContext.tsx +0 -30
- package/src/internal/useBuildDataSource.ts +9 -5
- package/src/internal/useBuildSideEntityController.tsx +22 -16
- 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/types/collections.ts +2 -0
- package/src/types/properties.ts +20 -1
- package/src/util/property_utils.tsx +7 -3
- package/src/util/references.ts +8 -6
- package/src/util/resolutions.ts +13 -7
- package/src/util/useStorageUploadController.tsx +4 -2
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { DataSource, DataSourceDelegate, NavigationController, PropertyConfig } from "../types";
|
|
1
|
+
import { AuthController, DataSource, DataSourceDelegate, NavigationController, PropertyConfig } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Use this hook to build a {@link DataSource} based on Firestore
|
|
4
4
|
* @param firebaseApp
|
|
5
5
|
* @group Firebase
|
|
6
6
|
*/
|
|
7
|
-
export declare function useBuildDataSource({ delegate, propertyConfigs, navigationController }: {
|
|
7
|
+
export declare function useBuildDataSource({ delegate, propertyConfigs, navigationController, authController }: {
|
|
8
8
|
delegate: DataSourceDelegate;
|
|
9
9
|
propertyConfigs?: Record<string, PropertyConfig>;
|
|
10
10
|
navigationController: NavigationController;
|
|
11
|
+
authController: AuthController;
|
|
11
12
|
}): DataSource;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomizationController, EntityCollection, EntitySidePanelProps, NavigationController, SideDialogsController, SideEntityController } from "../types";
|
|
2
|
-
export declare function getEntityViewWidth(props: EntitySidePanelProps<any>, small: boolean, customizationController: CustomizationController): string;
|
|
3
|
-
export declare const useBuildSideEntityController: (navigation: NavigationController, sideDialogsController: SideDialogsController) => SideEntityController;
|
|
1
|
+
import { AuthController, CustomizationController, EntityCollection, EntitySidePanelProps, NavigationController, SideDialogsController, SideEntityController } from "../types";
|
|
2
|
+
export declare function getEntityViewWidth(props: EntitySidePanelProps<any>, small: boolean, customizationController: CustomizationController, authController: AuthController): string;
|
|
3
|
+
export declare const useBuildSideEntityController: (navigation: NavigationController, sideDialogsController: SideDialogsController, authController: AuthController) => SideEntityController;
|
|
4
4
|
export declare function buildSidePanelsFromUrl(path: string, collections: EntityCollection[], newFlag: boolean): EntitySidePanelProps<any>[];
|
|
@@ -189,12 +189,14 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
|
|
|
189
189
|
* Force a filter in this view. If applied, the rest of the filters will
|
|
190
190
|
* be disabled. Filters applied with this prop cannot be changed.
|
|
191
191
|
* e.g. `forceFilter: { age: [">=", 18] }`
|
|
192
|
+
* e.g. `forceFilter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
|
|
192
193
|
*/
|
|
193
194
|
forceFilter?: FilterValues<Extract<keyof M, string>>;
|
|
194
195
|
/**
|
|
195
196
|
* Initial filters applied to the collection this collection is related to.
|
|
196
197
|
* Defaults to none. Filters applied with this prop can be changed.
|
|
197
198
|
* e.g. `initialFilter: { age: [">=", 18] }`
|
|
199
|
+
* e.g. `initialFilter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
|
|
198
200
|
*/
|
|
199
201
|
initialFilter?: FilterValues<Extract<keyof M, string>>;
|
|
200
202
|
/**
|
|
@@ -5,6 +5,7 @@ import { EntityReference, EntityValues, GeoPoint, Vector } from "./entities";
|
|
|
5
5
|
import { ResolvedArrayProperty, ResolvedStringProperty } from "./resolved_entities";
|
|
6
6
|
import { FilterValues } from "./collections";
|
|
7
7
|
import { ChipColorKey, ChipColorScheme } from "@firecms/ui";
|
|
8
|
+
import { AuthController } from "./auth";
|
|
8
9
|
/**
|
|
9
10
|
* @group Entity properties
|
|
10
11
|
*/
|
|
@@ -205,6 +206,10 @@ export type PropertyBuilderProps<M extends Record<string, any> = any> = {
|
|
|
205
206
|
* Entity ID
|
|
206
207
|
*/
|
|
207
208
|
entityId?: string;
|
|
209
|
+
/**
|
|
210
|
+
* Controller to manage authentication
|
|
211
|
+
*/
|
|
212
|
+
authController: AuthController;
|
|
208
213
|
};
|
|
209
214
|
/**
|
|
210
215
|
* You can use this type to define a property dynamically, based
|
|
@@ -212,7 +217,7 @@ export type PropertyBuilderProps<M extends Record<string, any> = any> = {
|
|
|
212
217
|
* current value of the property, as well as the path and entity ID.
|
|
213
218
|
* @group Entity properties
|
|
214
219
|
*/
|
|
215
|
-
export type PropertyBuilder<T extends CMSType = any, M extends Record<string, any> = any> = ({ values, previousValues, propertyValue, index, path, entityId }: PropertyBuilderProps<M>) => Property<T> | null;
|
|
220
|
+
export type PropertyBuilder<T extends CMSType = any, M extends Record<string, any> = any> = ({ values, previousValues, propertyValue, index, path, entityId, authController }: PropertyBuilderProps<M>) => Property<T> | null;
|
|
216
221
|
/**
|
|
217
222
|
* @group Entity properties
|
|
218
223
|
*/
|
|
@@ -371,6 +376,16 @@ export interface ArrayProperty<T extends ArrayT[] = any[], ArrayT extends CMSTyp
|
|
|
371
376
|
* extendable panel.
|
|
372
377
|
*/
|
|
373
378
|
minimalistView?: boolean;
|
|
379
|
+
/**
|
|
380
|
+
* Can the elements in this array be reordered. Defaults to `true`.
|
|
381
|
+
* This prop has no effect if `disabled` is set to true.
|
|
382
|
+
*/
|
|
383
|
+
sortable?: boolean;
|
|
384
|
+
/**
|
|
385
|
+
* Can the elements in this array be added. Defaults to `true`
|
|
386
|
+
* This prop has no effect if `disabled` is set to true.
|
|
387
|
+
*/
|
|
388
|
+
canAddElements?: boolean;
|
|
374
389
|
}
|
|
375
390
|
/**
|
|
376
391
|
* @group Entity properties
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { EntityCollection, PropertiesOrBuilders, PropertyConfig, PropertyOrBuilder, ResolvedProperties, ResolvedProperty } from "../types";
|
|
3
|
-
export declare function isReferenceProperty(propertyOrBuilder: PropertyOrBuilder, fields: Record<string, PropertyConfig>): boolean | null;
|
|
2
|
+
import { AuthController, EntityCollection, PropertiesOrBuilders, PropertyConfig, PropertyOrBuilder, ResolvedProperties, ResolvedProperty } from "../types";
|
|
3
|
+
export declare function isReferenceProperty(authController: AuthController, propertyOrBuilder: PropertyOrBuilder, fields: Record<string, PropertyConfig>): boolean | null;
|
|
4
4
|
export declare function getIdIcon(size: "small" | "medium" | "large"): React.ReactNode;
|
|
5
5
|
export declare function getIconForWidget(widget: PropertyConfig | undefined, size: "small" | "medium" | "large"): import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export declare function getIconForProperty(property: PropertyOrBuilder<any> | ResolvedProperty<any>, size?: "small" | "medium" | "large", fields?: Record<string, PropertyConfig>): React.ReactNode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntityCollection, PropertyConfig, ResolvedEntityCollection } from "../types";
|
|
2
|
-
export declare function getEntityPreviewKeys(targetCollection: EntityCollection<any>, fields: Record<string, PropertyConfig>, previewProperties?: string[], limit?: number): string[];
|
|
1
|
+
import { AuthController, EntityCollection, PropertyConfig, ResolvedEntityCollection } from "../types";
|
|
2
|
+
export declare function getEntityPreviewKeys(authController: AuthController, targetCollection: EntityCollection<any>, fields: Record<string, PropertyConfig>, previewProperties?: string[], limit?: number): string[];
|
|
3
3
|
export declare function getEntityTitlePropertyKey<M extends Record<string, any>>(collection: EntityCollection<M>, propertyConfigs: Record<string, PropertyConfig<any>>): string | undefined;
|
|
4
4
|
export declare function getEntityImagePreviewPropertyKey<M extends object>(collection: ResolvedEntityCollection<M>): string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ArrayProperty, CMSType, CustomizationController, EntityCollection, EntityCustomView, EntityValues, EnumValueConfig, EnumValues, NumberProperty, PropertiesOrBuilders, PropertyConfig, PropertyOrBuilder, ResolvedArrayProperty, ResolvedEntityCollection, ResolvedNumberProperty, ResolvedProperties, ResolvedProperty, ResolvedStringProperty, StringProperty, UserConfigurationPersistence } from "../types";
|
|
2
|
-
export declare const resolveCollection: <M extends Record<string, any>>({ collection, path, entityId, values, previousValues, userConfigPersistence, propertyConfigs, ignoreMissingFields }: {
|
|
1
|
+
import { ArrayProperty, AuthController, CMSType, CustomizationController, EntityCollection, EntityCustomView, EntityValues, EnumValueConfig, EnumValues, NumberProperty, PropertiesOrBuilders, PropertyConfig, PropertyOrBuilder, ResolvedArrayProperty, ResolvedEntityCollection, ResolvedNumberProperty, ResolvedProperties, ResolvedProperty, ResolvedStringProperty, StringProperty, UserConfigurationPersistence } from "../types";
|
|
2
|
+
export declare const resolveCollection: <M extends Record<string, any>>({ collection, path, entityId, values, previousValues, userConfigPersistence, propertyConfigs, ignoreMissingFields, authController }: {
|
|
3
3
|
collection: EntityCollection<M> | ResolvedEntityCollection<M>;
|
|
4
4
|
path: string;
|
|
5
5
|
entityId?: string;
|
|
@@ -8,6 +8,7 @@ export declare const resolveCollection: <M extends Record<string, any>>({ collec
|
|
|
8
8
|
userConfigPersistence?: UserConfigurationPersistence;
|
|
9
9
|
propertyConfigs?: Record<string, PropertyConfig>;
|
|
10
10
|
ignoreMissingFields?: boolean;
|
|
11
|
+
authController: AuthController;
|
|
11
12
|
}) => ResolvedEntityCollection<M>;
|
|
12
13
|
/**
|
|
13
14
|
* Resolve property builders, enums and arrays.
|
|
@@ -25,6 +26,7 @@ export declare function resolveProperty<T extends CMSType = CMSType, M extends R
|
|
|
25
26
|
fromBuilder?: boolean;
|
|
26
27
|
propertyConfigs?: Record<string, PropertyConfig<any>>;
|
|
27
28
|
ignoreMissingFields?: boolean;
|
|
29
|
+
authController: AuthController;
|
|
28
30
|
}): ResolvedProperty<T> | null;
|
|
29
31
|
export declare function getArrayResolvedProperties<M>({ propertyKey, propertyValue, property, ...props }: {
|
|
30
32
|
propertyValue: any;
|
|
@@ -38,6 +40,7 @@ export declare function getArrayResolvedProperties<M>({ propertyKey, propertyVal
|
|
|
38
40
|
index?: number;
|
|
39
41
|
fromBuilder?: boolean;
|
|
40
42
|
propertyConfigs?: Record<string, PropertyConfig>;
|
|
43
|
+
authController: AuthController;
|
|
41
44
|
}): ResolvedProperty[];
|
|
42
45
|
export declare function resolveArrayProperty<T extends any[], M>({ propertyKey, property, ignoreMissingFields, ...props }: {
|
|
43
46
|
propertyKey?: string;
|
|
@@ -50,6 +53,7 @@ export declare function resolveArrayProperty<T extends any[], M>({ propertyKey,
|
|
|
50
53
|
fromBuilder?: boolean;
|
|
51
54
|
propertyConfigs?: Record<string, PropertyConfig>;
|
|
52
55
|
ignoreMissingFields?: boolean;
|
|
56
|
+
authController: AuthController;
|
|
53
57
|
}): ResolvedArrayProperty;
|
|
54
58
|
/**
|
|
55
59
|
* Resolve enums and arrays for properties
|
|
@@ -67,6 +71,7 @@ export declare function resolveProperties<M extends Record<string, any>>({ prope
|
|
|
67
71
|
fromBuilder?: boolean;
|
|
68
72
|
propertyConfigs?: Record<string, PropertyConfig>;
|
|
69
73
|
ignoreMissingFields?: boolean;
|
|
74
|
+
authController: AuthController;
|
|
70
75
|
}): ResolvedProperties<M>;
|
|
71
76
|
/**
|
|
72
77
|
* Resolve enum aliases for a string or number property
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-canary.
|
|
4
|
+
"version": "3.0.0-canary.213",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"./package.json": "./package.json"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@firecms/editor": "^3.0.0-canary.
|
|
54
|
-
"@firecms/formex": "^3.0.0-canary.
|
|
55
|
-
"@firecms/ui": "^3.0.0-canary.
|
|
53
|
+
"@firecms/editor": "^3.0.0-canary.213",
|
|
54
|
+
"@firecms/formex": "^3.0.0-canary.213",
|
|
55
|
+
"@firecms/ui": "^3.0.0-canary.213",
|
|
56
56
|
"@hello-pangea/dnd": "^17.0.0",
|
|
57
57
|
"@radix-ui/react-portal": "^1.1.3",
|
|
58
58
|
"clsx": "^2.1.1",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"dist",
|
|
106
106
|
"src"
|
|
107
107
|
],
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "e57f5d7fbaf78a58ac7eb116efde1c1445b0e5cd",
|
|
109
109
|
"publishConfig": {
|
|
110
110
|
"access": "public"
|
|
111
111
|
},
|
|
@@ -37,7 +37,12 @@ export interface ArrayContainerProps<T> {
|
|
|
37
37
|
disabled?: boolean;
|
|
38
38
|
size?: "small" | "medium";
|
|
39
39
|
onInternalIdAdded?: (id: number) => void;
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Use `canAddElements` instead
|
|
42
|
+
*/
|
|
40
43
|
includeAddButton?: boolean;
|
|
44
|
+
canAddElements?: boolean;
|
|
45
|
+
sortable?: boolean;
|
|
41
46
|
newDefaultEntry: T;
|
|
42
47
|
onValueChange: (value: T[]) => void,
|
|
43
48
|
className?: string;
|
|
@@ -66,7 +71,9 @@ export function ArrayContainer<T>({
|
|
|
66
71
|
buildEntry,
|
|
67
72
|
size = "medium",
|
|
68
73
|
onInternalIdAdded,
|
|
69
|
-
includeAddButton,
|
|
74
|
+
includeAddButton: deprecatedIncludeAddButton,
|
|
75
|
+
canAddElements: canAddElementsProp = true,
|
|
76
|
+
sortable = true,
|
|
70
77
|
newDefaultEntry,
|
|
71
78
|
onValueChange,
|
|
72
79
|
className,
|
|
@@ -74,6 +81,9 @@ export function ArrayContainer<T>({
|
|
|
74
81
|
max = Infinity
|
|
75
82
|
}: ArrayContainerProps<T>) {
|
|
76
83
|
|
|
84
|
+
const canAddElements = (canAddElementsProp || canAddElementsProp === undefined)
|
|
85
|
+
&& (deprecatedIncludeAddButton === undefined || deprecatedIncludeAddButton);
|
|
86
|
+
|
|
77
87
|
const hasValue = value && Array.isArray(value) && value.length > 0;
|
|
78
88
|
|
|
79
89
|
// Used to track the ids that have displayed the initial show animation
|
|
@@ -193,7 +203,8 @@ export function ArrayContainer<T>({
|
|
|
193
203
|
storedProps={itemCustomPropsRef.current[internalId]}
|
|
194
204
|
updateItemCustomProps={updateItemCustomProps}
|
|
195
205
|
addInIndex={addInIndex}
|
|
196
|
-
|
|
206
|
+
canAddElements={canAddElements}
|
|
207
|
+
sortable={sortable}
|
|
197
208
|
/>
|
|
198
209
|
);
|
|
199
210
|
}}
|
|
@@ -208,7 +219,7 @@ export function ArrayContainer<T>({
|
|
|
208
219
|
<Draggable
|
|
209
220
|
key={`array_field_${internalId}`}
|
|
210
221
|
draggableId={`array_field_${internalId}`}
|
|
211
|
-
isDragDisabled={disabled}
|
|
222
|
+
isDragDisabled={disabled || !sortable}
|
|
212
223
|
index={index}>
|
|
213
224
|
{(provided, snapshot) => (
|
|
214
225
|
<ArrayContainerItem
|
|
@@ -224,7 +235,8 @@ export function ArrayContainer<T>({
|
|
|
224
235
|
storedProps={itemCustomPropsRef.current[internalId]}
|
|
225
236
|
updateItemCustomProps={updateItemCustomProps}
|
|
226
237
|
addInIndex={addInIndex}
|
|
227
|
-
|
|
238
|
+
canAddElements={canAddElements}
|
|
239
|
+
sortable={sortable}
|
|
228
240
|
/>
|
|
229
241
|
)}
|
|
230
242
|
</Draggable>
|
|
@@ -233,7 +245,7 @@ export function ArrayContainer<T>({
|
|
|
233
245
|
|
|
234
246
|
{droppableProvided.placeholder}
|
|
235
247
|
|
|
236
|
-
{
|
|
248
|
+
{canAddElements && (
|
|
237
249
|
<div className="my-4 justify-center text-left">
|
|
238
250
|
<Button
|
|
239
251
|
variant={"text"}
|
|
@@ -263,7 +275,8 @@ type ArrayContainerItemProps = {
|
|
|
263
275
|
remove: (index: number) => void,
|
|
264
276
|
copy: (index: number) => void,
|
|
265
277
|
addInIndex?: (index: number) => void,
|
|
266
|
-
|
|
278
|
+
canAddElements?: boolean,
|
|
279
|
+
sortable: boolean,
|
|
267
280
|
isDragging: boolean,
|
|
268
281
|
storedProps?: object,
|
|
269
282
|
updateItemCustomProps: (internalId: number, props: object) => void
|
|
@@ -278,7 +291,8 @@ export function ArrayContainerItem({
|
|
|
278
291
|
buildEntry,
|
|
279
292
|
remove,
|
|
280
293
|
addInIndex,
|
|
281
|
-
|
|
294
|
+
canAddElements,
|
|
295
|
+
sortable,
|
|
282
296
|
copy,
|
|
283
297
|
isDragging,
|
|
284
298
|
storedProps,
|
|
@@ -311,7 +325,8 @@ export function ArrayContainerItem({
|
|
|
311
325
|
index={index}
|
|
312
326
|
provided={provided}
|
|
313
327
|
addInIndex={addInIndex}
|
|
314
|
-
|
|
328
|
+
canAddElements={canAddElements}
|
|
329
|
+
sortable={sortable}
|
|
315
330
|
copy={copy}/>
|
|
316
331
|
</div>
|
|
317
332
|
</div>;
|
|
@@ -324,7 +339,8 @@ export function ArrayItemOptions({
|
|
|
324
339
|
index,
|
|
325
340
|
provided,
|
|
326
341
|
copy,
|
|
327
|
-
|
|
342
|
+
canAddElements,
|
|
343
|
+
sortable,
|
|
328
344
|
addInIndex
|
|
329
345
|
}: {
|
|
330
346
|
direction?: "row" | "column",
|
|
@@ -333,7 +349,8 @@ export function ArrayItemOptions({
|
|
|
333
349
|
index: number,
|
|
334
350
|
provided: any,
|
|
335
351
|
copy: (index: number) => void,
|
|
336
|
-
|
|
352
|
+
sortable: boolean,
|
|
353
|
+
canAddElements?: boolean,
|
|
337
354
|
addInIndex?: (index: number) => void
|
|
338
355
|
}) {
|
|
339
356
|
|
|
@@ -349,10 +366,10 @@ export function ArrayItemOptions({
|
|
|
349
366
|
delayDuration={400}
|
|
350
367
|
open={menuOpen ? false : undefined}
|
|
351
368
|
side={direction === "column" ? "left" : undefined}
|
|
352
|
-
title="Drag to move. Click for more options">
|
|
369
|
+
title={!disabled && sortable ? "Drag to move. Click for more options" : undefined}>
|
|
353
370
|
<IconButton
|
|
354
371
|
size="small"
|
|
355
|
-
disabled={disabled}
|
|
372
|
+
disabled={disabled || !canAddElements}
|
|
356
373
|
onClick={(e) => {
|
|
357
374
|
e.preventDefault();
|
|
358
375
|
setMenuOpen(true);
|
|
@@ -360,7 +377,7 @@ export function ArrayItemOptions({
|
|
|
360
377
|
onDragStart={(e: any) => {
|
|
361
378
|
setMenuOpen(false);
|
|
362
379
|
}}
|
|
363
|
-
className={
|
|
380
|
+
className={disabled || !sortable ? "cursor-inherit" : "cursor-grab"}>
|
|
364
381
|
<HandleIcon/>
|
|
365
382
|
</IconButton>
|
|
366
383
|
|
|
@@ -384,20 +401,20 @@ export function ArrayItemOptions({
|
|
|
384
401
|
Copy
|
|
385
402
|
</MenuItem>
|
|
386
403
|
|
|
387
|
-
{
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
404
|
+
{addInIndex && <MenuItem dense
|
|
405
|
+
onClick={() => {
|
|
406
|
+
setMenuOpen(false);
|
|
407
|
+
addInIndex(index);
|
|
408
|
+
}}>
|
|
392
409
|
<KeyboardArrowUpIcon size={"small"}/>
|
|
393
410
|
Add on top
|
|
394
411
|
</MenuItem>}
|
|
395
412
|
|
|
396
|
-
{
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
413
|
+
{addInIndex && <MenuItem dense
|
|
414
|
+
onClick={() => {
|
|
415
|
+
setMenuOpen(false);
|
|
416
|
+
addInIndex(index + 1);
|
|
417
|
+
}}>
|
|
401
418
|
<KeyboardArrowDownIcon size={"small"}/>
|
|
402
419
|
Add below
|
|
403
420
|
</MenuItem>}
|
|
@@ -3,6 +3,7 @@ import React, { useCallback, useMemo, useState } from "react";
|
|
|
3
3
|
import { Button, CircularProgress, Dialog, DialogActions, DialogContent, DialogTitle } from "@firecms/ui";
|
|
4
4
|
import {
|
|
5
5
|
deleteEntityWithCallbacks,
|
|
6
|
+
useAuthController,
|
|
6
7
|
useCustomizationController,
|
|
7
8
|
useDataSource,
|
|
8
9
|
useFireCMSContext,
|
|
@@ -34,7 +35,7 @@ export function DeleteEntityDialog<M extends Record<string, any>>({
|
|
|
34
35
|
onMultipleEntitiesDelete,
|
|
35
36
|
path
|
|
36
37
|
}: DeleteEntityDialogProps<M>) {
|
|
37
|
-
|
|
38
|
+
const authController = useAuthController();
|
|
38
39
|
const dataSource = useDataSource(collection);
|
|
39
40
|
const customizationController = useCustomizationController();
|
|
40
41
|
const snackbarController = useSnackbarController();
|
|
@@ -50,7 +51,8 @@ export function DeleteEntityDialog<M extends Record<string, any>>({
|
|
|
50
51
|
const resolvedCollection = useMemo(() => resolveCollection<M>({
|
|
51
52
|
collection,
|
|
52
53
|
path,
|
|
53
|
-
propertyConfigs: customizationController.propertyConfigs
|
|
54
|
+
propertyConfigs: customizationController.propertyConfigs,
|
|
55
|
+
authController
|
|
54
56
|
}), [collection, path]);
|
|
55
57
|
|
|
56
58
|
const handleCancel = useCallback(() => {
|
|
@@ -21,7 +21,7 @@ import { ElementResizeListener } from "./ElementResizeListener";
|
|
|
21
21
|
import { getPropertyInPath, isReadOnly, resolveCollection } from "../../../../util";
|
|
22
22
|
import { Button, CloseIcon, DialogActions, IconButton, Typography } from "@firecms/ui";
|
|
23
23
|
import { PropertyFieldBinding, yupToFormErrors } from "../../../../form";
|
|
24
|
-
import { useCustomizationController, useDataSource, useFireCMSContext } from "../../../../hooks";
|
|
24
|
+
import { useAuthController, useCustomizationController, useDataSource, useFireCMSContext } from "../../../../hooks";
|
|
25
25
|
import { OnCellValueChangeParams } from "../../../common";
|
|
26
26
|
|
|
27
27
|
interface PopupFormFieldProps<M extends Record<string, any>> {
|
|
@@ -107,6 +107,7 @@ export function PopupFormFieldInternal<M extends Record<string, any>>({
|
|
|
107
107
|
}) {
|
|
108
108
|
|
|
109
109
|
const fireCMSContext = useFireCMSContext();
|
|
110
|
+
const authController = useAuthController();
|
|
110
111
|
const customizationController = useCustomizationController();
|
|
111
112
|
|
|
112
113
|
const [savingError, setSavingError] = React.useState<any>();
|
|
@@ -121,7 +122,8 @@ export function PopupFormFieldInternal<M extends Record<string, any>>({
|
|
|
121
122
|
path,
|
|
122
123
|
values: entity?.values,
|
|
123
124
|
entityId,
|
|
124
|
-
propertyConfigs: customizationController.propertyConfigs
|
|
125
|
+
propertyConfigs: customizationController.propertyConfigs,
|
|
126
|
+
authController
|
|
125
127
|
})
|
|
126
128
|
: undefined;
|
|
127
129
|
|
|
@@ -378,7 +378,8 @@ export const EntityCollectionView = React.memo(
|
|
|
378
378
|
const resolvedCollection = useMemo(() => resolveCollection<M>({
|
|
379
379
|
collection,
|
|
380
380
|
path: fullPath,
|
|
381
|
-
propertyConfigs: customizationController.propertyConfigs
|
|
381
|
+
propertyConfigs: customizationController.propertyConfigs,
|
|
382
|
+
authController,
|
|
382
383
|
}), [collection, fullPath]);
|
|
383
384
|
|
|
384
385
|
const getPropertyFor = useCallback(({
|
|
@@ -399,7 +400,8 @@ export const EntityCollectionView = React.memo(
|
|
|
399
400
|
path: entity.path,
|
|
400
401
|
values: entity.values,
|
|
401
402
|
entityId: entity.id,
|
|
402
|
-
propertyConfigs: customizationController.propertyConfigs
|
|
403
|
+
propertyConfigs: customizationController.propertyConfigs,
|
|
404
|
+
authController
|
|
403
405
|
});
|
|
404
406
|
}, [collection.properties, customizationController.propertyConfigs, resolvedCollection.properties]);
|
|
405
407
|
|
|
@@ -13,7 +13,12 @@ import {
|
|
|
13
13
|
} from "../util";
|
|
14
14
|
import { cls, defaultBorderMixin, IconButton, KeyboardTabIcon, Skeleton, Tooltip, Typography } from "@firecms/ui";
|
|
15
15
|
import { PreviewSize, PropertyPreview, SkeletonPropertyComponent } from "../preview";
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
useAuthController,
|
|
18
|
+
useCustomizationController,
|
|
19
|
+
useNavigationController,
|
|
20
|
+
useSideEntityController
|
|
21
|
+
} from "../hooks";
|
|
17
22
|
import { useAnalyticsController } from "../hooks/useAnalyticsController";
|
|
18
23
|
|
|
19
24
|
export type EntityPreviewProps = {
|
|
@@ -46,6 +51,7 @@ export function EntityPreview({
|
|
|
46
51
|
entity
|
|
47
52
|
}: EntityPreviewProps) {
|
|
48
53
|
|
|
54
|
+
const authController = useAuthController();
|
|
49
55
|
const analyticsController = useAnalyticsController();
|
|
50
56
|
const sideEntityController = useSideEntityController();
|
|
51
57
|
const customizationController = useCustomizationController();
|
|
@@ -62,10 +68,11 @@ export function EntityPreview({
|
|
|
62
68
|
collection,
|
|
63
69
|
path: entity.path,
|
|
64
70
|
values: entity.values,
|
|
65
|
-
propertyConfigs: customizationController.propertyConfigs
|
|
71
|
+
propertyConfigs: customizationController.propertyConfigs,
|
|
72
|
+
authController
|
|
66
73
|
}), [collection]);
|
|
67
74
|
|
|
68
|
-
const listProperties = useMemo(() => getEntityPreviewKeys(resolvedCollection, customizationController.propertyConfigs, previewProperties, size === "medium" || size === "large" ? 3 : 1),
|
|
75
|
+
const listProperties = useMemo(() => getEntityPreviewKeys(authController, resolvedCollection, customizationController.propertyConfigs, previewProperties, size === "medium" || size === "large" ? 3 : 1),
|
|
69
76
|
[previewProperties, resolvedCollection, size]);
|
|
70
77
|
|
|
71
78
|
const titleProperty = getEntityTitlePropertyKey(resolvedCollection, customizationController.propertyConfigs);
|
|
@@ -5,6 +5,7 @@ import { resolveCollection } from "../util";
|
|
|
5
5
|
import { cls, defaultBorderMixin, IconButton, OpenInNewIcon } from "@firecms/ui";
|
|
6
6
|
import { CustomizationController } from "../types/customization_controller";
|
|
7
7
|
import { useCustomizationController } from "../hooks/useCustomizationController";
|
|
8
|
+
import { useAuthController } from "../hooks";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @group Components
|
|
@@ -24,13 +25,15 @@ export function EntityView<M extends Record<string, any>>(
|
|
|
24
25
|
className
|
|
25
26
|
}: EntityViewProps<M>) {
|
|
26
27
|
|
|
28
|
+
const authController = useAuthController();
|
|
27
29
|
const customizationController: CustomizationController = useCustomizationController();
|
|
28
30
|
const resolvedCollection: ResolvedEntityCollection<M> = useMemo(() => resolveCollection<M>({
|
|
29
31
|
collection,
|
|
30
32
|
path,
|
|
31
33
|
entityId: entity.id,
|
|
32
34
|
values: entity.values,
|
|
33
|
-
propertyConfigs: customizationController.propertyConfigs
|
|
35
|
+
propertyConfigs: customizationController.propertyConfigs,
|
|
36
|
+
authController
|
|
34
37
|
}), [collection, path, entity, customizationController.propertyConfigs]);
|
|
35
38
|
|
|
36
39
|
const properties: ResolvedProperties = resolvedCollection.properties;
|
|
@@ -101,6 +101,7 @@ export function ReferenceSelectionTable<M extends Record<string, any>>(
|
|
|
101
101
|
maxSelection,
|
|
102
102
|
}: ReferenceSelectionInnerProps<M>) {
|
|
103
103
|
|
|
104
|
+
const authController = useAuthController();
|
|
104
105
|
const sideDialogContext = useSideDialogContext();
|
|
105
106
|
const sideEntityController = useSideEntityController();
|
|
106
107
|
const navigation = useNavigationController();
|
|
@@ -253,7 +254,8 @@ export function ReferenceSelectionTable<M extends Record<string, any>>(
|
|
|
253
254
|
collection: collection,
|
|
254
255
|
path: fullPath,
|
|
255
256
|
values: {},
|
|
256
|
-
propertyConfigs: customizationController.propertyConfigs
|
|
257
|
+
propertyConfigs: customizationController.propertyConfigs,
|
|
258
|
+
authController
|
|
257
259
|
}), [collection, customizationController.propertyConfigs, fullPath]);
|
|
258
260
|
|
|
259
261
|
const displayedColumnIds = useColumnIds(resolvedCollection, false);
|
package/src/core/FireCMS.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import React, { useMemo } from "react";
|
|
4
4
|
import { CenteredView, Typography } from "@firecms/ui";
|
|
5
|
-
import { CustomizationController,
|
|
5
|
+
import { CustomizationController, FireCMSContext, FireCMSPlugin, FireCMSProps, User } from "../types";
|
|
6
6
|
import { AuthControllerContext } from "../contexts";
|
|
7
7
|
import { useBuildSideEntityController } from "../internal/useBuildSideEntityController";
|
|
8
8
|
import { useCustomizationController, useFireCMSContext } from "../hooks";
|
|
@@ -53,17 +53,8 @@ export function FireCMS<USER extends User>(props: FireCMSProps<USER>) {
|
|
|
53
53
|
apiKey
|
|
54
54
|
} = props;
|
|
55
55
|
|
|
56
|
-
/**
|
|
57
|
-
* Controller in charge of fetching and persisting data
|
|
58
|
-
*/
|
|
59
|
-
const dataSource = useBuildDataSource({
|
|
60
|
-
delegate: dataSourceDelegate,
|
|
61
|
-
propertyConfigs,
|
|
62
|
-
navigationController
|
|
63
|
-
});
|
|
64
|
-
|
|
65
56
|
const sideDialogsController = useBuildSideDialogsController();
|
|
66
|
-
const sideEntityController = useBuildSideEntityController(navigationController, sideDialogsController);
|
|
57
|
+
const sideEntityController = useBuildSideEntityController(navigationController, sideDialogsController, authController);
|
|
67
58
|
|
|
68
59
|
const pluginsLoading = plugins?.some(p => p.loading) ?? false;
|
|
69
60
|
|
|
@@ -90,6 +81,16 @@ export function FireCMS<USER extends User>(props: FireCMSProps<USER>) {
|
|
|
90
81
|
plugins
|
|
91
82
|
});
|
|
92
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Controller in charge of fetching and persisting data
|
|
86
|
+
*/
|
|
87
|
+
const dataSource = useBuildDataSource({
|
|
88
|
+
delegate: dataSourceDelegate,
|
|
89
|
+
propertyConfigs,
|
|
90
|
+
navigationController,
|
|
91
|
+
authController
|
|
92
|
+
});
|
|
93
|
+
|
|
93
94
|
if (accessResponse?.message) {
|
|
94
95
|
console.warn(accessResponse.message);
|
|
95
96
|
}
|
package/src/form/EntityForm.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from "react";
|
|
2
2
|
import {
|
|
3
|
+
AuthController,
|
|
3
4
|
CMSAnalyticsEvent,
|
|
4
5
|
Entity,
|
|
5
6
|
EntityCollection,
|
|
@@ -28,6 +29,7 @@ import {
|
|
|
28
29
|
|
|
29
30
|
import {
|
|
30
31
|
saveEntityWithCallbacks,
|
|
32
|
+
useAuthController,
|
|
31
33
|
useCustomizationController,
|
|
32
34
|
useDataSource,
|
|
33
35
|
useFireCMSContext,
|
|
@@ -116,6 +118,7 @@ export function EntityForm<M extends Record<string, any>>({
|
|
|
116
118
|
console.warn(`The collection ${collection.path} has customId and formAutoSave enabled. This is not supported and formAutoSave will be ignored`);
|
|
117
119
|
}
|
|
118
120
|
|
|
121
|
+
const authController = useAuthController();
|
|
119
122
|
const [status, setStatus] = useState<EntityStatus>(initialStatus);
|
|
120
123
|
const [saving, setSaving] = useState(false);
|
|
121
124
|
|
|
@@ -204,7 +207,7 @@ export function EntityForm<M extends Record<string, any>>({
|
|
|
204
207
|
};
|
|
205
208
|
|
|
206
209
|
const formex: FormexController<M> = formexProp ?? useCreateFormex<M>({
|
|
207
|
-
initialValues: (initialDirtyValues ?? getInitialEntityValues(collection, path, status, entity, customizationController.propertyConfigs)) as M,
|
|
210
|
+
initialValues: (initialDirtyValues ?? getInitialEntityValues(authController, collection, path, status, entity, customizationController.propertyConfigs)) as M,
|
|
208
211
|
initialDirty: Boolean(initialDirtyValues),
|
|
209
212
|
onSubmit,
|
|
210
213
|
onReset: () => {
|
|
@@ -222,7 +225,6 @@ export function EntityForm<M extends Record<string, any>>({
|
|
|
222
225
|
}
|
|
223
226
|
});
|
|
224
227
|
|
|
225
|
-
|
|
226
228
|
useEffect(() => {
|
|
227
229
|
|
|
228
230
|
const handleKeyDown = (e: KeyboardEvent) => {
|
|
@@ -251,7 +253,8 @@ export function EntityForm<M extends Record<string, any>>({
|
|
|
251
253
|
entityId,
|
|
252
254
|
values: formex.values,
|
|
253
255
|
previousValues: formex.initialValues,
|
|
254
|
-
propertyConfigs: customizationController.propertyConfigs
|
|
256
|
+
propertyConfigs: customizationController.propertyConfigs,
|
|
257
|
+
authController
|
|
255
258
|
}), [collection, path, entityId, formex.values, formex.initialValues, customizationController.propertyConfigs]);
|
|
256
259
|
|
|
257
260
|
const onPreSaveHookError = useCallback((e: Error) => {
|
|
@@ -679,7 +682,7 @@ export function EntityForm<M extends Record<string, any>>({
|
|
|
679
682
|
<form
|
|
680
683
|
onSubmit={formContext.formex.handleSubmit}
|
|
681
684
|
onReset={() => formex.resetForm({
|
|
682
|
-
values: getInitialEntityValues(collection, path, status, entity, customizationController.propertyConfigs) as M
|
|
685
|
+
values: getInitialEntityValues(authController, collection, path, status, entity, customizationController.propertyConfigs) as M
|
|
683
686
|
})}
|
|
684
687
|
noValidate
|
|
685
688
|
className={cls("flex-1 flex flex-row w-full overflow-y-auto justify-center", className)}>
|
|
@@ -716,17 +719,19 @@ export function EntityForm<M extends Record<string, any>>({
|
|
|
716
719
|
}
|
|
717
720
|
|
|
718
721
|
function getInitialEntityValues<M extends object>(
|
|
722
|
+
authController: AuthController,
|
|
719
723
|
collection: EntityCollection,
|
|
720
724
|
path: string,
|
|
721
725
|
status: "new" | "existing" | "copy",
|
|
722
726
|
entity: Entity<M> | undefined,
|
|
723
|
-
propertyConfigs?: Record<string, PropertyConfig
|
|
727
|
+
propertyConfigs?: Record<string, PropertyConfig>,
|
|
724
728
|
): Partial<EntityValues<M>> {
|
|
725
729
|
const resolvedCollection = resolveCollection({
|
|
726
730
|
collection,
|
|
727
731
|
path,
|
|
728
732
|
values: entity?.values,
|
|
729
|
-
propertyConfigs
|
|
733
|
+
propertyConfigs,
|
|
734
|
+
authController
|
|
730
735
|
});
|
|
731
736
|
const properties = resolvedCollection.properties;
|
|
732
737
|
if ((status === "existing" || status === "copy") && entity) {
|