@firecms/core 3.0.0-canary.222 → 3.0.0-canary.223
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/index.es.js +93 -63
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +93 -63
- package/dist/index.umd.js.map +1 -1
- package/dist/types/collections.d.ts +4 -0
- package/dist/types/navigation.d.ts +4 -0
- package/package.json +5 -5
- package/src/components/common/default_entity_actions.tsx +11 -3
- package/src/core/EntityEditView.tsx +1 -1
- package/src/hooks/useBuildNavigationController.tsx +11 -0
- package/src/routes/FireCMSRoute.tsx +10 -2
- package/src/types/collections.ts +5 -0
- package/src/types/navigation.ts +5 -0
- package/src/util/navigation_from_path.ts +5 -1
|
@@ -289,6 +289,10 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
|
|
|
289
289
|
* Defaults to false.
|
|
290
290
|
*/
|
|
291
291
|
alwaysApplyDefaultValues?: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* If set to true, a tab including the JSON representation of the entity will be included.
|
|
294
|
+
*/
|
|
295
|
+
includeJsonView?: boolean;
|
|
292
296
|
}
|
|
293
297
|
/**
|
|
294
298
|
* Parameter passed to the `Actions` prop in the collection configuration.
|
|
@@ -49,6 +49,10 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
|
|
|
49
49
|
* The collection is resolved from the given path or alias.
|
|
50
50
|
*/
|
|
51
51
|
getCollection: (pathOrId: string, includeUserOverride?: boolean) => EC | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Get the top level collection configuration for a given id
|
|
54
|
+
*/
|
|
55
|
+
getCollectionById: (id: string) => EC | undefined;
|
|
52
56
|
/**
|
|
53
57
|
* Get the collection configuration from its parent ids.
|
|
54
58
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-canary.
|
|
4
|
+
"version": "3.0.0-canary.223",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"./package.json": "./package.json"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@firecms/editor": "^3.0.0-canary.
|
|
54
|
-
"@firecms/formex": "^3.0.0-canary.
|
|
55
|
-
"@firecms/ui": "^3.0.0-canary.
|
|
53
|
+
"@firecms/editor": "^3.0.0-canary.223",
|
|
54
|
+
"@firecms/formex": "^3.0.0-canary.223",
|
|
55
|
+
"@firecms/ui": "^3.0.0-canary.223",
|
|
56
56
|
"@hello-pangea/dnd": "^17.0.0",
|
|
57
57
|
"@radix-ui/react-portal": "^1.1.3",
|
|
58
58
|
"clsx": "^2.1.1",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"dist",
|
|
106
106
|
"src"
|
|
107
107
|
],
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "279654356c6a23355aab5fcf78d1171339025610",
|
|
109
109
|
"publishConfig": {
|
|
110
110
|
"access": "public"
|
|
111
111
|
},
|
|
@@ -2,7 +2,7 @@ import { DeleteIcon, EditIcon, FileCopyIcon } from "@firecms/ui";
|
|
|
2
2
|
import { EntityAction } from "../../types";
|
|
3
3
|
import { DeleteEntityDialog } from "../DeleteEntityDialog";
|
|
4
4
|
import { addRecentId } from "../EntityCollectionView/utils";
|
|
5
|
-
import { navigateToEntity } from "../../util";
|
|
5
|
+
import { navigateToEntity, resolveDefaultSelectedView } from "../../util";
|
|
6
6
|
|
|
7
7
|
export const editEntityAction: EntityAction = {
|
|
8
8
|
icon: <EditIcon/>,
|
|
@@ -30,7 +30,14 @@ export const editEntityAction: EntityAction = {
|
|
|
30
30
|
addRecentId(collection.id, entity.id);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const path = collection?.collectionGroup ? entity.path : (fullPath ?? entity.path)
|
|
33
|
+
const path = collection?.collectionGroup ? entity.path : (fullPath ?? entity.path);
|
|
34
|
+
const defaultSelectedView = resolveDefaultSelectedView(
|
|
35
|
+
collection ? collection.defaultSelectedView : undefined,
|
|
36
|
+
{
|
|
37
|
+
status: "existing",
|
|
38
|
+
entityId: entity.id,
|
|
39
|
+
}
|
|
40
|
+
);
|
|
34
41
|
navigateToEntity({
|
|
35
42
|
openEntityMode,
|
|
36
43
|
collection,
|
|
@@ -38,7 +45,8 @@ export const editEntityAction: EntityAction = {
|
|
|
38
45
|
path,
|
|
39
46
|
sideEntityController: context.sideEntityController,
|
|
40
47
|
onClose: () => unhighlightEntity?.(entity),
|
|
41
|
-
navigation: context.navigation
|
|
48
|
+
navigation: context.navigation,
|
|
49
|
+
selectedTab: defaultSelectedView
|
|
42
50
|
});
|
|
43
51
|
|
|
44
52
|
return Promise.resolve(undefined);
|
|
@@ -179,7 +179,7 @@ export function EntityEditViewInner<M extends Record<string, any>>({
|
|
|
179
179
|
const subcollectionsCount = subcollections?.length ?? 0;
|
|
180
180
|
const customViews = collection.entityViews;
|
|
181
181
|
const customViewsCount = customViews?.length ?? 0;
|
|
182
|
-
const includeJsonView = true;
|
|
182
|
+
const includeJsonView = collection.includeJsonView === undefined ? true : collection.includeJsonView;
|
|
183
183
|
const hasAdditionalViews = customViewsCount > 0 || subcollectionsCount > 0 || includeJsonView;
|
|
184
184
|
|
|
185
185
|
const {
|
|
@@ -291,6 +291,16 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
|
|
|
291
291
|
|
|
292
292
|
}, [userConfigPersistence]);
|
|
293
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
|
+
|
|
294
304
|
const getCollectionFromPaths = useCallback(<EC extends EntityCollection>(pathSegments: string[]): EC | undefined => {
|
|
295
305
|
|
|
296
306
|
const collections = collectionsRef.current;
|
|
@@ -398,6 +408,7 @@ export function useBuildNavigationController<EC extends EntityCollection, USER e
|
|
|
398
408
|
baseCollectionPath,
|
|
399
409
|
initialised,
|
|
400
410
|
getCollection,
|
|
411
|
+
getCollectionById,
|
|
401
412
|
getCollectionFromPaths,
|
|
402
413
|
getCollectionFromIds,
|
|
403
414
|
isUrlCollectionPath,
|
|
@@ -13,6 +13,7 @@ import { useBreadcrumbsController } from "../hooks/useBreadcrumbsController";
|
|
|
13
13
|
import { toArray } from "../util/arrays";
|
|
14
14
|
import { EntityCollectionView, NotFoundPage } from "../components";
|
|
15
15
|
import { UnsavedChangesDialog } from "../components/UnsavedChangesDialog";
|
|
16
|
+
import { EntityCollection } from "../types";
|
|
16
17
|
|
|
17
18
|
export function FireCMSRoute() {
|
|
18
19
|
|
|
@@ -68,7 +69,10 @@ export function FireCMSRoute() {
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
if (navigationEntries.length === 1 && navigationEntries[0].type === "collection") {
|
|
71
|
-
|
|
72
|
+
let collection: EntityCollection<any> | undefined;
|
|
73
|
+
collection = navigation.getCollectionById(navigationEntries[0].id);
|
|
74
|
+
if (!collection)
|
|
75
|
+
collection = navigation.getCollection(navigationEntries[0].path);
|
|
72
76
|
if (!collection)
|
|
73
77
|
return null;
|
|
74
78
|
return <EntityCollectionView
|
|
@@ -84,7 +88,11 @@ export function FireCMSRoute() {
|
|
|
84
88
|
if (isSidePanel) {
|
|
85
89
|
const lastCollectionEntry = navigationEntries.findLast((entry) => entry.type === "collection");
|
|
86
90
|
if (lastCollectionEntry) {
|
|
87
|
-
|
|
91
|
+
let collection: EntityCollection<any> | undefined;
|
|
92
|
+
const firstEntry = navigationEntries[0] as NavigationViewCollectionInternal<any>;
|
|
93
|
+
collection = navigation.getCollectionById(firstEntry.id);
|
|
94
|
+
if (!collection)
|
|
95
|
+
collection = navigation.getCollection(firstEntry.path);
|
|
88
96
|
if (!collection)
|
|
89
97
|
return null;
|
|
90
98
|
return <EntityCollectionView
|
package/src/types/collections.ts
CHANGED
|
@@ -332,6 +332,11 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
|
|
|
332
332
|
* Defaults to false.
|
|
333
333
|
*/
|
|
334
334
|
alwaysApplyDefaultValues?: boolean;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* If set to true, a tab including the JSON representation of the entity will be included.
|
|
338
|
+
*/
|
|
339
|
+
includeJsonView?: boolean;
|
|
335
340
|
}
|
|
336
341
|
|
|
337
342
|
/**
|
package/src/types/navigation.ts
CHANGED
|
@@ -59,6 +59,11 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
|
|
|
59
59
|
*/
|
|
60
60
|
getCollection: (pathOrId: string, includeUserOverride?: boolean) => EC | undefined;
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Get the top level collection configuration for a given id
|
|
64
|
+
*/
|
|
65
|
+
getCollectionById: (id: string) => EC | undefined;
|
|
66
|
+
|
|
62
67
|
/**
|
|
63
68
|
* Get the collection configuration from its parent ids.
|
|
64
69
|
*/
|
|
@@ -51,7 +51,11 @@ export function getNavigationEntriesFromPath(props: {
|
|
|
51
51
|
for (let i = 0; i < subpathCombinations.length; i++) {
|
|
52
52
|
const subpathCombination = subpathCombinations[i];
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
let collection: EntityCollection<any> | undefined;
|
|
55
|
+
collection = collections && collections.find((entry) => entry.id === subpathCombination);
|
|
56
|
+
if (!collection) {
|
|
57
|
+
collection = collections && collections.find((entry) => entry.path === subpathCombination);
|
|
58
|
+
}
|
|
55
59
|
|
|
56
60
|
if (collection) {
|
|
57
61
|
const pathOrAlias = collection.id ?? collection.path;
|