From 17cb4a51059135fa28a507d141e27cb155a33742 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 25 Nov 2022 16:44:42 -0600 Subject: [PATCH] StatusActionBar: include a link to the remote status in the 3-dots menu --- app/soapbox/components/status-action-bar.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/soapbox/components/status-action-bar.tsx b/app/soapbox/components/status-action-bar.tsx index 6735c1b29..1b195d31f 100644 --- a/app/soapbox/components/status-action-bar.tsx +++ b/app/soapbox/components/status-action-bar.tsx @@ -18,7 +18,7 @@ import StatusActionButton from 'soapbox/components/status-action-button'; import { HStack } from 'soapbox/components/ui'; import DropdownMenuContainer from 'soapbox/containers/dropdown-menu-container'; import { useAppDispatch, useAppSelector, useFeatures, useOwnAccount, useSettings, useSoapboxConfig } from 'soapbox/hooks'; -import { isLocal } from 'soapbox/utils/accounts'; +import { isLocal, isRemote } from 'soapbox/utils/accounts'; import { getReactForStatus, reduceEmoji } from 'soapbox/utils/emoji-reacts'; import type { Menu } from 'soapbox/components/dropdown-menu'; @@ -56,6 +56,7 @@ const messages = defineMessages({ copy: { id: 'status.copy', defaultMessage: 'Copy link to post' }, group_remove_account: { id: 'status.remove_account_from_group', defaultMessage: 'Remove account from group' }, group_remove_post: { id: 'status.remove_post_from_group', defaultMessage: 'Remove post from group' }, + external: { id: 'status.external', defaultMessage: 'View post on {domain}' }, deactivateUser: { id: 'admin.users.actions.deactivate_user', defaultMessage: 'Deactivate @{name}' }, deleteUser: { id: 'admin.users.actions.delete_user', defaultMessage: 'Delete @{name}' }, deleteStatus: { id: 'admin.statuses.actions.delete_status', defaultMessage: 'Delete post' }, @@ -150,6 +151,10 @@ const StatusActionBar: React.FC = ({ dispatch(toggleBookmark(status)); }; + const handleExternalClick = () => { + window.open(status.uri, '_blank'); + }; + const handleReblogClick: React.EventHandler = e => { if (me) { const modalReblog = () => dispatch(toggleReblog(status)); @@ -294,6 +299,8 @@ const StatusActionBar: React.FC = ({ const mutingConversation = status.muted; const ownAccount = status.getIn(['account', 'id']) === me; const username = String(status.getIn(['account', 'username'])); + const account = status.account as Account; + const domain = account.fqn.split('@')[1]; const menu: Menu = []; @@ -312,7 +319,7 @@ const StatusActionBar: React.FC = ({ icon: require('@tabler/icons/link.svg'), }); - if (features.embeds && isLocal(status.account as Account)) { + if (features.embeds && isLocal(account)) { menu.push({ text: intl.formatMessage(messages.embed), action: handleEmbed, @@ -333,6 +340,14 @@ const StatusActionBar: React.FC = ({ }); } + if (features.federating && isRemote(account)) { + menu.push({ + text: intl.formatMessage(messages.external, { domain }), + action: handleExternalClick, + icon: require('@tabler/icons/external-link.svg'), + }); + } + menu.push(null); if (ownAccount || withDismiss) {