@firecms/collection_editor 3.0.0-alpha.45 → 3.0.0-alpha.47

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 (44) hide show
  1. package/dist/index.es.js +1338 -1305
  2. package/dist/index.es.js.map +1 -1
  3. package/dist/index.umd.js +3 -1
  4. package/dist/index.umd.js.map +1 -1
  5. package/dist/types/collection_editor_controller.d.ts +3 -3
  6. package/dist/types/collection_inference.d.ts +1 -1
  7. package/dist/types/config_controller.d.ts +5 -5
  8. package/dist/ui/CollectionViewHeaderAction.d.ts +2 -2
  9. package/dist/ui/EditorCollectionAction.d.ts +1 -1
  10. package/dist/ui/PropertyAddColumnComponent.d.ts +2 -2
  11. package/dist/ui/collection_editor/CollectionDetailsForm.d.ts +2 -2
  12. package/dist/ui/collection_editor/CollectionEditorDialog.d.ts +2 -2
  13. package/dist/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +1 -1
  14. package/dist/ui/collection_editor/CollectionYupValidation.d.ts +3 -0
  15. package/dist/ui/collection_editor/SubcollectionsEditTab.d.ts +2 -2
  16. package/dist/useCollectionEditorPlugin.d.ts +3 -2
  17. package/package.json +4 -4
  18. package/src/ConfigControllerProvider.tsx +16 -23
  19. package/src/types/collection_editor_controller.tsx +4 -4
  20. package/src/types/collection_inference.ts +1 -1
  21. package/src/types/config_controller.tsx +5 -5
  22. package/src/types/persisted_collection.ts +1 -1
  23. package/src/ui/CollectionViewHeaderAction.tsx +4 -4
  24. package/src/ui/EditorCollectionAction.tsx +5 -5
  25. package/src/ui/HomePageEditorCollectionAction.tsx +10 -3
  26. package/src/ui/MissingReferenceWidget.tsx +4 -3
  27. package/src/ui/NewCollectionCard.tsx +1 -1
  28. package/src/ui/PropertyAddColumnComponent.tsx +4 -4
  29. package/src/ui/RootCollectionSuggestions.tsx +10 -2
  30. package/src/ui/collection_editor/CollectionDetailsForm.tsx +27 -38
  31. package/src/ui/collection_editor/CollectionEditorDialog.tsx +82 -34
  32. package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +11 -11
  33. package/src/ui/collection_editor/CollectionYupValidation.tsx +1 -0
  34. package/src/ui/collection_editor/GetCodeDialog.tsx +4 -4
  35. package/src/ui/collection_editor/PropertySelectItem.tsx +1 -1
  36. package/src/ui/collection_editor/SubcollectionsEditTab.tsx +4 -4
  37. package/src/ui/collection_editor/properties/BlockPropertyField.tsx +1 -1
  38. package/src/ui/collection_editor/properties/MapPropertyField.tsx +1 -1
  39. package/src/ui/collection_editor/properties/ReferencePropertyField.tsx +5 -6
  40. package/src/ui/collection_editor/properties/RepeatPropertyField.tsx +1 -10
  41. package/src/ui/collection_editor/templates/blog_template.ts +1 -0
  42. package/src/ui/collection_editor/templates/products_template.ts +1 -0
  43. package/src/ui/collection_editor/templates/users_template.ts +1 -0
  44. package/src/useCollectionEditorPlugin.tsx +10 -4
@@ -9,7 +9,7 @@ export interface CollectionEditorController {
9
9
  editCollection: (props: {
10
10
  path?: string;
11
11
  fullPath?: string;
12
- parentPathSegments: string[];
12
+ parentCollectionIds: string[];
13
13
  parentCollection?: PersistedCollection;
14
14
  }) => void;
15
15
  createCollection: (props: {
@@ -18,7 +18,7 @@ export interface CollectionEditorController {
18
18
  path?: string;
19
19
  name?: string;
20
20
  };
21
- parentPathSegments: string[];
21
+ parentCollectionIds: string[];
22
22
  parentCollection?: PersistedCollection;
23
23
  redirect: boolean;
24
24
  }) => void;
@@ -27,7 +27,7 @@ export interface CollectionEditorController {
27
27
  property?: Property;
28
28
  currentPropertiesOrder?: string[];
29
29
  editedCollectionPath: string;
30
- parentPathSegments: string[];
30
+ parentCollectionIds: string[];
31
31
  collection: PersistedCollection;
32
32
  }) => void;
33
33
  configPermissions: CollectionEditorPermissionsBuilder;
@@ -1,2 +1,2 @@
1
1
  import { EntityCollection } from "@firecms/core";
2
- export type CollectionInference = (path: string, collectionGroup: boolean, parentPathSegments: string[]) => Promise<EntityCollection | null>;
2
+ export type CollectionInference = (path: string, collectionGroup: boolean, parentCollectionIds: string[]) => Promise<Partial<EntityCollection> | null>;
@@ -15,10 +15,10 @@ export interface CollectionsConfigController {
15
15
  deleteCollection: (props: DeleteCollectionParams) => Promise<void>;
16
16
  }
17
17
  export type SaveCollectionParams<M extends Record<string, any>> = {
18
- path: string;
18
+ id: string;
19
19
  collectionData: PersistedCollection<M>;
20
20
  previousPath?: string;
21
- parentPathSegments?: string[];
21
+ parentCollectionIds?: string[];
22
22
  };
23
23
  export type SavePropertyParams = {
24
24
  path: string;
@@ -26,16 +26,16 @@ export type SavePropertyParams = {
26
26
  namespace?: string;
27
27
  newPropertiesOrder?: string[];
28
28
  property: Property;
29
- parentPathSegments?: string[];
29
+ parentCollectionIds?: string[];
30
30
  };
31
31
  export type DeletePropertyParams = {
32
32
  path: string;
33
33
  propertyKey: string;
34
34
  namespace?: string;
35
35
  newPropertiesOrder?: string[];
36
- parentPathSegments?: string[];
36
+ parentCollectionIds?: string[];
37
37
  };
38
38
  export type DeleteCollectionParams = {
39
39
  path: string;
40
- parentPathSegments?: string[];
40
+ parentCollectionIds?: string[];
41
41
  };
@@ -1,10 +1,10 @@
1
1
  import { ResolvedProperty } from "@firecms/core";
2
2
  import { PersistedCollection } from "../types/persisted_collection";
3
- export declare function CollectionViewHeaderAction({ propertyKey, onHover, property, fullPath, parentPathSegments, collection }: {
3
+ export declare function CollectionViewHeaderAction({ propertyKey, onHover, property, fullPath, parentCollectionIds, collection }: {
4
4
  property: ResolvedProperty;
5
5
  propertyKey: string;
6
6
  onHover: boolean;
7
7
  fullPath: string;
8
- parentPathSegments: string[];
8
+ parentCollectionIds: string[];
9
9
  collection: PersistedCollection;
10
10
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import { CollectionActionsProps } from "@firecms/core";
2
- export declare function EditorCollectionAction({ path: fullPath, parentPathSegments, collection, tableController }: CollectionActionsProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function EditorCollectionAction({ path: fullPath, parentCollectionIds, collection, tableController }: CollectionActionsProps): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { PersistedCollection } from "../types/persisted_collection";
2
- export declare function PropertyAddColumnComponent({ fullPath, parentPathSegments, collection }: {
2
+ export declare function PropertyAddColumnComponent({ fullPath, parentCollectionIds, collection }: {
3
3
  fullPath: string;
4
- parentPathSegments: string[];
4
+ parentCollectionIds: string[];
5
5
  collection: PersistedCollection;
6
6
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,9 @@
1
1
  import { EntityCollection } from "@firecms/core";
2
- export declare function CollectionDetailsForm({ isNewCollection, reservedGroups, existingPaths, existingAliases, groups, parentCollection }: {
2
+ export declare function CollectionDetailsForm({ isNewCollection, reservedGroups, existingPaths, existingIds, groups, parentCollection }: {
3
3
  isNewCollection: boolean;
4
4
  reservedGroups?: string[];
5
5
  existingPaths?: string[];
6
- existingAliases?: string[];
6
+ existingIds?: string[];
7
7
  groups: string[] | null;
8
8
  parentCollection?: EntityCollection;
9
9
  }): import("react/jsx-runtime").JSX.Element;
@@ -13,7 +13,7 @@ export interface CollectionEditorDialogProps {
13
13
  };
14
14
  editedCollectionPath?: string;
15
15
  fullPath?: string;
16
- parentPathSegments?: string[];
16
+ parentCollectionIds?: string[];
17
17
  handleClose: (collection?: EntityCollection) => void;
18
18
  configController: CollectionsConfigController;
19
19
  reservedGroups?: string[];
@@ -32,7 +32,7 @@ export interface CollectionEditorDialogProps {
32
32
  export declare function CollectionEditorDialog(props: CollectionEditorDialogProps): import("react/jsx-runtime").JSX.Element;
33
33
  export declare function CollectionEditorDialogInternal<M extends {
34
34
  [Key: string]: CMSType;
35
- }>({ isNewCollection, initialValues: initialValuesProp, configController, editedCollectionPath, parentPathSegments, fullPath, collectionInference, handleClose, reservedGroups, extraView, handleCancel, setFormDirty, pathSuggestions, getUser, parentCollection, getData }: CollectionEditorDialogProps & {
35
+ }>({ isNewCollection, initialValues: initialValuesProp, configController, editedCollectionPath, parentCollectionIds, fullPath, collectionInference, handleClose, reservedGroups, extraView, handleCancel, setFormDirty, pathSuggestions, getUser, parentCollection, getData }: CollectionEditorDialogProps & {
36
36
  handleCancel: () => void;
37
37
  setFormDirty: (dirty: boolean) => void;
38
38
  }): import("react/jsx-runtime").JSX.Element;
@@ -12,7 +12,7 @@ type CollectionEditorFormProps = {
12
12
  extraIcon: React.ReactNode;
13
13
  getUser: (uid: string) => User | null;
14
14
  getData?: () => Promise<object[]>;
15
- doCollectionInference: (collection: PersistedCollection) => Promise<EntityCollection | null> | undefined;
15
+ doCollectionInference: (collection: PersistedCollection) => Promise<Partial<EntityCollection> | null> | undefined;
16
16
  propertyConfigs: Record<string, PropertyConfig>;
17
17
  collectionEditable: boolean;
18
18
  };
@@ -1,11 +1,14 @@
1
1
  import * as Yup from "yup";
2
2
  export declare const YupSchema: Yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
3
4
  name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
4
5
  path: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
5
6
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
7
+ id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
6
8
  name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
7
9
  path: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
10
  }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
11
+ id: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
9
12
  name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
10
13
  path: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
11
14
  }>>>;
@@ -2,11 +2,11 @@ import { EntityCollection, User } from "@firecms/core";
2
2
  import { CollectionsConfigController } from "../../types/config_controller";
3
3
  import { PersistedCollection } from "../../types/persisted_collection";
4
4
  import { CollectionInference } from "../../types/collection_inference";
5
- export declare function SubcollectionsEditTab({ collection, parentCollection, configController, collectionInference, getUser, parentPathSegments }: {
5
+ export declare function SubcollectionsEditTab({ collection, parentCollection, configController, collectionInference, getUser, parentCollectionIds }: {
6
6
  collection: PersistedCollection;
7
7
  parentCollection?: EntityCollection;
8
8
  configController: CollectionsConfigController;
9
9
  collectionInference?: CollectionInference;
10
10
  getUser: (uid: string) => User | null;
11
- parentPathSegments?: string[];
11
+ parentCollectionIds?: string[];
12
12
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { FireCMSPlugin, User } from "@firecms/core";
2
+ import { EntityCollection, FireCMSPlugin, ModifyCollectionProps, User } from "@firecms/core";
3
3
  import { CollectionEditorPermissionsBuilder } from "./types/config_permissions";
4
4
  import { PersistedCollection } from "./types/persisted_collection";
5
5
  import { CollectionInference } from "./types/collection_inference";
@@ -9,6 +9,7 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
9
9
  * Firebase app where the configuration is saved.
10
10
  */
11
11
  collectionConfigController: CollectionsConfigController;
12
+ modifyCollection?: (props: ModifyCollectionProps) => EntityCollection | undefined;
12
13
  /**
13
14
  * Define what actions can be performed on the configuration.
14
15
  */
@@ -41,4 +42,4 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
41
42
  * @param getUser
42
43
  * @param collectionInference
43
44
  */
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>;
45
+ export declare function useCollectionEditorPlugin<EC extends PersistedCollection = PersistedCollection, UserType extends User = User>({ collectionConfigController, modifyCollection, 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.45",
3
+ "version": "3.0.0-alpha.47",
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_export": "^3.0.0-alpha.45",
18
- "@firecms/schema_inference": "^3.0.0-alpha.45",
17
+ "@firecms/data_import_export": "^3.0.0-alpha.47",
18
+ "@firecms/schema_inference": "^3.0.0-alpha.47",
19
19
  "json5": "^2.2.3",
20
20
  "prism-react-renderer": "^2.3.0"
21
21
  },
@@ -78,5 +78,5 @@
78
78
  "publishConfig": {
79
79
  "access": "public"
80
80
  },
81
- "gitHead": "8a8223081bd7f76d655564ca995dca085f22d727"
81
+ "gitHead": "1c2310776f2da9bba46ba352e9a5244118dcdc3f"
82
82
  }
@@ -2,14 +2,7 @@ import React, { PropsWithChildren, useCallback, useEffect } from "react";
2
2
  import equal from "react-fast-compare"
3
3
 
4
4
  import { CollectionsConfigController } from "./types/config_controller";
5
- import {
6
- EntityCollection,
7
- Property,
8
- useFireCMSContext,
9
- useNavigationController,
10
- User,
11
- useSnackbarController
12
- } from "@firecms/core";
5
+ import { Property, useFireCMSContext, useNavigationController, User, useSnackbarController } from "@firecms/core";
13
6
  import { CollectionEditorDialog } from "./ui/collection_editor/CollectionEditorDialog";
14
7
  import { useNavigate } from "react-router";
15
8
  import { CollectionEditorController } from "./types/collection_editor_controller";
@@ -94,7 +87,7 @@ export const ConfigControllerProvider = React.memo(
94
87
  parentCollection?: PersistedCollection,
95
88
  editedCollectionPath?: string,
96
89
  fullPath?: string,
97
- parentPathSegments: string[],
90
+ parentCollectionIds: string[],
98
91
  initialValues?: {
99
92
  path?: string,
100
93
  group?: string,
@@ -111,7 +104,7 @@ export const ConfigControllerProvider = React.memo(
111
104
  currentPropertiesOrder?: string[],
112
105
  editedCollectionPath: string,
113
106
  fullPath?: string,
114
- parentPathSegments: string[],
107
+ parentCollectionIds: string[],
115
108
  collectionEditable: boolean;
116
109
  }>();
117
110
 
@@ -124,18 +117,18 @@ export const ConfigControllerProvider = React.memo(
124
117
  const editCollection = useCallback(({
125
118
  path,
126
119
  fullPath,
127
- parentPathSegments,
120
+ parentCollectionIds,
128
121
  parentCollection
129
122
  }: {
130
123
  path?: string,
131
124
  fullPath?: string,
132
- parentPathSegments: string[],
125
+ parentCollectionIds: string[],
133
126
  parentCollection?: PersistedCollection
134
127
  }) => {
135
128
  setCurrentDialog({
136
129
  editedCollectionPath: path,
137
130
  fullPath,
138
- parentPathSegments,
131
+ parentCollectionIds,
139
132
  isNewCollection: false,
140
133
  parentCollection,
141
134
  redirect: false
@@ -147,14 +140,14 @@ export const ConfigControllerProvider = React.memo(
147
140
  property,
148
141
  editedCollectionPath,
149
142
  currentPropertiesOrder,
150
- parentPathSegments,
143
+ parentCollectionIds,
151
144
  collection
152
145
  }: {
153
146
  propertyKey?: string,
154
147
  property?: Property,
155
148
  currentPropertiesOrder?: string[],
156
149
  editedCollectionPath: string,
157
- parentPathSegments: string[],
150
+ parentCollectionIds: string[],
158
151
  collection: PersistedCollection,
159
152
  }) => {
160
153
  // namespace is all the path until the last dot
@@ -171,18 +164,18 @@ export const ConfigControllerProvider = React.memo(
171
164
  namespace,
172
165
  currentPropertiesOrder,
173
166
  editedCollectionPath,
174
- parentPathSegments,
167
+ parentCollectionIds,
175
168
  collectionEditable: collection?.editable ?? false
176
169
  });
177
170
  }, []);
178
171
 
179
172
  const createCollection = React.useCallback(({
180
- parentPathSegments,
173
+ parentCollectionIds,
181
174
  parentCollection,
182
175
  initialValues,
183
176
  redirect
184
177
  }: {
185
- parentPathSegments: string[],
178
+ parentCollectionIds: string[],
186
179
  parentCollection?: PersistedCollection
187
180
  initialValues?: {
188
181
  group?: string,
@@ -193,7 +186,7 @@ export const ConfigControllerProvider = React.memo(
193
186
  }) => {
194
187
  setCurrentDialog({
195
188
  isNewCollection: true,
196
- parentPathSegments,
189
+ parentCollectionIds,
197
190
  parentCollection,
198
191
  initialValues,
199
192
  redirect
@@ -236,8 +229,8 @@ export const ConfigControllerProvider = React.memo(
236
229
  getUser={getUser}
237
230
  handleClose={(collection) => {
238
231
  if (currentDialog?.redirect) {
239
- if (collection && currentDialog?.isNewCollection && !currentDialog.parentPathSegments.length) {
240
- const url = navigation.buildUrlCollectionPath(collection.alias ?? collection.path);
232
+ if (collection && currentDialog?.isNewCollection && !currentDialog.parentCollectionIds.length) {
233
+ const url = navigation.buildUrlCollectionPath(collection.id ?? collection.path);
241
234
  navigate(url);
242
235
  }
243
236
  }
@@ -272,7 +265,7 @@ export const ConfigControllerProvider = React.memo(
272
265
  propertyKey: id,
273
266
  newPropertiesOrder: newProperty && currentPropertyDialog.currentPropertiesOrder ? [...currentPropertyDialog.currentPropertiesOrder, id] : undefined,
274
267
  namespace: currentPropertyDialog.namespace,
275
- parentPathSegments: currentPropertyDialog.parentPathSegments
268
+ parentCollectionIds: currentPropertyDialog.parentCollectionIds
276
269
  })
277
270
  .catch((e) => {
278
271
  console.error(e);
@@ -292,7 +285,7 @@ export const ConfigControllerProvider = React.memo(
292
285
  propertyKey: currentPropertyDialog?.propertyKey,
293
286
  namespace: currentPropertyDialog?.namespace,
294
287
  newPropertiesOrder,
295
- parentPathSegments: currentPropertyDialog?.parentPathSegments
288
+ parentCollectionIds: currentPropertyDialog?.parentCollectionIds
296
289
  })
297
290
  .then(() => {
298
291
  setCurrentPropertyDialog(undefined);
@@ -1,5 +1,5 @@
1
1
  import { CollectionEditorPermissionsBuilder } from "./config_permissions";
2
- import { EntityCollection, Property } from "@firecms/core";
2
+ import { Property } from "@firecms/core";
3
3
  import { PersistedCollection } from "./persisted_collection";
4
4
 
5
5
  /**
@@ -11,7 +11,7 @@ export interface CollectionEditorController {
11
11
  editCollection: (props: {
12
12
  path?: string,
13
13
  fullPath?: string,
14
- parentPathSegments: string[],
14
+ parentCollectionIds: string[],
15
15
  parentCollection?: PersistedCollection
16
16
  }) => void;
17
17
 
@@ -21,7 +21,7 @@ export interface CollectionEditorController {
21
21
  path?: string,
22
22
  name?: string
23
23
  },
24
- parentPathSegments: string[],
24
+ parentCollectionIds: string[],
25
25
  parentCollection?: PersistedCollection,
26
26
  redirect: boolean
27
27
  }) => void;
@@ -31,7 +31,7 @@ export interface CollectionEditorController {
31
31
  property?: Property,
32
32
  currentPropertiesOrder?: string[],
33
33
  editedCollectionPath: string,
34
- parentPathSegments: string[],
34
+ parentCollectionIds: string[],
35
35
  collection: PersistedCollection
36
36
  }) => void;
37
37
 
@@ -1,3 +1,3 @@
1
1
  import { EntityCollection } from "@firecms/core";
2
2
 
3
- export type CollectionInference = (path: string, collectionGroup: boolean, parentPathSegments: string[]) => Promise<EntityCollection | null>;
3
+ export type CollectionInference = (path: string, collectionGroup: boolean, parentCollectionIds: string[]) => Promise<Partial<EntityCollection> | null>;
@@ -21,10 +21,10 @@ export interface CollectionsConfigController {
21
21
  }
22
22
 
23
23
  export type SaveCollectionParams<M extends Record<string, any>> = {
24
- path: string,
24
+ id: string,
25
25
  collectionData: PersistedCollection<M>,
26
26
  previousPath?: string,
27
- parentPathSegments?: string[]
27
+ parentCollectionIds?: string[]
28
28
  }
29
29
 
30
30
  export type SavePropertyParams = {
@@ -33,7 +33,7 @@ export type SavePropertyParams = {
33
33
  namespace?: string,
34
34
  newPropertiesOrder?: string[],
35
35
  property: Property,
36
- parentPathSegments?: string[]
36
+ parentCollectionIds?: string[]
37
37
  }
38
38
 
39
39
  export type DeletePropertyParams = {
@@ -41,10 +41,10 @@ export type DeletePropertyParams = {
41
41
  propertyKey: string,
42
42
  namespace?: string,
43
43
  newPropertiesOrder?: string[],
44
- parentPathSegments?: string[]
44
+ parentCollectionIds?: string[]
45
45
  }
46
46
 
47
47
  export type DeleteCollectionParams = {
48
48
  path: string,
49
- parentPathSegments?: string[]
49
+ parentCollectionIds?: string[]
50
50
  }
@@ -1,4 +1,4 @@
1
- import { EntityCollection, Properties, User } from "@firecms/core";
1
+ import { EntityCollection, User } from "@firecms/core";
2
2
 
3
3
  export type PersistedCollection<M extends Record<string, any> = any, UserType extends User = User>
4
4
  = Omit<EntityCollection<M, UserType>, "subcollections"> & {
@@ -1,4 +1,4 @@
1
- import { EntityCollection, IconButton, ResolvedProperty, SettingsIcon, Tooltip } from "@firecms/core";
1
+ import { IconButton, ResolvedProperty, SettingsIcon, Tooltip } from "@firecms/core";
2
2
  import React from "react";
3
3
  import { useCollectionEditorController } from "../useCollectionEditorController";
4
4
  import { PersistedCollection } from "../types/persisted_collection";
@@ -8,14 +8,14 @@ export function CollectionViewHeaderAction({
8
8
  onHover,
9
9
  property,
10
10
  fullPath,
11
- parentPathSegments,
11
+ parentCollectionIds,
12
12
  collection
13
13
  }: {
14
14
  property: ResolvedProperty,
15
15
  propertyKey: string,
16
16
  onHover: boolean,
17
17
  fullPath: string,
18
- parentPathSegments: string[],
18
+ parentCollectionIds: string[],
19
19
  collection: PersistedCollection;
20
20
  }) {
21
21
 
@@ -30,7 +30,7 @@ export function CollectionViewHeaderAction({
30
30
  propertyKey,
31
31
  property,
32
32
  editedCollectionPath: fullPath,
33
- parentPathSegments,
33
+ parentCollectionIds,
34
34
  collection
35
35
  });
36
36
  }}
@@ -19,7 +19,7 @@ import { PersistedCollection } from "../types/persisted_collection";
19
19
 
20
20
  export function EditorCollectionAction({
21
21
  path: fullPath,
22
- parentPathSegments,
22
+ parentCollectionIds,
23
23
  collection,
24
24
  tableController
25
25
  }: CollectionActionsProps) {
@@ -30,7 +30,7 @@ export function EditorCollectionAction({
30
30
  const configController = useCollectionsConfigController();
31
31
  const snackbarController = useSnackbarController();
32
32
 
33
- const parentCollection = navigationController.getCollectionFromPaths(parentPathSegments);
33
+ const parentCollection = navigationController.getCollectionFromIds(parentCollectionIds);
34
34
 
35
35
  const canEditCollection = collectionEditorController.configPermissions
36
36
  ? collectionEditorController.configPermissions({
@@ -50,8 +50,8 @@ export function EditorCollectionAction({
50
50
  variant={"outlined"}
51
51
  onClick={() => configController
52
52
  ?.saveCollection({
53
- path: collection.path,
54
- parentPathSegments,
53
+ id: collection.path,
54
+ parentCollectionIds,
55
55
  collectionData: mergeDeep(collection as PersistedCollection,
56
56
  {
57
57
  initialFilter: tableController.filterValues ?? null,
@@ -75,7 +75,7 @@ export function EditorCollectionAction({
75
75
  color={"primary"}
76
76
  disabled={!canEditCollection}
77
77
  onClick={canEditCollection
78
- ? () => collectionEditorController?.editCollection({ path: collection.path, fullPath, parentPathSegments, parentCollection: parentCollection as PersistedCollection })
78
+ ? () => collectionEditorController?.editCollection({ path: collection.path, fullPath, parentCollectionIds, parentCollection: parentCollection as PersistedCollection })
79
79
  : undefined}>
80
80
  <SettingsIcon/>
81
81
  </IconButton>
@@ -7,7 +7,7 @@ import {
7
7
  MoreVertIcon,
8
8
  PluginHomePageActionsProps,
9
9
  SettingsIcon,
10
- useAuthController
10
+ useAuthController, useSnackbarController
11
11
  } from "@firecms/core";
12
12
  import { useCollectionEditorController } from "../useCollectionEditorController";
13
13
  import { useCallback, useState } from "react";
@@ -18,6 +18,7 @@ export function HomePageEditorCollectionAction({
18
18
  collection
19
19
  }: PluginHomePageActionsProps) {
20
20
 
21
+ const snackbarController = useSnackbarController();
21
22
  const authController = useAuthController();
22
23
  const configController = useCollectionsConfigController();
23
24
  const collectionEditorController = useCollectionEditorController();
@@ -28,13 +29,19 @@ export function HomePageEditorCollectionAction({
28
29
  });
29
30
 
30
31
  const onEditCollectionClicked = useCallback(() => {
31
- collectionEditorController?.editCollection({ path, parentPathSegments: [] });
32
+ collectionEditorController?.editCollection({ path, parentCollectionIds: [] });
32
33
  }, [collectionEditorController, path]);
33
34
 
34
35
  const [deleteRequested, setDeleteRequested] = useState(false);
35
36
 
36
37
  const deleteCollection = useCallback(() => {
37
- configController?.deleteCollection({ path });
38
+ configController?.deleteCollection({ path }).then(() => {
39
+ setDeleteRequested(false);
40
+ snackbarController.open({
41
+ message: "Collection deleted",
42
+ type: "success"
43
+ });
44
+ });
38
45
  }, [path, configController]);
39
46
 
40
47
  return <>
@@ -1,11 +1,12 @@
1
- import { Button, ErrorView, unslugify } from "@firecms/core";
1
+ import { Button, ErrorView, unslugify, useNavigationController } from "@firecms/core";
2
2
  import { useCollectionEditorController } from "../useCollectionEditorController";
3
3
 
4
4
  export function MissingReferenceWidget({ path: pathProp }: {
5
5
  path: string
6
6
  }) {
7
+ const navigation = useNavigationController();
7
8
  const path = getLastSegment(pathProp);
8
- const parentPathSegments = getParentPathSegments(pathProp);
9
+ const parentCollectionIds = navigation.getParentCollectionIds(pathProp);
9
10
  const collectionEditor = useCollectionEditorController();
10
11
  return <div className={"p-1 flex flex-col items-center"}>
11
12
  <ErrorView error={"No collection for path: " + path}/>
@@ -13,7 +14,7 @@ export function MissingReferenceWidget({ path: pathProp }: {
13
14
  onClick={() => {
14
15
  collectionEditor.createCollection({
15
16
  initialValues: { path, name: unslugify(path) },
16
- parentPathSegments,
17
+ parentCollectionIds,
17
18
  redirect: false
18
19
  });
19
20
  }}>
@@ -23,7 +23,7 @@ export function NewCollectionCard({
23
23
  onClick={collectionEditorController && canCreateCollections
24
24
  ? () => collectionEditorController.createCollection({
25
25
  initialValues: group ? { group } : undefined,
26
- parentPathSegments: [],
26
+ parentCollectionIds: [],
27
27
  redirect: true
28
28
  })
29
29
  : undefined}>
@@ -1,14 +1,14 @@
1
- import { AddIcon, EntityCollection, getDefaultPropertiesOrder, Tooltip, useAuthController } from "@firecms/core";
1
+ import { AddIcon, getDefaultPropertiesOrder, Tooltip, useAuthController } from "@firecms/core";
2
2
  import { useCollectionEditorController } from "../useCollectionEditorController";
3
3
  import { PersistedCollection } from "../types/persisted_collection";
4
4
 
5
5
  export function PropertyAddColumnComponent({
6
6
  fullPath,
7
- parentPathSegments,
7
+ parentCollectionIds,
8
8
  collection
9
9
  }: {
10
10
  fullPath: string,
11
- parentPathSegments: string[],
11
+ parentCollectionIds: string[],
12
12
  collection: PersistedCollection;
13
13
  }) {
14
14
 
@@ -29,7 +29,7 @@ export function PropertyAddColumnComponent({
29
29
  onClick={() => {
30
30
  collectionEditorController.editProperty({
31
31
  editedCollectionPath: fullPath,
32
- parentPathSegments,
32
+ parentCollectionIds,
33
33
  currentPropertiesOrder: getDefaultPropertiesOrder(collection),
34
34
  collection
35
35
  });
@@ -1,4 +1,12 @@
1
- import { AddIcon, Chip, Collapse, Typography, unslugify, useAuthController, useNavigationController } from "@firecms/core";
1
+ import {
2
+ AddIcon,
3
+ Chip,
4
+ Collapse,
5
+ Typography,
6
+ unslugify,
7
+ useAuthController,
8
+ useNavigationController
9
+ } from "@firecms/core";
2
10
  import { useCollectionEditorController } from "../useCollectionEditorController";
3
11
  import React from "react";
4
12
 
@@ -38,7 +46,7 @@ export function RootCollectionSuggestions() {
38
46
  onClick={collectionEditorController && canCreateCollections
39
47
  ? () => collectionEditorController.createCollection({
40
48
  initialValues: { path, name: unslugify(path) },
41
- parentPathSegments: [],
49
+ parentCollectionIds: [],
42
50
  redirect: true
43
51
  })
44
52
  : undefined}