robust-apricot
robust-apricot6mo ago

how to hidden 'cancel' list

resources={[
{
name: 'customergroups',
list: '/customergroups',
meta: {
label: '혜택 관리',
canDelete: true,
},
},
{
name: 'points',
list: '/points',
meta: {
label: '적립금 관리',
canDelete: false,
},
},
{
name: 'cancel',
list: '/cancel',
meta: {
label: '해지 구독 관리',
canDelete: false,
},
show: 'false',
},
]}
resources={[
{
name: 'customergroups',
list: '/customergroups',
meta: {
label: '혜택 관리',
canDelete: true,
},
},
{
name: 'points',
list: '/points',
meta: {
label: '적립금 관리',
canDelete: false,
},
},
{
name: 'cancel',
list: '/cancel',
meta: {
label: '해지 구독 관리',
canDelete: false,
},
show: 'false',
},
]}
2 Replies
kapa.ai
kapa.ai6mo ago
Hi @florent. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To hide the 'cancel' resource from the menu, you can use the meta.hide property. This property ensures that the resource is not displayed in the Sider component but remains accessible via its URL. Here's how you can modify your code to hide the 'cancel' resource:
resources={[
{
name: 'customergroups',
list: '/customergroups',
meta: {
label: '혜택 관리',
canDelete: true,
},
},
{
name: 'points',
list: '/points',
meta: {
label: '적립금 관리',
canDelete: false,
},
},
{
name: 'cancel',
list: '/cancel',
meta: {
label: '해지 구독 관리',
canDelete: false,
hide: true, // This will hide the 'cancel' resource from the menu
},
},
]}
resources={[
{
name: 'customergroups',
list: '/customergroups',
meta: {
label: '혜택 관리',
canDelete: true,
},
},
{
name: 'points',
list: '/points',
meta: {
label: '적립금 관리',
canDelete: false,
},
},
{
name: 'cancel',
list: '/cancel',
meta: {
label: '해지 구독 관리',
canDelete: false,
hide: true, // This will hide the 'cancel' resource from the menu
},
},
]}
By setting meta.hide to true, the 'cancel' resource will be hidden from the Sider component but will still be accessible via the URL /cancel. For more information, you can refer to the documentation on hiding items from the Sider component (https://refine.dev/docs/guides-concepts/faq/#how-to-hide-items-from-the-sider-component). If you need to hide the resource based on user roles, you can integrate the access control provider as mentioned in the Discord support thread (https://discord.com/channels/837692625737613362/1197613916755349554).
import { AccessControlProvider } from '@refinedev/core';
import { authProvider } from './authProvider';

export const accessControlProvider: AccessControlProvider = {
can: async ({ resource, action, params }) => {
const permissions = await authProvider.getPermissions();
if (resource === 'cancel' && !permissions.includes('admin')) {
return { can: false };
}
return { can: true };
},
};
import { AccessControlProvider } from '@refinedev/core';
import { authProvider } from './authProvider';

export const accessControlProvider: AccessControlProvider = {
can: async ({ resource, action, params }) => {
const permissions = await authProvider.getPermissions();
if (resource === 'cancel' && !permissions.includes('admin')) {
return { can: false };
}
return { can: true };
},
};
This setup ensures that the 'cancel' resource is hidden based on user roles. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai6mo ago
<@1184365192482652173> kapa.ai is still learning and improving, please let us know how it did by reacting below