@firecms/core 3.0.0-beta.11 → 3.0.0-beta.13
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/app/Scaffold.d.ts +4 -0
- package/dist/components/ArrayContainer.d.ts +14 -3
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +2 -1
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +2 -2
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +15 -1
- package/dist/components/EntityCollectionTable/index.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +8 -0
- package/dist/components/EntityJsonPreview.d.ts +3 -0
- package/dist/components/PropertyIdCopyTooltip.d.ts +1 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +12 -2
- package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +1 -1
- package/dist/components/UnsavedChangesDialog.d.ts +8 -0
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +13 -0
- package/dist/components/common/default_entity_actions.d.ts +0 -2
- package/dist/components/common/index.d.ts +1 -1
- package/dist/components/common/useColumnsIds.d.ts +1 -0
- package/dist/components/common/{useDataSourceEntityCollectionTableController.d.ts → useDataSourceTableController.d.ts} +10 -2
- package/dist/components/common/useDebouncedCallback.d.ts +1 -0
- package/dist/components/common/useScrollRestoration.d.ts +14 -0
- package/dist/contexts/BreacrumbsContext.d.ts +8 -0
- package/dist/core/DefaultAppBar.d.ts +8 -2
- package/dist/core/EntityEditView.d.ts +36 -21
- package/dist/core/EntityEditViewFormActions.d.ts +2 -0
- package/dist/core/FireCMS.d.ts +2 -2
- package/dist/core/FireCMSRouter.d.ts +4 -0
- package/dist/core/NavigationRoutes.d.ts +0 -1
- package/dist/core/SideDialogs.d.ts +4 -2
- package/dist/core/index.d.ts +2 -1
- package/dist/form/EntityForm.d.ts +49 -0
- package/dist/form/EntityFormActions.d.ts +17 -0
- package/dist/form/PropertyFieldBinding.d.ts +1 -1
- package/dist/form/components/FormEntry.d.ts +6 -0
- package/dist/form/components/FormLayout.d.ts +5 -0
- package/dist/form/components/index.d.ts +2 -0
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/BlockFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/RepeatFieldBinding.d.ts +1 -1
- package/dist/form/index.d.ts +16 -16
- package/dist/hooks/data/save.d.ts +1 -1
- package/dist/hooks/data/useEntityFetch.d.ts +2 -1
- package/dist/hooks/useBreadcrumbsController.d.ts +26 -0
- package/dist/hooks/useBuildNavigationController.d.ts +4 -1
- package/dist/hooks/useModeController.d.ts +1 -2
- package/dist/index.es.js +15842 -14396
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +15833 -14389
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/useBuildDataSource.d.ts +3 -2
- package/dist/internal/useBuildSideEntityController.d.ts +3 -3
- package/dist/internal/useUnsavedChangesDialog.d.ts +7 -9
- package/dist/routes/CustomCMSRoute.d.ts +4 -0
- package/dist/routes/FireCMSRoute.d.ts +1 -0
- package/dist/routes/HomePageRoute.d.ts +3 -0
- package/dist/types/collections.d.ts +36 -10
- package/dist/types/datasource.d.ts +2 -2
- package/dist/types/dialogs_controller.d.ts +7 -3
- package/dist/types/entities.d.ts +1 -1
- package/dist/types/entity_actions.d.ts +10 -0
- package/dist/types/fields.d.ts +13 -3
- package/dist/types/firecms.d.ts +1 -1
- package/dist/types/navigation.d.ts +33 -12
- package/dist/types/plugins.d.ts +2 -0
- package/dist/types/properties.d.ts +40 -4
- package/dist/types/side_entity_controller.d.ts +6 -1
- package/dist/util/builders.d.ts +1 -1
- package/dist/util/createFormexStub.d.ts +2 -0
- package/dist/util/entity_actions.d.ts +2 -0
- package/dist/util/entity_cache.d.ts +23 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/navigation_from_path.d.ts +6 -1
- package/dist/util/navigation_utils.d.ts +13 -1
- package/dist/util/objects.d.ts +1 -1
- package/dist/util/property_utils.d.ts +2 -2
- package/dist/util/references.d.ts +2 -2
- package/dist/util/resolutions.d.ts +12 -2
- package/package.json +20 -21
- package/src/app/Scaffold.tsx +13 -3
- package/src/components/ArrayContainer.tsx +60 -24
- package/src/components/CircularProgressCenter.tsx +1 -1
- package/src/components/DeleteEntityDialog.tsx +5 -3
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +46 -23
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +10 -4
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +18 -1
- package/src/components/EntityCollectionTable/index.tsx +1 -1
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +3 -3
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +10 -13
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +105 -47
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +4 -2
- package/src/components/EntityJsonPreview.tsx +66 -0
- package/src/components/EntityPreview.tsx +10 -3
- package/src/components/EntityView.tsx +4 -1
- package/src/components/NotFoundPage.tsx +2 -2
- package/src/components/PropertyIdCopyTooltip.tsx +2 -3
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +14 -7
- package/src/components/SelectableTable/SelectableTable.tsx +18 -3
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +7 -7
- package/src/components/UnsavedChangesDialog.tsx +42 -0
- package/src/components/VirtualTable/VirtualTable.tsx +48 -3
- package/src/components/VirtualTable/VirtualTableProps.tsx +15 -0
- package/src/components/VirtualTable/fields/VirtualTableInput.tsx +1 -1
- package/src/components/common/default_entity_actions.tsx +37 -37
- package/src/components/common/index.ts +1 -1
- package/src/components/common/useColumnsIds.tsx +1 -1
- package/src/components/common/useDataSourceTableController.tsx +420 -0
- package/src/components/common/useDebouncedCallback.tsx +20 -0
- package/src/components/common/useScrollRestoration.tsx +68 -0
- package/src/contexts/BreacrumbsContext.tsx +38 -0
- package/src/contexts/DialogsProvider.tsx +3 -2
- package/src/contexts/ModeController.tsx +1 -3
- package/src/core/DefaultAppBar.tsx +59 -17
- package/src/core/DefaultDrawer.tsx +1 -1
- package/src/core/EntityEditView.tsx +354 -1000
- package/src/core/EntityEditViewFormActions.tsx +199 -0
- package/src/core/EntitySidePanel.tsx +85 -15
- package/src/core/FireCMS.tsx +20 -16
- package/src/core/FireCMSRouter.tsx +17 -0
- package/src/core/NavigationRoutes.tsx +23 -32
- package/src/core/SideDialogs.tsx +20 -11
- package/src/core/index.tsx +4 -2
- package/src/form/EntityForm.tsx +782 -0
- package/src/form/EntityFormActions.tsx +169 -0
- package/src/form/PropertyFieldBinding.tsx +21 -16
- package/src/form/components/FormEntry.tsx +22 -0
- package/src/form/components/FormLayout.tsx +16 -0
- package/src/form/components/LabelWithIcon.tsx +6 -3
- package/src/form/components/StorageUploadProgress.tsx +1 -1
- package/src/form/components/index.tsx +2 -0
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +8 -5
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +5 -2
- package/src/form/field_bindings/BlockFieldBinding.tsx +5 -3
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +1 -0
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +1 -1
- package/src/form/field_bindings/MapFieldBinding.tsx +14 -16
- package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +15 -8
- package/src/form/field_bindings/MultiSelectFieldBinding.tsx +3 -3
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +2 -2
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +1 -1
- package/src/form/field_bindings/RepeatFieldBinding.tsx +13 -4
- package/src/form/field_bindings/SelectFieldBinding.tsx +2 -2
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +11 -6
- package/src/form/field_bindings/SwitchFieldBinding.tsx +1 -0
- package/src/form/field_bindings/TextFieldBinding.tsx +1 -0
- package/src/form/index.tsx +16 -32
- package/src/form/validation.ts +12 -6
- package/src/hooks/data/save.ts +25 -30
- package/src/hooks/data/useCollectionFetch.tsx +1 -1
- package/src/hooks/data/useEntityFetch.tsx +5 -1
- package/src/hooks/useBreadcrumbsController.tsx +31 -0
- package/src/hooks/useBuildModeController.tsx +15 -28
- package/src/hooks/useBuildNavigationController.tsx +81 -24
- package/src/hooks/useFireCMSContext.tsx +0 -30
- package/src/hooks/useLargeLayout.tsx +0 -35
- package/src/hooks/useModeController.tsx +1 -2
- package/src/hooks/useResolvedNavigationFrom.tsx +4 -6
- package/src/internal/useBuildDataSource.ts +9 -5
- package/src/internal/useBuildSideDialogsController.tsx +3 -2
- package/src/internal/useBuildSideEntityController.tsx +135 -88
- package/src/internal/useUnsavedChangesDialog.tsx +126 -92
- package/src/preview/PropertyPreview.tsx +12 -10
- package/src/preview/components/UrlComponentPreview.tsx +17 -18
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +4 -3
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +4 -3
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +4 -2
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +4 -3
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +4 -2
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +4 -2
- package/src/preview/property_previews/MapPropertyPreview.tsx +3 -2
- package/src/routes/CustomCMSRoute.tsx +21 -0
- package/src/routes/FireCMSRoute.tsx +246 -0
- package/src/routes/HomePageRoute.tsx +17 -0
- package/src/types/collections.ts +45 -13
- package/src/types/datasource.ts +2 -1
- package/src/types/dialogs_controller.tsx +7 -3
- package/src/types/entities.ts +1 -1
- package/src/types/entity_actions.tsx +12 -0
- package/src/types/fields.tsx +18 -3
- package/src/types/firecms.tsx +1 -1
- package/src/types/navigation.ts +41 -16
- package/src/types/plugins.tsx +2 -0
- package/src/types/properties.ts +48 -4
- package/src/types/side_dialogs_controller.tsx +2 -0
- package/src/types/side_entity_controller.tsx +11 -1
- package/src/util/builders.ts +5 -3
- package/src/util/createFormexStub.tsx +62 -0
- package/src/util/entity_actions.ts +28 -0
- package/src/util/entity_cache.ts +204 -0
- package/src/util/index.ts +1 -0
- package/src/util/join_collections.ts +6 -1
- package/src/util/navigation_from_path.ts +18 -7
- package/src/util/navigation_utils.ts +115 -14
- package/src/util/objects.ts +9 -2
- package/src/util/parent_references_from_path.ts +3 -3
- package/src/util/property_utils.tsx +7 -3
- package/src/util/references.ts +8 -6
- package/src/util/resolutions.ts +41 -12
- package/src/util/useStorageUploadController.tsx +60 -23
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +0 -236
- /package/src/util/{common.tsx → common.ts} +0 -0
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
EntityCollection,
|
|
10
10
|
EntityCollectionsBuilder,
|
|
11
11
|
EntityReference,
|
|
12
|
+
NavigationBlocker,
|
|
12
13
|
NavigationController,
|
|
13
14
|
PermissionsBuilder,
|
|
14
15
|
TopNavigationEntry,
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
resolvePermissions
|
|
27
28
|
} from "../util";
|
|
28
29
|
import { getParentReferencesFromPath } from "../util/parent_references_from_path";
|
|
30
|
+
import { useBlocker, useNavigate } from "react-router-dom";
|
|
29
31
|
|
|
30
32
|
const DEFAULT_BASE_PATH = "/";
|
|
31
33
|
const DEFAULT_COLLECTION_PATH = "/c";
|
|
@@ -49,6 +51,11 @@ export type BuildNavigationContextProps<EC extends EntityCollection, USER extend
|
|
|
49
51
|
* @param collections
|
|
50
52
|
*/
|
|
51
53
|
injectCollections?: (collections: EntityCollection[]) => EntityCollection[];
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* If true, the navigation logic will not be updated until this flag is false
|
|
57
|
+
*/
|
|
58
|
+
disabled?: boolean;
|
|
52
59
|
};
|
|
53
60
|
|
|
54
61
|
export function useBuildNavigationController<EC extends EntityCollection, USER extends User>(props: BuildNavigationContextProps<EC, USER>): NavigationController {
|
|
@@ -63,9 +70,12 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
|
|
|
63
70
|
viewsOrder,
|
|
64
71
|
userConfigPersistence,
|
|
65
72
|
dataSourceDelegate,
|
|
66
|
-
injectCollections
|
|
73
|
+
injectCollections,
|
|
74
|
+
disabled
|
|
67
75
|
} = props;
|
|
68
76
|
|
|
77
|
+
const navigate = useNavigate();
|
|
78
|
+
|
|
69
79
|
const collectionsRef = useRef<EntityCollection[] | undefined>();
|
|
70
80
|
const viewsRef = useRef<CMSView[] | undefined>();
|
|
71
81
|
const adminViewsRef = useRef<CMSView[] | undefined>();
|
|
@@ -185,7 +195,7 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
|
|
|
185
195
|
|
|
186
196
|
const refreshNavigation = useCallback(async () => {
|
|
187
197
|
|
|
188
|
-
if (authController.initialLoading)
|
|
198
|
+
if (disabled || authController.initialLoading)
|
|
189
199
|
return;
|
|
190
200
|
|
|
191
201
|
console.debug("Refreshing navigation");
|
|
@@ -202,7 +212,7 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
|
|
|
202
212
|
let shouldUpdateTopLevelNav = false;
|
|
203
213
|
if (!areCollectionListsEqual(collectionsRef.current ?? [], resolvedCollections)) {
|
|
204
214
|
collectionsRef.current = resolvedCollections;
|
|
205
|
-
console.
|
|
215
|
+
console.debug("Collections have changed", resolvedCollections);
|
|
206
216
|
shouldUpdateTopLevelNav = true;
|
|
207
217
|
}
|
|
208
218
|
if (collectionsRef.current === undefined) {
|
|
@@ -237,6 +247,7 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
|
|
|
237
247
|
collectionPermissions,
|
|
238
248
|
authController.user,
|
|
239
249
|
authController.initialLoading,
|
|
250
|
+
disabled,
|
|
240
251
|
viewsProp,
|
|
241
252
|
adminViewsProp,
|
|
242
253
|
computeTopNavigation,
|
|
@@ -280,6 +291,16 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
|
|
|
280
291
|
|
|
281
292
|
}, [userConfigPersistence]);
|
|
282
293
|
|
|
294
|
+
const getCollectionById = useCallback((id: string): EC | undefined => {
|
|
295
|
+
const collections = collectionsRef.current;
|
|
296
|
+
if (collections === undefined)
|
|
297
|
+
throw Error("getCollectionById: Collections have not been initialised yet");
|
|
298
|
+
const collection: EntityCollection | undefined = collections.find(c => c.id === id);
|
|
299
|
+
if (!collection)
|
|
300
|
+
return undefined;
|
|
301
|
+
return collection as EC;
|
|
302
|
+
}, []);
|
|
303
|
+
|
|
283
304
|
const getCollectionFromPaths = useCallback(<EC extends EntityCollection>(pathSegments: string[]): EC | undefined => {
|
|
284
305
|
|
|
285
306
|
const collections = collectionsRef.current;
|
|
@@ -332,16 +353,7 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
|
|
|
332
353
|
throw Error("Expected path starting with " + fullCollectionPath);
|
|
333
354
|
}, [fullCollectionPath]);
|
|
334
355
|
|
|
335
|
-
const
|
|
336
|
-
path
|
|
337
|
-
}: {
|
|
338
|
-
path: string
|
|
339
|
-
}): string => {
|
|
340
|
-
return `s/edit/${encodePath(path)}`;
|
|
341
|
-
},
|
|
342
|
-
[]);
|
|
343
|
-
|
|
344
|
-
const resolveAliasesFrom = useCallback((path: string): string => {
|
|
356
|
+
const resolveIdsFrom = useCallback((path: string): string => {
|
|
345
357
|
const collections = collectionsRef.current ?? [];
|
|
346
358
|
return resolveCollectionPathIds(path, collections);
|
|
347
359
|
}, []);
|
|
@@ -396,29 +408,22 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
|
|
|
396
408
|
baseCollectionPath,
|
|
397
409
|
initialised,
|
|
398
410
|
getCollection,
|
|
411
|
+
getCollectionById,
|
|
399
412
|
getCollectionFromPaths,
|
|
400
413
|
getCollectionFromIds,
|
|
401
414
|
isUrlCollectionPath,
|
|
402
415
|
urlPathToDataPath,
|
|
403
416
|
buildUrlCollectionPath,
|
|
404
|
-
|
|
405
|
-
buildCMSUrlPath,
|
|
406
|
-
resolveAliasesFrom,
|
|
417
|
+
resolveIdsFrom,
|
|
407
418
|
topLevelNavigation,
|
|
408
419
|
refreshNavigation,
|
|
409
420
|
getParentReferencesFromPath: getAllParentReferencesForPath,
|
|
410
421
|
getParentCollectionIds,
|
|
411
|
-
convertIdsToPaths
|
|
422
|
+
convertIdsToPaths,
|
|
423
|
+
navigate,
|
|
412
424
|
};
|
|
413
425
|
}
|
|
414
426
|
|
|
415
|
-
export function getSidePanelKey(path: string, entityId?: string) {
|
|
416
|
-
if (entityId)
|
|
417
|
-
return `${removeInitialAndTrailingSlashes(path)}/${removeInitialAndTrailingSlashes(entityId)}`;
|
|
418
|
-
else
|
|
419
|
-
return removeInitialAndTrailingSlashes(path);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
427
|
function encodePath(input: string) {
|
|
423
428
|
return encodeURIComponent(removeInitialAndTrailingSlashes(input))
|
|
424
429
|
.replaceAll("%2F", "/")
|
|
@@ -427,6 +432,7 @@ function encodePath(input: string) {
|
|
|
427
432
|
|
|
428
433
|
function filterOutNotAllowedCollections(resolvedCollections: EntityCollection[], authController: AuthController<User>): EntityCollection[] {
|
|
429
434
|
return resolvedCollections
|
|
435
|
+
.filter((c) => Boolean(c.path))
|
|
430
436
|
.filter((c) => {
|
|
431
437
|
if (!c.permissions) return true;
|
|
432
438
|
const resolvedPermissions = resolvePermissions(c, authController, c.path, null);
|
|
@@ -513,3 +519,54 @@ function areCollectionsEqual(a: EntityCollection, b: EntityCollection) {
|
|
|
513
519
|
}
|
|
514
520
|
return equal(removeFunctions(restA), removeFunctions(restB));
|
|
515
521
|
}
|
|
522
|
+
|
|
523
|
+
function useCustomBlocker(): NavigationBlocker {
|
|
524
|
+
const [blockListeners, setBlockListeners] = useState<Record<string, {
|
|
525
|
+
block: boolean,
|
|
526
|
+
basePath?: string
|
|
527
|
+
}>>({});
|
|
528
|
+
|
|
529
|
+
const shouldBlock = Object.values(blockListeners).some(b => b.block);
|
|
530
|
+
|
|
531
|
+
let blocker: any;
|
|
532
|
+
try {
|
|
533
|
+
blocker = useBlocker(({
|
|
534
|
+
nextLocation
|
|
535
|
+
}) => {
|
|
536
|
+
const allBasePaths = Object.values(blockListeners).map(b => b.basePath).filter(Boolean) as string[];
|
|
537
|
+
if (allBasePaths && allBasePaths.some(path => nextLocation.pathname.startsWith(path)))
|
|
538
|
+
return false;
|
|
539
|
+
return shouldBlock;
|
|
540
|
+
});
|
|
541
|
+
} catch (e) {
|
|
542
|
+
// console.warn("Blocker not available, navigation will not be blocked");
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
const updateBlockListener = (path: string, block: boolean, basePath?: string) => {
|
|
546
|
+
setBlockListeners(prev => ({
|
|
547
|
+
...prev,
|
|
548
|
+
[path]: {
|
|
549
|
+
block,
|
|
550
|
+
basePath
|
|
551
|
+
}
|
|
552
|
+
}));
|
|
553
|
+
return () => setBlockListeners(prev => {
|
|
554
|
+
const {
|
|
555
|
+
[path]: removed,
|
|
556
|
+
...rest
|
|
557
|
+
} = prev;
|
|
558
|
+
return rest;
|
|
559
|
+
})
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
const isBlocked = (path: string) => {
|
|
563
|
+
return (blockListeners[path]?.block ?? false) && blocker?.state === "blocked";
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
return {
|
|
567
|
+
updateBlockListener,
|
|
568
|
+
isBlocked,
|
|
569
|
+
proceed: blocker?.proceed,
|
|
570
|
+
reset: blocker?.reset
|
|
571
|
+
}
|
|
572
|
+
}
|
|
@@ -67,33 +67,3 @@ export const useFireCMSContext = <USER extends User = User, AuthControllerType e
|
|
|
67
67
|
|
|
68
68
|
return fireCMSContextRef.current;
|
|
69
69
|
}
|
|
70
|
-
|
|
71
|
-
// export const useFireCMSContext = <USER extends User = User, AuthControllerType extends AuthController<USER> = AuthController<USER>>(): FireCMSContext<USER, AuthControllerType> => {
|
|
72
|
-
//
|
|
73
|
-
// const authController = useAuthController<USER, AuthControllerType>();
|
|
74
|
-
// const sideDialogsController = useSideDialogsController();
|
|
75
|
-
// const sideEntityController = useSideEntityController();
|
|
76
|
-
// const navigation = useNavigationController();
|
|
77
|
-
// const dataSource = useDataSource();
|
|
78
|
-
// const storageSource = useStorageSource();
|
|
79
|
-
// const snackbarController = useSnackbarController();
|
|
80
|
-
// const userConfigPersistence = useUserConfigurationPersistence();
|
|
81
|
-
// const dialogsController = useDialogsController();
|
|
82
|
-
// const customizationController = useCustomizationController();
|
|
83
|
-
// const analyticsController = useAnalyticsController();
|
|
84
|
-
//
|
|
85
|
-
// return {
|
|
86
|
-
// authController,
|
|
87
|
-
// sideDialogsController,
|
|
88
|
-
// sideEntityController,
|
|
89
|
-
// navigation,
|
|
90
|
-
// dataSource,
|
|
91
|
-
// storageSource,
|
|
92
|
-
// snackbarController,
|
|
93
|
-
// userConfigPersistence,
|
|
94
|
-
// dialogsController,
|
|
95
|
-
// customizationController,
|
|
96
|
-
// analyticsController
|
|
97
|
-
// };
|
|
98
|
-
//
|
|
99
|
-
// };
|
|
@@ -63,38 +63,3 @@ function checkLargeLayout(breakpoint: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" |
|
|
|
63
63
|
return false;
|
|
64
64
|
return window.matchMedia(`(min-width: ${breakpoints[breakpoint] + 1}px)`).matches;
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
// import { useEffect, useState } from "react";
|
|
68
|
-
//
|
|
69
|
-
// const breakpoints = {
|
|
70
|
-
// xs: 0,
|
|
71
|
-
// sm: 640,
|
|
72
|
-
// md: 768,
|
|
73
|
-
// lg: 1024,
|
|
74
|
-
// xl: 1280,
|
|
75
|
-
// "2xl": 1536,
|
|
76
|
-
// "3xl": 1920
|
|
77
|
-
// }
|
|
78
|
-
// export const useLargeLayout = (breakpoint: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" = "lg"): boolean => {
|
|
79
|
-
// const [isLargeLayout, setIsLargeLayout] = useState<boolean>(false);
|
|
80
|
-
//
|
|
81
|
-
// useEffect(() => {
|
|
82
|
-
// const handleResize = () => {
|
|
83
|
-
// const matched = window.matchMedia(`(min-width: ${breakpoints[breakpoint] + 1}px)`).matches;
|
|
84
|
-
// setIsLargeLayout(matched);
|
|
85
|
-
// };
|
|
86
|
-
//
|
|
87
|
-
// // Set initial state
|
|
88
|
-
// handleResize();
|
|
89
|
-
//
|
|
90
|
-
// // Set up event listener for resize events
|
|
91
|
-
// window.addEventListener("resize", handleResize);
|
|
92
|
-
//
|
|
93
|
-
// // Clean up event listener when component unmounts
|
|
94
|
-
// return () => {
|
|
95
|
-
// window.removeEventListener("resize", handleResize);
|
|
96
|
-
// };
|
|
97
|
-
// }, []);
|
|
98
|
-
//
|
|
99
|
-
// return isLargeLayout;
|
|
100
|
-
// };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Entity, EntityCollection, EntityCustomView, FireCMSContext, User } from "../types";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { getNavigationEntriesFromPath } from "../util/navigation_from_path";
|
|
4
4
|
import { useFireCMSContext } from "./useFireCMSContext";
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -67,10 +67,10 @@ export function resolveNavigationFrom<M extends Record<string, any>, USER extend
|
|
|
67
67
|
const navigation = context.navigation;
|
|
68
68
|
|
|
69
69
|
if (!navigation) {
|
|
70
|
-
throw Error("Calling
|
|
70
|
+
throw Error("Calling resolveNavigationFrom, but main navigation has not yet been initialised");
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
const navigationEntries =
|
|
73
|
+
const navigationEntries = getNavigationEntriesFromPath({
|
|
74
74
|
path,
|
|
75
75
|
collections: navigation.collections ?? []
|
|
76
76
|
});
|
|
@@ -143,9 +143,7 @@ export function useResolvedNavigationFrom<M extends Record<string, any>, USER ex
|
|
|
143
143
|
setDataLoading(true);
|
|
144
144
|
setDataLoadingError(undefined);
|
|
145
145
|
resolveNavigationFrom<M, USER>({ path, context })
|
|
146
|
-
.then(
|
|
147
|
-
setData(res);
|
|
148
|
-
})
|
|
146
|
+
.then(setData)
|
|
149
147
|
.catch((e) => setDataLoadingError(e))
|
|
150
148
|
.finally(() => setDataLoading(false));
|
|
151
149
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useCallback } from "react";
|
|
2
2
|
import {
|
|
3
|
+
AuthController,
|
|
3
4
|
DataSource,
|
|
4
5
|
DataSourceDelegate,
|
|
5
6
|
DeleteEntityProps,
|
|
@@ -27,11 +28,13 @@ import { resolveCollection, updateDateAutoValues } from "../util";
|
|
|
27
28
|
export function useBuildDataSource({
|
|
28
29
|
delegate,
|
|
29
30
|
propertyConfigs,
|
|
30
|
-
navigationController
|
|
31
|
+
navigationController,
|
|
32
|
+
authController
|
|
31
33
|
}: {
|
|
32
34
|
delegate: DataSourceDelegate,
|
|
33
35
|
propertyConfigs?: Record<string, PropertyConfig>;
|
|
34
36
|
navigationController: NavigationController;
|
|
37
|
+
authController: AuthController;
|
|
35
38
|
}): DataSource {
|
|
36
39
|
|
|
37
40
|
return {
|
|
@@ -209,26 +212,27 @@ export function useBuildDataSource({
|
|
|
209
212
|
collection,
|
|
210
213
|
path,
|
|
211
214
|
entityId,
|
|
212
|
-
propertyConfigs: propertyConfigs
|
|
215
|
+
propertyConfigs: propertyConfigs,
|
|
216
|
+
authController
|
|
213
217
|
})
|
|
214
218
|
: undefined;
|
|
215
219
|
|
|
216
220
|
const properties: ResolvedProperties<M> | undefined = resolvedCollection?.properties;
|
|
217
221
|
|
|
218
|
-
const
|
|
222
|
+
const delegateValues = usedDelegate.cmsToDelegateModel(
|
|
219
223
|
values,
|
|
220
224
|
);
|
|
221
225
|
|
|
222
226
|
const updatedValues: EntityValues<M> = properties
|
|
223
227
|
? updateDateAutoValues(
|
|
224
228
|
{
|
|
225
|
-
inputValues:
|
|
229
|
+
inputValues: delegateValues,
|
|
226
230
|
properties,
|
|
227
231
|
status,
|
|
228
232
|
timestampNowValue: usedDelegate.currentTime?.() ?? new Date(),
|
|
229
233
|
setDateToMidnight: usedDelegate.setDateToMidnight
|
|
230
234
|
})
|
|
231
|
-
:
|
|
235
|
+
: delegateValues;
|
|
232
236
|
|
|
233
237
|
return usedDelegate.saveEntity({
|
|
234
238
|
path,
|
|
@@ -25,8 +25,9 @@ export function useBuildSideDialogsController(): SideDialogsController {
|
|
|
25
25
|
const newPanels = panelKeys
|
|
26
26
|
.map(key => routesStore.current[key])
|
|
27
27
|
.filter(p => Boolean(p)) as SideDialogPanelProps[];
|
|
28
|
-
if (!equal(sidePanelsRef.current.map(p => p.key), newPanels.map(p => p.key)))
|
|
28
|
+
if (!equal(sidePanelsRef.current.map(p => p.key), newPanels.map(p => p.key))) {
|
|
29
29
|
updateSidePanels(newPanels);
|
|
30
|
+
}
|
|
30
31
|
}, [location]);
|
|
31
32
|
|
|
32
33
|
const close = useCallback(() => {
|
|
@@ -39,7 +40,7 @@ export function useBuildSideDialogsController(): SideDialogsController {
|
|
|
39
40
|
updateSidePanels(updatedPanels);
|
|
40
41
|
|
|
41
42
|
if (routesCount.current > 0) {
|
|
42
|
-
if (lastSidePanel.urlPath)
|
|
43
|
+
if (lastSidePanel.urlPath) // if it has a url path, we need to navigate back, don't remove this code
|
|
43
44
|
navigate(-1);
|
|
44
45
|
routesCount.current--;
|
|
45
46
|
} else if (lastSidePanel.parentUrlPath) {
|