forked from ddrilling/asb_cloud_front
Улучшена работа с правами категорий документов
This commit is contained in:
parent
8f5b48355d
commit
db41e9dabb
@ -5,7 +5,7 @@ import { Layout } from 'antd'
|
||||
|
||||
import { RootPathContext, useRootPath } from '@asb/context'
|
||||
import { PrivateMenu } from '@components/Private'
|
||||
import { getTabname, wrapPrivateComponent, NoAccessComponent } from '@utils'
|
||||
import { getTabname, wrapPrivateComponent, NoAccessComponent, hasPermission } from '@utils'
|
||||
|
||||
import DocumentsTemplate from './DocumentsTemplate'
|
||||
|
||||
@ -31,27 +31,28 @@ const MenuDocuments = memo(() => {
|
||||
const root = useRootPath()
|
||||
const rootPath = useMemo(() => `${root}/document`, [root])
|
||||
|
||||
const categories = useMemo(() => documentCategories.filter(({ permissions }) => hasPermission(permissions)))
|
||||
|
||||
return (
|
||||
<RootPathContext.Provider value={rootPath}>
|
||||
<PrivateMenu mode={'horizontal'} selectable={true} className={'well_menu'} selectedKeys={[category]}>
|
||||
{documentCategories.map(category => (
|
||||
{categories.map(category => (
|
||||
<PrivateMenu.Link
|
||||
key={`${category.key}`}
|
||||
icon={<FolderOutlined/>}
|
||||
title={category.title}
|
||||
permissions={category.permissions}
|
||||
/>
|
||||
))}
|
||||
</PrivateMenu>
|
||||
<Layout>
|
||||
<Content className={'site-layout-background'}>
|
||||
<Routes>
|
||||
{documentCategories.length > 0 && (
|
||||
<Route index element={<Navigate to={documentCategories[0].key} replace />} />
|
||||
{categories.length > 0 && (
|
||||
<Route index element={<Navigate to={categories[0].key} replace />} />
|
||||
)}
|
||||
<Route path={'*'} element={<NoAccessComponent />} />
|
||||
|
||||
{documentCategories.map(category => (
|
||||
{categories.map(category => (
|
||||
<Route key={category.key} path={category.key} element={(
|
||||
<DocumentsTemplate
|
||||
idCategory={category.id}
|
||||
|
Loading…
Reference in New Issue
Block a user