Access control for create Button doesnot work
<CreateButton accessControl={{ enabled: false }} type="primary" ghost icon={<PlusOutlined />}>
Add New Master Source
</CreateButton>
the enabled is not working , CreateButton is from refineantd
2 Replies
Hi @jash.s. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The
accessControl
prop in the CreateButton
component from @refinedev/antd
is used to control the visibility and accessibility of the button based on user permissions. The enabled
property within accessControl
is used to skip the access control check. If enabled
is set to false
, the access control check will not be skipped and the button will be hidden if the user does not have the necessary permissions.
However, the accessControl
prop only works when an accessControlProvider
is provided to the <Refine/>
component. If you haven't provided an accessControlProvider
, the accessControl
prop will not have any effect.
Here is an example of how to use the accessControl
prop:
In this example, the CreateButton
will be displayed if the enabled
property is true
, and it will be hidden if the hideIfUnauthorized
property is true
and the user does not have the necessary permissions.
If you have set enabled
to false
and the button is still visible, it could be because the user has the necessary permissions, or because you haven't provided an accessControlProvider
to the <Refine/>
component.
For more information, you can refer to the refine documentation (https://refine.dev/docs/ui-integrations/ant-design/components/buttons/create-button#accesscontrol).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1129363768661516329> kapa.ai is still learning and improving, please let us know how it did by reacting below