@firecms/collection_editor 3.0.0-beta.12 → 3.0.0-beta.14
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/README.md +165 -1
- package/dist/ConfigControllerProvider.d.ts +0 -1
- package/dist/index.es.js +1034 -844
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1030 -843
- package/dist/index.umd.js.map +1 -1
- package/dist/types/collection_editor_controller.d.ts +0 -1
- package/dist/ui/collection_editor/CollectionEditorWelcomeView.d.ts +1 -1
- package/dist/ui/collection_editor/PropertyTree.d.ts +2 -3
- package/dist/useCollectionEditorPlugin.d.ts +3 -3
- package/package.json +8 -9
- package/src/ConfigControllerProvider.tsx +0 -5
- package/src/types/collection_editor_controller.tsx +0 -2
- package/src/ui/HomePageEditorCollectionAction.tsx +2 -1
- package/src/ui/collection_editor/CollectionDetailsForm.tsx +40 -8
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +1 -1
- package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +5 -21
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +5 -4
- package/src/ui/collection_editor/EnumForm.tsx +1 -1
- package/src/ui/collection_editor/PropertyEditView.tsx +1 -2
- package/src/ui/collection_editor/PropertyTree.tsx +183 -139
- package/src/ui/collection_editor/import/CollectionEditorImportDataPreview.tsx +9 -2
- package/src/ui/collection_editor/properties/MapPropertyField.tsx +1 -1
- package/src/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.tsx +2 -0
- package/src/ui/collection_editor/utils/strings.ts +13 -6
- package/src/useCollectionEditorPlugin.tsx +5 -6
- package/src/utils/collections.ts +1 -0
|
@@ -6,7 +6,7 @@ export declare function CollectionEditorWelcomeView({ path, pathSuggestions, par
|
|
|
6
6
|
parentCollection?: EntityCollection;
|
|
7
7
|
onContinue: (importData?: object[], propertiesOrder?: string[]) => void;
|
|
8
8
|
existingCollectionPaths?: string[];
|
|
9
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
10
10
|
export declare function TemplateButton({ title, subtitle, icon, onClick }: {
|
|
11
11
|
title: string;
|
|
12
12
|
icon: React.ReactNode;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { AdditionalFieldDelegate, CMSType, PropertiesOrBuilders, PropertyOrBuilder } from "@firecms/core";
|
|
3
|
-
import { DraggableProvided } from "@hello-pangea/dnd";
|
|
4
3
|
export declare const PropertyTree: React.MemoExoticComponent<(<M extends {
|
|
5
4
|
[Key: string]: CMSType;
|
|
6
5
|
}>({ namespace, selectedPropertyKey, onPropertyClick, properties, propertiesOrder: propertiesOrderProp, additionalFields, errors, onPropertyMove, onPropertyRemove, className, inferredPropertyKeys, collectionEditable }: {
|
|
@@ -17,13 +16,13 @@ export declare const PropertyTree: React.MemoExoticComponent<(<M extends {
|
|
|
17
16
|
inferredPropertyKeys?: string[];
|
|
18
17
|
collectionEditable: boolean;
|
|
19
18
|
}) => import("react/jsx-runtime").JSX.Element)>;
|
|
20
|
-
export declare function PropertyTreeEntry({ propertyKey, namespace, propertyOrBuilder, additionalField,
|
|
19
|
+
export declare function PropertyTreeEntry({ id, propertyKey, namespace, propertyOrBuilder, additionalField, selectedPropertyKey, errors, onPropertyClick, onPropertyMove, onPropertyRemove, inferredPropertyKeys, collectionEditable }: {
|
|
20
|
+
id: string;
|
|
21
21
|
propertyKey: string;
|
|
22
22
|
namespace?: string;
|
|
23
23
|
propertyOrBuilder: PropertyOrBuilder;
|
|
24
24
|
additionalField?: AdditionalFieldDelegate<any>;
|
|
25
25
|
selectedPropertyKey?: string;
|
|
26
|
-
provided: DraggableProvided;
|
|
27
26
|
errors: Record<string, any>;
|
|
28
27
|
onPropertyClick?: (propertyKey: string, namespace?: string) => void;
|
|
29
28
|
onPropertyMove?: (propertiesOrder: string[], namespace?: string) => void;
|
|
@@ -25,11 +25,11 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
|
|
|
25
25
|
}>;
|
|
26
26
|
icon: React.ReactNode;
|
|
27
27
|
};
|
|
28
|
-
getPathSuggestions?: (path?: string) => Promise<string[]>;
|
|
29
28
|
collectionInference?: CollectionInference;
|
|
30
29
|
getData?: (path: string, parentPaths: string[]) => Promise<object[]>;
|
|
31
30
|
getUser?: (uid: string) => USER | null;
|
|
32
31
|
onAnalyticsEvent?: (event: string, params?: object) => void;
|
|
32
|
+
includeIntroView?: boolean;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Use this hook to initialise the Collection Editor plugin.
|
|
@@ -42,5 +42,5 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
|
|
|
42
42
|
* @param getUser
|
|
43
43
|
* @param collectionInference
|
|
44
44
|
*/
|
|
45
|
-
export declare function useCollectionEditorPlugin<EC extends PersistedCollection = PersistedCollection, USER extends User = User>({ collectionConfigController, configPermissions, reservedGroups, extraView,
|
|
46
|
-
export declare function IntroWidget(
|
|
45
|
+
export declare function useCollectionEditorPlugin<EC extends PersistedCollection = PersistedCollection, USER extends User = User>({ collectionConfigController, configPermissions, reservedGroups, extraView, getUser, collectionInference, getData, onAnalyticsEvent, includeIntroView }: CollectionConfigControllerProps<EC, USER>): FireCMSPlugin<any, any, PersistedCollection>;
|
|
46
|
+
export declare function IntroWidget(): import("react/jsx-runtime").JSX.Element | null;
|
package/package.json
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/collection_editor",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.14",
|
|
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_export": "^3.0.0-beta.
|
|
11
|
-
"@firecms/data_import": "^3.0.0-beta.
|
|
12
|
-
"@firecms/data_import_export": "^3.0.0-beta.
|
|
13
|
-
"@firecms/formex": "^3.0.0-beta.
|
|
14
|
-
"@firecms/schema_inference": "^3.0.0-beta.
|
|
15
|
-
"@firecms/ui": "^3.0.0-beta.
|
|
16
|
-
"@hello-pangea/dnd": "^17.0.0",
|
|
10
|
+
"@firecms/data_export": "^3.0.0-beta.14",
|
|
11
|
+
"@firecms/data_import": "^3.0.0-beta.14",
|
|
12
|
+
"@firecms/data_import_export": "^3.0.0-beta.14",
|
|
13
|
+
"@firecms/formex": "^3.0.0-beta.14",
|
|
14
|
+
"@firecms/schema_inference": "^3.0.0-beta.14",
|
|
15
|
+
"@firecms/ui": "^3.0.0-beta.14",
|
|
17
16
|
"json5": "^2.2.3",
|
|
18
17
|
"prism-react-renderer": "^2.4.1"
|
|
19
18
|
},
|
|
@@ -70,5 +69,5 @@
|
|
|
70
69
|
"publishConfig": {
|
|
71
70
|
"access": "public"
|
|
72
71
|
},
|
|
73
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "22973ce94cd4ee8ccb4d586ba7f15383dc2cf30b"
|
|
74
73
|
}
|
|
@@ -49,8 +49,6 @@ export interface ConfigControllerProviderProps {
|
|
|
49
49
|
icon: React.ReactNode
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
getPathSuggestions?: (path?: string) => Promise<string[]>;
|
|
53
|
-
|
|
54
52
|
getUser?: (uid: string) => User | null
|
|
55
53
|
|
|
56
54
|
getData?: (path: string, parentPaths: string[]) => Promise<object[]>;
|
|
@@ -67,7 +65,6 @@ export const ConfigControllerProvider = React.memo(
|
|
|
67
65
|
reservedGroups,
|
|
68
66
|
collectionInference,
|
|
69
67
|
extraView,
|
|
70
|
-
getPathSuggestions,
|
|
71
68
|
getUser,
|
|
72
69
|
getData,
|
|
73
70
|
onAnalyticsEvent,
|
|
@@ -230,7 +227,6 @@ export const ConfigControllerProvider = React.memo(
|
|
|
230
227
|
createCollection,
|
|
231
228
|
editProperty,
|
|
232
229
|
configPermissions: configPermissions ?? defaultConfigPermissions,
|
|
233
|
-
getPathSuggestions,
|
|
234
230
|
}}>
|
|
235
231
|
|
|
236
232
|
{children}
|
|
@@ -244,7 +240,6 @@ export const ConfigControllerProvider = React.memo(
|
|
|
244
240
|
getData={getData}
|
|
245
241
|
reservedGroups={reservedGroups}
|
|
246
242
|
extraView={extraView}
|
|
247
|
-
pathSuggestions={getPathSuggestions}
|
|
248
243
|
getUser={getUser}
|
|
249
244
|
handleClose={(collection) => {
|
|
250
245
|
if (currentDialog?.redirect) {
|
|
@@ -49,7 +49,7 @@ export function HomePageEditorCollectionAction({
|
|
|
49
49
|
<div>
|
|
50
50
|
{permissions.deleteCollections &&
|
|
51
51
|
<Menu
|
|
52
|
-
trigger={<IconButton>
|
|
52
|
+
trigger={<IconButton size={"small"}>
|
|
53
53
|
<MoreVertIcon size={"small"}/>
|
|
54
54
|
</IconButton>}
|
|
55
55
|
>
|
|
@@ -70,6 +70,7 @@ export function HomePageEditorCollectionAction({
|
|
|
70
70
|
|
|
71
71
|
{permissions.editCollections &&
|
|
72
72
|
<IconButton
|
|
73
|
+
size={"small"}
|
|
73
74
|
onClick={(event) => {
|
|
74
75
|
onEditCollectionClicked();
|
|
75
76
|
}}>
|
|
@@ -117,6 +117,7 @@ export function CollectionDetailsForm({
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
const showErrors = submitCount > 0;
|
|
120
|
+
|
|
120
121
|
return (
|
|
121
122
|
<div className={"overflow-auto my-auto"}>
|
|
122
123
|
<Container maxWidth={"4xl"} className={"flex flex-col gap-4 p-8 m-auto"}>
|
|
@@ -194,6 +195,7 @@ export function CollectionDetailsForm({
|
|
|
194
195
|
{groupOptions?.map((group, index) => {
|
|
195
196
|
return <AutocompleteItem
|
|
196
197
|
key={index + "_" + group}
|
|
198
|
+
className={"pr-6 pl-14"}
|
|
197
199
|
onClick={() => {
|
|
198
200
|
setAutoCompleteOpen(false);
|
|
199
201
|
setFieldValue("group", group ?? null);
|
|
@@ -217,6 +219,25 @@ export function CollectionDetailsForm({
|
|
|
217
219
|
value={values.openEntityMode ?? "side_panel"}
|
|
218
220
|
onChange={(value) => setFieldValue("openEntityMode", value)}/>
|
|
219
221
|
|
|
222
|
+
<div className={"col-span-12"}>
|
|
223
|
+
<BooleanSwitchWithLabel
|
|
224
|
+
position={"start"}
|
|
225
|
+
size={"large"}
|
|
226
|
+
allowIndeterminate={true}
|
|
227
|
+
label={values.history === null || values.history === undefined ? "Document history revisions enabled if enabled globally" : (
|
|
228
|
+
values.history ? "Document history revisions ENABLED" : "Document history revisions NOT enabled"
|
|
229
|
+
)}
|
|
230
|
+
onValueChange={(v) => setFieldValue("history", v)}
|
|
231
|
+
value={values.history === undefined ? null : values.history}
|
|
232
|
+
/>
|
|
233
|
+
<FieldCaption>
|
|
234
|
+
When enabled, each document in this collection will have a history of changes.
|
|
235
|
+
This is useful for auditing purposes. The data is stored in a subcollection of the document
|
|
236
|
+
in your database, called <b>__history</b>.
|
|
237
|
+
</FieldCaption>
|
|
238
|
+
</div>
|
|
239
|
+
|
|
240
|
+
|
|
220
241
|
<div className={"col-span-12 mt-8"}>
|
|
221
242
|
<ExpandablePanel
|
|
222
243
|
expanded={advancedPanelExpanded}
|
|
@@ -294,7 +315,7 @@ export function CollectionDetailsForm({
|
|
|
294
315
|
value={values.description ?? ""}
|
|
295
316
|
onChange={handleChange}
|
|
296
317
|
multiline
|
|
297
|
-
|
|
318
|
+
minRows={2}
|
|
298
319
|
aria-describedby="description-helper-text"
|
|
299
320
|
label="Description"
|
|
300
321
|
/>
|
|
@@ -323,6 +344,20 @@ export function CollectionDetailsForm({
|
|
|
323
344
|
))}
|
|
324
345
|
</Select>
|
|
325
346
|
</div>
|
|
347
|
+
|
|
348
|
+
<div className={"col-span-12"}>
|
|
349
|
+
<BooleanSwitchWithLabel
|
|
350
|
+
position={"start"}
|
|
351
|
+
size={"large"}
|
|
352
|
+
label={values.includeJsonView === undefined || values.includeJsonView ? "Include JSON view" : "Do not include JSON view"}
|
|
353
|
+
onValueChange={(v) => setFieldValue("includeJsonView", v)}
|
|
354
|
+
value={values.includeJsonView === undefined ? true : values.includeJsonView}
|
|
355
|
+
/>
|
|
356
|
+
<FieldCaption>
|
|
357
|
+
Include the JSON representation of the document.
|
|
358
|
+
</FieldCaption>
|
|
359
|
+
</div>
|
|
360
|
+
|
|
326
361
|
<div className={"col-span-12"}>
|
|
327
362
|
<Select
|
|
328
363
|
name="customId"
|
|
@@ -334,12 +369,7 @@ export function CollectionDetailsForm({
|
|
|
334
369
|
onValueChange={(v) => {
|
|
335
370
|
if (v === "code_defined")
|
|
336
371
|
throw new Error("This should not happen");
|
|
337
|
-
|
|
338
|
-
setFieldValue("customId", true);
|
|
339
|
-
else if (v === "false")
|
|
340
|
-
setFieldValue("customId", false);
|
|
341
|
-
else if (v === "optional")
|
|
342
|
-
setFieldValue("customId", "optional");
|
|
372
|
+
setFieldValue("customId", v);
|
|
343
373
|
}}
|
|
344
374
|
value={customIdValue ?? ""}
|
|
345
375
|
renderValue={(value: any) => {
|
|
@@ -364,9 +394,10 @@ export function CollectionDetailsForm({
|
|
|
364
394
|
</SelectItem>
|
|
365
395
|
</Select>
|
|
366
396
|
</div>
|
|
367
|
-
<div className={"col-span-12"}>
|
|
397
|
+
<div className={"col-span-12 mt-4"}>
|
|
368
398
|
<BooleanSwitchWithLabel
|
|
369
399
|
position={"start"}
|
|
400
|
+
size={"large"}
|
|
370
401
|
label="Collection group"
|
|
371
402
|
onValueChange={(v) => setFieldValue("collectionGroup", v)}
|
|
372
403
|
value={values.collectionGroup ?? false}
|
|
@@ -380,6 +411,7 @@ export function CollectionDetailsForm({
|
|
|
380
411
|
<div className={"col-span-12"}>
|
|
381
412
|
<BooleanSwitchWithLabel
|
|
382
413
|
position={"start"}
|
|
414
|
+
size={"large"}
|
|
383
415
|
label="Enable text search for this collection"
|
|
384
416
|
onValueChange={(v) => setFieldValue("textSearchEnabled", v)}
|
|
385
417
|
value={values.textSearchEnabled ?? false}
|
|
@@ -638,7 +638,7 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
638
638
|
The changes done in this editor will override the properties defined in code.
|
|
639
639
|
You can delete the overridden values to revert to the state defined in code.
|
|
640
640
|
</Typography>
|
|
641
|
-
<Button
|
|
641
|
+
<Button color={"neutral"}
|
|
642
642
|
onClick={() => {
|
|
643
643
|
setDeleteRequested(true);
|
|
644
644
|
}}>Reset to code</Button>
|
|
@@ -37,18 +37,6 @@ export function CollectionEditorWelcomeView({
|
|
|
37
37
|
}
|
|
38
38
|
}, [existingCollectionPaths, path, pathSuggestions]);
|
|
39
39
|
|
|
40
|
-
// const {
|
|
41
|
-
// values,
|
|
42
|
-
// setFieldValue,
|
|
43
|
-
// setValues,
|
|
44
|
-
// handleChange,
|
|
45
|
-
// touched,
|
|
46
|
-
// errors,
|
|
47
|
-
// setFieldTouched,
|
|
48
|
-
// isSubmitting,
|
|
49
|
-
// submitCount
|
|
50
|
-
// } = useFormex<EntityCollection>();
|
|
51
|
-
|
|
52
40
|
const {
|
|
53
41
|
values,
|
|
54
42
|
setFieldValue,
|
|
@@ -56,6 +44,11 @@ export function CollectionEditorWelcomeView({
|
|
|
56
44
|
submitCount
|
|
57
45
|
} = useFormex<EntityCollection>();
|
|
58
46
|
|
|
47
|
+
const noSuggestions = !loadingPathSuggestions && (filteredPathSuggestions ?? [])?.length === 0;
|
|
48
|
+
if (!noSuggestions) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
59
52
|
return (
|
|
60
53
|
<div className={"overflow-auto my-auto"}>
|
|
61
54
|
<Container maxWidth={"4xl"} className={"flex flex-col gap-4 p-8 m-auto"}>
|
|
@@ -97,12 +90,6 @@ export function CollectionEditorWelcomeView({
|
|
|
97
90
|
</Chip>
|
|
98
91
|
))}
|
|
99
92
|
|
|
100
|
-
{!loadingPathSuggestions && (filteredPathSuggestions ?? [])?.length === 0 &&
|
|
101
|
-
<Typography variant={"caption"}>
|
|
102
|
-
No suggestions
|
|
103
|
-
</Typography>
|
|
104
|
-
}
|
|
105
|
-
|
|
106
93
|
</div>
|
|
107
94
|
|
|
108
95
|
</div>
|
|
@@ -202,9 +189,6 @@ export function TemplateButton({
|
|
|
202
189
|
<Typography variant={"subtitle1"}>
|
|
203
190
|
{title}
|
|
204
191
|
</Typography>
|
|
205
|
-
{/*<Typography>*/}
|
|
206
|
-
{/* {subtitle}*/}
|
|
207
|
-
{/*</Typography>*/}
|
|
208
192
|
|
|
209
193
|
</div>
|
|
210
194
|
</Card>
|
|
@@ -310,8 +310,9 @@ export function CollectionPropertiesEditorForm({
|
|
|
310
310
|
};
|
|
311
311
|
|
|
312
312
|
const body = (
|
|
313
|
-
<div className={"grid grid-cols-12 gap-2 h-full bg-
|
|
313
|
+
<div className={"grid grid-cols-12 gap-2 h-full bg-white dark:bg-surface-950"}>
|
|
314
314
|
<div className={cls(
|
|
315
|
+
"bg-surface-50 dark:bg-surface-900",
|
|
315
316
|
"p-4 md:p-8 pb-20 md:pb-20",
|
|
316
317
|
"col-span-12 lg:col-span-5 h-full overflow-auto",
|
|
317
318
|
!asDialog && "border-r " + defaultBorderMixin
|
|
@@ -401,8 +402,8 @@ export function CollectionPropertiesEditorForm({
|
|
|
401
402
|
|
|
402
403
|
{!asDialog &&
|
|
403
404
|
<div className={"col-span-12 lg:col-span-7 p-4 md:py-8 md:px-4 h-full overflow-auto pb-20 md:pb-20"}>
|
|
404
|
-
<
|
|
405
|
-
className="sticky top-8
|
|
405
|
+
<div
|
|
406
|
+
className="sticky top-8 min-h-full w-full flex flex-col justify-center">
|
|
406
407
|
|
|
407
408
|
{selectedPropertyFullId &&
|
|
408
409
|
selectedProperty &&
|
|
@@ -446,7 +447,7 @@ export function CollectionPropertiesEditorForm({
|
|
|
446
447
|
<Typography variant={"label"} className="flex items-center justify-center">
|
|
447
448
|
{"This property is defined as a property builder in code"}
|
|
448
449
|
</Typography>}
|
|
449
|
-
</
|
|
450
|
+
</div>
|
|
450
451
|
</div>}
|
|
451
452
|
|
|
452
453
|
{asDialog && <PropertyFormDialog
|
|
@@ -197,7 +197,7 @@ function EnumFormFields({
|
|
|
197
197
|
size={"small"}
|
|
198
198
|
buildEntry={buildEntry}
|
|
199
199
|
onInternalIdAdded={setLastInternalIdAdded}
|
|
200
|
-
|
|
200
|
+
canAddElements={true}
|
|
201
201
|
onValueChange={(value) => setFieldValue(enumValuesPath, value)}
|
|
202
202
|
newDefaultEntry={{ id: "", label: "" }}/>
|
|
203
203
|
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
DEFAULT_FIELD_CONFIGS,
|
|
8
8
|
getFieldConfig,
|
|
9
9
|
getFieldId,
|
|
10
|
-
isEmptyObject,
|
|
11
10
|
isPropertyBuilder,
|
|
12
11
|
isValidRegExp,
|
|
13
12
|
mergeDeep,
|
|
@@ -384,7 +383,7 @@ function PropertyEditFormFields({
|
|
|
384
383
|
}, [deferredValues, includeIdAndTitle, propertyNamespace]);
|
|
385
384
|
|
|
386
385
|
useEffect(() => {
|
|
387
|
-
if (values?.id && onError
|
|
386
|
+
if (values?.id && onError) {
|
|
388
387
|
onError(values?.id, propertyNamespace, errors);
|
|
389
388
|
}
|
|
390
389
|
}, [errors, propertyNamespace, values?.id]);
|