@rebasepro/admin 0.6.1 → 0.7.0
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/{CollectionEditorDialog-HNXGxXdO.js → CollectionEditorDialog-iGgS4rLX.js} +233 -152
- package/dist/CollectionEditorDialog-iGgS4rLX.js.map +1 -0
- package/dist/{PropertyEditView-C2wp8kQ9.js → PropertyEditView-C9yhLyja.js} +129 -15
- package/dist/PropertyEditView-C9yhLyja.js.map +1 -0
- package/dist/{CollectionsStudioView-B1mN33GB.js → RouterCollectionsStudioView-Dqx27GD8.js} +61 -39
- package/dist/RouterCollectionsStudioView-Dqx27GD8.js.map +1 -0
- package/dist/collection_editor/extensibility_types.d.ts +135 -0
- package/dist/collection_editor/index.d.ts +6 -0
- package/dist/collection_editor/serializable_types.d.ts +374 -0
- package/dist/collection_editor/serializable_utils.d.ts +50 -0
- package/dist/collection_editor/ui/collection_editor/CollectionEditorDialog.d.ts +2 -1
- package/dist/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +12 -1
- package/dist/collection_editor/ui/collection_editor/CollectionStudioView.d.ts +13 -1
- package/dist/collection_editor/ui/collection_editor/CollectionsStudioView.d.ts +24 -2
- package/dist/collection_editor/ui/collection_editor/DisplaySettingsForm.d.ts +2 -1
- package/dist/collection_editor/ui/collection_editor/GeneralSettingsForm.d.ts +4 -1
- package/dist/collection_editor/ui/collection_editor/PropertyEditView.d.ts +12 -1
- package/dist/collection_editor/ui/collection_editor/RouterCollectionStudioView.d.ts +15 -0
- package/dist/collection_editor/ui/collection_editor/RouterCollectionsStudioView.d.ts +14 -0
- package/dist/collection_editor/useJsonCollectionsConfigController.d.ts +37 -0
- package/dist/collection_editor/useSafeSnackbarController.d.ts +2 -0
- package/dist/collection_editor_ui.d.ts +4 -0
- package/dist/collection_editor_ui.js +33 -4
- package/dist/collection_editor_ui.js.map +1 -0
- package/dist/components/EntityCollectionView/EntityBoardCard.d.ts +3 -3
- package/dist/components/EntityCollectionView/hooks/useKanbanDragAndDrop.d.ts +3 -3
- package/dist/components/EntityEditView.d.ts +3 -2
- package/dist/components/RebaseCMS.d.ts +1 -1
- package/dist/form/EntityForm.d.ts +10 -9
- package/dist/form/EntityFormBinding.d.ts +27 -0
- package/dist/form/form_utils.d.ts +8 -0
- package/dist/form/index.d.ts +5 -1
- package/dist/{history-BO6VT85a.js → history-ChHgyyvM.js} +2 -2
- package/dist/{history-BO6VT85a.js.map → history-ChHgyyvM.js.map} +1 -1
- package/dist/hooks/navigation/contexts/CollectionRegistryContext.d.ts +1 -1
- package/dist/hooks/navigation/useAsyncResolver.d.ts +26 -0
- package/dist/hooks/navigation/useBuildCollectionRegistryController.d.ts +2 -0
- package/dist/hooks/navigation/useTopLevelNavigation.d.ts +1 -1
- package/dist/hooks/navigation/utils.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -2
- package/dist/routes/CustomViewRoute.d.ts +2 -1
- package/dist/{src-BYniefVu.js → src-DOX2nOyh.js} +1586 -1283
- package/dist/src-DOX2nOyh.js.map +1 -0
- package/dist/types/components/EntityFormActionsProps.d.ts +1 -1
- package/dist/types/components/EntityFormProps.d.ts +59 -0
- package/dist/types/fields.d.ts +6 -1
- package/dist/util/dataControllerAdapter.d.ts +30 -0
- package/dist/util/navigation_utils.d.ts +1 -1
- package/dist/util/propertyConfigMapper.d.ts +17 -0
- package/package.json +18 -18
- package/src/collection_editor/extensibility_types.ts +168 -0
- package/src/collection_editor/index.ts +46 -0
- package/src/collection_editor/serializable_types.ts +487 -0
- package/src/collection_editor/serializable_utils.ts +588 -0
- package/src/collection_editor/ui/collection_editor/AICollectionGeneratorPopover.tsx +4 -4
- package/src/collection_editor/ui/collection_editor/CollectionEditorDialog.tsx +134 -70
- package/src/collection_editor/ui/collection_editor/CollectionPropertiesEditorForm.tsx +95 -78
- package/src/collection_editor/ui/collection_editor/CollectionStudioView.tsx +23 -20
- package/src/collection_editor/ui/collection_editor/CollectionsStudioView.tsx +79 -27
- package/src/collection_editor/ui/collection_editor/DisplaySettingsForm.tsx +9 -7
- package/src/collection_editor/ui/collection_editor/GeneralSettingsForm.tsx +22 -5
- package/src/collection_editor/ui/collection_editor/GetCodeDialog.tsx +3 -3
- package/src/collection_editor/ui/collection_editor/PropertyEditView.tsx +155 -10
- package/src/collection_editor/ui/collection_editor/PropertyFieldPreview.tsx +6 -6
- package/src/collection_editor/ui/collection_editor/PropertyTree.tsx +1 -0
- package/src/collection_editor/ui/collection_editor/RouterCollectionStudioView.tsx +44 -0
- package/src/collection_editor/ui/collection_editor/RouterCollectionsStudioView.tsx +41 -0
- package/src/collection_editor/ui/collection_editor/properties/EnumPropertyField.tsx +4 -3
- package/src/collection_editor/useJsonCollectionsConfigController.tsx +286 -0
- package/src/collection_editor/useSafeSnackbarController.ts +9 -0
- package/src/collection_editor_ui.ts +6 -0
- package/src/components/DefaultDrawer.tsx +13 -3
- package/src/components/DrawerNavigationGroup.tsx +2 -2
- package/src/components/EntityCollectionView/EntityBoardCard.tsx +6 -6
- package/src/components/EntityCollectionView/EntityCollectionBoardView.tsx +12 -11
- package/src/components/EntityCollectionView/EntityCollectionCardView.tsx +40 -190
- package/src/components/EntityCollectionView/EntityCollectionListView.tsx +54 -183
- package/src/components/EntityCollectionView/hooks/useKanbanDragAndDrop.ts +6 -6
- package/src/components/EntityEditView.tsx +5 -4
- package/src/components/EntityEditViewFormActions.tsx +32 -26
- package/src/components/HomePage/ContentHomePage.tsx +13 -4
- package/src/components/RebaseCMS.tsx +3 -2
- package/src/components/RebaseNavigation.tsx +71 -7
- package/src/components/SelectableTable/SelectableTable.tsx +2 -2
- package/src/components/SideDialogs.tsx +0 -7
- package/src/components/common/default_entity_actions.tsx +9 -9
- package/src/contexts/BreacrumbsContext.tsx +15 -6
- package/src/editor/selectors/ai-selector.tsx +0 -1
- package/src/form/EntityForm.tsx +191 -428
- package/src/form/EntityFormActions.tsx +33 -47
- package/src/form/EntityFormBinding.tsx +323 -0
- package/src/form/components/FormLayout.tsx +1 -1
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +7 -2
- package/src/form/form_utils.ts +163 -0
- package/src/form/index.tsx +14 -5
- package/src/hooks/navigation/contexts/CollectionRegistryContext.tsx +2 -2
- package/src/hooks/navigation/contexts/NavigationStateContext.tsx +2 -2
- package/src/hooks/navigation/contexts/UrlContext.tsx +1 -2
- package/src/hooks/navigation/useAsyncResolver.ts +100 -0
- package/src/hooks/navigation/useBuildCollectionRegistryController.tsx +15 -8
- package/src/hooks/navigation/useBuildNavigationStateController.tsx +12 -8
- package/src/hooks/navigation/useNavigationResolution.ts +33 -0
- package/src/hooks/navigation/useResolvedCollections.ts +29 -71
- package/src/hooks/navigation/useResolvedViews.tsx +40 -70
- package/src/hooks/navigation/useTopLevelNavigation.ts +20 -16
- package/src/hooks/navigation/utils.ts +7 -4
- package/src/index.ts +5 -0
- package/src/routes/CustomViewRoute.tsx +14 -6
- package/src/types/components/EntityFormActionsProps.tsx +1 -1
- package/src/types/components/EntityFormProps.tsx +68 -0
- package/src/types/fields.tsx +7 -1
- package/src/util/dataControllerAdapter.ts +93 -0
- package/src/util/navigation_utils.ts +1 -1
- package/src/util/propertyConfigMapper.ts +134 -0
- package/LICENSE +0 -21
- package/dist/CollectionEditorDialog-HNXGxXdO.js.map +0 -1
- package/dist/CollectionsStudioView-B1mN33GB.js.map +0 -1
- package/dist/PropertyEditView-C2wp8kQ9.js.map +0 -1
- package/dist/components/EntityCollectionView/Board.d.ts +0 -3
- package/dist/components/EntityCollectionView/BoardColumn.d.ts +0 -42
- package/dist/components/EntityCollectionView/BoardColumnTitle.d.ts +0 -9
- package/dist/components/EntityCollectionView/BoardSortableList.d.ts +0 -14
- package/dist/components/EntityCollectionView/board_types.d.ts +0 -105
- package/dist/hooks/navigation/useNavigationRegistry.d.ts +0 -12
- package/dist/hooks/navigation/useNavigationURLs.d.ts +0 -11
- package/dist/src-BYniefVu.js.map +0 -1
- package/src/components/EntityCollectionView/Board.tsx +0 -475
- package/src/components/EntityCollectionView/BoardColumn.tsx +0 -165
- package/src/components/EntityCollectionView/BoardColumnTitle.tsx +0 -46
- package/src/components/EntityCollectionView/BoardSortableList.tsx +0 -177
- package/src/components/EntityCollectionView/board_types.ts +0 -113
- package/src/hooks/navigation/useNavigationRegistry.ts +0 -164
- package/src/hooks/navigation/useNavigationURLs.ts +0 -56
|
@@ -4,6 +4,7 @@ import { useNavigationStateController, useCollectionRegistryController, useUrlCo
|
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { useEffect, useRef, useState } from "react";
|
|
6
6
|
import { ConfirmationDialog, ErrorView, useAuthController, useCustomizationController, useSnackbarController } from "@rebasepro/core";
|
|
7
|
+
import { useSafeSnackbarController } from "../../useSafeSnackbarController";
|
|
7
8
|
import { CircularProgressCenter } from "@rebasepro/ui";
|
|
8
9
|
import {
|
|
9
10
|
ArrowLeftIcon,
|
|
@@ -46,8 +47,9 @@ import { CollectionRLSTab } from "./CollectionRLSTab";
|
|
|
46
47
|
import { buildCollectionFromTableMetadata } from "../../pgColumnToProperty";
|
|
47
48
|
import { TableMetadata } from "@rebasepro/types";
|
|
48
49
|
import { mergeDeep, randomString, removeUndefined } from "@rebasepro/utils";
|
|
50
|
+
import type { CollectionEditorExtensionProps, CollectionEditorTab } from "../../extensibility_types";
|
|
49
51
|
|
|
50
|
-
export interface CollectionEditorDialogProps {
|
|
52
|
+
export interface CollectionEditorDialogProps extends CollectionEditorExtensionProps {
|
|
51
53
|
open: boolean;
|
|
52
54
|
isNewCollection: boolean;
|
|
53
55
|
initialValues?: {
|
|
@@ -139,6 +141,7 @@ export function CollectionEditorDialog(props: CollectionEditorDialogProps) {
|
|
|
139
141
|
fullHeight={true}
|
|
140
142
|
scrollable={false}
|
|
141
143
|
maxWidth={"7xl"}
|
|
144
|
+
className="bg-surface-50 dark:bg-surface-800"
|
|
142
145
|
onOpenChange={(open) => !open ? handleCancel() : undefined}
|
|
143
146
|
>
|
|
144
147
|
<DialogTitle hidden>Collection editor</DialogTitle>
|
|
@@ -168,17 +171,23 @@ export function CollectionEditor(props: CollectionEditorDialogProps & {
|
|
|
168
171
|
handleCancel: () => void,
|
|
169
172
|
setFormDirty: (dirty: boolean) => void
|
|
170
173
|
}) {
|
|
171
|
-
const {
|
|
174
|
+
const { standalone } = props;
|
|
175
|
+
|
|
176
|
+
const customizationController = useCustomizationController();
|
|
172
177
|
const navigationState = useNavigationStateController();
|
|
173
178
|
const collectionRegistry = useCollectionRegistryController();
|
|
174
179
|
const authController = useAuthController();
|
|
175
180
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
181
|
+
// In standalone mode, use safe defaults instead of context values
|
|
182
|
+
const propertyConfigs = standalone
|
|
183
|
+
? (customizationController?.propertyConfigs ?? {})
|
|
184
|
+
: customizationController.propertyConfigs;
|
|
185
|
+
const topLevelNavigation = standalone
|
|
186
|
+
? (navigationState?.topLevelNavigation ?? [])
|
|
187
|
+
: navigationState.topLevelNavigation;
|
|
188
|
+
const collections = standalone
|
|
189
|
+
? (collectionRegistry?.collections ?? [])
|
|
190
|
+
: collectionRegistry.collections;
|
|
182
191
|
|
|
183
192
|
const initialValuesProp = props.initialValues;
|
|
184
193
|
const copyFromProp = props.copyFrom;
|
|
@@ -192,7 +201,13 @@ export function CollectionEditor(props: CollectionEditorDialogProps & {
|
|
|
192
201
|
|
|
193
202
|
useEffect(() => {
|
|
194
203
|
try {
|
|
195
|
-
|
|
204
|
+
const initialised = (standalone
|
|
205
|
+
? true
|
|
206
|
+
: (collectionRegistry?.initialised ?? true)) && !props.configController?.loading;
|
|
207
|
+
const getRawCollection = standalone
|
|
208
|
+
? (() => undefined)
|
|
209
|
+
: collectionRegistry.getRawCollection;
|
|
210
|
+
if (initialised) {
|
|
196
211
|
if (props.editedCollectionId) {
|
|
197
212
|
// We must use getRawCollection so the editor schema fields
|
|
198
213
|
// aren't polluted with dynamically injected runtime `relations`.
|
|
@@ -200,7 +215,9 @@ export function CollectionEditor(props: CollectionEditorDialogProps & {
|
|
|
200
215
|
const collectionPath = [...(props.parentCollectionSlugs ?? []), props.editedCollectionId]
|
|
201
216
|
.reduce((acc, segment, i) => i === 0 ? segment : `${acc}/fake_id/${segment}`, "");
|
|
202
217
|
|
|
203
|
-
|
|
218
|
+
const registryCol = getRawCollection ? getRawCollection(collectionPath) : undefined;
|
|
219
|
+
const configCol = props.configController?.collections?.find(c => c.slug === props.editedCollectionId);
|
|
220
|
+
setCollection((registryCol ?? configCol) as EntityCollection<any>);
|
|
204
221
|
} else {
|
|
205
222
|
setCollection(undefined);
|
|
206
223
|
}
|
|
@@ -209,44 +226,51 @@ export function CollectionEditor(props: CollectionEditorDialogProps & {
|
|
|
209
226
|
} catch (e) {
|
|
210
227
|
console.error(e);
|
|
211
228
|
}
|
|
212
|
-
}, [props.editedCollectionId, props.parentCollectionSlugs, props.parentEntityIds, collectionRegistry.initialised, collectionRegistry.getRawCollection]);
|
|
229
|
+
}, [props.editedCollectionId, props.parentCollectionSlugs, props.parentEntityIds, standalone, collectionRegistry.initialised, collectionRegistry.getRawCollection, props.configController.collections, props.configController.loading, collections]);
|
|
213
230
|
|
|
214
231
|
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
232
|
+
const initialIcon = React.useMemo(() => coolIconKeys[Math.floor(Math.random() * coolIconKeys.length)], []);
|
|
233
|
+
const fallbackSlug = React.useMemo(() => randomString(16), []);
|
|
234
|
+
|
|
235
|
+
const initialCollection = React.useMemo(() => {
|
|
236
|
+
return collection
|
|
237
|
+
? {
|
|
238
|
+
...collection,
|
|
239
|
+
slug: collection.slug ?? fallbackSlug
|
|
240
|
+
}
|
|
241
|
+
: undefined;
|
|
242
|
+
}, [collection, fallbackSlug]);
|
|
221
243
|
|
|
222
244
|
// Build initial values - handle copyFrom for duplication
|
|
223
|
-
const initialValues: EntityCollection<any> =
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
245
|
+
const initialValues: EntityCollection<any> = React.useMemo(() => {
|
|
246
|
+
return initialCollection
|
|
247
|
+
? applyPropertyConfigs(initialCollection, propertyConfigs)
|
|
248
|
+
: copyFromProp
|
|
249
|
+
? (() => {
|
|
250
|
+
// When duplicating, copy all properties but clear identifiers
|
|
251
|
+
const { subcollections: _sub, ...rest } = copyFromProp as unknown as Record<string, unknown>;
|
|
252
|
+
return {
|
|
253
|
+
...rest,
|
|
254
|
+
name: "",
|
|
255
|
+
ownerId: authController.user?.uid ?? ""
|
|
256
|
+
} as EntityCollection<any>;
|
|
257
|
+
})()
|
|
258
|
+
: {
|
|
259
|
+
slug: initialValuesProp?.slug ?? fallbackSlug,
|
|
260
|
+
table: initialValuesProp?.slug ?? "",
|
|
261
|
+
name: initialValuesProp?.name ?? "",
|
|
262
|
+
properties: {} as Properties,
|
|
263
|
+
propertiesOrder: [],
|
|
264
|
+
icon: initialIcon,
|
|
232
265
|
ownerId: authController.user?.uid ?? ""
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
: {
|
|
236
|
-
slug: initialValuesProp?.slug ?? randomString(16),
|
|
237
|
-
table: initialValuesProp?.slug ?? "",
|
|
238
|
-
name: initialValuesProp?.name ?? "",
|
|
239
|
-
properties: {} as Properties,
|
|
240
|
-
propertiesOrder: [],
|
|
241
|
-
icon: coolIconKeys[Math.floor(Math.random() * coolIconKeys.length)],
|
|
242
|
-
ownerId: authController.user?.uid ?? ""
|
|
243
|
-
};
|
|
266
|
+
};
|
|
267
|
+
}, [initialCollection, propertyConfigs, copyFromProp, initialValuesProp, fallbackSlug, initialIcon, authController.user?.uid]);
|
|
244
268
|
|
|
245
269
|
if (!initialLoadingCompleted) {
|
|
246
270
|
return <CircularProgressCenter/>;
|
|
247
271
|
}
|
|
248
272
|
|
|
249
|
-
if (!props.isNewCollection && (!collectionRegistry
|
|
273
|
+
if (!props.isNewCollection && (!(standalone ? true : (collectionRegistry?.initialised ?? true)) || !initialLoadingCompleted)) {
|
|
250
274
|
return <CircularProgressCenter/>;
|
|
251
275
|
}
|
|
252
276
|
|
|
@@ -290,7 +314,13 @@ function CollectionEditorInternal<M extends Record<string, unknown>>({
|
|
|
290
314
|
onAnalyticsEvent,
|
|
291
315
|
fullScreen,
|
|
292
316
|
unmappedTables,
|
|
293
|
-
onFetchTableMetadata
|
|
317
|
+
onFetchTableMetadata,
|
|
318
|
+
propertyTypePresets,
|
|
319
|
+
hiddenPropertyTypes,
|
|
320
|
+
renderExtraPropertyFields,
|
|
321
|
+
renderExtraCollectionFields,
|
|
322
|
+
visibleTabs,
|
|
323
|
+
standalone
|
|
294
324
|
}: CollectionEditorDialogProps & {
|
|
295
325
|
handleCancel: () => void,
|
|
296
326
|
setFormDirty: (dirty: boolean) => void,
|
|
@@ -304,10 +334,33 @@ function CollectionEditorInternal<M extends Record<string, unknown>>({
|
|
|
304
334
|
}
|
|
305
335
|
) {
|
|
306
336
|
|
|
307
|
-
const
|
|
308
|
-
const
|
|
309
|
-
const
|
|
310
|
-
const
|
|
337
|
+
const importConfigRaw = useImportConfig();
|
|
338
|
+
const urlControllerRaw = useUrlController();
|
|
339
|
+
const collectionRegistryRaw = useCollectionRegistryController();
|
|
340
|
+
const snackbarControllerRaw = useSafeSnackbarController();
|
|
341
|
+
|
|
342
|
+
// In standalone mode, use safe defaults
|
|
343
|
+
const importConfig = standalone ? undefined : importConfigRaw;
|
|
344
|
+
const urlController = standalone
|
|
345
|
+
? {
|
|
346
|
+
basePath: "/",
|
|
347
|
+
baseCollectionPath: "/c",
|
|
348
|
+
urlPathToDataPath: () => "",
|
|
349
|
+
homeUrl: "/",
|
|
350
|
+
isUrlCollectionPath: () => false,
|
|
351
|
+
buildUrlCollectionPath: () => "",
|
|
352
|
+
buildAppUrlPath: () => "",
|
|
353
|
+
resolveDatabasePathsFrom: (p: string) => p,
|
|
354
|
+
navigate: () => { }
|
|
355
|
+
}
|
|
356
|
+
: urlControllerRaw;
|
|
357
|
+
const collectionRegistryInternal = standalone
|
|
358
|
+
? { convertIdsToPaths: (ids: string[]) => ids }
|
|
359
|
+
: collectionRegistryRaw;
|
|
360
|
+
const snackbarController = snackbarControllerRaw ?? {
|
|
361
|
+
open: () => { },
|
|
362
|
+
close: () => { }
|
|
363
|
+
};
|
|
311
364
|
|
|
312
365
|
// Use this ref to store which properties have errors
|
|
313
366
|
const propertyErrorsRef = useRef<Record<string, any>>({});
|
|
@@ -317,6 +370,12 @@ function CollectionEditorInternal<M extends Record<string, unknown>>({
|
|
|
317
370
|
: (initialViewProp ?? "properties");
|
|
318
371
|
const [currentView, setCurrentView] = useState<EditorView>(initialView); // this view can edit either the details view or the properties one
|
|
319
372
|
|
|
373
|
+
useEffect(() => {
|
|
374
|
+
if (visibleTabs && !visibleTabs.includes(currentView as CollectionEditorTab)) {
|
|
375
|
+
setCurrentView(visibleTabs[0] || "general");
|
|
376
|
+
}
|
|
377
|
+
}, [visibleTabs, currentView]);
|
|
378
|
+
|
|
320
379
|
const [error, setError] = React.useState<Error | undefined>();
|
|
321
380
|
|
|
322
381
|
const saveCollection = (updatedCollection: EntityCollection<M>): Promise<boolean> => {
|
|
@@ -345,7 +404,7 @@ function CollectionEditorInternal<M extends Record<string, unknown>>({
|
|
|
345
404
|
|
|
346
405
|
const setNextMode = () => {
|
|
347
406
|
if (currentView === "general") {
|
|
348
|
-
if (importConfig
|
|
407
|
+
if (importConfig?.inUse) {
|
|
349
408
|
setCurrentView("import_data_saving");
|
|
350
409
|
} else if (extraView) {
|
|
351
410
|
setCurrentView("extra_view");
|
|
@@ -439,7 +498,7 @@ function CollectionEditorInternal<M extends Record<string, unknown>>({
|
|
|
439
498
|
setNextMode();
|
|
440
499
|
formexController.resetForm({ values: newCollectionState });
|
|
441
500
|
} else if (currentView === "general") {
|
|
442
|
-
if (extraView || importConfig
|
|
501
|
+
if (extraView || importConfig?.inUse) {
|
|
443
502
|
formexController.resetForm({ values: newCollectionState });
|
|
444
503
|
setNextMode();
|
|
445
504
|
} else if (isNewCollection) {
|
|
@@ -537,7 +596,7 @@ function CollectionEditorInternal<M extends Record<string, unknown>>({
|
|
|
537
596
|
const usedPath = getTableName(values);
|
|
538
597
|
const pathError = validatePath(usedPath, isNewCollection, existingPaths, values.slug);
|
|
539
598
|
|
|
540
|
-
const parentPaths = !pathError && parentCollectionSlugs ?
|
|
599
|
+
const parentPaths = !pathError && parentCollectionSlugs ? collectionRegistryInternal.convertIdsToPaths(parentCollectionSlugs) : undefined;
|
|
541
600
|
|
|
542
601
|
const updatedFullPath = parentPaths && parentPaths.length > 0
|
|
543
602
|
? [...parentPaths, usedPath].join("/fake_id/")
|
|
@@ -558,18 +617,18 @@ function CollectionEditorInternal<M extends Record<string, unknown>>({
|
|
|
558
617
|
}, [dirty]);
|
|
559
618
|
|
|
560
619
|
function onImportDataSet(data: object[], propertiesOrder?: string[]) {
|
|
561
|
-
importConfig
|
|
620
|
+
importConfig?.setInUse(true);
|
|
562
621
|
buildEntityPropertiesFromData(data, getInferenceType)
|
|
563
|
-
.then((properties:
|
|
622
|
+
.then((properties: unknown) => {
|
|
564
623
|
const res = cleanPropertiesFromImport(properties as Properties);
|
|
565
624
|
|
|
566
|
-
importConfig
|
|
567
|
-
importConfig
|
|
568
|
-
importConfig
|
|
625
|
+
importConfig?.setIdColumn(res.idColumn);
|
|
626
|
+
importConfig?.setImportData(data);
|
|
627
|
+
importConfig?.setHeadersMapping(res.headersMapping);
|
|
569
628
|
const filteredHeadingsOrder = ((propertiesOrder ?? [])
|
|
570
629
|
.filter((key) => res.headersMapping[key]) as string[]) ?? Object.keys(res.properties);
|
|
571
|
-
importConfig
|
|
572
|
-
importConfig
|
|
630
|
+
importConfig?.setHeadingsOrder(filteredHeadingsOrder);
|
|
631
|
+
importConfig?.setOriginProperties(res.properties);
|
|
573
632
|
|
|
574
633
|
const mappedHeadings = (propertiesOrder ?? []).map((key) => res.headersMapping[key]).filter(Boolean) as string[] ?? Object.keys(res.properties);
|
|
575
634
|
setFieldValue("properties", res.properties);
|
|
@@ -581,7 +640,7 @@ function CollectionEditorInternal<M extends Record<string, unknown>>({
|
|
|
581
640
|
|
|
582
641
|
const onImportMappingComplete = () => {
|
|
583
642
|
const updatedProperties = { ...values.properties };
|
|
584
|
-
if (importConfig
|
|
643
|
+
if (importConfig?.idColumn)
|
|
585
644
|
delete updatedProperties[importConfig.idColumn];
|
|
586
645
|
setFieldValue("properties", updatedProperties);
|
|
587
646
|
// setFieldValue("propertiesOrder", Object.values(importConfig.headersMapping));
|
|
@@ -620,25 +679,25 @@ function CollectionEditorInternal<M extends Record<string, unknown>>({
|
|
|
620
679
|
}
|
|
621
680
|
};
|
|
622
681
|
|
|
623
|
-
return <div className="h-full w-full flex flex-col bg-
|
|
682
|
+
return <div className="h-full w-full flex flex-col bg-surface-50 dark:bg-surface-800">
|
|
624
683
|
<Formex value={formController}>
|
|
625
684
|
|
|
626
685
|
<>
|
|
627
|
-
{!isNewCollection && <div className={cls("px-4 py-2 w-full flex shrink-0 items-center justify-between gap-4 bg-surface-50 dark:bg-surface-
|
|
686
|
+
{!isNewCollection && <div className={cls("px-4 py-2 w-full flex shrink-0 items-center justify-between gap-4 bg-surface-50 dark:bg-surface-900 border-b", defaultBorderMixin)}>
|
|
628
687
|
<div className="flex flex-1 items-center justify-end gap-4 min-w-0">
|
|
629
688
|
<Tabs value={currentView}
|
|
630
689
|
className="bg-transparent !w-fit max-w-full"
|
|
631
690
|
onValueChange={(v) => setCurrentView(v as EditorView)}>
|
|
632
|
-
<Tab value={"general"}>
|
|
691
|
+
{(!visibleTabs || visibleTabs.includes("general")) && <Tab value={"general"}>
|
|
633
692
|
General
|
|
634
|
-
</Tab>
|
|
635
|
-
<Tab value={"display"}>
|
|
693
|
+
</Tab>}
|
|
694
|
+
{(!visibleTabs || visibleTabs.includes("display")) && <Tab value={"display"}>
|
|
636
695
|
Display
|
|
637
|
-
</Tab>
|
|
638
|
-
<Tab value={"properties"}>
|
|
696
|
+
</Tab>}
|
|
697
|
+
{(!visibleTabs || visibleTabs.includes("properties")) && <Tab value={"properties"}>
|
|
639
698
|
Properties
|
|
640
|
-
</Tab>
|
|
641
|
-
{getDataSourceCapabilities(values.driver).supportsRLS && <Tab value={"rls"}>
|
|
699
|
+
</Tab>}
|
|
700
|
+
{(!visibleTabs || visibleTabs.includes("rls")) && getDataSourceCapabilities(values.driver).supportsRLS && <Tab value={"rls"}>
|
|
642
701
|
RLS
|
|
643
702
|
</Tab>}
|
|
644
703
|
</Tabs>
|
|
@@ -673,7 +732,7 @@ function CollectionEditorInternal<M extends Record<string, unknown>>({
|
|
|
673
732
|
onSubmit={formController.handleSubmit}
|
|
674
733
|
className="flex-grow flex flex-col min-h-0 relative">
|
|
675
734
|
|
|
676
|
-
<div className="flex-grow flex flex-col min-h-0
|
|
735
|
+
<div className="flex-grow flex flex-col min-h-0 no-scrollbar relative w-full h-full bg-surface-50 dark:bg-surface-800">
|
|
677
736
|
|
|
678
737
|
{currentView === "loading" &&
|
|
679
738
|
<CircularProgressCenter/>}
|
|
@@ -736,14 +795,16 @@ function CollectionEditorInternal<M extends Record<string, unknown>>({
|
|
|
736
795
|
|
|
737
796
|
{currentView === "general" &&
|
|
738
797
|
<GeneralSettingsForm
|
|
798
|
+
isNewCollection={isNewCollection}
|
|
739
799
|
existingPaths={existingPaths}
|
|
740
800
|
existingIds={existingIds}
|
|
741
801
|
parentCollection={parentCollection}
|
|
742
|
-
|
|
802
|
+
renderExtraCollectionFields={renderExtraCollectionFields}
|
|
803
|
+
standalone={standalone}/>
|
|
743
804
|
}
|
|
744
805
|
|
|
745
806
|
{currentView === "display" &&
|
|
746
|
-
<DisplaySettingsForm expandKanban={expandKanban}/>
|
|
807
|
+
<DisplaySettingsForm expandKanban={expandKanban} standalone={standalone}/>
|
|
747
808
|
}
|
|
748
809
|
|
|
749
810
|
{currentView === "rls" && getDataSourceCapabilities(values.driver).supportsRLS &&
|
|
@@ -766,25 +827,28 @@ function CollectionEditorInternal<M extends Record<string, unknown>>({
|
|
|
766
827
|
getData={getDataWithPath}
|
|
767
828
|
doCollectionInference={doCollectionInference}
|
|
768
829
|
propertyConfigs={propertyConfigs}
|
|
769
|
-
|
|
830
|
+
propertyTypePresets={propertyTypePresets}
|
|
831
|
+
hiddenPropertyTypes={hiddenPropertyTypes}
|
|
832
|
+
renderExtraPropertyFields={renderExtraPropertyFields}
|
|
770
833
|
extraIcon={extraView?.icon &&
|
|
771
834
|
<IconButton
|
|
772
835
|
color={"primary"}
|
|
773
836
|
onClick={() => setCurrentView("extra_view")}>
|
|
774
837
|
{extraView.icon}
|
|
775
|
-
</IconButton>}
|
|
838
|
+
</IconButton>}
|
|
839
|
+
standalone={standalone}/>
|
|
776
840
|
}
|
|
777
841
|
|
|
778
842
|
</div>
|
|
779
843
|
{(!fullScreen || isNewCollection || !!error) && (
|
|
780
|
-
<div className="shrink-0 w-full p-4 sm:px-6 sm:py-4 border-t border-surface-200 dark:border-surface-900 flex items-center justify-between gap-4 bg-
|
|
844
|
+
<div className="shrink-0 w-full p-4 sm:px-6 sm:py-4 border-t border-surface-200 dark:border-surface-900 flex items-center justify-between gap-4 bg-surface-50 dark:bg-surface-900">
|
|
781
845
|
{error && <ErrorView error={error}/>}
|
|
782
846
|
|
|
783
847
|
{isNewCollection && includeTemplates && currentView === "import_data_mapping" &&
|
|
784
848
|
<Button variant={"text"}
|
|
785
849
|
type="button"
|
|
786
850
|
onClick={() => {
|
|
787
|
-
importConfig
|
|
851
|
+
importConfig?.setInUse(false);
|
|
788
852
|
return setCurrentView("welcome");
|
|
789
853
|
}}>
|
|
790
854
|
Back
|