From 9004151e340f1d8080b415afc3668437de32ebc2 Mon Sep 17 00:00:00 2001 From: Sorin Davidoi Date: Fri, 28 Jul 2017 00:55:15 +0200 Subject: [PATCH] feat: Web Share for detailed status and account (#4402) * feat: Web Share for detailed status and account * fix(account/action_bar): Move share under mention --- .../features/account/components/action_bar.js | 10 ++++++++++ .../features/status/components/action_bar.js | 13 +++++++++++++ app/javascript/mastodon/locales/ar.json | 1 + app/javascript/mastodon/locales/bg.json | 1 + app/javascript/mastodon/locales/ca.json | 1 + app/javascript/mastodon/locales/de.json | 1 + .../mastodon/locales/defaultMessages.json | 8 ++++++++ app/javascript/mastodon/locales/en.json | 1 + app/javascript/mastodon/locales/eo.json | 1 + app/javascript/mastodon/locales/es.json | 1 + app/javascript/mastodon/locales/fa.json | 1 + app/javascript/mastodon/locales/fi.json | 1 + app/javascript/mastodon/locales/fr.json | 1 + app/javascript/mastodon/locales/he.json | 1 + app/javascript/mastodon/locales/hr.json | 1 + app/javascript/mastodon/locales/hu.json | 1 + app/javascript/mastodon/locales/id.json | 1 + app/javascript/mastodon/locales/io.json | 1 + app/javascript/mastodon/locales/it.json | 1 + app/javascript/mastodon/locales/ja.json | 1 + app/javascript/mastodon/locales/ko.json | 1 + app/javascript/mastodon/locales/nl.json | 1 + app/javascript/mastodon/locales/no.json | 1 + app/javascript/mastodon/locales/oc.json | 1 + app/javascript/mastodon/locales/pl.json | 1 + app/javascript/mastodon/locales/pt-BR.json | 1 + app/javascript/mastodon/locales/pt.json | 1 + app/javascript/mastodon/locales/ru.json | 1 + app/javascript/mastodon/locales/th.json | 1 + app/javascript/mastodon/locales/tr.json | 1 + app/javascript/mastodon/locales/uk.json | 1 + app/javascript/mastodon/locales/zh-CN.json | 1 + app/javascript/mastodon/locales/zh-HK.json | 1 + app/javascript/mastodon/locales/zh-TW.json | 1 + 34 files changed, 62 insertions(+) diff --git a/app/javascript/mastodon/features/account/components/action_bar.js b/app/javascript/mastodon/features/account/components/action_bar.js index b773045fb9e..c12c0889e4b 100644 --- a/app/javascript/mastodon/features/account/components/action_bar.js +++ b/app/javascript/mastodon/features/account/components/action_bar.js @@ -15,6 +15,7 @@ const messages = defineMessages({ mute: { id: 'account.mute', defaultMessage: 'Mute @{name}' }, follow: { id: 'account.follow', defaultMessage: 'Follow' }, report: { id: 'account.report', defaultMessage: 'Report @{name}' }, + share: { id: 'account.share', defaultMessage: 'Share @{name}\'s profile' }, media: { id: 'account.media', defaultMessage: 'Media' }, blockDomain: { id: 'account.block_domain', defaultMessage: 'Hide everything from {domain}' }, unblockDomain: { id: 'account.unblock_domain', defaultMessage: 'Unhide {domain}' }, @@ -36,6 +37,12 @@ export default class ActionBar extends React.PureComponent { intl: PropTypes.object.isRequired, }; + handleShare = () => { + navigator.share({ + url: this.props.account.get('url'), + }); + } + render () { const { account, me, intl } = this.props; @@ -43,6 +50,9 @@ export default class ActionBar extends React.PureComponent { let extraInfo = ''; menu.push({ text: intl.formatMessage(messages.mention, { name: account.get('username') }), action: this.props.onMention }); + if ('share' in navigator) { + menu.push({ text: intl.formatMessage(messages.share, { name: account.get('username') }), action: this.handleShare }); + } menu.push(null); menu.push({ text: intl.formatMessage(messages.media), to: `/accounts/${account.get('id')}/media` }); menu.push(null); diff --git a/app/javascript/mastodon/features/status/components/action_bar.js b/app/javascript/mastodon/features/status/components/action_bar.js index c4d4bb7475f..91ac64de27e 100644 --- a/app/javascript/mastodon/features/status/components/action_bar.js +++ b/app/javascript/mastodon/features/status/components/action_bar.js @@ -13,6 +13,7 @@ const messages = defineMessages({ cannot_reblog: { id: 'status.cannot_reblog', defaultMessage: 'This post cannot be boosted' }, favourite: { id: 'status.favourite', defaultMessage: 'Favourite' }, report: { id: 'status.report', defaultMessage: 'Report @{name}' }, + share: { id: 'status.share', defaultMessage: 'Share' }, }); @injectIntl @@ -58,6 +59,13 @@ export default class ActionBar extends React.PureComponent { this.props.onReport(this.props.status); } + handleShare = () => { + navigator.share({ + text: this.props.status.get('search_index'), + url: this.props.status.get('url'), + }); + } + render () { const { status, me, intl } = this.props; @@ -71,6 +79,10 @@ export default class ActionBar extends React.PureComponent { menu.push({ text: intl.formatMessage(messages.report, { name: status.getIn(['account', 'username']) }), action: this.handleReport }); } + const shareButton = ('share' in navigator) && status.get('visibility') === 'public' && ( +
+ ); + let reblogIcon = 'retweet'; if (status.get('visibility') === 'direct') reblogIcon = 'envelope'; else if (status.get('visibility') === 'private') reblogIcon = 'lock'; @@ -82,6 +94,7 @@ export default class ActionBar extends React.PureComponent {
+ {shareButton}
diff --git a/app/javascript/mastodon/locales/ar.json b/app/javascript/mastodon/locales/ar.json index b21bec4aa88..089cc32454d 100644 --- a/app/javascript/mastodon/locales/ar.json +++ b/app/javascript/mastodon/locales/ar.json @@ -13,6 +13,7 @@ "account.posts": "المشاركات", "account.report": "أبلغ عن @{name}", "account.requested": "في انتظار الموافقة", + "account.share": "Share @{name}'s profile", "account.unblock": "إلغاء الحظر عن @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "إلغاء المتابعة", diff --git a/app/javascript/mastodon/locales/bg.json b/app/javascript/mastodon/locales/bg.json index 9b6c1bc0482..ba19de1b5a2 100644 --- a/app/javascript/mastodon/locales/bg.json +++ b/app/javascript/mastodon/locales/bg.json @@ -13,6 +13,7 @@ "account.posts": "Публикации", "account.report": "Report @{name}", "account.requested": "В очакване на одобрение", + "account.share": "Share @{name}'s profile", "account.unblock": "Не блокирай", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Не следвай", diff --git a/app/javascript/mastodon/locales/ca.json b/app/javascript/mastodon/locales/ca.json index 195e1e7f993..3d2620be5e1 100644 --- a/app/javascript/mastodon/locales/ca.json +++ b/app/javascript/mastodon/locales/ca.json @@ -13,6 +13,7 @@ "account.posts": "Publicacions", "account.report": "Informe @{name}", "account.requested": "Esperant aprovació", + "account.share": "Share @{name}'s profile", "account.unblock": "Desbloquejar @{name}", "account.unblock_domain": "Mostra {domain}", "account.unfollow": "Deixar de seguir", diff --git a/app/javascript/mastodon/locales/de.json b/app/javascript/mastodon/locales/de.json index 473a97ec4b6..cf74ce081b1 100644 --- a/app/javascript/mastodon/locales/de.json +++ b/app/javascript/mastodon/locales/de.json @@ -13,6 +13,7 @@ "account.posts": "Beiträge", "account.report": "@{name} melden", "account.requested": "Warte auf Erlaubnis", + "account.share": "Share @{name}'s profile", "account.unblock": "@{name} entblocken", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Entfolgen", diff --git a/app/javascript/mastodon/locales/defaultMessages.json b/app/javascript/mastodon/locales/defaultMessages.json index db635c975d2..bc1c7b8b73c 100644 --- a/app/javascript/mastodon/locales/defaultMessages.json +++ b/app/javascript/mastodon/locales/defaultMessages.json @@ -374,6 +374,10 @@ "defaultMessage": "Report @{name}", "id": "account.report" }, + { + "defaultMessage": "Share @{name}'s profile", + "id": "account.share" + }, { "defaultMessage": "Media", "id": "account.media" @@ -1027,6 +1031,10 @@ { "defaultMessage": "Report @{name}", "id": "status.report" + }, + { + "defaultMessage": "Share", + "id": "status.share" } ], "path": "app/javascript/mastodon/features/status/components/action_bar.json" diff --git a/app/javascript/mastodon/locales/en.json b/app/javascript/mastodon/locales/en.json index 3297effd057..70c95d0279d 100644 --- a/app/javascript/mastodon/locales/en.json +++ b/app/javascript/mastodon/locales/en.json @@ -13,6 +13,7 @@ "account.posts": "Posts", "account.report": "Report @{name}", "account.requested": "Awaiting approval", + "account.share": "Share @{name}'s profile", "account.unblock": "Unblock @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Unfollow", diff --git a/app/javascript/mastodon/locales/eo.json b/app/javascript/mastodon/locales/eo.json index a148ba3abe9..e7e52106055 100644 --- a/app/javascript/mastodon/locales/eo.json +++ b/app/javascript/mastodon/locales/eo.json @@ -13,6 +13,7 @@ "account.posts": "Mesaĝoj", "account.report": "Report @{name}", "account.requested": "Atendas aprobon", + "account.share": "Share @{name}'s profile", "account.unblock": "Malbloki @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Malsekvi", diff --git a/app/javascript/mastodon/locales/es.json b/app/javascript/mastodon/locales/es.json index c4e9220ad0a..3d27bd0fc9b 100644 --- a/app/javascript/mastodon/locales/es.json +++ b/app/javascript/mastodon/locales/es.json @@ -13,6 +13,7 @@ "account.posts": "Publicaciones", "account.report": "Report @{name}", "account.requested": "Esperando aprobación", + "account.share": "Share @{name}'s profile", "account.unblock": "Desbloquear", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Dejar de seguir", diff --git a/app/javascript/mastodon/locales/fa.json b/app/javascript/mastodon/locales/fa.json index 17b957387e6..1b533114a61 100644 --- a/app/javascript/mastodon/locales/fa.json +++ b/app/javascript/mastodon/locales/fa.json @@ -13,6 +13,7 @@ "account.posts": "نوشته‌ها", "account.report": "گزارش @{name}", "account.requested": "در انتظار پذیرش", + "account.share": "Share @{name}'s profile", "account.unblock": "رفع انسداد @{name}", "account.unblock_domain": "رفع پنهان‌سازی از {domain}", "account.unfollow": "پایان پیگیری", diff --git a/app/javascript/mastodon/locales/fi.json b/app/javascript/mastodon/locales/fi.json index 1ed9e4e7ceb..0c95f5fd234 100644 --- a/app/javascript/mastodon/locales/fi.json +++ b/app/javascript/mastodon/locales/fi.json @@ -13,6 +13,7 @@ "account.posts": "Postit", "account.report": "Report @{name}", "account.requested": "Odottaa hyväksyntää", + "account.share": "Share @{name}'s profile", "account.unblock": "Salli @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Lopeta seuraaminen", diff --git a/app/javascript/mastodon/locales/fr.json b/app/javascript/mastodon/locales/fr.json index 5cb5871d418..5d7896c8c9f 100644 --- a/app/javascript/mastodon/locales/fr.json +++ b/app/javascript/mastodon/locales/fr.json @@ -13,6 +13,7 @@ "account.posts": "Statuts", "account.report": "Signaler", "account.requested": "Invitation envoyée", + "account.share": "Share @{name}'s profile", "account.unblock": "Débloquer", "account.unblock_domain": "Ne plus masquer {domain}", "account.unfollow": "Ne plus suivre", diff --git a/app/javascript/mastodon/locales/he.json b/app/javascript/mastodon/locales/he.json index d25922401fd..724a18cde7a 100644 --- a/app/javascript/mastodon/locales/he.json +++ b/app/javascript/mastodon/locales/he.json @@ -13,6 +13,7 @@ "account.posts": "הודעות", "account.report": "לדווח על @{name}", "account.requested": "בהמתנה לאישור", + "account.share": "Share @{name}'s profile", "account.unblock": "הסרת חסימה מעל @{name}", "account.unblock_domain": "הסר חסימה מקהילת {domain}", "account.unfollow": "הפסקת מעקב", diff --git a/app/javascript/mastodon/locales/hr.json b/app/javascript/mastodon/locales/hr.json index 05b67000442..b4625c1d4d0 100644 --- a/app/javascript/mastodon/locales/hr.json +++ b/app/javascript/mastodon/locales/hr.json @@ -13,6 +13,7 @@ "account.posts": "Postovi", "account.report": "Prijavi @{name}", "account.requested": "Čeka pristanak", + "account.share": "Share @{name}'s profile", "account.unblock": "Deblokiraj @{name}", "account.unblock_domain": "Otkrij {domain}", "account.unfollow": "Prestani slijediti", diff --git a/app/javascript/mastodon/locales/hu.json b/app/javascript/mastodon/locales/hu.json index 2d03afcb852..8a50889f3fe 100644 --- a/app/javascript/mastodon/locales/hu.json +++ b/app/javascript/mastodon/locales/hu.json @@ -13,6 +13,7 @@ "account.posts": "Posts", "account.report": "Report @{name}", "account.requested": "Awaiting approval", + "account.share": "Share @{name}'s profile", "account.unblock": "Blokkolás levétele", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Követés abbahagyása", diff --git a/app/javascript/mastodon/locales/id.json b/app/javascript/mastodon/locales/id.json index 65286dcf120..8c775d7650d 100644 --- a/app/javascript/mastodon/locales/id.json +++ b/app/javascript/mastodon/locales/id.json @@ -13,6 +13,7 @@ "account.posts": "Postingan", "account.report": "Laporkan @{name}", "account.requested": "Menunggu persetujuan", + "account.share": "Share @{name}'s profile", "account.unblock": "Hapus blokir @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Berhenti mengikuti", diff --git a/app/javascript/mastodon/locales/io.json b/app/javascript/mastodon/locales/io.json index 7255436e0f7..dc29dc8ab98 100644 --- a/app/javascript/mastodon/locales/io.json +++ b/app/javascript/mastodon/locales/io.json @@ -13,6 +13,7 @@ "account.posts": "Mesaji", "account.report": "Denuncar @{name}", "account.requested": "Vartante aprobo", + "account.share": "Share @{name}'s profile", "account.unblock": "Desblokusar @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Ne plus sequar", diff --git a/app/javascript/mastodon/locales/it.json b/app/javascript/mastodon/locales/it.json index 27096f4e15c..ceeaae843d6 100644 --- a/app/javascript/mastodon/locales/it.json +++ b/app/javascript/mastodon/locales/it.json @@ -13,6 +13,7 @@ "account.posts": "Posts", "account.report": "Segnala @{name}", "account.requested": "In attesa di approvazione", + "account.share": "Share @{name}'s profile", "account.unblock": "Sblocca @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Non seguire", diff --git a/app/javascript/mastodon/locales/ja.json b/app/javascript/mastodon/locales/ja.json index e18686a252f..dd92e905392 100644 --- a/app/javascript/mastodon/locales/ja.json +++ b/app/javascript/mastodon/locales/ja.json @@ -13,6 +13,7 @@ "account.posts": "投稿", "account.report": "通報", "account.requested": "承認待ち", + "account.share": "Share @{name}'s profile", "account.unblock": "ブロック解除", "account.unblock_domain": "{domain}を表示", "account.unfollow": "フォロー解除", diff --git a/app/javascript/mastodon/locales/ko.json b/app/javascript/mastodon/locales/ko.json index 597f17aea88..e06ac583c9e 100644 --- a/app/javascript/mastodon/locales/ko.json +++ b/app/javascript/mastodon/locales/ko.json @@ -13,6 +13,7 @@ "account.posts": "포스트", "account.report": "신고", "account.requested": "승인 대기 중", + "account.share": "Share @{name}'s profile", "account.unblock": "차단 해제", "account.unblock_domain": "{domain} 숨김 해제", "account.unfollow": "팔로우 해제", diff --git a/app/javascript/mastodon/locales/nl.json b/app/javascript/mastodon/locales/nl.json index f90431383fe..c477e79d80a 100644 --- a/app/javascript/mastodon/locales/nl.json +++ b/app/javascript/mastodon/locales/nl.json @@ -13,6 +13,7 @@ "account.posts": "Toots", "account.report": "Rapporteer @{name}", "account.requested": "Wacht op goedkeuring", + "account.share": "Share @{name}'s profile", "account.unblock": "Deblokkeer @{name}", "account.unblock_domain": "{domain} niet meer negeren", "account.unfollow": "Ontvolgen", diff --git a/app/javascript/mastodon/locales/no.json b/app/javascript/mastodon/locales/no.json index 4ac9c497b05..2589d3fee32 100644 --- a/app/javascript/mastodon/locales/no.json +++ b/app/javascript/mastodon/locales/no.json @@ -13,6 +13,7 @@ "account.posts": "Innlegg", "account.report": "Rapportér @{name}", "account.requested": "Venter på godkjennelse", + "account.share": "Share @{name}'s profile", "account.unblock": "Avblokker @{name}", "account.unblock_domain": "Vis {domain}", "account.unfollow": "Avfølg", diff --git a/app/javascript/mastodon/locales/oc.json b/app/javascript/mastodon/locales/oc.json index ad5a6ace40e..190428bda8c 100644 --- a/app/javascript/mastodon/locales/oc.json +++ b/app/javascript/mastodon/locales/oc.json @@ -13,6 +13,7 @@ "account.posts": "Estatuts", "account.report": "Senhalar @{name}", "account.requested": "Invitacion mandada", + "account.share": "Share @{name}'s profile", "account.unblock": "Desblocar @{name}", "account.unblock_domain": "Desblocar {domain}", "account.unfollow": "Quitar de sègre", diff --git a/app/javascript/mastodon/locales/pl.json b/app/javascript/mastodon/locales/pl.json index 53ec58d9da0..0deb744e9bd 100644 --- a/app/javascript/mastodon/locales/pl.json +++ b/app/javascript/mastodon/locales/pl.json @@ -13,6 +13,7 @@ "account.posts": "Posty", "account.report": "Zgłoś @{name}", "account.requested": "Oczekująca prośba", + "account.share": "Share @{name}'s profile", "account.unblock": "Odblokuj @{name}", "account.unblock_domain": "Odblokuj domenę {domain}", "account.unfollow": "Przestań śledzić", diff --git a/app/javascript/mastodon/locales/pt-BR.json b/app/javascript/mastodon/locales/pt-BR.json index 7483a913dd0..fce3aaaa04e 100644 --- a/app/javascript/mastodon/locales/pt-BR.json +++ b/app/javascript/mastodon/locales/pt-BR.json @@ -13,6 +13,7 @@ "account.posts": "Posts", "account.report": "Denunciar @{name}", "account.requested": "A aguardar aprovação", + "account.share": "Share @{name}'s profile", "account.unblock": "Não bloquear @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Deixar de seguir", diff --git a/app/javascript/mastodon/locales/pt.json b/app/javascript/mastodon/locales/pt.json index 7483a913dd0..fce3aaaa04e 100644 --- a/app/javascript/mastodon/locales/pt.json +++ b/app/javascript/mastodon/locales/pt.json @@ -13,6 +13,7 @@ "account.posts": "Posts", "account.report": "Denunciar @{name}", "account.requested": "A aguardar aprovação", + "account.share": "Share @{name}'s profile", "account.unblock": "Não bloquear @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Deixar de seguir", diff --git a/app/javascript/mastodon/locales/ru.json b/app/javascript/mastodon/locales/ru.json index 3fe1f5eca61..90ab15de076 100644 --- a/app/javascript/mastodon/locales/ru.json +++ b/app/javascript/mastodon/locales/ru.json @@ -13,6 +13,7 @@ "account.posts": "Посты", "account.report": "Пожаловаться", "account.requested": "Ожидает подтверждения", + "account.share": "Share @{name}'s profile", "account.unblock": "Разблокировать", "account.unblock_domain": "Разблокировать {domain}", "account.unfollow": "Отписаться", diff --git a/app/javascript/mastodon/locales/th.json b/app/javascript/mastodon/locales/th.json index fb64a1074fa..e0b680b064a 100644 --- a/app/javascript/mastodon/locales/th.json +++ b/app/javascript/mastodon/locales/th.json @@ -13,6 +13,7 @@ "account.posts": "Posts", "account.report": "Report @{name}", "account.requested": "Awaiting approval", + "account.share": "Share @{name}'s profile", "account.unblock": "Unblock @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Unfollow", diff --git a/app/javascript/mastodon/locales/tr.json b/app/javascript/mastodon/locales/tr.json index 565b90b3ca4..4c728c57a72 100644 --- a/app/javascript/mastodon/locales/tr.json +++ b/app/javascript/mastodon/locales/tr.json @@ -13,6 +13,7 @@ "account.posts": "Gönderiler", "account.report": "Rapor et @{name}", "account.requested": "Onay bekleniyor", + "account.share": "Share @{name}'s profile", "account.unblock": "Engeli kaldır @{name}", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "Takipten vazgeç", diff --git a/app/javascript/mastodon/locales/uk.json b/app/javascript/mastodon/locales/uk.json index 761910976c4..e8ea1101ae9 100644 --- a/app/javascript/mastodon/locales/uk.json +++ b/app/javascript/mastodon/locales/uk.json @@ -13,6 +13,7 @@ "account.posts": "Пости", "account.report": "Поскаржитися", "account.requested": "Очікує підтвердження", + "account.share": "Share @{name}'s profile", "account.unblock": "Розблокувати", "account.unblock_domain": "Розблокувати {domain}", "account.unfollow": "Відписатися", diff --git a/app/javascript/mastodon/locales/zh-CN.json b/app/javascript/mastodon/locales/zh-CN.json index 37bca74bead..98e963bee46 100644 --- a/app/javascript/mastodon/locales/zh-CN.json +++ b/app/javascript/mastodon/locales/zh-CN.json @@ -13,6 +13,7 @@ "account.posts": "嘟文", "account.report": "举报 @{name}", "account.requested": "等待审批", + "account.share": "Share @{name}'s profile", "account.unblock": "解除对 @{name} 的屏蔽", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "取消关注", diff --git a/app/javascript/mastodon/locales/zh-HK.json b/app/javascript/mastodon/locales/zh-HK.json index 8215ab6cacb..b92a88f3bc2 100644 --- a/app/javascript/mastodon/locales/zh-HK.json +++ b/app/javascript/mastodon/locales/zh-HK.json @@ -13,6 +13,7 @@ "account.posts": "文章", "account.report": "舉報 @{name}", "account.requested": "等候審批", + "account.share": "Share @{name}'s profile", "account.unblock": "解除對 @{name} 的封鎖", "account.unblock_domain": "Unhide {domain}", "account.unfollow": "取消關注", diff --git a/app/javascript/mastodon/locales/zh-TW.json b/app/javascript/mastodon/locales/zh-TW.json index 5eb5a43419f..f45be6c5e36 100644 --- a/app/javascript/mastodon/locales/zh-TW.json +++ b/app/javascript/mastodon/locales/zh-TW.json @@ -13,6 +13,7 @@ "account.posts": "貼文", "account.report": "檢舉 @{name}", "account.requested": "正在等待許可", + "account.share": "Share @{name}'s profile", "account.unblock": "取消封鎖 @{name}", "account.unblock_domain": "不再隱藏 {domain}", "account.unfollow": "取消關注",