Merge branch 'account-header-menu' into 'develop'

Slightly reorder account header menu items, add 'Copy link to profile'

See merge request soapbox-pub/soapbox!2514
This commit is contained in:
marcin mikołajczak 2023-05-15 07:22:02 +00:00
commit 6b39172122

View file

@ -30,6 +30,7 @@ import { queryClient } from 'soapbox/queries/client';
import toast from 'soapbox/toast'; import toast from 'soapbox/toast';
import { Account } from 'soapbox/types/entities'; import { Account } from 'soapbox/types/entities';
import { isDefaultHeader, isLocal, isRemote } from 'soapbox/utils/accounts'; import { isDefaultHeader, isLocal, isRemote } from 'soapbox/utils/accounts';
import copy from 'soapbox/utils/copy';
import { MASTODON, parseVersion } from 'soapbox/utils/features'; import { MASTODON, parseVersion } from 'soapbox/utils/features';
const messages = defineMessages({ const messages = defineMessages({
@ -44,6 +45,7 @@ const messages = defineMessages({
unblock: { id: 'account.unblock', defaultMessage: 'Unblock @{name}' }, unblock: { id: 'account.unblock', defaultMessage: 'Unblock @{name}' },
mute: { id: 'account.mute', defaultMessage: 'Mute @{name}' }, mute: { id: 'account.mute', defaultMessage: 'Mute @{name}' },
report: { id: 'account.report', defaultMessage: 'Report @{name}' }, report: { id: 'account.report', defaultMessage: 'Report @{name}' },
copy: { id: 'status.copy', defaultMessage: 'Copy link to profile' },
share: { id: 'account.share', defaultMessage: 'Share @{name}\'s profile' }, share: { id: 'account.share', defaultMessage: 'Share @{name}\'s profile' },
media: { id: 'account.media', defaultMessage: 'Media' }, media: { id: 'account.media', defaultMessage: 'Media' },
blockDomain: { id: 'account.block_domain', defaultMessage: 'Hide everything from {domain}' }, blockDomain: { id: 'account.block_domain', defaultMessage: 'Hide everything from {domain}' },
@ -273,6 +275,10 @@ const Header: React.FC<IHeader> = ({ account }) => {
}); });
}; };
const handleCopy: React.EventHandler<React.MouseEvent> = (e) => {
copy(account.url);
};
const makeMenu = () => { const makeMenu = () => {
const menu: Menu = []; const menu: Menu = [];
@ -306,8 +312,22 @@ const Header: React.FC<IHeader> = ({ account }) => {
}); });
} }
menu.push({
text: intl.formatMessage(messages.copy),
action: handleCopy,
icon: require('@tabler/icons/clipboard-copy.svg'),
});
if (!ownAccount) return menu; if (!ownAccount) return menu;
if (features.searchFromAccount) {
menu.push({
text: intl.formatMessage(account.id === ownAccount.id ? messages.searchSelf : messages.search, { name: account.username }),
action: onSearch,
icon: require('@tabler/icons/search.svg'),
});
}
if (menu.length) { if (menu.length) {
menu.push(null); menu.push(null);
} }
@ -323,13 +343,6 @@ const Header: React.FC<IHeader> = ({ account }) => {
to: '/settings', to: '/settings',
icon: require('@tabler/icons/settings.svg'), icon: require('@tabler/icons/settings.svg'),
}); });
if (features.searchFromAccount) {
menu.push({
text: intl.formatMessage(messages.searchSelf, { name: account.username }),
action: onSearch,
icon: require('@tabler/icons/search.svg'),
});
}
menu.push(null); menu.push(null);
menu.push({ menu.push({
text: intl.formatMessage(messages.mutes), text: intl.formatMessage(messages.mutes),
@ -386,8 +399,6 @@ const Header: React.FC<IHeader> = ({ account }) => {
icon: require('@tabler/icons/user-check.svg'), icon: require('@tabler/icons/user-check.svg'),
}); });
} }
menu.push(null);
} else if (features.lists && features.unrestrictedLists) { } else if (features.lists && features.unrestrictedLists) {
menu.push({ menu.push({
text: intl.formatMessage(messages.add_or_remove_from_list), text: intl.formatMessage(messages.add_or_remove_from_list),
@ -396,13 +407,7 @@ const Header: React.FC<IHeader> = ({ account }) => {
}); });
} }
if (features.searchFromAccount) { menu.push(null);
menu.push({
text: intl.formatMessage(messages.search, { name: account.username }),
action: onSearch,
icon: require('@tabler/icons/search.svg'),
});
}
if (features.removeFromFollowers && account.relationship?.followed_by) { if (features.removeFromFollowers && account.relationship?.followed_by) {
menu.push({ menu.push({