@firecms/core 3.0.0-canary.227 → 3.0.0-canary.228
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/components/EntityCollectionView/EntityCollectionView.d.ts +4 -0
- package/dist/core/EntityEditView.d.ts +5 -1
- package/dist/index.es.js +87 -71
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +87 -71
- package/dist/index.umd.js.map +1 -1
- package/dist/util/navigation_utils.d.ts +2 -1
- package/package.json +5 -5
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +17 -3
- package/src/components/common/default_entity_actions.tsx +2 -0
- package/src/core/EntityEditView.tsx +12 -4
- package/src/internal/useBuildSideEntityController.tsx +2 -3
- package/src/routes/FireCMSRoute.tsx +4 -1
- package/src/types/side_entity_controller.tsx +5 -0
- package/src/util/navigation_utils.ts +6 -2
|
@@ -18,13 +18,14 @@ export declare function getCollectionByPathOrId(pathOrId: string, collections: E
|
|
|
18
18
|
* @param subpaths
|
|
19
19
|
*/
|
|
20
20
|
export declare function getCollectionPathsCombinations(subpaths: string[]): string[];
|
|
21
|
-
export declare function navigateToEntity({ openEntityMode, collection, entityId, copy, path, selectedTab, sideEntityController, onClose, navigation }: {
|
|
21
|
+
export declare function navigateToEntity({ openEntityMode, collection, entityId, copy, path, fullIdPath, selectedTab, sideEntityController, onClose, navigation }: {
|
|
22
22
|
openEntityMode: "side_panel" | "full_screen";
|
|
23
23
|
collection?: EntityCollection;
|
|
24
24
|
entityId?: string;
|
|
25
25
|
selectedTab?: string;
|
|
26
26
|
copy?: boolean;
|
|
27
27
|
path: string;
|
|
28
|
+
fullIdPath?: string;
|
|
28
29
|
sideEntityController: SideEntityController;
|
|
29
30
|
onClose?: () => void;
|
|
30
31
|
navigation: NavigationController;
|
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.228",
|
|
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.228",
|
|
54
|
+
"@firecms/formex": "^3.0.0-canary.228",
|
|
55
|
+
"@firecms/ui": "^3.0.0-canary.228",
|
|
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": "6b0cda6fb616bccabeb7e082b7ff589b3475cfa0",
|
|
109
109
|
"publishConfig": {
|
|
110
110
|
"access": "public"
|
|
111
111
|
},
|
|
@@ -93,6 +93,10 @@ export type EntityCollectionViewProps<M extends Record<string, any>> = {
|
|
|
93
93
|
* It defaults to the collection path if not provided.
|
|
94
94
|
*/
|
|
95
95
|
fullPath?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Full path using navigation ids.
|
|
98
|
+
*/
|
|
99
|
+
fullIdPath?: string;
|
|
96
100
|
/**
|
|
97
101
|
* If this is a subcollection, specify the parent collection ids.
|
|
98
102
|
*/
|
|
@@ -138,6 +142,7 @@ export type EntityCollectionViewProps<M extends Record<string, any>> = {
|
|
|
138
142
|
export const EntityCollectionView = React.memo(
|
|
139
143
|
function EntityCollectionView<M extends Record<string, any>>({
|
|
140
144
|
fullPath: fullPathProp,
|
|
145
|
+
fullIdPath,
|
|
141
146
|
parentCollectionIds,
|
|
142
147
|
isSubCollection,
|
|
143
148
|
className,
|
|
@@ -146,6 +151,7 @@ export const EntityCollectionView = React.memo(
|
|
|
146
151
|
}: EntityCollectionViewProps<M>
|
|
147
152
|
) {
|
|
148
153
|
|
|
154
|
+
|
|
149
155
|
const context = useFireCMSContext();
|
|
150
156
|
const navigation = useNavigationController();
|
|
151
157
|
const fullPath = fullPathProp ?? collectionProp.path;
|
|
@@ -240,6 +246,7 @@ export const EntityCollectionView = React.memo(
|
|
|
240
246
|
navigateToEntity({
|
|
241
247
|
navigation,
|
|
242
248
|
path,
|
|
249
|
+
fullIdPath,
|
|
243
250
|
sideEntityController,
|
|
244
251
|
openEntityMode,
|
|
245
252
|
collection,
|
|
@@ -259,6 +266,7 @@ export const EntityCollectionView = React.memo(
|
|
|
259
266
|
collection,
|
|
260
267
|
entityId: undefined,
|
|
261
268
|
path: fullPath,
|
|
269
|
+
fullIdPath,
|
|
262
270
|
sideEntityController,
|
|
263
271
|
navigation,
|
|
264
272
|
onClose: unselectNavigatedEntity
|
|
@@ -426,6 +434,7 @@ export const EntityCollectionView = React.memo(
|
|
|
426
434
|
entityId: entity.id,
|
|
427
435
|
selectedTab: subcollection.id ?? subcollection.path,
|
|
428
436
|
path: fullPath,
|
|
437
|
+
fullIdPath,
|
|
429
438
|
navigation,
|
|
430
439
|
sideEntityController
|
|
431
440
|
})
|
|
@@ -529,7 +538,7 @@ export const EntityCollectionView = React.memo(
|
|
|
529
538
|
highlightEntity={setHighlightedEntity}
|
|
530
539
|
unhighlightEntity={unselectNavigatedEntity}
|
|
531
540
|
collection={collection}
|
|
532
|
-
fullPath={fullPath}
|
|
541
|
+
fullPath={fullIdPath ?? fullPath}
|
|
533
542
|
actions={actions}
|
|
534
543
|
hideId={collection?.hideIdFromCollection}
|
|
535
544
|
onCollectionChange={updateLastDeleteTimestamp}
|
|
@@ -693,6 +702,7 @@ export const EntityCollectionView = React.memo(
|
|
|
693
702
|
getIdColumnWidth={getIdColumnWidth}
|
|
694
703
|
additionalIDHeaderWidget={<EntityIdHeaderWidget
|
|
695
704
|
path={fullPath}
|
|
705
|
+
fullIdPath={fullIdPath ?? fullPath}
|
|
696
706
|
collection={collection}/>}
|
|
697
707
|
openEntityMode={openEntityMode}
|
|
698
708
|
/>
|
|
@@ -809,10 +819,12 @@ function buildPropertyWidthOverwrite(key: string, width: number): PartialEntityC
|
|
|
809
819
|
|
|
810
820
|
function EntityIdHeaderWidget({
|
|
811
821
|
collection,
|
|
812
|
-
path
|
|
822
|
+
path,
|
|
823
|
+
fullIdPath
|
|
813
824
|
}: {
|
|
814
825
|
collection: EntityCollection,
|
|
815
|
-
path: string
|
|
826
|
+
path: string,
|
|
827
|
+
fullIdPath: string
|
|
816
828
|
}) {
|
|
817
829
|
|
|
818
830
|
const navigation = useNavigationController();
|
|
@@ -850,6 +862,7 @@ function EntityIdHeaderWidget({
|
|
|
850
862
|
collection,
|
|
851
863
|
entityId,
|
|
852
864
|
path,
|
|
865
|
+
fullIdPath,
|
|
853
866
|
sideEntityController,
|
|
854
867
|
navigation
|
|
855
868
|
})
|
|
@@ -884,6 +897,7 @@ function EntityIdHeaderWidget({
|
|
|
884
897
|
collection,
|
|
885
898
|
entityId: id,
|
|
886
899
|
path,
|
|
900
|
+
fullIdPath,
|
|
887
901
|
sideEntityController,
|
|
888
902
|
navigation
|
|
889
903
|
})
|
|
@@ -43,6 +43,7 @@ export const editEntityAction: EntityAction = {
|
|
|
43
43
|
collection,
|
|
44
44
|
entityId: entity.id,
|
|
45
45
|
path,
|
|
46
|
+
fullIdPath: path,
|
|
46
47
|
sideEntityController: context.sideEntityController,
|
|
47
48
|
onClose: () => unhighlightEntity?.(entity),
|
|
48
49
|
navigation: context.navigation,
|
|
@@ -78,6 +79,7 @@ export const copyEntityAction: EntityAction = {
|
|
|
78
79
|
collection,
|
|
79
80
|
entityId: entity.id,
|
|
80
81
|
path,
|
|
82
|
+
fullIdPath: path,
|
|
81
83
|
copy: true,
|
|
82
84
|
sideEntityController: context.sideEntityController,
|
|
83
85
|
onClose: () => unhighlightEntity?.(entity),
|
|
@@ -45,6 +45,10 @@ export type OnTabChangeParams<M extends Record<string, any>> = {
|
|
|
45
45
|
|
|
46
46
|
export interface EntityEditViewProps<M extends Record<string, any>> {
|
|
47
47
|
path: string;
|
|
48
|
+
/**
|
|
49
|
+
* The navigation path to the entity.
|
|
50
|
+
*/
|
|
51
|
+
fullIdPath?: string;
|
|
48
52
|
collection: EntityCollection<M>;
|
|
49
53
|
entityId?: string;
|
|
50
54
|
databaseId?: string;
|
|
@@ -119,6 +123,7 @@ export function EntityEditView<M extends Record<string, any>, USER extends User>
|
|
|
119
123
|
|
|
120
124
|
export function EntityEditViewInner<M extends Record<string, any>>({
|
|
121
125
|
path,
|
|
126
|
+
fullIdPath,
|
|
122
127
|
entityId,
|
|
123
128
|
selectedTab: selectedTabProp,
|
|
124
129
|
collection,
|
|
@@ -272,7 +277,9 @@ export function EntityEditViewInner<M extends Record<string, any>>({
|
|
|
272
277
|
|
|
273
278
|
const subCollectionsViews = subcollections && subcollections.map((subcollection) => {
|
|
274
279
|
const subcollectionId = subcollection.id ?? subcollection.path;
|
|
275
|
-
const
|
|
280
|
+
const newFullPath = usedEntity ? `${path}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollectionId)}` : undefined;
|
|
281
|
+
const newFullIdPath = fullIdPath ? `${fullIdPath}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollectionId)}` : undefined;
|
|
282
|
+
|
|
276
283
|
if (selectedTab !== subcollectionId) return null;
|
|
277
284
|
return (
|
|
278
285
|
<div
|
|
@@ -283,9 +290,10 @@ export function EntityEditViewInner<M extends Record<string, any>>({
|
|
|
283
290
|
{globalLoading && <CircularProgressCenter/>}
|
|
284
291
|
|
|
285
292
|
{!globalLoading &&
|
|
286
|
-
(usedEntity &&
|
|
293
|
+
(usedEntity && newFullPath
|
|
287
294
|
? <EntityCollectionView
|
|
288
|
-
fullPath={
|
|
295
|
+
fullPath={newFullPath}
|
|
296
|
+
fullIdPath={newFullIdPath}
|
|
289
297
|
parentCollectionIds={[...parentCollectionIds, collection.id]}
|
|
290
298
|
isSubCollection={true}
|
|
291
299
|
updateUrl={false}
|
|
@@ -307,7 +315,7 @@ export function EntityEditViewInner<M extends Record<string, any>>({
|
|
|
307
315
|
setSelectedTab(value);
|
|
308
316
|
if (status === "existing") {
|
|
309
317
|
onTabChange?.({
|
|
310
|
-
path,
|
|
318
|
+
path: fullIdPath ?? path,
|
|
311
319
|
entityId,
|
|
312
320
|
selectedTab: value === MAIN_TAB_VALUE ? undefined : value,
|
|
313
321
|
collection
|
|
@@ -233,6 +233,7 @@ export function buildSidePanelsFromUrl(path: string, collections: EntityCollecti
|
|
|
233
233
|
if (navigationEntry.type === "entity") {
|
|
234
234
|
sidePanel = {
|
|
235
235
|
path: navigationEntry.path,
|
|
236
|
+
// fullIdPath: navigationEntry.path,
|
|
236
237
|
entityId: navigationEntry.entityId,
|
|
237
238
|
copy: false,
|
|
238
239
|
width: navigationEntry.parentCollection?.sideDialogWidth
|
|
@@ -254,6 +255,7 @@ export function buildSidePanelsFromUrl(path: string, collections: EntityCollecti
|
|
|
254
255
|
if (newFlag) {
|
|
255
256
|
sidePanel = {
|
|
256
257
|
path: lastCollectionPath,
|
|
258
|
+
// fullIdPath: lastCollectionPath,
|
|
257
259
|
copy: false
|
|
258
260
|
}
|
|
259
261
|
}
|
|
@@ -274,16 +276,13 @@ const propsToSidePanel = (props: EntitySidePanelProps,
|
|
|
274
276
|
const newPath = props.entityId
|
|
275
277
|
? buildUrlCollectionPath(`${collectionPath}/${props.entityId}${props.selectedTab ? "/" + props.selectedTab : ""}#${SIDE_URL_HASH}`)
|
|
276
278
|
: buildUrlCollectionPath(`${collectionPath}#${NEW_URL_HASH}`);
|
|
277
|
-
const resolvedPath = resolveIdsFrom(props.path);
|
|
278
279
|
|
|
279
280
|
const resolvedPanelProps: EntitySidePanelProps<any> = {
|
|
280
281
|
...props,
|
|
281
|
-
path: resolvedPath,
|
|
282
282
|
formProps: props.formProps
|
|
283
283
|
};
|
|
284
284
|
|
|
285
285
|
const entityViewWidth = getEntityViewWidth(props, smallLayout, customizationController, authController);
|
|
286
|
-
|
|
287
286
|
return {
|
|
288
287
|
key: `${props.path}/${props.entityId}`,
|
|
289
288
|
component: <EntitySidePanel {...resolvedPanelProps}/>,
|
|
@@ -97,6 +97,7 @@ export function FireCMSRoute() {
|
|
|
97
97
|
return null;
|
|
98
98
|
return <EntityCollectionView
|
|
99
99
|
key={`collection_view_${collection.id ?? collection.path}`}
|
|
100
|
+
fullIdPath={collection.id}
|
|
100
101
|
isSubCollection={false}
|
|
101
102
|
parentCollectionIds={[]}
|
|
102
103
|
fullPath={collection.id}
|
|
@@ -197,12 +198,14 @@ function EntityFullScreenRoute({
|
|
|
197
198
|
}
|
|
198
199
|
|
|
199
200
|
const collection = isNew ? lastCollectionEntry!.collection : lastEntityEntry!.parentCollection;
|
|
200
|
-
const
|
|
201
|
+
const fullIdPath = isNew ? lastCollectionEntry!.path : lastEntityEntry!.path;
|
|
202
|
+
const collectionPath = navigation.resolveIdsFrom(fullIdPath);
|
|
201
203
|
|
|
202
204
|
return <>
|
|
203
205
|
<EntityEditView
|
|
204
206
|
key={collection.id + "_" + (isNew ? "new" : (isCopy ? entityId + "_copy" : entityId))}
|
|
205
207
|
entityId={isNew ? undefined : entityId}
|
|
208
|
+
fullIdPath={fullIdPath}
|
|
206
209
|
collection={collection}
|
|
207
210
|
layout={"full_screen"}
|
|
208
211
|
path={collectionPath}
|
|
@@ -20,6 +20,11 @@ export interface EntitySidePanelProps<M extends Record<string, any> = any> {
|
|
|
20
20
|
*/
|
|
21
21
|
entityId?: string;
|
|
22
22
|
|
|
23
|
+
// /**
|
|
24
|
+
// * Navigation path with ids of the entity
|
|
25
|
+
// */
|
|
26
|
+
// fullIdPath: string;
|
|
27
|
+
|
|
23
28
|
/**
|
|
24
29
|
* Set this flag to true if you want to make a copy of an existing entity
|
|
25
30
|
*/
|
|
@@ -102,6 +102,7 @@ export function resolveCollectionPathIds(path: string, allCollections: EntityCol
|
|
|
102
102
|
// Default case - couldn't match subcollection
|
|
103
103
|
return `${matchingCollection.path}/${entityId}/${remainingPath.join("/")}`;
|
|
104
104
|
}
|
|
105
|
+
|
|
105
106
|
/**
|
|
106
107
|
* Find the corresponding view at any depth for a given path.
|
|
107
108
|
* Note that path or segments of the paths can be collection aliases.
|
|
@@ -161,6 +162,7 @@ export function navigateToEntity({
|
|
|
161
162
|
entityId,
|
|
162
163
|
copy,
|
|
163
164
|
path,
|
|
165
|
+
fullIdPath,
|
|
164
166
|
selectedTab,
|
|
165
167
|
sideEntityController,
|
|
166
168
|
onClose,
|
|
@@ -174,6 +176,7 @@ export function navigateToEntity({
|
|
|
174
176
|
selectedTab?: string;
|
|
175
177
|
copy?: boolean;
|
|
176
178
|
path: string;
|
|
179
|
+
fullIdPath?: string;
|
|
177
180
|
sideEntityController: SideEntityController;
|
|
178
181
|
onClose?: () => void;
|
|
179
182
|
navigation: NavigationController
|
|
@@ -183,7 +186,8 @@ export function navigateToEntity({
|
|
|
183
186
|
|
|
184
187
|
sideEntityController.open({
|
|
185
188
|
entityId,
|
|
186
|
-
path,
|
|
189
|
+
path: fullIdPath ?? path,
|
|
190
|
+
// fullIdPath,
|
|
187
191
|
copy,
|
|
188
192
|
selectedTab,
|
|
189
193
|
collection,
|
|
@@ -192,7 +196,7 @@ export function navigateToEntity({
|
|
|
192
196
|
});
|
|
193
197
|
|
|
194
198
|
} else {
|
|
195
|
-
let to = navigation.buildUrlCollectionPath(entityId ? `${path}/${entityId}` : path);
|
|
199
|
+
let to = navigation.buildUrlCollectionPath(entityId ? `${fullIdPath ?? path}/${entityId}` : fullIdPath ?? path);
|
|
196
200
|
if (entityId && selectedTab) {
|
|
197
201
|
to += `/${selectedTab}`;
|
|
198
202
|
}
|