@firecms/collection_editor 3.0.0-beta.2-pre.2 → 3.0.0-beta.2-pre.4
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/index.es.js +2532 -2386
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/types/collection_editor_controller.d.ts +3 -2
- package/dist/types/config_controller.d.ts +3 -3
- package/dist/ui/collection_editor/CollectionEditorDialog.d.ts +3 -5
- package/dist/ui/collection_editor/CollectionEditorWelcomeView.d.ts +2 -2
- package/dist/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +1 -2
- package/dist/ui/collection_editor/EnumForm.d.ts +1 -2
- package/dist/ui/collection_editor/PropertyEditView.d.ts +5 -5
- package/dist/ui/collection_editor/PropertyTree.d.ts +14 -13
- package/dist/ui/collection_editor/SwitchControl.d.ts +8 -0
- package/dist/ui/collection_editor/properties/CommonPropertyFields.d.ts +0 -1
- package/dist/ui/collection_editor/util.d.ts +1 -0
- package/package.json +6 -5
- package/src/ConfigControllerProvider.tsx +24 -22
- package/src/types/collection_editor_controller.tsx +4 -3
- package/src/types/config_controller.tsx +3 -3
- package/src/ui/CollectionViewHeaderAction.tsx +1 -1
- package/src/ui/EditorCollectionAction.tsx +3 -3
- package/src/ui/HomePageEditorCollectionAction.tsx +2 -2
- package/src/ui/MissingReferenceWidget.tsx +2 -1
- package/src/ui/NewCollectionButton.tsx +3 -3
- package/src/ui/NewCollectionCard.tsx +2 -1
- package/src/ui/PropertyAddColumnComponent.tsx +1 -1
- package/src/ui/RootCollectionSuggestions.tsx +3 -2
- package/src/ui/collection_editor/CollectionDetailsForm.tsx +2 -2
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +420 -374
- package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +19 -12
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +26 -18
- package/src/ui/collection_editor/EnumForm.tsx +118 -114
- package/src/ui/collection_editor/GetCodeDialog.tsx +1 -1
- package/src/ui/collection_editor/PropertyEditView.tsx +199 -142
- package/src/ui/collection_editor/PropertyFieldPreview.tsx +5 -1
- package/src/ui/collection_editor/PropertyTree.tsx +132 -113
- package/src/ui/collection_editor/SubcollectionsEditTab.tsx +18 -11
- package/src/ui/collection_editor/SwitchControl.tsx +39 -0
- package/src/ui/collection_editor/import/CollectionEditorImportMapping.tsx +10 -2
- package/src/ui/collection_editor/properties/BlockPropertyField.tsx +2 -2
- package/src/ui/collection_editor/properties/BooleanPropertyField.tsx +13 -9
- package/src/ui/collection_editor/properties/CommonPropertyFields.tsx +11 -37
- package/src/ui/collection_editor/properties/DateTimePropertyField.tsx +2 -2
- package/src/ui/collection_editor/properties/EnumPropertyField.tsx +3 -6
- package/src/ui/collection_editor/properties/MapPropertyField.tsx +2 -2
- package/src/ui/collection_editor/properties/NumberPropertyField.tsx +2 -2
- package/src/ui/collection_editor/properties/ReferencePropertyField.tsx +11 -14
- package/src/ui/collection_editor/properties/RepeatPropertyField.tsx +10 -9
- package/src/ui/collection_editor/properties/StoragePropertyField.tsx +15 -9
- package/src/ui/collection_editor/properties/StringPropertyField.tsx +2 -2
- package/src/ui/collection_editor/properties/UrlPropertyField.tsx +2 -2
- package/src/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.tsx +27 -18
- package/src/ui/collection_editor/properties/validation/ArrayPropertyValidation.tsx +2 -2
- package/src/ui/collection_editor/properties/validation/GeneralPropertyValidation.tsx +27 -16
- package/src/ui/collection_editor/properties/validation/NumberPropertyValidation.tsx +33 -18
- package/src/ui/collection_editor/properties/validation/StringPropertyValidation.tsx +99 -80
- package/src/ui/collection_editor/util.ts +7 -0
- package/src/ui/collection_editor/utils/strings.ts +2 -1
- package/src/useCollectionEditorPlugin.tsx +1 -16
|
@@ -7,7 +7,7 @@ import { PersistedCollection } from "./persisted_collection";
|
|
|
7
7
|
*/
|
|
8
8
|
export interface CollectionEditorController {
|
|
9
9
|
editCollection: (props: {
|
|
10
|
-
|
|
10
|
+
id?: string;
|
|
11
11
|
fullPath?: string;
|
|
12
12
|
parentCollectionIds: string[];
|
|
13
13
|
parentCollection?: PersistedCollection;
|
|
@@ -21,12 +21,13 @@ export interface CollectionEditorController {
|
|
|
21
21
|
parentCollectionIds: string[];
|
|
22
22
|
parentCollection?: PersistedCollection;
|
|
23
23
|
redirect: boolean;
|
|
24
|
+
sourceClick?: string;
|
|
24
25
|
}) => void;
|
|
25
26
|
editProperty: (props: {
|
|
26
27
|
propertyKey?: string;
|
|
27
28
|
property?: Property;
|
|
28
29
|
currentPropertiesOrder?: string[];
|
|
29
|
-
|
|
30
|
+
editedCollectionId: string;
|
|
30
31
|
parentCollectionIds: string[];
|
|
31
32
|
collection: PersistedCollection;
|
|
32
33
|
}) => void;
|
|
@@ -21,13 +21,13 @@ export interface CollectionsConfigController {
|
|
|
21
21
|
export type UpdateCollectionParams<M extends Record<string, any>> = {
|
|
22
22
|
id: string;
|
|
23
23
|
collectionData: Partial<PersistedCollection<M>>;
|
|
24
|
-
|
|
24
|
+
previousId?: string;
|
|
25
25
|
parentCollectionIds?: string[];
|
|
26
26
|
};
|
|
27
27
|
export type SaveCollectionParams<M extends Record<string, any>> = {
|
|
28
28
|
id: string;
|
|
29
29
|
collectionData: PersistedCollection<M>;
|
|
30
|
-
|
|
30
|
+
previousId?: string;
|
|
31
31
|
parentCollectionIds?: string[];
|
|
32
32
|
};
|
|
33
33
|
export type SavePropertyParams = {
|
|
@@ -46,6 +46,6 @@ export type DeletePropertyParams = {
|
|
|
46
46
|
parentCollectionIds?: string[];
|
|
47
47
|
};
|
|
48
48
|
export type DeleteCollectionParams = {
|
|
49
|
-
|
|
49
|
+
id: string;
|
|
50
50
|
parentCollectionIds?: string[];
|
|
51
51
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { EntityCollection, User } from "@firecms/core";
|
|
3
3
|
import { CollectionsConfigController } from "../../types/config_controller";
|
|
4
4
|
import { CollectionInference } from "../../types/collection_inference";
|
|
5
5
|
import { PersistedCollection } from "../../types/persisted_collection";
|
|
@@ -11,7 +11,7 @@ export interface CollectionEditorDialogProps {
|
|
|
11
11
|
path?: string;
|
|
12
12
|
name?: string;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
editedCollectionId?: string;
|
|
15
15
|
fullPath?: string;
|
|
16
16
|
parentCollectionIds?: string[];
|
|
17
17
|
handleClose: (collection?: EntityCollection) => void;
|
|
@@ -30,9 +30,7 @@ export interface CollectionEditorDialogProps {
|
|
|
30
30
|
parentCollection?: PersistedCollection;
|
|
31
31
|
}
|
|
32
32
|
export declare function CollectionEditorDialog(props: CollectionEditorDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
-
export declare function
|
|
34
|
-
[Key: string]: CMSType;
|
|
35
|
-
}>({ isNewCollection, initialValues: initialValuesProp, configController, editedCollectionPath, parentCollectionIds, fullPath, collectionInference, handleClose, reservedGroups, extraView, handleCancel, setFormDirty, pathSuggestions, getUser, parentCollection, getData }: CollectionEditorDialogProps & {
|
|
33
|
+
export declare function CollectionEditor<M extends Record<string, any>>(props: CollectionEditorDialogProps & {
|
|
36
34
|
handleCancel: () => void;
|
|
37
35
|
setFormDirty: (dirty: boolean) => void;
|
|
38
36
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { EntityCollection } from "@firecms/core";
|
|
3
|
-
export declare function CollectionEditorWelcomeView({ path, pathSuggestions, parentCollection, onContinue,
|
|
3
|
+
export declare function CollectionEditorWelcomeView({ path, pathSuggestions, parentCollection, onContinue, existingCollectionPaths }: {
|
|
4
4
|
path: string;
|
|
5
5
|
pathSuggestions?: (path: string) => Promise<string[]>;
|
|
6
6
|
parentCollection?: EntityCollection;
|
|
7
7
|
onContinue: (importData?: object[]) => void;
|
|
8
|
-
|
|
8
|
+
existingCollectionPaths?: string[];
|
|
9
9
|
}): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export declare function TemplateButton({ title, subtitle, icon, onClick }: {
|
|
11
11
|
title: string;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { FormikErrors } from "formik";
|
|
3
2
|
import { EntityCollection, PropertyConfig, User } from "@firecms/core";
|
|
4
3
|
import { PersistedCollection } from "../../types/persisted_collection";
|
|
5
4
|
type CollectionEditorFormProps = {
|
|
6
5
|
showErrors: boolean;
|
|
7
6
|
isNewCollection: boolean;
|
|
8
7
|
propertyErrorsRef?: React.MutableRefObject<any>;
|
|
9
|
-
onPropertyError: (propertyKey: string, namespace: string | undefined, error?:
|
|
8
|
+
onPropertyError: (propertyKey: string, namespace: string | undefined, error?: Record<string, any>) => void;
|
|
10
9
|
setDirty?: (dirty: boolean) => void;
|
|
11
10
|
reservedGroups?: string[];
|
|
12
11
|
extraIcon: React.ReactNode;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from "react";
|
|
2
1
|
import { EnumValueConfig } from "@firecms/core";
|
|
3
2
|
type EnumFormProps = {
|
|
4
3
|
enumValues: EnumValueConfig[];
|
|
@@ -9,5 +8,5 @@ type EnumFormProps = {
|
|
|
9
8
|
allowDataInference?: boolean;
|
|
10
9
|
getData?: () => Promise<string[]>;
|
|
11
10
|
};
|
|
12
|
-
export declare
|
|
11
|
+
export declare function EnumForm({ enumValues, onValuesChanged, onError, updateIds, disabled, allowDataInference, getData }: EnumFormProps): import("react/jsx-runtime").JSX.Element;
|
|
13
12
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { FormexController } from "@firecms/formex";
|
|
3
3
|
import { Property, PropertyConfig } from "@firecms/core";
|
|
4
4
|
export type PropertyWithId = Property & {
|
|
5
5
|
id?: string;
|
|
@@ -22,13 +22,13 @@ export type PropertyFormProps = {
|
|
|
22
22
|
onPropertyChanged?: (params: OnPropertyChangedParams) => void;
|
|
23
23
|
onPropertyChangedImmediate?: boolean;
|
|
24
24
|
onDelete?: (id?: string, namespace?: string) => void;
|
|
25
|
-
onError?: (id: string, namespace?: string, error?:
|
|
26
|
-
initialErrors?:
|
|
27
|
-
forceShowErrors?: boolean;
|
|
25
|
+
onError?: (id: string, namespace?: string, error?: Record<string, any>) => void;
|
|
26
|
+
initialErrors?: Record<string, any>;
|
|
28
27
|
existingPropertyKeys?: string[];
|
|
28
|
+
forceShowErrors?: boolean;
|
|
29
29
|
allowDataInference: boolean;
|
|
30
30
|
getData?: () => Promise<object[]>;
|
|
31
|
-
|
|
31
|
+
getController?: (formex: FormexController<PropertyWithId>) => void;
|
|
32
32
|
propertyConfigs: Record<string, PropertyConfig>;
|
|
33
33
|
collectionEditable: boolean;
|
|
34
34
|
};
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import { AdditionalFieldDelegate, CMSType, PropertiesOrBuilders, PropertyOrBuilder } from "@firecms/core";
|
|
2
3
|
import { DraggableProvided } from "@hello-pangea/dnd";
|
|
3
|
-
export declare
|
|
4
|
+
export declare const PropertyTree: React.MemoExoticComponent<(<M extends {
|
|
4
5
|
[Key: string]: CMSType;
|
|
5
|
-
}>({ namespace, selectedPropertyKey, onPropertyClick, properties, propertiesOrder: propertiesOrderProp, additionalFields, errors, onPropertyMove, onPropertyRemove, className, inferredPropertyKeys, collectionEditable
|
|
6
|
-
namespace?: string;
|
|
7
|
-
selectedPropertyKey?: string;
|
|
8
|
-
onPropertyClick?: (propertyKey: string, namespace?: string) => void;
|
|
6
|
+
}>({ namespace, selectedPropertyKey, onPropertyClick, properties, propertiesOrder: propertiesOrderProp, additionalFields, errors, onPropertyMove, onPropertyRemove, className, inferredPropertyKeys, collectionEditable }: {
|
|
7
|
+
namespace?: string | undefined;
|
|
8
|
+
selectedPropertyKey?: string | undefined;
|
|
9
|
+
onPropertyClick?: ((propertyKey: string, namespace?: string) => void) | undefined;
|
|
9
10
|
properties: PropertiesOrBuilders<M>;
|
|
10
|
-
propertiesOrder?: string[];
|
|
11
|
-
additionalFields?: AdditionalFieldDelegate<M>[];
|
|
11
|
+
propertiesOrder?: string[] | undefined;
|
|
12
|
+
additionalFields?: AdditionalFieldDelegate<M, import("@firecms/core").User>[] | undefined;
|
|
12
13
|
errors: Record<string, any>;
|
|
13
|
-
onPropertyMove?: (propertiesOrder: string[], namespace?: string) => void;
|
|
14
|
-
onPropertyRemove?: (propertyKey: string, namespace?: string) => void;
|
|
15
|
-
className?: string;
|
|
16
|
-
inferredPropertyKeys?: string[];
|
|
14
|
+
onPropertyMove?: ((propertiesOrder: string[], namespace?: string) => void) | undefined;
|
|
15
|
+
onPropertyRemove?: ((propertyKey: string, namespace?: string) => void) | undefined;
|
|
16
|
+
className?: string | undefined;
|
|
17
|
+
inferredPropertyKeys?: string[] | undefined;
|
|
17
18
|
collectionEditable: boolean;
|
|
18
|
-
})
|
|
19
|
-
export declare function PropertyTreeEntry({ propertyKey, namespace, propertyOrBuilder, additionalField, provided, selectedPropertyKey, errors, onPropertyClick, onPropertyMove, onPropertyRemove, inferredPropertyKeys, collectionEditable
|
|
19
|
+
}) => import("react/jsx-runtime").JSX.Element)>;
|
|
20
|
+
export declare function PropertyTreeEntry({ propertyKey, namespace, propertyOrBuilder, additionalField, provided, selectedPropertyKey, errors, onPropertyClick, onPropertyMove, onPropertyRemove, inferredPropertyKeys, collectionEditable }: {
|
|
20
21
|
propertyKey: string;
|
|
21
22
|
namespace?: string;
|
|
22
23
|
propertyOrBuilder: PropertyOrBuilder;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FormexFieldProps } from "@firecms/formex";
|
|
2
|
+
export declare function SwitchControl({ field, form, label, tooltip, disabled, size, allowIndeterminate }: FormexFieldProps & {
|
|
3
|
+
label: string;
|
|
4
|
+
tooltip?: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
size?: "small" | "medium";
|
|
7
|
+
allowIndeterminate?: boolean;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,3 +2,4 @@ export declare function idToPropertiesPath(id: string): string;
|
|
|
2
2
|
export declare function namespaceToPropertiesPath(namespace?: string): string;
|
|
3
3
|
export declare function namespaceToPropertiesOrderPath(namespace?: string): string;
|
|
4
4
|
export declare function getFullId(propertyKey: string, propertyNamespace?: string): string;
|
|
5
|
+
export declare function getFullIdPath(propertyKey: string, propertyNamespace?: string): string;
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/collection_editor",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-beta.2-pre.
|
|
4
|
+
"version": "3.0.0-beta.2-pre.4",
|
|
5
5
|
"main": "./dist/index.umd.js",
|
|
6
6
|
"module": "./dist/index.es.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"source": "src/index.ts",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@firecms/data_import_export": "^3.0.0-beta.2-pre.
|
|
11
|
-
"@firecms/
|
|
12
|
-
"@firecms/
|
|
10
|
+
"@firecms/data_import_export": "^3.0.0-beta.2-pre.4",
|
|
11
|
+
"@firecms/formex": "^3.0.0-beta.2-pre.4",
|
|
12
|
+
"@firecms/schema_inference": "^3.0.0-beta.2-pre.4",
|
|
13
|
+
"@firecms/ui": "^3.0.0-beta.2-pre.4",
|
|
13
14
|
"json5": "^2.2.3",
|
|
14
15
|
"prism-react-renderer": "^2.3.1"
|
|
15
16
|
},
|
|
@@ -72,5 +73,5 @@
|
|
|
72
73
|
"publishConfig": {
|
|
73
74
|
"access": "public"
|
|
74
75
|
},
|
|
75
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "a947c08aada0e374aec7dff2b0dc9e540e170834"
|
|
76
77
|
}
|
|
@@ -80,7 +80,7 @@ export const ConfigControllerProvider = React.memo(
|
|
|
80
80
|
const {
|
|
81
81
|
collections
|
|
82
82
|
} = navigation;
|
|
83
|
-
const existingPaths = collections.map(col => col.path.trim().toLowerCase());
|
|
83
|
+
const existingPaths = (collections ?? []).map(col => col.path.trim().toLowerCase());
|
|
84
84
|
|
|
85
85
|
const [rootPathSuggestions, setRootPathSuggestions] = React.useState<string[] | undefined>();
|
|
86
86
|
useEffect(() => {
|
|
@@ -94,7 +94,7 @@ export const ConfigControllerProvider = React.memo(
|
|
|
94
94
|
const [currentDialog, setCurrentDialog] = React.useState<{
|
|
95
95
|
isNewCollection: boolean,
|
|
96
96
|
parentCollection?: PersistedCollection,
|
|
97
|
-
|
|
97
|
+
editedCollectionId?: string,
|
|
98
98
|
fullPath?: string,
|
|
99
99
|
parentCollectionIds: string[],
|
|
100
100
|
initialValues?: {
|
|
@@ -111,7 +111,7 @@ export const ConfigControllerProvider = React.memo(
|
|
|
111
111
|
namespace?: string,
|
|
112
112
|
parentCollection?: PersistedCollection,
|
|
113
113
|
currentPropertiesOrder?: string[],
|
|
114
|
-
|
|
114
|
+
editedCollectionId: string,
|
|
115
115
|
fullPath?: string,
|
|
116
116
|
parentCollectionIds: string[],
|
|
117
117
|
collectionEditable: boolean;
|
|
@@ -124,20 +124,20 @@ export const ConfigControllerProvider = React.memo(
|
|
|
124
124
|
}), []);
|
|
125
125
|
|
|
126
126
|
const editCollection = useCallback(({
|
|
127
|
-
|
|
127
|
+
id,
|
|
128
128
|
fullPath,
|
|
129
129
|
parentCollectionIds,
|
|
130
130
|
parentCollection
|
|
131
131
|
}: {
|
|
132
|
-
|
|
132
|
+
id?: string,
|
|
133
133
|
fullPath?: string,
|
|
134
134
|
parentCollectionIds: string[],
|
|
135
135
|
parentCollection?: PersistedCollection
|
|
136
136
|
}) => {
|
|
137
|
-
console.debug("
|
|
138
|
-
onAnalyticsEvent?.("edit_collection", {
|
|
137
|
+
console.debug("Edit collection", id, fullPath, parentCollectionIds, parentCollection);
|
|
138
|
+
onAnalyticsEvent?.("edit_collection", { id, fullPath });
|
|
139
139
|
setCurrentDialog({
|
|
140
|
-
|
|
140
|
+
editedCollectionId: id,
|
|
141
141
|
fullPath,
|
|
142
142
|
parentCollectionIds,
|
|
143
143
|
isNewCollection: false,
|
|
@@ -149,7 +149,7 @@ export const ConfigControllerProvider = React.memo(
|
|
|
149
149
|
const editProperty = useCallback(({
|
|
150
150
|
propertyKey,
|
|
151
151
|
property,
|
|
152
|
-
|
|
152
|
+
editedCollectionId,
|
|
153
153
|
currentPropertiesOrder,
|
|
154
154
|
parentCollectionIds,
|
|
155
155
|
collection
|
|
@@ -157,12 +157,12 @@ export const ConfigControllerProvider = React.memo(
|
|
|
157
157
|
propertyKey?: string,
|
|
158
158
|
property?: Property,
|
|
159
159
|
currentPropertiesOrder?: string[],
|
|
160
|
-
|
|
160
|
+
editedCollectionId: string,
|
|
161
161
|
parentCollectionIds: string[],
|
|
162
162
|
collection: PersistedCollection,
|
|
163
163
|
}) => {
|
|
164
|
-
console.debug("edit property", propertyKey, property,
|
|
165
|
-
onAnalyticsEvent?.("edit_property", { propertyKey,
|
|
164
|
+
console.debug("edit property", propertyKey, property, editedCollectionId, currentPropertiesOrder, parentCollectionIds, collection);
|
|
165
|
+
onAnalyticsEvent?.("edit_property", { propertyKey, editedCollectionId });
|
|
166
166
|
// namespace is all the path until the last dot
|
|
167
167
|
const namespace = propertyKey && propertyKey.includes(".")
|
|
168
168
|
? propertyKey.substring(0, propertyKey.lastIndexOf("."))
|
|
@@ -175,7 +175,7 @@ export const ConfigControllerProvider = React.memo(
|
|
|
175
175
|
property,
|
|
176
176
|
namespace,
|
|
177
177
|
currentPropertiesOrder,
|
|
178
|
-
|
|
178
|
+
editedCollectionId: editedCollectionId,
|
|
179
179
|
parentCollectionIds,
|
|
180
180
|
collectionEditable: collection?.editable ?? false
|
|
181
181
|
});
|
|
@@ -185,7 +185,8 @@ export const ConfigControllerProvider = React.memo(
|
|
|
185
185
|
parentCollectionIds,
|
|
186
186
|
parentCollection,
|
|
187
187
|
initialValues,
|
|
188
|
-
redirect
|
|
188
|
+
redirect,
|
|
189
|
+
sourceClick
|
|
189
190
|
}: {
|
|
190
191
|
parentCollectionIds: string[],
|
|
191
192
|
parentCollection?: PersistedCollection
|
|
@@ -194,10 +195,11 @@ export const ConfigControllerProvider = React.memo(
|
|
|
194
195
|
path?: string,
|
|
195
196
|
name?: string
|
|
196
197
|
},
|
|
197
|
-
redirect: boolean
|
|
198
|
+
redirect: boolean,
|
|
199
|
+
sourceClick?: string
|
|
198
200
|
}) => {
|
|
199
|
-
console.debug("
|
|
200
|
-
onAnalyticsEvent?.("create_collection", { parentCollectionIds, parentCollection, initialValues, redirect });
|
|
201
|
+
console.debug("Create collection", { parentCollectionIds, parentCollection, initialValues, redirect, sourceClick });
|
|
202
|
+
onAnalyticsEvent?.("create_collection", { parentCollectionIds, parentCollection, initialValues, redirect, sourceClick });
|
|
201
203
|
setCurrentDialog({
|
|
202
204
|
isNewCollection: true,
|
|
203
205
|
parentCollectionIds,
|
|
@@ -260,10 +262,10 @@ export const ConfigControllerProvider = React.memo(
|
|
|
260
262
|
autoOpenTypeSelect={!currentPropertyDialog ? false : !currentPropertyDialog?.propertyKey}
|
|
261
263
|
inArray={false}
|
|
262
264
|
collectionEditable={currentPropertyDialog?.collectionEditable ?? false}
|
|
263
|
-
getData={getData && currentPropertyDialog?.
|
|
265
|
+
getData={getData && currentPropertyDialog?.editedCollectionId
|
|
264
266
|
? () => {
|
|
265
|
-
console.debug("get data for property", currentPropertyDialog?.
|
|
266
|
-
const resolvedPath = navigation.resolveAliasesFrom(currentPropertyDialog.
|
|
267
|
+
console.debug("get data for property", currentPropertyDialog?.editedCollectionId);
|
|
268
|
+
const resolvedPath = navigation.resolveAliasesFrom(currentPropertyDialog.editedCollectionId!)
|
|
267
269
|
return getData(resolvedPath, []);
|
|
268
270
|
}
|
|
269
271
|
: undefined}
|
|
@@ -275,7 +277,7 @@ export const ConfigControllerProvider = React.memo(
|
|
|
275
277
|
if (!id) return;
|
|
276
278
|
const newProperty = !(currentPropertyDialog.propertyKey);
|
|
277
279
|
return collectionConfigController.saveProperty({
|
|
278
|
-
path: currentPropertyDialog?.
|
|
280
|
+
path: currentPropertyDialog?.editedCollectionId,
|
|
279
281
|
property,
|
|
280
282
|
propertyKey: id,
|
|
281
283
|
newPropertiesOrder: newProperty && currentPropertyDialog.currentPropertiesOrder ? [...currentPropertyDialog.currentPropertiesOrder, id] : undefined,
|
|
@@ -296,7 +298,7 @@ export const ConfigControllerProvider = React.memo(
|
|
|
296
298
|
if (!currentPropertyDialog?.propertyKey) return;
|
|
297
299
|
const newPropertiesOrder = currentPropertyDialog?.currentPropertiesOrder?.filter(p => p !== currentPropertyDialog?.propertyKey);
|
|
298
300
|
return collectionConfigController.deleteProperty({
|
|
299
|
-
path: currentPropertyDialog?.
|
|
301
|
+
path: currentPropertyDialog?.editedCollectionId,
|
|
300
302
|
propertyKey: currentPropertyDialog?.propertyKey,
|
|
301
303
|
namespace: currentPropertyDialog?.namespace,
|
|
302
304
|
newPropertiesOrder,
|
|
@@ -9,7 +9,7 @@ import { PersistedCollection } from "./persisted_collection";
|
|
|
9
9
|
export interface CollectionEditorController {
|
|
10
10
|
|
|
11
11
|
editCollection: (props: {
|
|
12
|
-
|
|
12
|
+
id?: string,
|
|
13
13
|
fullPath?: string,
|
|
14
14
|
parentCollectionIds: string[],
|
|
15
15
|
parentCollection?: PersistedCollection
|
|
@@ -23,14 +23,15 @@ export interface CollectionEditorController {
|
|
|
23
23
|
},
|
|
24
24
|
parentCollectionIds: string[],
|
|
25
25
|
parentCollection?: PersistedCollection,
|
|
26
|
-
redirect: boolean
|
|
26
|
+
redirect: boolean,
|
|
27
|
+
sourceClick?: string
|
|
27
28
|
}) => void;
|
|
28
29
|
|
|
29
30
|
editProperty: (props: {
|
|
30
31
|
propertyKey?: string,
|
|
31
32
|
property?: Property,
|
|
32
33
|
currentPropertiesOrder?: string[],
|
|
33
|
-
|
|
34
|
+
editedCollectionId: string,
|
|
34
35
|
parentCollectionIds: string[],
|
|
35
36
|
collection: PersistedCollection
|
|
36
37
|
}) => void;
|
|
@@ -26,14 +26,14 @@ export interface CollectionsConfigController {
|
|
|
26
26
|
export type UpdateCollectionParams<M extends Record<string, any>> = {
|
|
27
27
|
id: string,
|
|
28
28
|
collectionData: Partial<PersistedCollection<M>>,
|
|
29
|
-
|
|
29
|
+
previousId?: string,
|
|
30
30
|
parentCollectionIds?: string[]
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export type SaveCollectionParams<M extends Record<string, any>> = {
|
|
34
34
|
id: string,
|
|
35
35
|
collectionData: PersistedCollection<M>,
|
|
36
|
-
|
|
36
|
+
previousId?: string,
|
|
37
37
|
parentCollectionIds?: string[]
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -55,6 +55,6 @@ export type DeletePropertyParams = {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
export type DeleteCollectionParams = {
|
|
58
|
-
|
|
58
|
+
id: string,
|
|
59
59
|
parentCollectionIds?: string[]
|
|
60
60
|
}
|
|
@@ -39,7 +39,7 @@ export function EditorCollectionAction({
|
|
|
39
39
|
if (!equal(getObjectOrNull(tableController.filterValues), getObjectOrNull(collection.initialFilter)) ||
|
|
40
40
|
!equal(getObjectOrNull(tableController.sortBy), getObjectOrNull(collection.initialSort))) {
|
|
41
41
|
saveDefaultFilterButton = <>
|
|
42
|
-
{collection.initialFilter || collection.initialSort && <Tooltip
|
|
42
|
+
{(collection.initialFilter || collection.initialSort) && <Tooltip
|
|
43
43
|
title={"Reset to default filter and sort"}>
|
|
44
44
|
<Button
|
|
45
45
|
color={"primary"}
|
|
@@ -64,7 +64,7 @@ export function EditorCollectionAction({
|
|
|
64
64
|
variant={"outlined"}
|
|
65
65
|
onClick={() => configController
|
|
66
66
|
?.saveCollection({
|
|
67
|
-
id: collection.
|
|
67
|
+
id: collection.id,
|
|
68
68
|
parentCollectionIds,
|
|
69
69
|
collectionData: mergeDeep(collection as PersistedCollection,
|
|
70
70
|
{
|
|
@@ -89,7 +89,7 @@ export function EditorCollectionAction({
|
|
|
89
89
|
color={"primary"}
|
|
90
90
|
disabled={!canEditCollection}
|
|
91
91
|
onClick={canEditCollection
|
|
92
|
-
? () => collectionEditorController?.editCollection({
|
|
92
|
+
? () => collectionEditorController?.editCollection({ id: collection.id, fullPath, parentCollectionIds, parentCollection: parentCollection as PersistedCollection })
|
|
93
93
|
: undefined}>
|
|
94
94
|
<SettingsIcon/>
|
|
95
95
|
</IconButton>
|
|
@@ -25,13 +25,13 @@ export function HomePageEditorCollectionAction({
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
const onEditCollectionClicked = useCallback(() => {
|
|
28
|
-
collectionEditorController?.editCollection({
|
|
28
|
+
collectionEditorController?.editCollection({ id: collection.id, parentCollectionIds: [] });
|
|
29
29
|
}, [collectionEditorController, path]);
|
|
30
30
|
|
|
31
31
|
const [deleteRequested, setDeleteRequested] = useState(false);
|
|
32
32
|
|
|
33
33
|
const deleteCollection = useCallback(() => {
|
|
34
|
-
configController?.deleteCollection({
|
|
34
|
+
configController?.deleteCollection({ id: collection.id }).then(() => {
|
|
35
35
|
setDeleteRequested(false);
|
|
36
36
|
snackbarController.open({
|
|
37
37
|
message: "Collection deleted",
|
|
@@ -16,7 +16,8 @@ export function MissingReferenceWidget({ path: pathProp }: {
|
|
|
16
16
|
collectionEditor.createCollection({
|
|
17
17
|
initialValues: { path, name: unslugify(path) },
|
|
18
18
|
parentCollectionIds,
|
|
19
|
-
redirect: false
|
|
19
|
+
redirect: false,
|
|
20
|
+
sourceClick: "missing_reference"
|
|
20
21
|
});
|
|
21
22
|
}}>
|
|
22
23
|
Create
|
|
@@ -7,9 +7,9 @@ export function NewCollectionButton() {
|
|
|
7
7
|
variant={"outlined"}
|
|
8
8
|
onClick={() => collectionEditorController.createCollection({
|
|
9
9
|
parentCollectionIds: [],
|
|
10
|
-
redirect: true
|
|
11
|
-
|
|
12
|
-
}>
|
|
10
|
+
redirect: true,
|
|
11
|
+
sourceClick: "new_collection_button"
|
|
12
|
+
})}>
|
|
13
13
|
<AddIcon/>
|
|
14
14
|
New collection
|
|
15
15
|
</Button>
|
|
@@ -25,7 +25,8 @@ export function NewCollectionCard({
|
|
|
25
25
|
? () => collectionEditorController.createCollection({
|
|
26
26
|
initialValues: group ? { group } : undefined,
|
|
27
27
|
parentCollectionIds: [],
|
|
28
|
-
redirect: true
|
|
28
|
+
redirect: true,
|
|
29
|
+
sourceClick: "new_collection_card"
|
|
29
30
|
})
|
|
30
31
|
: undefined}>
|
|
31
32
|
|
|
@@ -29,7 +29,7 @@ export function PropertyAddColumnComponent({
|
|
|
29
29
|
// className={onHover ? "bg-white dark:bg-gray-950" : undefined}
|
|
30
30
|
onClick={() => {
|
|
31
31
|
collectionEditorController.editProperty({
|
|
32
|
-
|
|
32
|
+
editedCollectionId: collection.id,
|
|
33
33
|
parentCollectionIds,
|
|
34
34
|
currentPropertiesOrder: getDefaultPropertiesOrder(collection),
|
|
35
35
|
collection
|
|
@@ -17,7 +17,7 @@ export function RootCollectionSuggestions() {
|
|
|
17
17
|
|
|
18
18
|
const rootPathSuggestions = collectionEditorController.rootPathSuggestions ?? [];
|
|
19
19
|
|
|
20
|
-
const showSuggestions = rootPathSuggestions.length > 3 || (navigationController.collections.length === 0 && rootPathSuggestions.length > 0);
|
|
20
|
+
const showSuggestions = rootPathSuggestions.length > 3 || ((navigationController.collections ?? []).length === 0 && rootPathSuggestions.length > 0);
|
|
21
21
|
return <Collapse
|
|
22
22
|
in={showSuggestions}>
|
|
23
23
|
|
|
@@ -40,7 +40,8 @@ export function RootCollectionSuggestions() {
|
|
|
40
40
|
? () => collectionEditorController.createCollection({
|
|
41
41
|
initialValues: { path, name: unslugify(path) },
|
|
42
42
|
parentCollectionIds: [],
|
|
43
|
-
redirect: true
|
|
43
|
+
redirect: true,
|
|
44
|
+
sourceClick: "root_collection_suggestion"
|
|
44
45
|
})
|
|
45
46
|
: undefined}
|
|
46
47
|
size="small">
|
|
@@ -19,9 +19,9 @@ import {
|
|
|
19
19
|
Typography,
|
|
20
20
|
useAutoComplete
|
|
21
21
|
} from "@firecms/ui";
|
|
22
|
-
import { Field, getIn, useFormikContext } from "formik";
|
|
23
22
|
|
|
24
23
|
import { FieldHelperView } from "./properties/FieldHelperView";
|
|
24
|
+
import { useFormex, Field, getIn } from "@firecms/formex";
|
|
25
25
|
|
|
26
26
|
export function CollectionDetailsForm({
|
|
27
27
|
isNewCollection,
|
|
@@ -50,7 +50,7 @@ export function CollectionDetailsForm({
|
|
|
50
50
|
setFieldTouched,
|
|
51
51
|
isSubmitting,
|
|
52
52
|
submitCount
|
|
53
|
-
} =
|
|
53
|
+
} = useFormex<EntityCollection>();
|
|
54
54
|
|
|
55
55
|
const [iconDialogOpen, setIconDialogOpen] = useState(false);
|
|
56
56
|
const [advancedPanelExpanded, setAdvancedPanelExpanded] = useState(false);
|