The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/components/Sidebar/NavigationItem.js

37 lines
976 B

import { Box, Icon, Tag } from '@rocket.chat/fuselage';
import React, { memo, useMemo } from 'react';
import { useRoutePath } from '../../contexts/RouterContext';
import Sidebar from './Sidebar';
const NavigationItem = ({
permissionGranted,
pathGroup,
pathSection,
icon,
label,
currentPath,
tag,
}) => {
const params = useMemo(() => ({ group: pathGroup }), [pathGroup]);
const path = useRoutePath(pathSection, params);
const isActive = path === currentPath || false;
if (permissionGranted && !permissionGranted()) {
return null;
}
return (
<Sidebar.GenericItem active={isActive} href={path} key={path}>
{icon && <Icon name={icon} size='x20' mi='x4' />}
<Box withTruncatedText fontScale='p1' mi='x4' color='info'>
{label}{' '}
{tag && (
<Tag style={{ display: 'inline', backgroundColor: '#000', color: '#FFF', marginLeft: 4 }}>
{tag}
</Tag>
)}
</Box>
</Sidebar.GenericItem>
);
};
export default memo(NavigationItem);