refine icon indicating copy to clipboard operation
refine copied to clipboard

[FEAT] Option for a toast message with CanAccess/CatchAllNavigate component

Open shahan007 opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe.

Currently with CanAccess component, I am unable to show a toast message. This is how I am calling it, where the fallback is a navigation component.

<CanAccess fallback={<CatchAllNavigate to="/" />} >

Describe alternatives you've considered

One way to hack it is by wrapping my fallback inside a component which will just fire a toast (either that or I can just customise my fallback to handle the toast).

Additional context

At present, CanAccess works but there is no visual feedback unless I chose to make the fallback be a component that lays out the reason. Lets say the user tries to access a page that he doesn't have access to directly through the URL. Now the CanAccess component will run and redirect him back to whatever the fallback component is, but there would be no visual feedback if used along side a navigation component (like in my case). At least the way that I am using it which is with navigation back to my home page, upon redirection there is no visual feedback as to why the user wasnt able to access that page. Adding an option to show toast upon redirection will be helpful.

Describe the thing to improve

Maybe we can have an optional prop to show a toast.

For example in the case of CanAccess we can have optional props like showToast and toastMessage. If the showToast is true and no toastMessage is passed the CanAccess component can just get the reason that we defined in the accessProvider. As noticed that reason is an optional CanReturnType so maybe we can just have default message that runs if the showToast is true however, both the reason in accessProvider and, toastMessage as a prop is not provided, then in this case the default message will be shown in the toast.

We can also choose to employ the same logic inside the CatchAllNavigate component (excluding the reason as this is a routing mechanism).

shahan007 avatar Jun 16 '23 09:06 shahan007

Hey @shahan007, thank you for the issue! We're planning this feature and hoping to release it in the next sprint 🚀

aliemir avatar Jun 19 '23 09:06 aliemir

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 22 '23 13:08 stale[bot]

Hey @shahan007 -- good news, we released this feature today! You can check here for more, https://github.com/refinedev/refine/releases/tag/%40refinedev%2Fcore%404.38.0

omeraplak avatar Sep 12 '23 06:09 omeraplak