@firecms/collection_editor 3.0.0-canary.13 → 3.0.0-canary.131
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/dist/ConfigControllerProvider.d.ts +11 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +4715 -3491
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +6685 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/types/collection_editor_controller.d.ts +14 -2
- package/dist/types/collection_inference.d.ts +1 -1
- package/dist/ui/CollectionViewHeaderAction.d.ts +3 -2
- package/dist/ui/EditorCollectionActionStart.d.ts +2 -0
- package/dist/ui/PropertyAddColumnComponent.d.ts +3 -1
- package/dist/ui/collection_editor/CollectionEditorDialog.d.ts +4 -3
- package/dist/ui/collection_editor/CollectionEditorWelcomeView.d.ts +1 -1
- package/dist/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +1 -1
- package/dist/ui/collection_editor/PropertyTree.d.ts +9 -9
- package/dist/ui/collection_editor/SubcollectionsEditTab.d.ts +1 -1
- package/dist/ui/collection_editor/properties/MarkdownPropertyField.d.ts +4 -0
- package/dist/ui/collection_editor/properties/StringPropertyField.d.ts +1 -1
- package/dist/useCollectionEditorPlugin.d.ts +15 -9
- package/dist/utils/collections.d.ts +6 -0
- package/package.json +20 -34
- package/src/ConfigControllerProvider.tsx +75 -63
- package/src/index.ts +1 -0
- package/src/types/collection_editor_controller.tsx +14 -4
- package/src/types/collection_inference.ts +1 -1
- package/src/ui/CollectionViewHeaderAction.tsx +9 -4
- package/src/ui/EditorCollectionAction.tsx +10 -63
- package/src/ui/EditorCollectionActionStart.tsx +88 -0
- package/src/ui/HomePageEditorCollectionAction.tsx +18 -13
- package/src/ui/NewCollectionButton.tsx +12 -10
- package/src/ui/NewCollectionCard.tsx +3 -3
- package/src/ui/PropertyAddColumnComponent.tsx +9 -4
- package/src/ui/collection_editor/CollectionDetailsForm.tsx +69 -8
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +57 -32
- package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +6 -5
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +33 -27
- package/src/ui/collection_editor/GetCodeDialog.tsx +15 -3
- package/src/ui/collection_editor/PropertyEditView.tsx +21 -13
- package/src/ui/collection_editor/PropertyFieldPreview.tsx +3 -6
- package/src/ui/collection_editor/PropertySelectItem.tsx +3 -3
- package/src/ui/collection_editor/PropertyTree.tsx +7 -5
- package/src/ui/collection_editor/SubcollectionsEditTab.tsx +26 -19
- package/src/ui/collection_editor/import/CollectionEditorImportDataPreview.tsx +25 -9
- package/src/ui/collection_editor/import/CollectionEditorImportMapping.tsx +9 -7
- package/src/ui/collection_editor/properties/BlockPropertyField.tsx +14 -8
- package/src/ui/collection_editor/properties/DateTimePropertyField.tsx +50 -47
- package/src/ui/collection_editor/properties/EnumPropertyField.tsx +1 -1
- package/src/ui/collection_editor/properties/MapPropertyField.tsx +5 -5
- package/src/ui/collection_editor/properties/MarkdownPropertyField.tsx +139 -0
- package/src/ui/collection_editor/properties/RepeatPropertyField.tsx +0 -1
- package/src/ui/collection_editor/properties/StoragePropertyField.tsx +31 -16
- package/src/ui/collection_editor/properties/StringPropertyField.tsx +1 -10
- package/src/ui/collection_editor/templates/pages_template.ts +1 -6
- package/src/useCollectionEditorPlugin.tsx +37 -27
- package/src/utils/collections.ts +30 -0
- package/dist/ui/RootCollectionSuggestions.d.ts +0 -3
- package/src/ui/RootCollectionSuggestions.tsx +0 -63
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import {
|
|
3
3
|
Button,
|
|
4
|
-
Checkbox,
|
|
5
4
|
DebouncedTextField,
|
|
6
5
|
ExpandablePanel,
|
|
7
6
|
FileUploadIcon,
|
|
@@ -44,11 +43,13 @@ export function StoragePropertyField({
|
|
|
44
43
|
|
|
45
44
|
const metadata = `${baseStoragePath}.metadata`;
|
|
46
45
|
const fileName = `${baseStoragePath}.fileName`;
|
|
46
|
+
const maxSize = `${baseStoragePath}.maxSize`;
|
|
47
47
|
const storagePath = `${baseStoragePath}.storagePath`;
|
|
48
48
|
const storeUrl = `${baseStoragePath}.storeUrl`;
|
|
49
49
|
|
|
50
50
|
const fileNameValue = getIn(values, fileName) ?? "{rand}_{file}";
|
|
51
51
|
const storagePathValue = getIn(values, storagePath) ?? "/";
|
|
52
|
+
const maxSizeValue = getIn(values, maxSize);
|
|
52
53
|
|
|
53
54
|
const storedValue = getIn(values, acceptedFiles);
|
|
54
55
|
const fileTypesValue: string[] | undefined = Array.isArray(storedValue) ? storedValue : undefined;
|
|
@@ -56,10 +57,10 @@ export function StoragePropertyField({
|
|
|
56
57
|
|
|
57
58
|
const handleTypesChange = (value: string[]) => {
|
|
58
59
|
if (!value) setFieldValue(acceptedFiles, undefined);
|
|
59
|
-
else if (value.includes("all")) setFieldValue(acceptedFiles, undefined);
|
|
60
|
-
else if (value.length >= Object.keys(fileTypes).length) setFieldValue(acceptedFiles, undefined);
|
|
61
|
-
else if (allFileTypesSelected)
|
|
62
|
-
|
|
60
|
+
// else if (value.includes("all")) setFieldValue(acceptedFiles, undefined);
|
|
61
|
+
// else if (value.length >= Object.keys(fileTypes).length) setFieldValue(acceptedFiles, undefined);
|
|
62
|
+
// else if (allFileTypesSelected)
|
|
63
|
+
// setFieldValue(acceptedFiles, Object.keys(fileTypes).filter((v) => !value.includes(v)));
|
|
63
64
|
else setFieldValue(acceptedFiles, value);
|
|
64
65
|
};
|
|
65
66
|
|
|
@@ -87,10 +88,12 @@ export function StoragePropertyField({
|
|
|
87
88
|
<div className={"col-span-12"}>
|
|
88
89
|
|
|
89
90
|
<MultiSelect
|
|
91
|
+
className={"w-full"}
|
|
92
|
+
placeholder={"All file types allowed"}
|
|
90
93
|
disabled={disabled}
|
|
91
94
|
name={acceptedFiles}
|
|
92
95
|
value={fileTypesValue ?? []}
|
|
93
|
-
|
|
96
|
+
onValueChange={handleTypesChange}
|
|
94
97
|
label={allFileTypesSelected ? undefined : "Allowed file types"}
|
|
95
98
|
renderValues={(selected) => {
|
|
96
99
|
if (!selected || selected.length === 0) return "All file types allowed";
|
|
@@ -99,21 +102,15 @@ export function StoragePropertyField({
|
|
|
99
102
|
.join(", ");
|
|
100
103
|
}}>
|
|
101
104
|
|
|
102
|
-
<MultiSelectItem key={"all"} value={"all"} className={"flex items-center gap-2"}>
|
|
103
|
-
<Checkbox
|
|
104
|
-
checked={!fileTypesValue}/>
|
|
105
|
-
All
|
|
106
|
-
</MultiSelectItem>
|
|
107
|
-
|
|
108
105
|
{Object.entries(fileTypes).map(([value, label]) => (
|
|
109
106
|
<MultiSelectItem key={value} value={value} className={"flex items-center gap-2"}>
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
{/*<Checkbox*/}
|
|
108
|
+
{/* checked={allFileTypesSelected || fileTypesValue.indexOf(value) > -1}/>*/}
|
|
112
109
|
<div className={"flex-grow"}>
|
|
113
110
|
{label}
|
|
114
111
|
</div>
|
|
115
112
|
<Button size={"small"}
|
|
116
|
-
variant={"
|
|
113
|
+
variant={"text"}
|
|
117
114
|
onClick={(e) => {
|
|
118
115
|
e.preventDefault();
|
|
119
116
|
e.stopPropagation();
|
|
@@ -161,7 +158,10 @@ export function StoragePropertyField({
|
|
|
161
158
|
|
|
162
159
|
<Field name={storeUrl}
|
|
163
160
|
type="checkbox">
|
|
164
|
-
{({
|
|
161
|
+
{({
|
|
162
|
+
field,
|
|
163
|
+
form
|
|
164
|
+
}: FormexFieldProps) => {
|
|
165
165
|
return <SwitchControl
|
|
166
166
|
label={"Save URL instead of storage path"}
|
|
167
167
|
disabled={existing || disabled}
|
|
@@ -178,6 +178,21 @@ export function StoragePropertyField({
|
|
|
178
178
|
You can only change this prop upon creation.
|
|
179
179
|
</Typography>
|
|
180
180
|
</div>
|
|
181
|
+
|
|
182
|
+
<div className={"col-span-12"}>
|
|
183
|
+
<DebouncedTextField name={maxSize}
|
|
184
|
+
type={"number"}
|
|
185
|
+
label={"Max size (in bytes)"}
|
|
186
|
+
size={"small"}
|
|
187
|
+
value={maxSizeValue !== undefined && maxSizeValue !== null ? maxSizeValue.toString() : ""}
|
|
188
|
+
onChange={(e) => {
|
|
189
|
+
const value = e.target.value;
|
|
190
|
+
if (value === "") setFieldValue(maxSize, undefined);
|
|
191
|
+
else setFieldValue(maxSize, parseInt(value));
|
|
192
|
+
}}
|
|
193
|
+
/>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
181
196
|
</div>
|
|
182
197
|
</ExpandablePanel>
|
|
183
198
|
|
|
@@ -10,7 +10,7 @@ export function StringPropertyField({
|
|
|
10
10
|
disabled,
|
|
11
11
|
showErrors
|
|
12
12
|
}: {
|
|
13
|
-
widgetId: "text_field" | "multiline" | "
|
|
13
|
+
widgetId: "text_field" | "multiline" | "email";
|
|
14
14
|
disabled: boolean;
|
|
15
15
|
showErrors: boolean;
|
|
16
16
|
}) {
|
|
@@ -42,15 +42,6 @@ export function StringPropertyField({
|
|
|
42
42
|
trim={true}
|
|
43
43
|
uppercase={true}
|
|
44
44
|
showErrors={showErrors}/>}
|
|
45
|
-
{widgetId === "markdown" &&
|
|
46
|
-
<StringPropertyValidation disabled={disabled}
|
|
47
|
-
length={true}
|
|
48
|
-
lowercase={true}
|
|
49
|
-
max={true}
|
|
50
|
-
min={true}
|
|
51
|
-
trim={true}
|
|
52
|
-
uppercase={true}
|
|
53
|
-
showErrors={showErrors}/>}
|
|
54
45
|
|
|
55
46
|
{widgetId === "email" &&
|
|
56
47
|
<StringPropertyValidation disabled={disabled}
|
|
@@ -19,7 +19,7 @@ export const pagesCollectionTemplate: EntityCollection = {
|
|
|
19
19
|
validation: {
|
|
20
20
|
required: true,
|
|
21
21
|
unique: true,
|
|
22
|
-
matches:
|
|
22
|
+
matches: "^[a-z0-9]+(?:-[a-z0-9]+)*$",
|
|
23
23
|
matchesMessage: "Must be lowercase, alphanumeric, and hyphenated"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
@@ -178,11 +178,6 @@ export const pagesCollectionTemplate: EntityCollection = {
|
|
|
178
178
|
name: "Is Published",
|
|
179
179
|
columnWidth: 100,
|
|
180
180
|
description: "Should this page be live on the site?"
|
|
181
|
-
},
|
|
182
|
-
author_uid: {
|
|
183
|
-
dataType: "reference",
|
|
184
|
-
name: "Author",
|
|
185
|
-
path: "users"
|
|
186
181
|
}
|
|
187
182
|
}
|
|
188
183
|
};
|
|
@@ -4,16 +4,16 @@ import { ConfigControllerProvider } from "./ConfigControllerProvider";
|
|
|
4
4
|
import { CollectionEditorPermissionsBuilder } from "./types/config_permissions";
|
|
5
5
|
import { EditorCollectionAction } from "./ui/EditorCollectionAction";
|
|
6
6
|
import { HomePageEditorCollectionAction } from "./ui/HomePageEditorCollectionAction";
|
|
7
|
-
import { NewCollectionCard } from "./ui/NewCollectionCard";
|
|
8
7
|
import { PersistedCollection } from "./types/persisted_collection";
|
|
9
8
|
import { CollectionInference } from "./types/collection_inference";
|
|
10
9
|
import { CollectionsConfigController } from "./types/config_controller";
|
|
11
|
-
import { RootCollectionSuggestions } from "./ui/RootCollectionSuggestions";
|
|
12
10
|
import { CollectionViewHeaderAction } from "./ui/CollectionViewHeaderAction";
|
|
13
11
|
import { PropertyAddColumnComponent } from "./ui/PropertyAddColumnComponent";
|
|
14
12
|
import { NewCollectionButton } from "./ui/NewCollectionButton";
|
|
15
|
-
import { AddIcon, Button, Typography } from "@firecms/ui";
|
|
13
|
+
import { AddIcon, Button, Paper, Typography } from "@firecms/ui";
|
|
16
14
|
import { useCollectionEditorController } from "./useCollectionEditorController";
|
|
15
|
+
import { EditorCollectionActionStart } from "./ui/EditorCollectionActionStart";
|
|
16
|
+
import { NewCollectionCard } from "./ui/NewCollectionCard";
|
|
17
17
|
|
|
18
18
|
export interface CollectionConfigControllerProps<EC extends PersistedCollection = PersistedCollection, UserType extends User = User> {
|
|
19
19
|
|
|
@@ -32,7 +32,7 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
|
|
|
32
32
|
* names when creating collections.
|
|
33
33
|
* e.g. ["admin"]
|
|
34
34
|
*/
|
|
35
|
-
reservedGroups
|
|
35
|
+
reservedGroups?: string[];
|
|
36
36
|
|
|
37
37
|
extraView?: {
|
|
38
38
|
View: React.ComponentType<{
|
|
@@ -41,17 +41,22 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
|
|
|
41
41
|
icon: React.ReactNode
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
getPathSuggestions?: (path?: string) => Promise<string[]>;
|
|
45
45
|
|
|
46
46
|
collectionInference?: CollectionInference;
|
|
47
47
|
|
|
48
48
|
getData?: (path: string, parentPaths: string[]) => Promise<object[]>;
|
|
49
49
|
|
|
50
|
-
getUser
|
|
50
|
+
getUser?: (uid: string) => UserType | null;
|
|
51
51
|
|
|
52
52
|
onAnalyticsEvent?: (event: string, params?: object) => void;
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
components?: {
|
|
55
|
+
/**
|
|
56
|
+
* Custom component to render the database field
|
|
57
|
+
*/
|
|
58
|
+
DatabaseField?: React.ComponentType<{ databaseId?: string, onDatabaseIdUpdate: (databaseId:string) => void }>;
|
|
59
|
+
};
|
|
55
60
|
|
|
56
61
|
}
|
|
57
62
|
|
|
@@ -62,22 +67,22 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
|
|
|
62
67
|
* @param configPermissions
|
|
63
68
|
* @param reservedGroups
|
|
64
69
|
* @param extraView
|
|
65
|
-
* @param
|
|
70
|
+
* @param getData
|
|
66
71
|
* @param getUser
|
|
67
72
|
* @param collectionInference
|
|
68
73
|
*/
|
|
69
74
|
export function useCollectionEditorPlugin<EC extends PersistedCollection = PersistedCollection, UserType extends User = User>
|
|
70
75
|
({
|
|
71
76
|
collectionConfigController,
|
|
72
|
-
introMode,
|
|
73
77
|
configPermissions,
|
|
74
78
|
reservedGroups,
|
|
75
79
|
extraView,
|
|
76
|
-
|
|
80
|
+
getPathSuggestions,
|
|
77
81
|
getUser,
|
|
78
82
|
collectionInference,
|
|
79
83
|
getData,
|
|
80
|
-
onAnalyticsEvent
|
|
84
|
+
onAnalyticsEvent,
|
|
85
|
+
components
|
|
81
86
|
}: CollectionConfigControllerProps<EC, UserType>): FireCMSPlugin<any, any, PersistedCollection> {
|
|
82
87
|
|
|
83
88
|
return {
|
|
@@ -91,20 +96,22 @@ export function useCollectionEditorPlugin<EC extends PersistedCollection = Persi
|
|
|
91
96
|
collectionInference,
|
|
92
97
|
reservedGroups,
|
|
93
98
|
extraView,
|
|
94
|
-
|
|
99
|
+
getPathSuggestions,
|
|
95
100
|
getUser,
|
|
96
101
|
getData,
|
|
97
|
-
onAnalyticsEvent
|
|
102
|
+
onAnalyticsEvent,
|
|
103
|
+
components
|
|
98
104
|
}
|
|
99
105
|
},
|
|
100
106
|
homePage: {
|
|
101
107
|
additionalActions: <NewCollectionButton/>,
|
|
102
|
-
additionalChildrenStart:
|
|
103
|
-
additionalChildrenEnd: <RootCollectionSuggestions introMode={introMode}/>,
|
|
108
|
+
additionalChildrenStart: <IntroWidget/>,
|
|
109
|
+
// additionalChildrenEnd: <RootCollectionSuggestions introMode={introMode}/>,
|
|
104
110
|
CollectionActions: HomePageEditorCollectionAction,
|
|
105
|
-
AdditionalCards:
|
|
111
|
+
AdditionalCards: NewCollectionCard,
|
|
106
112
|
},
|
|
107
113
|
collectionView: {
|
|
114
|
+
CollectionActionsStart: EditorCollectionActionStart,
|
|
108
115
|
CollectionActions: EditorCollectionAction,
|
|
109
116
|
HeaderAction: CollectionViewHeaderAction,
|
|
110
117
|
AddColumnComponent: PropertyAddColumnComponent
|
|
@@ -112,9 +119,7 @@ export function useCollectionEditorPlugin<EC extends PersistedCollection = Persi
|
|
|
112
119
|
};
|
|
113
120
|
}
|
|
114
121
|
|
|
115
|
-
export function IntroWidget({
|
|
116
|
-
introMode?: "new_project" | "existing_project";
|
|
117
|
-
}) {
|
|
122
|
+
export function IntroWidget({}: {}) {
|
|
118
123
|
|
|
119
124
|
const navigation = useNavigationController();
|
|
120
125
|
if (!navigation.topLevelNavigation)
|
|
@@ -129,17 +134,19 @@ export function IntroWidget({ introMode }: {
|
|
|
129
134
|
}).createCollections
|
|
130
135
|
: true;
|
|
131
136
|
|
|
137
|
+
if (!navigation.initialised || (navigation.collections ?? []).length > 0) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
|
|
132
141
|
return (
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
<Typography
|
|
136
|
-
<Typography
|
|
142
|
+
<Paper
|
|
143
|
+
className={"my-4 px-4 py-6 flex flex-col bg-white dark:bg-slate-800 gap-2"}>
|
|
144
|
+
<Typography variant={"subtitle2"} className={"uppercase"}>No collections found</Typography>
|
|
145
|
+
<Typography>
|
|
137
146
|
Start building collections in FireCMS easily. Map them to your existing
|
|
138
|
-
database data, import from files, or use our templates.
|
|
139
|
-
now.
|
|
147
|
+
database data, import from files, or use our templates.
|
|
140
148
|
</Typography>
|
|
141
149
|
{canCreateCollections && <Button
|
|
142
|
-
className={"mt-4"}
|
|
143
150
|
onClick={collectionEditorController && canCreateCollections
|
|
144
151
|
? () => collectionEditorController.createCollection({
|
|
145
152
|
parentCollectionIds: [],
|
|
@@ -149,6 +156,9 @@ export function IntroWidget({ introMode }: {
|
|
|
149
156
|
: undefined}>
|
|
150
157
|
<AddIcon/>Create your first collection
|
|
151
158
|
</Button>}
|
|
152
|
-
|
|
159
|
+
<Typography color={"secondary"}>
|
|
160
|
+
You can also define collections programmatically.
|
|
161
|
+
</Typography>
|
|
162
|
+
</Paper>
|
|
153
163
|
);
|
|
154
164
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
const storedCollections = backendCollections ?? [];
|
|
23
|
+
storedCollections.forEach(markAsEditable);
|
|
24
|
+
|
|
25
|
+
console.debug("Collections specified in code:", baseCollections);
|
|
26
|
+
console.debug("Collections stored in the backend", storedCollections);
|
|
27
|
+
const result = joinCollectionLists(baseCollections, storedCollections, [], modifyCollection);
|
|
28
|
+
console.debug("Collections after joining:", result);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
@@ -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
|
-
}
|