@firecms/collection_editor 3.0.0-alpha.28 → 3.0.0-alpha.30

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.
Files changed (35) hide show
  1. package/dist/components/CollectionViewHeaderAction.d.ts +3 -1
  2. package/dist/components/PropertyAddColumnComponent.d.ts +2 -2
  3. package/dist/components/collection_editor/CollectionPropertiesEditorForm.d.ts +3 -2
  4. package/dist/components/collection_editor/PropertyEditView.d.ts +2 -1
  5. package/dist/components/collection_editor/PropertyTree.d.ts +4 -2
  6. package/dist/components/collection_editor/import/CollectionEditorImportMapping.d.ts +2 -1
  7. package/dist/components/collection_editor/properties/BlockPropertyField.d.ts +2 -1
  8. package/dist/components/collection_editor/properties/MapPropertyField.d.ts +2 -1
  9. package/dist/components/collection_editor/properties/RepeatPropertyField.d.ts +2 -1
  10. package/dist/components/collection_editor/templates/blog_template.d.ts +1 -1
  11. package/dist/components/collection_editor/templates/products_template.d.ts +1 -1
  12. package/dist/components/collection_editor/templates/users_template.d.ts +1 -1
  13. package/dist/index.es.js +1907 -1871
  14. package/dist/index.es.js.map +1 -1
  15. package/dist/index.umd.js +1 -1
  16. package/dist/index.umd.js.map +1 -1
  17. package/dist/types/collection_editor_controller.d.ts +4 -2
  18. package/dist/types/persisted_collection.d.ts +2 -1
  19. package/dist/useCollectionEditorPlugin.d.ts +1 -1
  20. package/package.json +4 -4
  21. package/src/ConfigControllerProvider.tsx +14 -5
  22. package/src/components/CollectionViewHeaderAction.tsx +7 -3
  23. package/src/components/PropertyAddColumnComponent.tsx +4 -2
  24. package/src/components/collection_editor/CollectionEditorDialog.tsx +7 -3
  25. package/src/components/collection_editor/CollectionPropertiesEditorForm.tsx +8 -2
  26. package/src/components/collection_editor/EnumForm.tsx +8 -6
  27. package/src/components/collection_editor/PropertyEditView.tsx +15 -4
  28. package/src/components/collection_editor/PropertyTree.tsx +15 -6
  29. package/src/components/collection_editor/import/CollectionEditorImportMapping.tsx +6 -3
  30. package/src/components/collection_editor/properties/BlockPropertyField.tsx +5 -2
  31. package/src/components/collection_editor/properties/MapPropertyField.tsx +5 -2
  32. package/src/components/collection_editor/properties/RepeatPropertyField.tsx +6 -3
  33. package/src/types/collection_editor_controller.tsx +4 -2
  34. package/src/types/persisted_collection.ts +3 -2
  35. package/src/useCollectionEditorPlugin.tsx +3 -8
@@ -1,5 +1,6 @@
1
1
  import { CollectionEditorPermissionsBuilder } from "./config_permissions";
2
2
  import { EntityCollection, Property } from "@firecms/core";
3
+ import { PersistedCollection } from "./persisted_collection";
3
4
  /**
4
5
  * Controller to open the collection editor dialog.
5
6
  * @category Hooks and utilities
@@ -9,7 +10,7 @@ export interface CollectionEditorController {
9
10
  path?: string;
10
11
  fullPath?: string;
11
12
  parentPathSegments: string[];
12
- parentCollection?: EntityCollection<any, any, any>;
13
+ parentCollection?: EntityCollection;
13
14
  }) => void;
14
15
  createCollection: (props: {
15
16
  initialValues?: {
@@ -18,7 +19,7 @@ export interface CollectionEditorController {
18
19
  name?: string;
19
20
  };
20
21
  parentPathSegments: string[];
21
- parentCollection?: EntityCollection<any, any, any>;
22
+ parentCollection?: PersistedCollection;
22
23
  redirect: boolean;
23
24
  }) => void;
24
25
  editProperty: (props: {
@@ -27,6 +28,7 @@ export interface CollectionEditorController {
27
28
  currentPropertiesOrder?: string[];
28
29
  editedCollectionPath: string;
29
30
  parentPathSegments: string[];
31
+ collection: PersistedCollection;
30
32
  }) => void;
31
33
  configPermissions: CollectionEditorPermissionsBuilder;
32
34
  rootPathSuggestions?: string[];
@@ -1,6 +1,7 @@
1
1
  import { EntityCollection, Properties, User } from "@firecms/core";
2
- export type PersistedCollection<M extends Record<string, any> = any, AdditionalKey extends string = string, UserType extends User = User> = Omit<EntityCollection<M, AdditionalKey, UserType>, "properties" | "subcollections"> & {
2
+ export type PersistedCollection<M extends Record<string, any> = any, UserType extends User = User> = Omit<EntityCollection<M, UserType>, "properties" | "subcollections"> & {
3
3
  properties: Properties<M>;
4
4
  ownerId: string;
5
5
  subcollections?: PersistedCollection<any, any>[];
6
+ editable?: boolean;
6
7
  };
@@ -41,4 +41,4 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
41
41
  * @param getUser
42
42
  * @param collectionInference
43
43
  */
44
- export declare function useCollectionEditorPlugin<EC extends PersistedCollection = PersistedCollection, UserType extends User = User>({ collectionConfigController, configPermissions, reservedGroups, extraView, pathSuggestions, getUser, collectionInference, getData }: CollectionConfigControllerProps<EC, UserType>): FireCMSPlugin;
44
+ export declare function useCollectionEditorPlugin<EC extends PersistedCollection = PersistedCollection, UserType extends User = User>({ collectionConfigController, configPermissions, reservedGroups, extraView, pathSuggestions, getUser, collectionInference, getData }: CollectionConfigControllerProps<EC, UserType>): FireCMSPlugin<any, any, PersistedCollection>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firecms/collection_editor",
3
- "version": "3.0.0-alpha.28",
3
+ "version": "3.0.0-alpha.30",
4
4
  "main": "./dist/index.umd.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,8 +14,8 @@
14
14
  "./package.json": "./package.json"
15
15
  },
16
16
  "dependencies": {
17
- "@firecms/data_import": "^3.0.0-alpha.28",
18
- "@firecms/schema_inference": "^3.0.0-alpha.28"
17
+ "@firecms/data_import": "^3.0.0-alpha.30",
18
+ "@firecms/schema_inference": "^3.0.0-alpha.30"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "react": "^18.2.0",
@@ -76,5 +76,5 @@
76
76
  "publishConfig": {
77
77
  "access": "public"
78
78
  },
79
- "gitHead": "aba9501b45cf2dc84dc172084510b90e417b42f1"
79
+ "gitHead": "89854d00f9088e09134623a84be752990c6cbc32"
80
80
  }
@@ -16,6 +16,7 @@ import { CollectionEditorController } from "./types/collection_editor_controller
16
16
  import { CollectionEditorPermissionsBuilder } from "./types/config_permissions";
17
17
  import { CollectionInference } from "./types/collection_inference";
18
18
  import { PropertyFormDialog } from "./components/collection_editor/PropertyEditView";
19
+ import { PersistedCollection } from "./types/persisted_collection";
19
20
 
20
21
  export const ConfigControllerContext = React.createContext<CollectionsConfigController>({} as any);
21
22
  export const CollectionEditorContext = React.createContext<CollectionEditorController>({} as any);
@@ -111,6 +112,7 @@ export const ConfigControllerProvider = React.memo(
111
112
  editedCollectionPath: string,
112
113
  fullPath?: string,
113
114
  parentPathSegments: string[],
115
+ collectionEditable: boolean;
114
116
  }>();
115
117
 
116
118
  const defaultConfigPermissions: CollectionEditorPermissionsBuilder = useCallback(() => ({
@@ -146,14 +148,14 @@ export const ConfigControllerProvider = React.memo(
146
148
  editedCollectionPath,
147
149
  currentPropertiesOrder,
148
150
  parentPathSegments,
149
- parentCollection
151
+ collection
150
152
  }: {
151
153
  propertyKey?: string,
152
154
  property?: Property,
153
155
  currentPropertiesOrder?: string[],
154
156
  editedCollectionPath: string,
155
157
  parentPathSegments: string[],
156
- parentCollection?: EntityCollection
158
+ collection: PersistedCollection,
157
159
  }) => {
158
160
  // namespace is all the path until the last dot
159
161
  const namespace = propertyKey && propertyKey.includes(".")
@@ -162,6 +164,7 @@ export const ConfigControllerProvider = React.memo(
162
164
  const propertyKeyWithoutNamespace = propertyKey && propertyKey.includes(".")
163
165
  ? propertyKey.substring(propertyKey.lastIndexOf(".") + 1)
164
166
  : propertyKey;
167
+ console.log("edit property", propertyKeyWithoutNamespace, collection)
165
168
  setCurrentPropertyDialog({
166
169
  propertyKey: propertyKeyWithoutNamespace,
167
170
  property,
@@ -169,7 +172,7 @@ export const ConfigControllerProvider = React.memo(
169
172
  currentPropertiesOrder,
170
173
  editedCollectionPath,
171
174
  parentPathSegments,
172
- parentCollection
175
+ collectionEditable: collection?.editable ?? false
173
176
  });
174
177
  }, []);
175
178
 
@@ -180,7 +183,7 @@ export const ConfigControllerProvider = React.memo(
180
183
  redirect
181
184
  }: {
182
185
  parentPathSegments: string[],
183
- parentCollection?: EntityCollection<any, any, any>
186
+ parentCollection?: EntityCollection
184
187
  initialValues?: {
185
188
  group?: string,
186
189
  path?: string,
@@ -249,7 +252,13 @@ export const ConfigControllerProvider = React.memo(
249
252
  autoUpdateId={!currentPropertyDialog ? false : !currentPropertyDialog?.propertyKey}
250
253
  autoOpenTypeSelect={!currentPropertyDialog ? false : !currentPropertyDialog?.propertyKey}
251
254
  inArray={false}
252
- getData={getData && currentDialog?.fullPath ? () => getData(currentDialog.fullPath!) : undefined}
255
+ collectionEditable={currentPropertyDialog?.collectionEditable ?? false}
256
+ getData={getData && currentPropertyDialog?.editedCollectionPath
257
+ ? () => {
258
+ const resolvedPath = navigation.resolveAliasesFrom(currentPropertyDialog.editedCollectionPath!)
259
+ return getData(resolvedPath);
260
+ }
261
+ : undefined}
253
262
  onPropertyChanged={({
254
263
  id,
255
264
  property
@@ -1,19 +1,22 @@
1
- import { IconButton, ResolvedProperty, SettingsIcon, Tooltip } from "@firecms/core";
1
+ import { EntityCollection, IconButton, ResolvedProperty, SettingsIcon, Tooltip } from "@firecms/core";
2
2
  import React from "react";
3
3
  import { useCollectionEditorController } from "../useCollectionEditorController";
4
+ import { PersistedCollection } from "../types/persisted_collection";
4
5
 
5
6
  export function CollectionViewHeaderAction({
6
7
  propertyKey,
7
8
  onHover,
8
9
  property,
9
10
  fullPath,
10
- parentPathSegments
11
+ parentPathSegments,
12
+ collection
11
13
  }: {
12
14
  property: ResolvedProperty,
13
15
  propertyKey: string,
14
16
  onHover: boolean,
15
17
  fullPath: string,
16
18
  parentPathSegments: string[],
19
+ collection: PersistedCollection;
17
20
  }) {
18
21
 
19
22
  const collectionEditorController = useCollectionEditorController();
@@ -27,7 +30,8 @@ export function CollectionViewHeaderAction({
27
30
  propertyKey,
28
31
  property,
29
32
  editedCollectionPath: fullPath,
30
- parentPathSegments
33
+ parentPathSegments,
34
+ collection
31
35
  });
32
36
  }}
33
37
  size={"small"}>
@@ -1,5 +1,6 @@
1
1
  import { AddIcon, EntityCollection, getDefaultPropertiesOrder, Tooltip, useAuthController } from "@firecms/core";
2
2
  import { useCollectionEditorController } from "../useCollectionEditorController";
3
+ import { PersistedCollection } from "../types/persisted_collection";
3
4
 
4
5
  export function PropertyAddColumnComponent({
5
6
  fullPath,
@@ -8,7 +9,7 @@ export function PropertyAddColumnComponent({
8
9
  }: {
9
10
  fullPath: string,
10
11
  parentPathSegments: string[],
11
- collection: EntityCollection;
12
+ collection: PersistedCollection;
12
13
  }) {
13
14
 
14
15
  const authController = useAuthController();
@@ -29,7 +30,8 @@ export function PropertyAddColumnComponent({
29
30
  collectionEditorController.editProperty({
30
31
  editedCollectionPath: fullPath,
31
32
  parentPathSegments,
32
- currentPropertiesOrder: getDefaultPropertiesOrder(collection)
33
+ currentPropertiesOrder: getDefaultPropertiesOrder(collection),
34
+ collection
33
35
  });
34
36
  }}>
35
37
  <AddIcon color={"inherit"}/>
@@ -285,11 +285,11 @@ export function CollectionEditorDialogInternal<M extends {
285
285
 
286
286
  if (Object.keys(inferredCollection.properties ?? {}).length > 0) {
287
287
  values.properties = inferredCollection.properties as Properties<M>;
288
- values.propertiesOrder = inferredCollection.propertiesOrder
288
+ values.propertiesOrder = inferredCollection.propertiesOrder as Extract<keyof M, string>[];
289
289
  }
290
290
 
291
291
  if (!values.propertiesOrder) {
292
- values.propertiesOrder = Object.keys(values.properties);
292
+ values.propertiesOrder = Object.keys(values.properties) as Extract<keyof M, string>[];
293
293
  return values;
294
294
  }
295
295
 
@@ -392,7 +392,8 @@ export function CollectionEditorDialogInternal<M extends {
392
392
 
393
393
  const path = values.path ?? editedCollectionPath;
394
394
  const updatedFullPath = fullPath?.includes("/") ? fullPath?.split("/").slice(0, -1).join("/") + "/" + path : path;
395
- const getDataWithPath = updatedFullPath && getData ? () => getData(updatedFullPath) : undefined;
395
+ const resolvedPath = navigation.resolveAliasesFrom(updatedFullPath);
396
+ const getDataWithPath = resolvedPath && getData ? () => getData(resolvedPath) : undefined;
396
397
 
397
398
  // eslint-disable-next-line react-hooks/rules-of-hooks
398
399
  useEffect(() => {
@@ -430,6 +431,7 @@ export function CollectionEditorDialogInternal<M extends {
430
431
  })
431
432
  };
432
433
 
434
+ const collectionEditable = collection?.editable || isNewCollection;
433
435
  return (
434
436
  <>
435
437
  {!isNewCollection && <Tabs value={currentView}
@@ -476,6 +478,7 @@ export function CollectionEditorDialogInternal<M extends {
476
478
 
477
479
  {currentView === "import_data_mapping" && importConfig &&
478
480
  <CollectionEditorImportMapping importConfig={importConfig}
481
+ collectionEditable={collectionEditable}
479
482
  customFields={customFields}/>}
480
483
 
481
484
  {currentView === "import_data_preview" && importConfig &&
@@ -527,6 +530,7 @@ export function CollectionEditorDialogInternal<M extends {
527
530
  getData={getDataWithPath}
528
531
  doCollectionInference={doCollectionInference}
529
532
  customFields={customFields}
533
+ collectionEditable={collectionEditable}
530
534
  extraIcon={extraView?.icon &&
531
535
  <IconButton
532
536
  color={"primary"}
@@ -40,8 +40,9 @@ type CollectionEditorFormProps = {
40
40
  extraIcon: React.ReactNode;
41
41
  getUser: (uid: string) => User | null;
42
42
  getData?: () => Promise<object[]>;
43
- doCollectionInference: (collection: PersistedCollection<any, string>) => Promise<EntityCollection | null> | undefined;
43
+ doCollectionInference: (collection: PersistedCollection) => Promise<EntityCollection | null> | undefined;
44
44
  customFields: Record<string, PropertyConfig>;
45
+ collectionEditable: boolean;
45
46
  };
46
47
 
47
48
  export function CollectionPropertiesEditorForm({
@@ -55,7 +56,8 @@ export function CollectionPropertiesEditorForm({
55
56
  getUser,
56
57
  getData,
57
58
  doCollectionInference,
58
- customFields
59
+ customFields,
60
+ collectionEditable
59
61
  }: CollectionEditorFormProps) {
60
62
 
61
63
  const {
@@ -354,6 +356,7 @@ export function CollectionPropertiesEditorForm({
354
356
  propertiesOrder={usedPropertiesOrder}
355
357
  onPropertyMove={onPropertyMove}
356
358
  onPropertyRemove={isNewCollection ? deleteProperty : undefined}
359
+ collectionEditable={collectionEditable}
357
360
  errors={showErrors ? errors : {}}/>
358
361
  </ErrorBoundary>
359
362
 
@@ -392,6 +395,7 @@ export function CollectionPropertiesEditorForm({
392
395
  initialErrors={initialErrors}
393
396
  getData={getData}
394
397
  customFields={customFields}
398
+ collectionEditable={collectionEditable}
395
399
  />}
396
400
 
397
401
  {!selectedProperty &&
@@ -426,6 +430,7 @@ export function CollectionPropertiesEditorForm({
426
430
  initialErrors={initialErrors}
427
431
  getData={getData}
428
432
  customFields={customFields}
433
+ collectionEditable={collectionEditable}
429
434
  onOkClicked={asDialog
430
435
  ? closePropertyDialog
431
436
  : undefined
@@ -450,6 +455,7 @@ export function CollectionPropertiesEditorForm({
450
455
  getData={getData}
451
456
  allowDataInference={!isNewCollection}
452
457
  customFields={customFields}
458
+ collectionEditable={collectionEditable}
453
459
  existingPropertyKeys={values.propertiesOrder as string[]}/>
454
460
 
455
461
  </>
@@ -14,7 +14,6 @@ import {
14
14
  FormikArrayContainer,
15
15
  IconButton,
16
16
  ListIcon,
17
- LoadingButton,
18
17
  Paper,
19
18
  SettingsIcon,
20
19
  Typography
@@ -132,7 +131,8 @@ function EnumFormFields({
132
131
  };
133
132
 
134
133
  const inferValues = async () => {
135
-
134
+ if (!getData)
135
+ return;
136
136
  setInferring(true);
137
137
  getData?.().then((data) => {
138
138
  if (!data)
@@ -169,12 +169,14 @@ function EnumFormFields({
169
169
  Values
170
170
  </Typography>
171
171
  {allowDataInference &&
172
- <LoadingButton loading={inferring}
173
- disabled={disabled || inferring}
174
- variant={"text"} size={"small"} onClick={inferValues}>
172
+ <Button loading={inferring}
173
+ disabled={disabled || inferring}
174
+ variant={"text"}
175
+ size={"small"}
176
+ onClick={inferValues}>
175
177
  {inferring ? <CircularProgress size={"small"}/> : <AutoAwesomeIcon/>}
176
178
  Infer values from data
177
- </LoadingButton>}
179
+ </Button>}
178
180
  </div>
179
181
 
180
182
  <Paper className="p-4 m-1">
@@ -20,7 +20,7 @@ import {
20
20
  isPropertyBuilder,
21
21
  mergeDeep,
22
22
  Property,
23
- PropertyConfig,
23
+ PropertyConfig, PropertyOrBuilder,
24
24
  Select,
25
25
  toSnakeCase,
26
26
  Typography
@@ -73,6 +73,7 @@ export type PropertyFormProps = {
73
73
  getData?: () => Promise<object[]>;
74
74
  getHelpers?: (formikProps: FormikProps<PropertyWithId>) => void;
75
75
  customFields: Record<string, PropertyConfig>;
76
+ collectionEditable: boolean;
76
77
  };
77
78
 
78
79
  export const PropertyForm = React.memo(
@@ -95,7 +96,8 @@ export const PropertyForm = React.memo(
95
96
  allowDataInference,
96
97
  getHelpers,
97
98
  getData,
98
- customFields
99
+ customFields,
100
+ collectionEditable
99
101
  }: PropertyFormProps) {
100
102
 
101
103
  const initialValue: PropertyWithId = {
@@ -103,7 +105,8 @@ export const PropertyForm = React.memo(
103
105
  name: ""
104
106
  } as PropertyWithId;
105
107
 
106
- const disabled = (property && !editableProperty(property)) ?? false;
108
+ const disabled = (Boolean(property && !editableProperty(property)) && !collectionEditable);
109
+ console.log("PropertyForm disabled", disabled)
107
110
 
108
111
  const lastSubmittedProperty = useRef<OnPropertyChangedParams | undefined>(property ? {
109
112
  id: propertyKey,
@@ -182,6 +185,7 @@ export const PropertyForm = React.memo(
182
185
  getData={getData}
183
186
  allowDataInference={allowDataInference}
184
187
  customFields={customFields}
188
+ collectionEditable={collectionEditable}
185
189
  {...props}/>;
186
190
 
187
191
  }}
@@ -201,6 +205,7 @@ export function PropertyFormDialog({
201
205
  onOkClicked,
202
206
  onPropertyChanged,
203
207
  getData,
208
+ collectionEditable,
204
209
  ...formProps
205
210
  }: PropertyFormProps & {
206
211
  open?: boolean;
@@ -224,6 +229,7 @@ export function PropertyFormDialog({
224
229
  onPropertyChanged?.(params);
225
230
  onOkClicked?.();
226
231
  }}
232
+ collectionEditable={collectionEditable}
227
233
  onPropertyChangedImmediate={false}
228
234
  getHelpers={getHelpers}
229
235
  getData={getData}
@@ -271,7 +277,8 @@ function PropertyEditView({
271
277
  existingPropertyKeys,
272
278
  getData,
273
279
  allowDataInference,
274
- customFields
280
+ customFields,
281
+ collectionEditable
275
282
  }: {
276
283
  includeIdAndTitle?: boolean;
277
284
  existing: boolean;
@@ -288,6 +295,7 @@ function PropertyEditView({
288
295
  getData?: () => Promise<object[]>;
289
296
  allowDataInference: boolean;
290
297
  customFields: Record<string, PropertyConfig>;
298
+ collectionEditable: boolean;
291
299
  } & FormikProps<PropertyWithId>) {
292
300
 
293
301
  const [selectOpen, setSelectOpen] = useState(autoOpenTypeSelect);
@@ -395,10 +403,12 @@ function PropertyEditView({
395
403
  } else if (selectedFieldConfigId === "group") {
396
404
  childComponent =
397
405
  <MapPropertyField disabled={disabled} getData={getData} allowDataInference={allowDataInference}
406
+ collectionEditable={collectionEditable}
398
407
  customFields={customFields}/>;
399
408
  } else if (selectedFieldConfigId === "block") {
400
409
  childComponent =
401
410
  <BlockPropertyField disabled={disabled} getData={getData} allowDataInference={allowDataInference}
411
+ collectionEditable={collectionEditable}
402
412
  customFields={customFields}/>;
403
413
  } else if (selectedFieldConfigId === "reference") {
404
414
  childComponent =
@@ -421,6 +431,7 @@ function PropertyEditView({
421
431
  getData={getData}
422
432
  allowDataInference={allowDataInference}
423
433
  disabled={disabled}
434
+ collectionEditable={collectionEditable}
424
435
  customFields={customFields}/>;
425
436
  } else if (selectedFieldConfigId === "key_value") {
426
437
  childComponent =
@@ -5,8 +5,10 @@ import {
5
5
  defaultBorderMixin,
6
6
  DragHandleIcon,
7
7
  ErrorBoundary,
8
- IconButton, isPropertyBuilder,
9
- PropertiesOrBuilders, PropertyOrBuilder,
8
+ IconButton,
9
+ isPropertyBuilder,
10
+ PropertiesOrBuilders,
11
+ PropertyOrBuilder,
10
12
  RemoveIcon,
11
13
  Tooltip
12
14
  } from "@firecms/core";
@@ -30,7 +32,8 @@ export function PropertyTree<M extends {
30
32
  onPropertyMove,
31
33
  onPropertyRemove,
32
34
  className,
33
- inferredPropertyKeys
35
+ inferredPropertyKeys,
36
+ collectionEditable
34
37
  }: {
35
38
  namespace?: string;
36
39
  selectedPropertyKey?: string;
@@ -43,6 +46,7 @@ export function PropertyTree<M extends {
43
46
  onPropertyRemove?: (propertyKey: string, namespace?: string) => void;
44
47
  className?: string;
45
48
  inferredPropertyKeys?: string[];
49
+ collectionEditable: boolean;
46
50
  }) {
47
51
 
48
52
  const propertiesOrder = propertiesOrderProp ?? Object.keys(properties);
@@ -102,6 +106,7 @@ export function PropertyTree<M extends {
102
106
  onPropertyRemove={onPropertyRemove}
103
107
  onPropertyClick={snapshot.isDragging ? undefined : onPropertyClick}
104
108
  selectedPropertyKey={selectedPropertyKey}
109
+ collectionEditable={collectionEditable}
105
110
  />
106
111
  </ErrorBoundary>
107
112
  );
@@ -131,7 +136,8 @@ export function PropertyTreeEntry({
131
136
  onPropertyClick,
132
137
  onPropertyMove,
133
138
  onPropertyRemove,
134
- inferredPropertyKeys
139
+ inferredPropertyKeys,
140
+ collectionEditable
135
141
  }: {
136
142
  propertyKey: string;
137
143
  namespace?: string;
@@ -144,6 +150,7 @@ export function PropertyTreeEntry({
144
150
  onPropertyMove?: (propertiesOrder: string[], namespace?: string) => void;
145
151
  onPropertyRemove?: (propertyKey: string, namespace?: string) => void;
146
152
  inferredPropertyKeys?: string[];
153
+ collectionEditable: boolean;
147
154
  }) {
148
155
 
149
156
  const isPropertyInferred = inferredPropertyKeys?.includes(namespace ? `${namespace}.${propertyKey}` : propertyKey);
@@ -161,13 +168,15 @@ export function PropertyTreeEntry({
161
168
  errors={errors}
162
169
  onPropertyClick={onPropertyClick}
163
170
  onPropertyMove={onPropertyMove}
164
- onPropertyRemove={onPropertyRemove}/>
171
+ onPropertyRemove={onPropertyRemove}
172
+ collectionEditable={collectionEditable}
173
+ />
165
174
  }
166
175
  }
167
176
 
168
177
  const hasError = fullId ? getIn(errors, idToPropertiesPath(fullId)) : false;
169
178
  const selected = selectedPropertyKey === fullId;
170
- const editable = propertyOrBuilder && editableProperty(propertyOrBuilder);
179
+ const editable = propertyOrBuilder && ((collectionEditable && !isPropertyBuilder(propertyOrBuilder)) || editableProperty(propertyOrBuilder));
171
180
 
172
181
  return (
173
182
  <div
@@ -8,12 +8,12 @@ import { getIn, useFormikContext } from "formik";
8
8
 
9
9
  import {
10
10
  Container,
11
- PropertyConfig,
12
11
  FieldConfigBadge,
13
12
  getFieldConfig,
14
13
  getFieldId,
15
14
  Properties,
16
15
  Property,
16
+ PropertyConfig,
17
17
  Select,
18
18
  Tooltip,
19
19
  Typography,
@@ -30,11 +30,13 @@ import { buildPropertyFromData } from "@firecms/schema_inference";
30
30
 
31
31
  export function CollectionEditorImportMapping({
32
32
  importConfig,
33
- customFields
33
+ customFields,
34
+ collectionEditable
34
35
  }:
35
36
  {
36
37
  importConfig: ImportConfig,
37
- customFields: Record<string, PropertyConfig>
38
+ customFields: Record<string, PropertyConfig>,
39
+ collectionEditable: boolean
38
40
  }) {
39
41
 
40
42
  const {
@@ -192,6 +194,7 @@ export function CollectionEditorImportMapping({
192
194
  autoUpdateId={false}
193
195
  onPropertyChanged={onPropertyChanged}
194
196
  allowDataInference={false}
197
+ collectionEditable={collectionEditable}
195
198
  onOkClicked={() => {
196
199
  setSelectedProperty(undefined);
197
200
  }}
@@ -5,11 +5,12 @@ import { PropertyFormDialog } from "../PropertyEditView";
5
5
  import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath } from "../util";
6
6
  import { PropertyTree } from "../PropertyTree";
7
7
 
8
- export function BlockPropertyField({ disabled, getData, allowDataInference, customFields }: {
8
+ export function BlockPropertyField({ disabled, getData, allowDataInference, customFields, collectionEditable }: {
9
9
  disabled: boolean;
10
10
  getData?: () => Promise<object[]>;
11
11
  allowDataInference: boolean;
12
- customFields: Record<string, PropertyConfig>
12
+ customFields: Record<string, PropertyConfig>,
13
+ collectionEditable: boolean;
13
14
  }) {
14
15
 
15
16
  const {
@@ -81,6 +82,7 @@ export function BlockPropertyField({ disabled, getData, allowDataInference, cust
81
82
  properties={values.oneOf?.properties ?? {}}
82
83
  propertiesOrder={values.oneOf?.propertiesOrder}
83
84
  errors={{}}
85
+ collectionEditable={collectionEditable}
84
86
  onPropertyClick={disabled
85
87
  ? undefined
86
88
  : (propertyKey, namespace) => {
@@ -116,6 +118,7 @@ export function BlockPropertyField({ disabled, getData, allowDataInference, cust
116
118
  setSelectedPropertyKey(undefined);
117
119
  setSelectedPropertyNamespace(undefined);
118
120
  }}
121
+ collectionEditable={collectionEditable}
119
122
  onDelete={deleteProperty}
120
123
  propertyKey={selectedPropertyKey}
121
124
  propertyNamespace={selectedPropertyNamespace}
@@ -15,11 +15,12 @@ import { PropertyTree } from "../PropertyTree";
15
15
  import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath, namespaceToPropertiesPath } from "../util";
16
16
  import { FieldHelperView } from "./FieldHelperView";
17
17
 
18
- export function MapPropertyField({ disabled, getData, allowDataInference, customFields }: {
18
+ export function MapPropertyField({ disabled, getData, allowDataInference, customFields, collectionEditable }: {
19
19
  disabled: boolean;
20
20
  getData?: () => Promise<object[]>;
21
21
  allowDataInference: boolean;
22
- customFields: Record<string, PropertyConfig>
22
+ customFields: Record<string, PropertyConfig>,
23
+ collectionEditable: boolean;
23
24
  }) {
24
25
 
25
26
  const {
@@ -94,6 +95,7 @@ export function MapPropertyField({ disabled, getData, allowDataInference, custom
94
95
  properties={values.properties ?? {}}
95
96
  propertiesOrder={propertiesOrder}
96
97
  errors={{}}
98
+ collectionEditable={collectionEditable}
97
99
  onPropertyClick={(propertyKey, namespace) => {
98
100
  setSelectedPropertyKey(propertyKey);
99
101
  setSelectedPropertyNamespace(namespace);
@@ -127,6 +129,7 @@ export function MapPropertyField({ disabled, getData, allowDataInference, custom
127
129
  forceShowErrors={false}
128
130
  open={propertyDialogOpen}
129
131
  allowDataInference={allowDataInference}
132
+ collectionEditable={collectionEditable}
130
133
  onCancel={() => {
131
134
  setPropertyDialogOpen(false);
132
135
  setSelectedPropertyKey(undefined);
@@ -2,10 +2,10 @@ import React, { useCallback, useState } from "react";
2
2
  import {
3
3
  ArrayProperty,
4
4
  Button,
5
- PropertyConfig,
6
5
  getFieldConfig,
7
6
  Paper,
8
7
  Property,
8
+ PropertyConfig,
9
9
  Typography,
10
10
  useFireCMSContext
11
11
  } from "@firecms/core";
@@ -21,14 +21,16 @@ export function RepeatPropertyField({
21
21
  disabled,
22
22
  getData,
23
23
  allowDataInference,
24
- customFields
24
+ customFields,
25
+ collectionEditable
25
26
  }: {
26
27
  showErrors: boolean,
27
28
  existing: boolean,
28
29
  disabled: boolean,
29
30
  getData?: () => Promise<object[]>;
30
31
  allowDataInference: boolean;
31
- customFields: Record<string, PropertyConfig>
32
+ customFields: Record<string, PropertyConfig>,
33
+ collectionEditable: boolean;
32
34
  }) {
33
35
 
34
36
  const { fields } = useFireCMSContext();
@@ -96,6 +98,7 @@ export function RepeatPropertyField({
96
98
  onPropertyChanged={onPropertyChanged}
97
99
  forceShowErrors={showErrors}
98
100
  customFields={customFields}
101
+ collectionEditable={collectionEditable}
99
102
  />
100
103
  </Paper>
101
104
  )}