import React from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { Stack } from 'soapbox/components/ui'; import { useStatContext } from 'soapbox/contexts/stat-context'; import ComposeButton from 'soapbox/features/ui/components/compose-button'; import { useAppSelector, useGroupsPath, useFeatures, useOwnAccount, useSettings } from 'soapbox/hooks'; import DropdownMenu, { Menu } from './dropdown-menu'; import SidebarNavigationLink from './sidebar-navigation-link'; const messages = defineMessages({ follow_requests: { id: 'navigation_bar.follow_requests', defaultMessage: 'Follow requests' }, bookmarks: { id: 'column.bookmarks', defaultMessage: 'Bookmarks' }, lists: { id: 'column.lists', defaultMessage: 'Lists' }, events: { id: 'column.events', defaultMessage: 'Events' }, developers: { id: 'navigation.developers', defaultMessage: 'Developers' }, }); /** Desktop sidebar with links to different views in the app. */ const SidebarNavigation = () => { const intl = useIntl(); const { unreadChatsCount } = useStatContext(); const features = useFeatures(); const settings = useSettings(); const account = useOwnAccount(); const groupsPath = useGroupsPath(); const notificationCount = useAppSelector((state) => state.notifications.unread); const followRequestsCount = useAppSelector((state) => state.user_lists.follow_requests.items.count()); const dashboardCount = useAppSelector((state) => state.admin.openReports.count() + state.admin.awaitingApproval.count()); const makeMenu = (): Menu => { const menu: Menu = []; if (account) { if (account.locked || followRequestsCount > 0) { menu.push({ to: '/follow_requests', text: intl.formatMessage(messages.follow_requests), icon: require('@tabler/icons/user-plus.svg'), count: followRequestsCount, }); } if (features.bookmarks) { menu.push({ to: '/bookmarks', text: intl.formatMessage(messages.bookmarks), icon: require('@tabler/icons/bookmark.svg'), }); } if (features.lists) { menu.push({ to: '/lists', text: intl.formatMessage(messages.lists), icon: require('@tabler/icons/list.svg'), }); } if (features.events) { menu.push({ to: '/events', text: intl.formatMessage(messages.events), icon: require('@tabler/icons/calendar-event.svg'), }); } if (settings.get('isDeveloper')) { menu.push({ to: '/developers', icon: require('@tabler/icons/code.svg'), text: intl.formatMessage(messages.developers), }); } } return menu; }; const menu = makeMenu(); /** Conditionally render the supported messages link */ const renderMessagesLink = (): React.ReactNode => { if (features.chats) { return ( } /> ); } if (features.directTimeline || features.conversations) { return ( } /> ); } return null; }; return ( } /> } /> {account && ( <> } /> {renderMessagesLink()} {features.groups && ( } /> )} } /> } /> {account.staff && ( } /> )} )} {features.publicTimeline && ( <> : } /> {features.federating && ( } /> )} )} {menu.length > 0 && ( } /> )} {account && ( )} ); }; export default SidebarNavigation;