Skip to content

Commit

Permalink
Fix for overriding collection in sideentitycontroller
Browse files Browse the repository at this point in the history
  • Loading branch information
fgatti675 committed Jan 28, 2025
1 parent e75810c commit def41e0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export function ExampleCMSView() {
variant={"outlined"}
onClick={() => sideEntityController.open({
entityId: "B003WT1622",
path: "/products-test",
path: "/products",
collection: customProductCollection,
width: 1000
})}>
Expand Down
1 change: 0 additions & 1 deletion packages/firecms_core/src/core/EntityEditView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ export function EntityEditViewInner<M extends Record<string, any>>({
}, [authController, usedEntity, status]);

const readOnly = !canEdit;
console.log("readOnly", readOnly);

const onPreSaveHookError = useCallback((e: Error) => {
setSaving(false);
Expand Down
16 changes: 7 additions & 9 deletions packages/firecms_core/src/core/EntitySidePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,18 @@ export function EntitySidePanel(props: EntitySidePanelProps) {
}, [navigationController, props.path]);

const collection = useMemo(() => {
if (!props) return undefined;
let usedCollection = props.collection;
if (props.collection) {
return props.collection;
}

const registryCollection = navigationController.getCollection(props.path);
if (registryCollection) {
usedCollection = registryCollection;
}
if (!usedCollection) {
console.error("ERROR: No collection found in path `", props.path, "`. Entity id: ", props.entityId);
throw Error("ERROR: No collection found in path `" + props.path + "`. Make sure you have defined a collection for this path in the root navigation.");
return registryCollection;
}

return usedCollection;
}, [navigationController, props]);
console.error("ERROR: No collection found in path `", props.path, "`. Entity id: ", props.entityId);
throw Error("ERROR: No collection found in path `" + props.path + "`. Make sure you have defined a collection for this path in the root navigation.");
}, [navigationController, props.collection]);

useEffect(() => {
function beforeunload(e: any) {
Expand Down

0 comments on commit def41e0

Please sign in to comment.