@firecms/collection_editor 3.0.0-alpha.50 → 3.0.0-alpha.52

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.
@@ -1,3 +1,3 @@
1
- import { FieldConfigId } from "@firecms/core";
1
+ import { FieldConfigId, PropertyConfig } from "@firecms/core";
2
2
  export declare const supportedFieldsIds: FieldConfigId[];
3
- export declare const supportedFields: [string, import("@firecms/core").PropertyConfig<any>][];
3
+ export declare const supportedFields: Record<string, PropertyConfig>;
@@ -30,6 +30,7 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
30
30
  collectionInference?: CollectionInference;
31
31
  getData?: (path: string) => Promise<object[]>;
32
32
  getUser: (uid: string) => UserType | null;
33
+ onAnalyticsEvent?: (event: string, params?: object) => void;
33
34
  }
34
35
  /**
35
36
  * Use this hook to initialise the Collection Editor plugin.
@@ -42,4 +43,4 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
42
43
  * @param getUser
43
44
  * @param collectionInference
44
45
  */
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>;
46
+ export declare function useCollectionEditorPlugin<EC extends PersistedCollection = PersistedCollection, UserType extends User = User>({ collectionConfigController, modifyCollection, configPermissions, reservedGroups, extraView, pathSuggestions, getUser, collectionInference, getData, onAnalyticsEvent }: 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.50",
3
+ "version": "3.0.0-alpha.52",
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.50",
18
- "@firecms/schema_inference": "^3.0.0-alpha.50",
17
+ "@firecms/data_import_export": "^3.0.0-alpha.52",
18
+ "@firecms/schema_inference": "^3.0.0-alpha.52",
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": "2e2d454587689100ef33374e2340fc0df62481cb"
81
+ "gitHead": "347fb05aab3d2c4399ba9370f10c6d142c4721f6"
82
82
  }
@@ -48,6 +48,8 @@ export interface ConfigControllerProviderProps {
48
48
 
49
49
  getData?: (path: string) => Promise<object[]>;
50
50
 
51
+ onAnalyticsEvent?: (event: string, params?: object) => void;
52
+
51
53
  }
52
54
 
53
55
  export const ConfigControllerProvider = React.memo(
@@ -60,7 +62,8 @@ export const ConfigControllerProvider = React.memo(
60
62
  extraView,
61
63
  pathSuggestions,
62
64
  getUser,
63
- getData
65
+ getData,
66
+ onAnalyticsEvent
64
67
  }: PropsWithChildren<ConfigControllerProviderProps>) {
65
68
 
66
69
  const navigation = useNavigationController();
@@ -125,6 +128,8 @@ export const ConfigControllerProvider = React.memo(
125
128
  parentCollectionIds: string[],
126
129
  parentCollection?: PersistedCollection
127
130
  }) => {
131
+ console.debug("edit collection", path, fullPath, parentCollectionIds, parentCollection);
132
+ onAnalyticsEvent?.("edit_collection", { path, fullPath });
128
133
  setCurrentDialog({
129
134
  editedCollectionPath: path,
130
135
  fullPath,
@@ -150,6 +155,8 @@ export const ConfigControllerProvider = React.memo(
150
155
  parentCollectionIds: string[],
151
156
  collection: PersistedCollection,
152
157
  }) => {
158
+ console.debug("edit property", propertyKey, property, editedCollectionPath, currentPropertiesOrder, parentCollectionIds, collection);
159
+ onAnalyticsEvent?.("edit_property", { propertyKey, editedCollectionPath });
153
160
  // namespace is all the path until the last dot
154
161
  const namespace = propertyKey && propertyKey.includes(".")
155
162
  ? propertyKey.substring(0, propertyKey.lastIndexOf("."))
@@ -184,6 +191,8 @@ export const ConfigControllerProvider = React.memo(
184
191
  },
185
192
  redirect: boolean
186
193
  }) => {
194
+ console.debug("create collection", parentCollectionIds, parentCollection, initialValues, redirect);
195
+ onAnalyticsEvent?.("create_collection", { parentCollectionIds, parentCollection, initialValues, redirect });
187
196
  setCurrentDialog({
188
197
  isNewCollection: true,
189
198
  parentCollectionIds,
@@ -42,6 +42,7 @@ import { KeyValuePropertyField } from "./properties/KeyValuePropertyField";
42
42
  import { updatePropertyFromWidget } from "./utils/update_property_for_widget";
43
43
  import { PropertySelectItem } from "./PropertySelectItem";
44
44
  import { UrlPropertyField } from "./properties/UrlPropertyField";
45
+ import { supportedFields } from "./utils/supported_fields";
45
46
 
46
47
  export type PropertyWithId = Property & {
47
48
  id?: string
@@ -302,7 +303,7 @@ function PropertyEditView({
302
303
  const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
303
304
  const [selectedFieldConfigId, setSelectedFieldConfigId] = useState<string | undefined>(values?.dataType ? getFieldId(values) : undefined);
304
305
 
305
- const allSupportedFields = Object.entries(DEFAULT_FIELD_CONFIGS).concat(Object.entries(propertyConfigs));
306
+ const allSupportedFields = Object.entries(supportedFields).concat(Object.entries(propertyConfigs));
306
307
 
307
308
  const displayedWidgets = inArray
308
309
  ? allSupportedFields.filter(([_, propertyConfig]) => !isPropertyBuilder(propertyConfig.property) && propertyConfig.property?.dataType !== "array")
@@ -261,7 +261,7 @@ function PropertySelect({
261
261
  });
262
262
  console.log("newSelectedWidgetId", newSelectedWidgetId);
263
263
  }}>
264
- {supportedFields.map(([key, widget]) => {
264
+ {Object.entries(supportedFields).map(([key, widget]) => {
265
265
  return <PropertySelectItem
266
266
  key={key}
267
267
  value={key}
@@ -1,4 +1,4 @@
1
- import { DEFAULT_FIELD_CONFIGS, FieldConfigId } from "@firecms/core";
1
+ import { DEFAULT_FIELD_CONFIGS, FieldConfigId, PropertyConfig } from "@firecms/core";
2
2
 
3
3
  export const supportedFieldsIds: FieldConfigId[] = [
4
4
  "text_field",
@@ -13,16 +13,17 @@ export const supportedFieldsIds: FieldConfigId[] = [
13
13
  "multi_number_select",
14
14
  "file_upload",
15
15
  "multi_file_upload",
16
- "group",
17
- "key_value",
18
16
  "reference",
19
17
  "multi_references",
20
18
  "switch",
21
19
  "date_time",
20
+ "group",
21
+ "key_value",
22
22
  "repeat",
23
23
  "block"
24
24
  ];
25
25
 
26
- export const supportedFields = Object.entries(DEFAULT_FIELD_CONFIGS).filter(([id]) =>
27
- supportedFieldsIds.includes(id as FieldConfigId)
28
- );
26
+ export const supportedFields: Record<string, PropertyConfig> = Object.entries(DEFAULT_FIELD_CONFIGS)
27
+ .filter(([id]) => supportedFieldsIds.includes(id as FieldConfigId))
28
+ .map(([id, config]) => ({ [id]: config }))
29
+ .reduce((a, b) => ({ ...a, ...b }), {});
@@ -56,8 +56,9 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
56
56
 
57
57
  getUser: (uid: string) => UserType | null;
58
58
 
59
- }
59
+ onAnalyticsEvent?: (event: string, params?: object) => void;
60
60
 
61
+ }
61
62
 
62
63
  /**
63
64
  * Use this hook to initialise the Collection Editor plugin.
@@ -73,14 +74,15 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
73
74
  export function useCollectionEditorPlugin<EC extends PersistedCollection = PersistedCollection, UserType extends User = User>
74
75
  ({
75
76
  collectionConfigController,
76
- modifyCollection,
77
+ modifyCollection,
77
78
  configPermissions,
78
79
  reservedGroups,
79
80
  extraView,
80
81
  pathSuggestions,
81
82
  getUser,
82
83
  collectionInference,
83
- getData
84
+ getData,
85
+ onAnalyticsEvent
84
86
  }: CollectionConfigControllerProps<EC, UserType>): FireCMSPlugin<any, any, PersistedCollection> {
85
87
 
86
88
  const injectCollections = useCallback(
@@ -112,7 +114,8 @@ export function useCollectionEditorPlugin<EC extends PersistedCollection = Persi
112
114
  extraView,
113
115
  pathSuggestions,
114
116
  getUser,
115
- getData
117
+ getData,
118
+ onAnalyticsEvent
116
119
  }
117
120
  },
118
121
  homePage: {