Browse Source

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
pull/4/head
Sorin Davidoi 6 years ago
committed by Eugen Rochko
parent
commit
9004151e34
34 changed files with 62 additions and 0 deletions
  1. +10
    -0
      app/javascript/mastodon/features/account/components/action_bar.js
  2. +13
    -0
      app/javascript/mastodon/features/status/components/action_bar.js
  3. +1
    -0
      app/javascript/mastodon/locales/ar.json
  4. +1
    -0
      app/javascript/mastodon/locales/bg.json
  5. +1
    -0
      app/javascript/mastodon/locales/ca.json
  6. +1
    -0
      app/javascript/mastodon/locales/de.json
  7. +8
    -0
      app/javascript/mastodon/locales/defaultMessages.json
  8. +1
    -0
      app/javascript/mastodon/locales/en.json
  9. +1
    -0
      app/javascript/mastodon/locales/eo.json
  10. +1
    -0
      app/javascript/mastodon/locales/es.json
  11. +1
    -0
      app/javascript/mastodon/locales/fa.json
  12. +1
    -0
      app/javascript/mastodon/locales/fi.json
  13. +1
    -0
      app/javascript/mastodon/locales/fr.json
  14. +1
    -0
      app/javascript/mastodon/locales/he.json
  15. +1
    -0
      app/javascript/mastodon/locales/hr.json
  16. +1
    -0
      app/javascript/mastodon/locales/hu.json
  17. +1
    -0
      app/javascript/mastodon/locales/id.json
  18. +1
    -0
      app/javascript/mastodon/locales/io.json
  19. +1
    -0
      app/javascript/mastodon/locales/it.json
  20. +1
    -0
      app/javascript/mastodon/locales/ja.json
  21. +1
    -0
      app/javascript/mastodon/locales/ko.json
  22. +1
    -0
      app/javascript/mastodon/locales/nl.json
  23. +1
    -0
      app/javascript/mastodon/locales/no.json
  24. +1
    -0
      app/javascript/mastodon/locales/oc.json
  25. +1
    -0
      app/javascript/mastodon/locales/pl.json
  26. +1
    -0
      app/javascript/mastodon/locales/pt-BR.json
  27. +1
    -0
      app/javascript/mastodon/locales/pt.json
  28. +1
    -0
      app/javascript/mastodon/locales/ru.json
  29. +1
    -0
      app/javascript/mastodon/locales/th.json
  30. +1
    -0
      app/javascript/mastodon/locales/tr.json
  31. +1
    -0
      app/javascript/mastodon/locales/uk.json
  32. +1
    -0
      app/javascript/mastodon/locales/zh-CN.json
  33. +1
    -0
      app/javascript/mastodon/locales/zh-HK.json
  34. +1
    -0
      app/javascript/mastodon/locales/zh-TW.json

+ 10
- 0
app/javascript/mastodon/features/account/components/action_bar.js View File

@ -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);

+ 13
- 0
app/javascript/mastodon/features/status/components/action_bar.js View File

@ -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' />

+ 1
- 0
app/javascript/mastodon/locales/ar.json View File

@ -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": "إلغاء المتابعة",

+ 1
- 0
app/javascript/mastodon/locales/bg.json View File

@ -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": "Не следвай",

+ 1
- 0
app/javascript/mastodon/locales/ca.json View File

@ -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",

+ 1
- 0
app/javascript/mastodon/locales/de.json View File

@ -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",

+ 8
- 0
app/javascript/mastodon/locales/defaultMessages.json View File

@ -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"

+ 1
- 0
app/javascript/mastodon/locales/en.json View File

@ -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",

+ 1
- 0
app/javascript/mastodon/locales/eo.json View File

@ -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",

+ 1
- 0
app/javascript/mastodon/locales/es.json View File

@ -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",

+ 1
- 0
app/javascript/mastodon/locales/fa.json View File

@ -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": "پایان پیگیری",

+ 1
- 0
app/javascript/mastodon/locales/fi.json View File

@ -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",

+ 1
- 0
app/javascript/mastodon/locales/fr.json View File

@ -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",

+ 1
- 0
app/javascript/mastodon/locales/he.json View File

@ -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": "הפסקת מעקב",

+ 1
- 0
app/javascript/mastodon/locales/hr.json View File

@ -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",

+ 1
- 0
app/javascript/mastodon/locales/hu.json View File

@ -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",

+ 1
- 0
app/javascript/mastodon/locales/id.json View File

@ -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",

+ 1
- 0
app/javascript/mastodon/locales/io.json View File

@ -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",

+ 1
- 0
app/javascript/mastodon/locales/it.json View File

@ -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",

+ 1
- 0
app/javascript/mastodon/locales/ja.json View File

@ -13,6 +13,7 @@
"account.posts": "投稿",
"account.report": "通報",
"account.requested": "承認待ち",
"account.share": "Share @{name}'s profile",
"account.unblock": "ブロック解除",
"account.unblock_domain": "{domain}を表示",
"account.unfollow": "フォロー解除",

+ 1
- 0
app/javascript/mastodon/locales/ko.json View File

@ -13,6 +13,7 @@
"account.posts": "포스트",
"account.report": "신고",
"account.requested": "승인 대기 중",
"account.share": "Share @{name}'s profile",
"account.unblock": "차단 해제",
"account.unblock_domain": "{domain} 숨김 해제",
"account.unfollow": "팔로우 해제",

+ 1
- 0
app/javascript/mastodon/locales/nl.json View File

@ -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",

+ 1
- 0
app/javascript/mastodon/locales/no.json View File

@ -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",

+ 1
- 0
app/javascript/mastodon/locales/oc.json View File

@ -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",

+ 1
- 0
app/javascript/mastodon/locales/pl.json View File

@ -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ć",

+ 1
- 0
app/javascript/mastodon/locales/pt-BR.json View File

@ -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",

+ 1
- 0
app/javascript/mastodon/locales/pt.json View File

@ -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",

+ 1
- 0
app/javascript/mastodon/locales/ru.json View File

@ -13,6 +13,7 @@
"account.posts": "Посты",
"account.report": "Пожаловаться",
"account.requested": "Ожидает подтверждения",
"account.share": "Share @{name}'s profile",
"account.unblock": "Разблокировать",
"account.unblock_domain": "Разблокировать {domain}",
"account.unfollow": "Отписаться",

+ 1
- 0
app/javascript/mastodon/locales/th.json View File

@ -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",

+ 1
- 0
app/javascript/mastodon/locales/tr.json View File

@ -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ç",

+ 1
- 0
app/javascript/mastodon/locales/uk.json View File

@ -13,6 +13,7 @@
"account.posts": "Пости",
"account.report": "Поскаржитися",
"account.requested": "Очікує підтвердження",
"account.share": "Share @{name}'s profile",
"account.unblock": "Розблокувати",
"account.unblock_domain": "Розблокувати {domain}",
"account.unfollow": "Відписатися",

+ 1
- 0
app/javascript/mastodon/locales/zh-CN.json View File

@ -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": "取消关注",

+ 1
- 0
app/javascript/mastodon/locales/zh-HK.json View File

@ -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": "取消關注",

+ 1
- 0
app/javascript/mastodon/locales/zh-TW.json View File

@ -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": "取消關注",

Loading…
Cancel
Save