DeleteResource does not work with folder tree based navigation
ncomont opened this issue · 0 comments
In this method :
function deleteResource(event, data, context) {
const { model } = data;
const { pathname } = context.router ? context.router.getCurrentLocation() : { pathname: '/' };
return {
type: deleteResourceConst.DIALOG_BOX_DELETE_RESOURCE,
cmf: {
routerReplace: `${pathname}/${model.id}/delete`,
},
model,
redirectUrl: pathname,
};
}
The location is replaced by ${pathname}/${model.id}/delete
, which is invalid if the route already contains an id.
For example, if I'm in the HOME folder, the route is the following :
https://plop.net/preparations/
Then if I wan't to remove a folder, the new location is :
https://plop.net/preparations/ID_TO_REMOVE/delete
This is correct. But, if I'm in a subfolder, the route is :
https://plop.net/preparations/FOLDER_ID
So if I want to remove a folder which is in this folder, the new location is :
https://plop.net/preparations/FOLDER_ID/ID_TO_REMOVE/delete
This cannot be efficiently matched with a react router route.
I propose to replace :
routerReplace:
${pathname}/${model.id}/delete``
By :
routerReplace:
${pathname}/delete/${model.id}``
Yes, this is a breaking change.