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 { RootPathContext, useRootPath } from '@asb/context'
|
||||||
import { PrivateMenu } from '@components/Private'
|
import { PrivateMenu } from '@components/Private'
|
||||||
import { getTabname, wrapPrivateComponent, NoAccessComponent } from '@utils'
|
import { getTabname, wrapPrivateComponent, NoAccessComponent, hasPermission } from '@utils'
|
||||||
|
|
||||||
import DocumentsTemplate from './DocumentsTemplate'
|
import DocumentsTemplate from './DocumentsTemplate'
|
||||||
|
|
||||||
@ -31,27 +31,28 @@ const MenuDocuments = memo(() => {
|
|||||||
const root = useRootPath()
|
const root = useRootPath()
|
||||||
const rootPath = useMemo(() => `${root}/document`, [root])
|
const rootPath = useMemo(() => `${root}/document`, [root])
|
||||||
|
|
||||||
|
const categories = useMemo(() => documentCategories.filter(({ permissions }) => hasPermission(permissions)))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RootPathContext.Provider value={rootPath}>
|
<RootPathContext.Provider value={rootPath}>
|
||||||
<PrivateMenu mode={'horizontal'} selectable={true} className={'well_menu'} selectedKeys={[category]}>
|
<PrivateMenu mode={'horizontal'} selectable={true} className={'well_menu'} selectedKeys={[category]}>
|
||||||
{documentCategories.map(category => (
|
{categories.map(category => (
|
||||||
<PrivateMenu.Link
|
<PrivateMenu.Link
|
||||||
key={`${category.key}`}
|
key={`${category.key}`}
|
||||||
icon={<FolderOutlined/>}
|
icon={<FolderOutlined/>}
|
||||||
title={category.title}
|
title={category.title}
|
||||||
permissions={category.permissions}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</PrivateMenu>
|
</PrivateMenu>
|
||||||
<Layout>
|
<Layout>
|
||||||
<Content className={'site-layout-background'}>
|
<Content className={'site-layout-background'}>
|
||||||
<Routes>
|
<Routes>
|
||||||
{documentCategories.length > 0 && (
|
{categories.length > 0 && (
|
||||||
<Route index element={<Navigate to={documentCategories[0].key} replace />} />
|
<Route index element={<Navigate to={categories[0].key} replace />} />
|
||||||
)}
|
)}
|
||||||
<Route path={'*'} element={<NoAccessComponent />} />
|
<Route path={'*'} element={<NoAccessComponent />} />
|
||||||
|
|
||||||
{documentCategories.map(category => (
|
{categories.map(category => (
|
||||||
<Route key={category.key} path={category.key} element={(
|
<Route key={category.key} path={category.key} element={(
|
||||||
<DocumentsTemplate
|
<DocumentsTemplate
|
||||||
idCategory={category.id}
|
idCategory={category.id}
|
||||||
|
Loading…
Reference in New Issue
Block a user