Hide *Button for forbidden actions

Hi! Is there a way to avoid the disabled button for actions an user cannot do (because unauthorized)? Right now my "basic user" should only be able to see (not edit) a list, and its detail. Using <EditButton> in the actions column instead makes the button appear as disabled (but still clickable). Is there a way to either : 1- disable also the click on the button 2- do not print the button at all if can is false
extended-yellow
extended-yellowโ€ข579d ago
<DeleteButton> already has Solution #1, because it relies on the onClick, which is not triggered on a disabled button I'd love to see a prop "showWhenUnauthorized" (default true) that hides the button at all if can for that action is false
Omer
Omerโ€ข579d ago
Hey @kino90 , I hope you are very well. I am happy to see you again ๐Ÿป Item 1 is a BUG that definitely needs to be fixed. Can you create an issue for this? (https://github.com/pankod/refine/issues/new?assignees=&labels=bug&template=bug_report.yml&title=%5BBUG%5D) temporarily you can try this,
<CanAccess
resource="posts"
action="edit"
params={{ id: 1 }}
>
<EditButton ignoreAccessControlProvider />;
</CanAccess>
<CanAccess
resource="posts"
action="edit"
params={{ id: 1 }}
>
<EditButton ignoreAccessControlProvider />;
</CanAccess>
extended-yellow
extended-yellowโ€ข579d ago
Thanks, I'll open the issue right now ๐Ÿ™‚ in the meantime I'll try with the <CanAccess> component! Thanks! ๐Ÿ˜‰
extended-yellow
extended-yellowโ€ข579d ago
GitHub
[BUG] Disable click on <*Button>s when unauthorized ยท Issue #2828 ยท...
Describe the bug Right now my &quot;basic user&quot; should only be able to see (not edit) a list, and its detail. Using &lt;EditButton&gt; in the List actions column instead makes ...
Omer
Omerโ€ข579d ago
Thank you! @kino90 By the way, which UI library are you using?
extended-yellow
extended-yellowโ€ข579d ago
Mantine ui, sorry.. but if I recall correctly there was the same issue in the antd lib
Omer
Omerโ€ข578d ago
Hey @kino90 , We've released @pankod/refine-mantine@1.9.0. Could you approve fix? https://github.com/refinedev/refine/releases/tag/%40pankod%2Frefine-mantine%401.9.0
extended-yellow
extended-yellowโ€ข578d ago
Today and tomorrow I'm not at work, I'll test it next monday! Thanks for the quick fix! ๐Ÿš€
More Posts
difference between importing from refinecore and refineantdfor example i have a component useSelect so if i import it from refinecore it dont have same props cI am getting 301 status using refine-simple-rest although there is not any error on postman.I am using refine-simple-rest as my data provider to connect with the django rest API but I get backchange label of breadcrumbi am using breadcrumb in create page but i am getting its as patients/create i want to change labeluseSelect onSearch without call API cos i got limit call APIcan i call API once and search query without recall API?How to submit a modal form to create a Comment when you are in the Post show page?Given the fact that I'm a first timer using React, Building refine app has been amazing. What I'd liMaking duplicate calls in the apiUsing the github example (finefoods - mui), the application is making duplicate calls in the api Docustom route element not visible{ element:<div> <LayoutWrapper>sssshhhhh</LayoutWrapper> </divpagination not working if i use filtered value and onfilter props in ant table columnfilteredValue={[consultationState]} onFilter={(value:any,record:any)=>{ return recorduseform-metadataBut the error is coming from the UserWithRolesRemove useModal form titleI want to remove title from useModalForm so i gave title ={null } its not workinguseExport with arrays in schemaI have resources that have array fields, which I am spreading to fields like `arrayItem.0.name, arrastartswith operatorstartswith operator not supportedediting usemodal form footeri am having a custom button in antmodal footer footer={<Button >okk</Button>} if i click on this sasetFilters for json objectis there a way to apply nested filters for json b object retuning from usetable , using setFiltersfiltering ant table based on useSelect hookconsider i have select dropdown where i have values as one, two and three . Below i have ant table wselectionSet issueError: unexpected null value for type "uuid": {"response":{"errors":[{"extensions":{"path":"$.selectselection sort issuefield "krseva_frequencies" not found in type: 'query_root': {"response":{"errors":[{"extensions":{"pmigration issues./node_modules/@pankod/refine-react-router/dist/esm/index.js 49:10-11 export 'useIsAuthenticated' (iNested Filtering in useTablehow to do nested filtering in useTable hook?Strapi issue.I am trying to replicate the invoice generator from here: https://refine.dev/blog/refine-react-admin