stormy-gold
stormy-gold15mo ago

how to add parent attribute to resource

i tried to add a parent to my resource but there is no parent attributes
9 Replies
kapa.ai
kapa.ai15mo ago
Hi @saji_nael. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To add a parent to your resource, you can use the meta.parent property in the resource object. Here's an example of how to do this:
<Refine
...
resources={[
{
name: "parent",
},
{
name: "child",
meta: {
parent: "parent",
},
},
]}
/>
<Refine
...
resources={[
{
name: "parent",
},
{
name: "child",
meta: {
parent: "parent",
},
},
]}
/>
In this example, the child resource is nested under the parent resource. Make sure the meta.parent value matches the name of the parent resource you want to nest under. For more information on multi-level menus and nesting resources, you can refer to this documentation (https://refine.dev/docs/advanced-tutorials/multi-level-menu). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai15mo ago
<@1000087684632547538> kapa.ai is still learning and improving, please let us how it did by reacting below
stormy-gold
stormy-gold15mo ago
i tried to add this meta: { parent: "parent", }, and I got a compiler error @kapa.ai
kapa.ai
kapa.ai15mo ago
Let me check the knowledge base for you. One moment! :books: Sorry @saji_nael, I seem to be having a bit of trouble. Don't worry though, I've pinged my supprt and they will try to fix me up! :technologist: Perhaps try again in 15mins?
sunny-green
sunny-green15mo ago
Hey @saji_nael, in the resources property; you can do as follows:
<Refine
resources={[
{
name: "posts",
meta: { parent: "CMS" },
}
]}
>
/* ... */
</Refine>
<Refine
resources={[
{
name: "posts",
meta: { parent: "CMS" },
}
]}
>
/* ... */
</Refine>
Even if there's no CMS resource, it will be accepted as parent and menu will be rendered accordingly. If this gives you errors, can you please share the error? We can try to find a solution to it.
stormy-gold
stormy-gold15mo ago
No description
stormy-gold
stormy-gold15mo ago
here is my code it is not working i got compile error for meta Type '{ name: string; create: FC<{}>; edit: FC<any>; show: FC<any>; list: FC<{}>; canDelete: true; meta: { parent: string; }; }' is not assignable to type 'ResourceProps'. Object literal may only specify known properties, and 'meta' does not exist in type 'ResourceProps'
sunny-green
sunny-green15mo ago
Looks like you are using v3, you can do { name: "posts", parentName: "parent" }
stormy-gold
stormy-gold15mo ago
thank you