Fix external links in sidebar/sidenav
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
38b960244a
commit
5149ed1342
|
@ -57,9 +57,10 @@ const SidebarNavigation = () => {
|
||||||
|
|
||||||
if (instance.invites_enabled) {
|
if (instance.invites_enabled) {
|
||||||
menu.push({
|
menu.push({
|
||||||
to: `${baseURL}/invites`,
|
href: `${baseURL}/invites`,
|
||||||
icon: require('@tabler/icons/icons/mailbox.svg'),
|
icon: require('@tabler/icons/icons/mailbox.svg'),
|
||||||
text: <FormattedMessage id='navigation.invites' defaultMessage='Invites' />,
|
text: <FormattedMessage id='navigation.invites' defaultMessage='Invites' />,
|
||||||
|
newTab: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,14 +42,15 @@ const messages = defineMessages({
|
||||||
});
|
});
|
||||||
|
|
||||||
interface ISidebarLink {
|
interface ISidebarLink {
|
||||||
to: string,
|
href?: string,
|
||||||
|
to?: string,
|
||||||
icon: string,
|
icon: string,
|
||||||
text: string | JSX.Element,
|
text: string | JSX.Element,
|
||||||
onClick: React.EventHandler<React.MouseEvent>,
|
onClick: React.EventHandler<React.MouseEvent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const SidebarLink: React.FC<ISidebarLink> = ({ to, icon, text, onClick }) => (
|
const SidebarLink: React.FC<ISidebarLink> = ({ href, to, icon, text, onClick }) => {
|
||||||
<NavLink className='group py-1 rounded-md' to={to} onClick={onClick}>
|
const body = (
|
||||||
<HStack space={2} alignItems='center'>
|
<HStack space={2} alignItems='center'>
|
||||||
<div className='bg-primary-50 dark:bg-slate-700 relative rounded inline-flex p-2'>
|
<div className='bg-primary-50 dark:bg-slate-700 relative rounded inline-flex p-2'>
|
||||||
<Icon src={icon} className='text-primary-600 h-5 w-5' />
|
<Icon src={icon} className='text-primary-600 h-5 w-5' />
|
||||||
|
@ -57,8 +58,22 @@ const SidebarLink: React.FC<ISidebarLink> = ({ to, icon, text, onClick }) => (
|
||||||
|
|
||||||
<Text tag='span' weight='medium' theme='muted' className='group-hover:text-gray-800 dark:group-hover:text-gray-200'>{text}</Text>
|
<Text tag='span' weight='medium' theme='muted' className='group-hover:text-gray-800 dark:group-hover:text-gray-200'>{text}</Text>
|
||||||
</HStack>
|
</HStack>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (to) {
|
||||||
|
return (
|
||||||
|
<NavLink className='group py-1 rounded-md' to={to} onClick={onClick}>
|
||||||
|
{body}
|
||||||
</NavLink>
|
</NavLink>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<a className='group py-1 rounded-md' href={href} target='_blank' onClick={onClick}>
|
||||||
|
{body}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const getOtherAccounts = makeGetOtherAccounts();
|
const getOtherAccounts = makeGetOtherAccounts();
|
||||||
|
|
||||||
|
@ -228,7 +243,7 @@ const SidebarMenu: React.FC = (): JSX.Element | null => {
|
||||||
|
|
||||||
{instance.invites_enabled && (
|
{instance.invites_enabled && (
|
||||||
<SidebarLink
|
<SidebarLink
|
||||||
to={`${baseURL}/invites`}
|
href={`${baseURL}/invites`}
|
||||||
icon={require('@tabler/icons/icons/mailbox.svg')}
|
icon={require('@tabler/icons/icons/mailbox.svg')}
|
||||||
text={intl.formatMessage(messages.invites)}
|
text={intl.formatMessage(messages.invites)}
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
|
|
Loading…
Reference in New Issue