bigbuffet-rw/app/soapbox/features/ui/components/link-footer.tsx

87 lines
3.5 KiB
TypeScript
Raw Normal View History

2023-02-06 10:01:03 -08:00
import clsx from 'clsx';
2022-03-30 13:50:16 -07:00
import React from 'react';
import { FormattedMessage } from 'react-intl';
2022-03-30 13:50:16 -07:00
import { Link } from 'react-router-dom';
import { logOut } from 'soapbox/actions/auth';
import { Text } from 'soapbox/components/ui';
2022-07-04 13:30:35 -07:00
import emojify from 'soapbox/features/emoji';
import { useSoapboxConfig, useOwnAccount, useFeatures, useAppDispatch } from 'soapbox/hooks';
2022-03-30 13:50:16 -07:00
import sourceCode from 'soapbox/utils/code';
interface IFooterLink {
to: string
className?: string
onClick?: React.EventHandler<React.MouseEvent>
children: React.ReactNode
2022-03-30 13:50:16 -07:00
}
const FooterLink: React.FC<IFooterLink> = ({ children, className, ...rest }): JSX.Element => {
return (
2022-06-27 08:52:05 -07:00
<div>
2023-02-06 10:06:44 -08:00
<Link className={clsx('text-gray-700 hover:text-gray-800 hover:underline dark:text-gray-600 dark:hover:text-gray-500', className)} {...rest}>{children}</Link>
2022-06-27 08:52:05 -07:00
</div>
2022-03-30 13:50:16 -07:00
);
};
const LinkFooter: React.FC = (): JSX.Element => {
const account = useOwnAccount();
const features = useFeatures();
const soapboxConfig = useSoapboxConfig();
const dispatch = useAppDispatch();
2022-03-30 13:50:16 -07:00
const onClickLogOut: React.EventHandler<React.MouseEvent> = (e) => {
dispatch(logOut());
2022-03-30 13:50:16 -07:00
e.preventDefault();
};
return (
<div className='space-y-2'>
2023-02-01 14:13:42 -08:00
<div className='divide-x-dot flex flex-wrap items-center text-gray-600'>
2022-03-30 13:50:16 -07:00
{account && <>
{features.profileDirectory && (
2022-03-30 13:51:49 -07:00
<FooterLink to='/directory'><FormattedMessage id='navigation_bar.profile_directory' defaultMessage='Profile directory' /></FooterLink>
2022-03-30 13:50:16 -07:00
)}
2022-03-30 13:51:49 -07:00
<FooterLink to='/blocks'><FormattedMessage id='navigation_bar.blocks' defaultMessage='Blocks' /></FooterLink>
<FooterLink to='/mutes'><FormattedMessage id='navigation_bar.mutes' defaultMessage='Mutes' /></FooterLink>
{(features.filters || features.filtersV2) && (
2022-03-30 13:51:49 -07:00
<FooterLink to='/filters'><FormattedMessage id='navigation_bar.filters' defaultMessage='Filters' /></FooterLink>
2022-03-30 13:50:16 -07:00
)}
{features.federating && (
2022-03-30 13:51:49 -07:00
<FooterLink to='/domain_blocks'><FormattedMessage id='navigation_bar.domain_blocks' defaultMessage='Domain blocks' /></FooterLink>
2022-03-30 13:50:16 -07:00
)}
{account.admin && (
<FooterLink to='/soapbox/config'><FormattedMessage id='navigation_bar.soapbox_config' defaultMessage='Soapbox config' /></FooterLink>
)}
2022-03-30 13:50:16 -07:00
{account.locked && (
2022-03-30 13:51:49 -07:00
<FooterLink to='/follow_requests'><FormattedMessage id='navigation_bar.follow_requests' defaultMessage='Follow requests' /></FooterLink>
2022-03-30 13:50:16 -07:00
)}
2022-04-19 12:37:48 -07:00
<FooterLink to='/logout' onClick={onClickLogOut}><FormattedMessage id='navigation_bar.logout' defaultMessage='Logout' /></FooterLink>
2022-03-30 13:50:16 -07:00
</>}
2022-03-30 13:51:49 -07:00
</div>
2022-03-30 13:50:16 -07:00
<Text theme='muted' size='sm'>
{soapboxConfig.linkFooterMessage ? (
<span
className='inline-block align-middle'
dangerouslySetInnerHTML={{ __html: emojify(soapboxConfig.linkFooterMessage) }}
/>
) : (
<FormattedMessage
id='getting_started.open_source_notice'
defaultMessage='{code_name} is open source software. You can contribute or report issues at {code_link} (v{code_version}).'
values={{
code_name: sourceCode.displayName,
2023-01-10 10:17:57 -08:00
code_link: <Text theme='subtle' tag='span'><a className='underline' href={sourceCode.url} rel='noopener' target='_blank'>{sourceCode.repository}</a></Text>,
2022-03-30 13:50:16 -07:00
code_version: sourceCode.version,
}}
/>
)}
</Text>
</div>
);
};
export default LinkFooter;