@firecms/collection_editor 3.0.0-canary.29 → 3.0.0-canary.290
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/LICENSE +114 -21
- package/README.md +165 -1
- package/dist/ConfigControllerProvider.d.ts +1 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +11093 -4800
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +11750 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/types/collection_editor_controller.d.ts +3 -2
- package/dist/types/collection_inference.d.ts +4 -1
- package/dist/types/config_controller.d.ts +3 -1
- package/dist/types/config_permissions.d.ts +2 -2
- package/dist/types/persisted_collection.d.ts +1 -1
- package/dist/ui/CollectionViewHeaderAction.d.ts +3 -2
- package/dist/ui/EditorCollectionActionStart.d.ts +2 -0
- package/dist/ui/EditorEntityAction.d.ts +2 -0
- package/dist/ui/PropertyAddColumnComponent.d.ts +3 -1
- package/dist/ui/collection_editor/CollectionDetailsForm.d.ts +3 -1
- package/dist/ui/collection_editor/CollectionEditorDialog.d.ts +3 -2
- package/dist/ui/collection_editor/CollectionEditorWelcomeView.d.ts +2 -2
- package/dist/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +2 -2
- package/dist/ui/collection_editor/EntityActionsEditTab.d.ts +4 -0
- package/dist/ui/collection_editor/EntityActionsSelectDialog.d.ts +4 -0
- package/dist/ui/collection_editor/LayoutModeSwitch.d.ts +5 -0
- package/dist/ui/collection_editor/PropertyEditView.d.ts +8 -0
- package/dist/ui/collection_editor/PropertyTree.d.ts +11 -12
- package/dist/ui/collection_editor/SubcollectionsEditTab.d.ts +1 -1
- package/dist/ui/collection_editor/import/CollectionEditorImportDataPreview.d.ts +1 -1
- package/dist/ui/collection_editor/import/CollectionEditorImportMapping.d.ts +8 -1
- package/dist/ui/collection_editor/import/clean_import_data.d.ts +1 -1
- package/dist/ui/collection_editor/properties/MarkdownPropertyField.d.ts +4 -0
- package/dist/ui/collection_editor/properties/ReferencePropertyField.d.ts +2 -1
- package/dist/ui/collection_editor/properties/StringPropertyField.d.ts +1 -1
- package/dist/useCollectionEditorPlugin.d.ts +8 -11
- package/dist/utils/collections.d.ts +6 -0
- package/dist/utils/entities.d.ts +1 -1
- package/package.json +25 -37
- package/src/ConfigControllerProvider.tsx +64 -66
- package/src/index.ts +1 -0
- package/src/types/collection_editor_controller.tsx +6 -5
- package/src/types/collection_inference.ts +4 -1
- package/src/types/config_controller.tsx +4 -1
- package/src/types/config_permissions.ts +1 -1
- package/src/types/persisted_collection.ts +2 -3
- package/src/ui/CollectionViewHeaderAction.tsx +10 -5
- package/src/ui/EditorCollectionAction.tsx +12 -70
- package/src/ui/EditorCollectionActionStart.tsx +87 -0
- package/src/ui/EditorEntityAction.tsx +51 -0
- package/src/ui/HomePageEditorCollectionAction.tsx +21 -14
- package/src/ui/NewCollectionButton.tsx +1 -1
- package/src/ui/NewCollectionCard.tsx +3 -3
- package/src/ui/PropertyAddColumnComponent.tsx +11 -6
- package/src/ui/collection_editor/CollectionDetailsForm.tsx +170 -50
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +119 -39
- package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +24 -33
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +46 -49
- package/src/ui/collection_editor/EntityActionsEditTab.tsx +163 -0
- package/src/ui/collection_editor/EntityActionsSelectDialog.tsx +41 -0
- package/src/ui/collection_editor/EntityCustomViewsSelectDialog.tsx +11 -7
- package/src/ui/collection_editor/EnumForm.tsx +11 -7
- package/src/ui/collection_editor/GetCodeDialog.tsx +60 -28
- package/src/ui/collection_editor/LayoutModeSwitch.tsx +54 -0
- package/src/ui/collection_editor/PropertyEditView.tsx +269 -81
- package/src/ui/collection_editor/PropertyFieldPreview.tsx +12 -14
- package/src/ui/collection_editor/PropertyTree.tsx +184 -138
- package/src/ui/collection_editor/SubcollectionsEditTab.tsx +26 -19
- package/src/ui/collection_editor/UnsavedChangesDialog.tsx +9 -7
- package/src/ui/collection_editor/import/CollectionEditorImportDataPreview.tsx +41 -9
- package/src/ui/collection_editor/import/CollectionEditorImportMapping.tsx +43 -10
- package/src/ui/collection_editor/import/clean_import_data.ts +1 -1
- package/src/ui/collection_editor/properties/BlockPropertyField.tsx +32 -20
- package/src/ui/collection_editor/properties/DateTimePropertyField.tsx +54 -47
- package/src/ui/collection_editor/properties/EnumPropertyField.tsx +3 -1
- package/src/ui/collection_editor/properties/MapPropertyField.tsx +8 -7
- package/src/ui/collection_editor/properties/MarkdownPropertyField.tsx +139 -0
- package/src/ui/collection_editor/properties/ReferencePropertyField.tsx +7 -3
- package/src/ui/collection_editor/properties/RepeatPropertyField.tsx +0 -1
- package/src/ui/collection_editor/properties/StoragePropertyField.tsx +165 -20
- package/src/ui/collection_editor/properties/StringPropertyField.tsx +4 -9
- package/src/ui/collection_editor/properties/UrlPropertyField.tsx +1 -0
- package/src/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.tsx +2 -0
- package/src/ui/collection_editor/properties/validation/ValidationPanel.tsx +3 -3
- package/src/ui/collection_editor/templates/blog_template.ts +1 -4
- package/src/ui/collection_editor/templates/pages_template.ts +1 -6
- package/src/ui/collection_editor/utils/strings.ts +13 -6
- package/src/ui/collection_editor/utils/supported_fields.tsx +2 -0
- package/src/ui/collection_editor/utils/update_property_for_widget.ts +37 -6
- package/src/useCollectionEditorPlugin.tsx +38 -32
- package/src/utils/collections.ts +45 -0
- package/src/utils/entities.ts +6 -9
- package/dist/ui/RootCollectionSuggestions.d.ts +0 -3
- package/dist/ui/collection_editor/PropertySelectItem.d.ts +0 -8
- package/src/ui/RootCollectionSuggestions.tsx +0 -63
- package/src/ui/collection_editor/PropertySelectItem.tsx +0 -32
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EntityCollection,
|
|
3
|
+
joinCollectionLists,
|
|
4
|
+
makePropertiesEditable,
|
|
5
|
+
ModifyCollectionProps,
|
|
6
|
+
Properties
|
|
7
|
+
} from "@firecms/core";
|
|
8
|
+
import { PersistedCollection } from "../types/persisted_collection";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Function in charge of merging collections defined in code with those stored in the backend.
|
|
12
|
+
*/
|
|
13
|
+
export const mergeCollections = (baseCollections: EntityCollection[],
|
|
14
|
+
backendCollections: PersistedCollection[] = [],
|
|
15
|
+
modifyCollection?: (props: ModifyCollectionProps) => EntityCollection | void
|
|
16
|
+
) => {
|
|
17
|
+
|
|
18
|
+
const markAsEditable = (c: PersistedCollection) => {
|
|
19
|
+
makePropertiesEditable(c.properties as Properties);
|
|
20
|
+
c.subcollections?.forEach(markAsEditable);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
backendCollections.forEach(markAsEditable);
|
|
24
|
+
|
|
25
|
+
const result = joinCollectionLists(baseCollections, backendCollections, [], modifyCollection);
|
|
26
|
+
|
|
27
|
+
// sort the collections so they are in the same order as the base collections
|
|
28
|
+
result.sort((a, b) => {
|
|
29
|
+
const indexA = baseCollections.findIndex(c => c.id === a.id);
|
|
30
|
+
const indexB = baseCollections.findIndex(c => c.id === b.id);
|
|
31
|
+
|
|
32
|
+
if (indexA === -1 && indexB === -1) {
|
|
33
|
+
return 0; // Keep original order for items not in baseCollections
|
|
34
|
+
}
|
|
35
|
+
if (indexA === -1) {
|
|
36
|
+
return 1; // a is not in base, so it goes to the end
|
|
37
|
+
}
|
|
38
|
+
if (indexB === -1) {
|
|
39
|
+
return -1; // b is not in base, so it goes to the end
|
|
40
|
+
}
|
|
41
|
+
return indexA - indexB;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return result;
|
|
45
|
+
}
|
package/src/utils/entities.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { isPropertyBuilder, Properties, PropertiesOrBuilders, Property, PropertyOrBuilder } from "@firecms/core";
|
|
2
2
|
|
|
3
|
-
export function editableProperty(property: PropertyOrBuilder
|
|
4
|
-
if (isPropertyBuilder(property))
|
|
3
|
+
export function editableProperty(property: PropertyOrBuilder): boolean {
|
|
4
|
+
if (isPropertyBuilder(property)) {
|
|
5
5
|
return false;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
else {
|
|
9
|
-
const eProperty = property as Property;
|
|
10
|
-
if (eProperty.dataType === "array" && typeof eProperty.of === "function")
|
|
6
|
+
} else {
|
|
7
|
+
if (property.dataType === "array" && typeof property.of === "function")
|
|
11
8
|
return false;
|
|
12
|
-
else if (
|
|
9
|
+
else if (property.dataType === "array" && Array.isArray(property.of))
|
|
13
10
|
return false;
|
|
14
|
-
return Boolean(
|
|
11
|
+
return property.editable === undefined ? true : Boolean(property.editable);
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
14
|
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { PropertyConfig } from "@firecms/core";
|
|
2
|
-
export interface PropertySelectItemProps {
|
|
3
|
-
value: string;
|
|
4
|
-
optionDisabled: boolean;
|
|
5
|
-
propertyConfig: PropertyConfig;
|
|
6
|
-
existing: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare function PropertySelectItem({ value, optionDisabled, propertyConfig, existing }: PropertySelectItemProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { unslugify, useAuthController, useNavigationController } from "@firecms/core";
|
|
2
|
-
import { AddIcon, Chip, CircularProgress, Collapse, Typography, } from "@firecms/ui";
|
|
3
|
-
import { useCollectionEditorController } from "../useCollectionEditorController";
|
|
4
|
-
import React from "react";
|
|
5
|
-
|
|
6
|
-
export function RootCollectionSuggestions({ introMode }: { introMode?: "new_project" | "existing_project" }) {
|
|
7
|
-
|
|
8
|
-
const authController = useAuthController();
|
|
9
|
-
const navigationController = useNavigationController();
|
|
10
|
-
|
|
11
|
-
const collectionEditorController = useCollectionEditorController();
|
|
12
|
-
const canCreateCollections = collectionEditorController.configPermissions
|
|
13
|
-
? collectionEditorController.configPermissions({
|
|
14
|
-
user: authController.user
|
|
15
|
-
}).createCollections
|
|
16
|
-
: true;
|
|
17
|
-
|
|
18
|
-
const rootPathSuggestions = collectionEditorController.rootPathSuggestions;
|
|
19
|
-
|
|
20
|
-
const showSuggestions = (rootPathSuggestions ?? []).length > 3 || ((navigationController.collections ?? []).length === 0 && (rootPathSuggestions ?? []).length > 0);
|
|
21
|
-
const forceShowSuggestions = introMode === "existing_project";
|
|
22
|
-
return <Collapse
|
|
23
|
-
in={forceShowSuggestions || showSuggestions}>
|
|
24
|
-
|
|
25
|
-
<div
|
|
26
|
-
className={"flex flex-col gap-1 p-2 my-4"}>
|
|
27
|
-
|
|
28
|
-
{!introMode && <Typography variant={"body2"} color={"secondary"}>
|
|
29
|
-
Create a collection <b>automatically</b> from your data:
|
|
30
|
-
</Typography>}
|
|
31
|
-
|
|
32
|
-
{introMode === "existing_project" && <Typography>
|
|
33
|
-
You will see your <b>database collections</b> here, a few seconds after project creation
|
|
34
|
-
</Typography>}
|
|
35
|
-
|
|
36
|
-
<div
|
|
37
|
-
className={"flex flex-row gap-1 overflow-scroll no-scrollbar "}>
|
|
38
|
-
{(rootPathSuggestions ?? []).map((path) => {
|
|
39
|
-
return (
|
|
40
|
-
<div key={path}>
|
|
41
|
-
<Chip
|
|
42
|
-
icon={<AddIcon size={"small"}/>}
|
|
43
|
-
colorScheme={"cyanLighter"}
|
|
44
|
-
onClick={collectionEditorController && canCreateCollections
|
|
45
|
-
? () => collectionEditorController.createCollection({
|
|
46
|
-
initialValues: { path, name: unslugify(path) },
|
|
47
|
-
parentCollectionIds: [],
|
|
48
|
-
redirect: true,
|
|
49
|
-
sourceClick: "root_collection_suggestion"
|
|
50
|
-
})
|
|
51
|
-
: undefined}
|
|
52
|
-
size="small">
|
|
53
|
-
{path}
|
|
54
|
-
</Chip>
|
|
55
|
-
</div>
|
|
56
|
-
);
|
|
57
|
-
})}
|
|
58
|
-
{rootPathSuggestions === undefined && <CircularProgress size={"small"}/>}
|
|
59
|
-
{rootPathSuggestions?.length === 0 && <Typography variant={"caption"}>No suggestions</Typography>}
|
|
60
|
-
</div>
|
|
61
|
-
</div>
|
|
62
|
-
</Collapse>
|
|
63
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { PropertyConfigBadge, PropertyConfig } from "@firecms/core";
|
|
2
|
-
import { cn, SelectItem, Typography } from "@firecms/ui";
|
|
3
|
-
|
|
4
|
-
export interface PropertySelectItemProps {
|
|
5
|
-
value: string;
|
|
6
|
-
optionDisabled: boolean;
|
|
7
|
-
propertyConfig: PropertyConfig;
|
|
8
|
-
existing: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function PropertySelectItem({ value, optionDisabled, propertyConfig, existing }: PropertySelectItemProps) {
|
|
12
|
-
return <SelectItem value={value}
|
|
13
|
-
disabled={optionDisabled}
|
|
14
|
-
className={"flex flex-row items-center"}>
|
|
15
|
-
<div
|
|
16
|
-
className={cn(
|
|
17
|
-
"flex flex-row items-center text-base min-h-[52px]",
|
|
18
|
-
optionDisabled ? "w-full" : "")}>
|
|
19
|
-
<div className={"mr-8"}>
|
|
20
|
-
<PropertyConfigBadge propertyConfig={propertyConfig}/>
|
|
21
|
-
</div>
|
|
22
|
-
<div>
|
|
23
|
-
<div>{propertyConfig.name}</div>
|
|
24
|
-
<Typography variant={"caption"}
|
|
25
|
-
color={"disabled"}
|
|
26
|
-
className={"max-w-sm"}>
|
|
27
|
-
{existing && optionDisabled ? "You can only switch to widgets that use the same data type" : propertyConfig.description}
|
|
28
|
-
</Typography>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
</SelectItem>
|
|
32
|
-
}
|