diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2022-11-10 08:49:35 +0100 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2022-11-10 11:06:56 +0100 |
commit | c4d2c729245fab1dda31d0de73be9bc03217b06a (patch) | |
tree | 86d51ac7c13d2b08fae534a44524c2ef8b131315 /app/javascript/flavours/glitch/features/status/components | |
parent | 099b3011aafe417c87de0b566ae72836228d793f (diff) |
[Glitch] Add option to open original page in dropdowns of remote content in web UI
Port ef582dc4f2fe53b08988faf8d51f567ac32e5b93 to glitch-soc Signed-off-by: Claire <claire.github-309c@sitedethib.com>
Diffstat (limited to 'app/javascript/flavours/glitch/features/status/components')
-rw-r--r-- | app/javascript/flavours/glitch/features/status/components/action_bar.js | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/app/javascript/flavours/glitch/features/status/components/action_bar.js b/app/javascript/flavours/glitch/features/status/components/action_bar.js index 0e21ca5cc..b6f8a9877 100644 --- a/app/javascript/flavours/glitch/features/status/components/action_bar.js +++ b/app/javascript/flavours/glitch/features/status/components/action_bar.js @@ -35,6 +35,7 @@ const messages = defineMessages({ admin_account: { id: 'status.admin_account', defaultMessage: 'Open moderation interface for @{name}' }, admin_status: { id: 'status.admin_status', defaultMessage: 'Open this status in the moderation interface' }, copy: { id: 'status.copy', defaultMessage: 'Copy link to status' }, + openOriginalPage: { id: 'account.open_original_page', defaultMessage: 'Open original page' }, }); export default @injectIntl @@ -132,22 +133,8 @@ class ActionBar extends React.PureComponent { } handleCopy = () => { - const url = this.props.status.get('url'); - const textarea = document.createElement('textarea'); - - textarea.textContent = url; - textarea.style.position = 'fixed'; - - document.body.appendChild(textarea); - - try { - textarea.select(); - document.execCommand('copy'); - } catch (e) { - - } finally { - document.body.removeChild(textarea); - } + const url = this.props.status.get('url'); + navigator.clipboard.writeText(url); } render () { @@ -158,10 +145,15 @@ class ActionBar extends React.PureComponent { const pinnableStatus = ['public', 'unlisted', 'private'].includes(status.get('visibility')); const mutingConversation = status.get('muted'); const writtenByMe = status.getIn(['account', 'id']) === me; + const isRemote = status.getIn(['account', 'username']) !== status.getIn(['account', 'acct']); let menu = []; if (publicStatus) { + if (isRemote) { + menu.push({ text: intl.formatMessage(messages.openOriginalPage), href: status.get('url') }); + } + menu.push({ text: intl.formatMessage(messages.copy), action: this.handleCopy }); menu.push({ text: intl.formatMessage(messages.embed), action: this.handleEmbed }); menu.push(null); |