File size: 1,485 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
import React, { FC } from 'react'
import { Navigation } from '@adminjs/design-system'
import { useTranslation } from '../../../hooks/use-translation.js'
import { ResourceJSON } from '../../../interfaces/index.js'
import allowOverride from '../../../hoc/allow-override.js'
import { useNavigationResources } from '../../../hooks/index.js'
/**
* @alias SidebarResourceSectionProps
* @memberof SidebarResourceSection
*/
export type SidebarResourceSectionProps = {
/** List of the resources which should be rendered */
resources: Array<ResourceJSON>;
}
/**
* Groups resources by sections and renders the list in {@link Sidebar}
*
* ### Usage
*
* ```
* import { SidebarResourceSection } from 'adminjs`
* ```
*
* @component
* @subcategory Application
* @name SidebarResourceSection
*/
const SidebarResourceSectionOriginal: FC<SidebarResourceSectionProps> = ({ resources }) => {
const elements = useNavigationResources(resources)
const { translateLabel } = useTranslation()
return (
<Navigation
label={translateLabel('navigation')}
elements={elements}
/>
)
}
// Rollup cannot handle type exports well - that is why we need to do this hack with
// exporting default and named SidebarResourceSection
const SidebarResourceSection = allowOverride(SidebarResourceSectionOriginal, 'SidebarResourceSection')
export { SidebarResourceSection, SidebarResourceSectionOriginal as OriginalSidebarResourceSection }
export default SidebarResourceSection
|