2024-01-26 02:41:31 +11:00
|
|
|
import { useCallback } from 'react';
|
2023-05-24 01:15:17 +10:00
|
|
|
|
2024-01-26 02:41:31 +11:00
|
|
|
import { defineMessages, useIntl } from 'react-intl';
|
2023-05-24 01:15:17 +10:00
|
|
|
|
2024-01-26 02:41:31 +11:00
|
|
|
import { useDispatch } from 'react-redux';
|
2023-05-24 01:15:17 +10:00
|
|
|
|
2024-01-26 02:41:31 +11:00
|
|
|
import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react';
|
|
|
|
import { openModal } from 'mastodon/actions/modal';
|
|
|
|
import DropdownMenuContainer from 'mastodon/containers/dropdown_menu_container';
|
|
|
|
import { logOut } from 'mastodon/utils/log_out';
|
2018-06-13 22:44:50 +10:00
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
edit_profile: { id: 'account.edit_profile', defaultMessage: 'Edit profile' },
|
2022-04-29 08:24:31 +10:00
|
|
|
pins: { id: 'navigation_bar.pins', defaultMessage: 'Pinned posts' },
|
2018-06-13 22:44:50 +10:00
|
|
|
preferences: { id: 'navigation_bar.preferences', defaultMessage: 'Preferences' },
|
|
|
|
follow_requests: { id: 'navigation_bar.follow_requests', defaultMessage: 'Follow requests' },
|
2023-07-22 03:09:13 +10:00
|
|
|
favourites: { id: 'navigation_bar.favourites', defaultMessage: 'Favorites' },
|
2018-06-13 22:44:50 +10:00
|
|
|
lists: { id: 'navigation_bar.lists', defaultMessage: 'Lists' },
|
2023-01-19 02:44:33 +11:00
|
|
|
followed_tags: { id: 'navigation_bar.followed_tags', defaultMessage: 'Followed hashtags' },
|
2018-06-13 22:44:50 +10:00
|
|
|
blocks: { id: 'navigation_bar.blocks', defaultMessage: 'Blocked users' },
|
2023-05-24 20:38:50 +10:00
|
|
|
domain_blocks: { id: 'navigation_bar.domain_blocks', defaultMessage: 'Blocked domains' },
|
2018-06-13 22:44:50 +10:00
|
|
|
mutes: { id: 'navigation_bar.mutes', defaultMessage: 'Muted users' },
|
2018-07-11 08:56:54 +10:00
|
|
|
filters: { id: 'navigation_bar.filters', defaultMessage: 'Muted words' },
|
2019-07-19 11:58:46 +10:00
|
|
|
logout: { id: 'navigation_bar.logout', defaultMessage: 'Logout' },
|
2020-03-21 13:14:28 +11:00
|
|
|
bookmarks: { id: 'navigation_bar.bookmarks', defaultMessage: 'Bookmarks' },
|
2024-01-26 02:41:31 +11:00
|
|
|
logoutMessage: { id: 'confirmations.logout.message', defaultMessage: 'Are you sure you want to log out?' },
|
|
|
|
logoutConfirm: { id: 'confirmations.logout.confirm', defaultMessage: 'Log out' },
|
2018-06-13 22:44:50 +10:00
|
|
|
});
|
|
|
|
|
2024-01-26 02:41:31 +11:00
|
|
|
export const ActionBar = () => {
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
const intl = useIntl();
|
2018-06-13 22:44:50 +10:00
|
|
|
|
2024-01-26 02:41:31 +11:00
|
|
|
const handleLogoutClick = useCallback(() => {
|
|
|
|
dispatch(openModal({
|
|
|
|
modalType: 'CONFIRM',
|
|
|
|
modalProps: {
|
|
|
|
message: intl.formatMessage(messages.logoutMessage),
|
|
|
|
confirm: intl.formatMessage(messages.logoutConfirm),
|
|
|
|
closeWhenConfirm: false,
|
|
|
|
onConfirm: () => logOut(),
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
}, [dispatch, intl]);
|
2018-06-13 22:44:50 +10:00
|
|
|
|
2024-01-26 02:41:31 +11:00
|
|
|
let menu = [];
|
2018-06-13 22:44:50 +10:00
|
|
|
|
2024-01-26 02:41:31 +11:00
|
|
|
menu.push({ text: intl.formatMessage(messages.edit_profile), href: '/settings/profile' });
|
|
|
|
menu.push({ text: intl.formatMessage(messages.preferences), href: '/settings/preferences' });
|
|
|
|
menu.push({ text: intl.formatMessage(messages.pins), to: '/pinned' });
|
|
|
|
menu.push(null);
|
|
|
|
menu.push({ text: intl.formatMessage(messages.follow_requests), to: '/follow_requests' });
|
|
|
|
menu.push({ text: intl.formatMessage(messages.favourites), to: '/favourites' });
|
|
|
|
menu.push({ text: intl.formatMessage(messages.bookmarks), to: '/bookmarks' });
|
|
|
|
menu.push({ text: intl.formatMessage(messages.lists), to: '/lists' });
|
|
|
|
menu.push({ text: intl.formatMessage(messages.followed_tags), to: '/followed_tags' });
|
|
|
|
menu.push(null);
|
|
|
|
menu.push({ text: intl.formatMessage(messages.mutes), to: '/mutes' });
|
|
|
|
menu.push({ text: intl.formatMessage(messages.blocks), to: '/blocks' });
|
|
|
|
menu.push({ text: intl.formatMessage(messages.domain_blocks), to: '/domain_blocks' });
|
|
|
|
menu.push({ text: intl.formatMessage(messages.filters), href: '/filters' });
|
|
|
|
menu.push(null);
|
|
|
|
menu.push({ text: intl.formatMessage(messages.logout), action: handleLogoutClick });
|
2023-03-24 13:17:53 +11:00
|
|
|
|
2024-01-26 02:41:31 +11:00
|
|
|
return (
|
|
|
|
<DropdownMenuContainer
|
|
|
|
items={menu}
|
|
|
|
icon='bars'
|
|
|
|
iconComponent={MoreHorizIcon}
|
|
|
|
size={24}
|
|
|
|
direction='right'
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|