diff options
author | Sorin Davidoi <sorin.davidoi@gmail.com> | 2017-07-28 00:55:15 +0200 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-07-28 00:55:15 +0200 |
commit | 9004151e340f1d8080b415afc3668437de32ebc2 (patch) | |
tree | 0d31798c8cf2d31c6d57c4f8cd9957e2abd4efd9 /app/javascript | |
parent | 6884dd79ba8909e17cc6d48e658775fcf7f87890 (diff) |
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
Diffstat (limited to 'app/javascript')
34 files changed, 62 insertions, 0 deletions
diff --git a/app/javascript/mastodon/features/account/components/action_bar.js b/app/javascript/mastodon/features/account/components/action_bar.js index b773045fb..c12c0889e 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 c4d4bb747..91ac64de2 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' && ( + <div className='detailed-status__button'><IconButton title={intl.formatMessage(messages.share)} icon='share-alt' onClick={this.handleShare} /></div> + ); + 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 { <div className='detailed-status__button'><IconButton title={intl.formatMessage(messages.reply)} icon={status.get('in_reply_to_id', null) === null ? 'reply' : 'reply-all'} onClick={this.handleReplyClick} /></div> <div className='detailed-status__button'><IconButton disabled={reblog_disabled} active={status.get('reblogged')} title={reblog_disabled ? intl.formatMessage(messages.cannot_reblog) : intl.formatMessage(messages.reblog)} icon={reblogIcon} onClick={this.handleReblogClick} /></div> <div className='detailed-status__button'><IconButton animate active={status.get('favourited')} title={intl.formatMessage(messages.favourite)} icon='star' onClick={this.handleFavouriteClick} activeStyle={{ color: '#ca8f04' }} /></div> + {shareButton} <div className='detailed-status__action-bar-dropdown'> <DropdownMenuContainer size={18} icon='ellipsis-h' items={menu} direction='left' ariaLabel='More' /> diff --git a/app/javascript/mastodon/locales/ar.json b/app/javascript/mastodon/locales/ar.json index b21bec4aa..089cc3245 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 9b6c1bc04..ba19de1b5 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 195e1e7f9..3d2620be5 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 473a97ec4..cf74ce081 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 db635c975..bc1c7b8b7 100644 --- a/app/javascript/mastodon/locales/defaultMessages.json +++ b/app/javascript/mastodon/locales/defaultMessages.json @@ -375,6 +375,10 @@ "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 3297effd0..70c95d027 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 a148ba3ab..e7e521060 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 c4e9220ad..3d27bd0fc 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 17b957387..1b533114a 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 1ed9e4e7c..0c95f5fd2 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 5cb5871d4..5d7896c8c 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 d25922401..724a18cde 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 05b670004..b4625c1d4 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 2d03afcb8..8a50889f3 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 65286dcf1..8c775d765 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 7255436e0..dc29dc8ab 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 27096f4e1..ceeaae843 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 e18686a25..dd92e9053 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 597f17aea..e06ac583c 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 f90431383..c477e79d8 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 4ac9c497b..2589d3fee 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 ad5a6ace4..190428bda 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 53ec58d9d..0deb744e9 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 7483a913d..fce3aaaa0 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 7483a913d..fce3aaaa0 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 3fe1f5eca..90ab15de0 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 fb64a1074..e0b680b06 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 565b90b3c..4c728c57a 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 761910976..e8ea1101a 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 37bca74be..98e963bee 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 8215ab6ca..b92a88f3b 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 5eb5a4341..f45be6c5e 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": "取消關注", |