References
References
Injected data
To avoid Prop Drilling, Cockpit frontend relies a lot on Provide/Inject
. Meaning that it is not necessary to pass down the data to every single component in the tree.
provideResource()
The provideResource
function uses provide
a resource to every children component in the tree.
injectResource()
The injectResource
function uses inject
to retrieve the provided resource.
A best practice when creating a component that requires a resource is to accept an optional resource as a prop and if not provided, use the context.
This function will error if there is no resource provided.
provideRecord()
injectRecord()
Components
<CreateButton />
The CreateButton
displays a link to the create view.
<DeleteButton />
The DeleteButton
displays a button for deleting a resource with a confirmation dialog.
<IndexButton />
The IndexButton
displays a link to the index view.
<EditButton />
The EditButton
displays a link to the edit view of a record.
<ActionsMenu />
The ActionMenu
component displays a button to open a menu that list the available actions for the resource.
You must provide a list of records for it to be shown.
<ResourceForm />
The ResourceForm
component is used to display an "edit" or "create" form of a resource.
action
: Eithercreate
orupdate
data
: The initial data of the form
<ResourceDetail />
<ResourcePeek />
<ResourceTable />
Composables
useResource()
The useResource
composable is a utility to manage resources.
Types
Adonis Cockpit brings some type utils to improve the developer experience on the frontend.