about summary refs log tree commit diff
path: root/app/javascript/mastodon/features/account_timeline/components/moved_note.js
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-11-18 19:39:02 +0100
committerGitHub <noreply@github.com>2017-11-18 19:39:02 +0100
commit58cede4808baa4db6cc143b80ef23e8179a8415b (patch)
treeacaac099fc46d9293768f9fa70c1d1826d06d7e8 /app/javascript/mastodon/features/account_timeline/components/moved_note.js
parent6be72a3ec6d87af4de245b96fea45191ac01114e (diff)
Profile redirect notes (#5746)
* Serialize moved accounts into REST and ActivityPub APIs

* Parse federated moved accounts from ActivityPub

* Add note about moved accounts to public profiles

* Add moved account message to web UI

* Fix code style issues
Diffstat (limited to 'app/javascript/mastodon/features/account_timeline/components/moved_note.js')
-rw-r--r--app/javascript/mastodon/features/account_timeline/components/moved_note.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/app/javascript/mastodon/features/account_timeline/components/moved_note.js b/app/javascript/mastodon/features/account_timeline/components/moved_note.js
new file mode 100644
index 000000000..1c0e081cc
--- /dev/null
+++ b/app/javascript/mastodon/features/account_timeline/components/moved_note.js
@@ -0,0 +1,48 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import ImmutablePropTypes from 'react-immutable-proptypes';
+import { FormattedMessage } from 'react-intl';
+import ImmutablePureComponent from 'react-immutable-pure-component';
+import AvatarOverlay from '../../../components/avatar_overlay';
+import DisplayName from '../../../components/display_name';
+
+export default class MovedNote extends ImmutablePureComponent {
+
+  static contextTypes = {
+    router: PropTypes.object,
+  };
+
+  static propTypes = {
+    from: ImmutablePropTypes.map.isRequired,
+    to: ImmutablePropTypes.map.isRequired,
+  };
+
+  handleAccountClick = e => {
+    if (e.button === 0) {
+      e.preventDefault();
+      this.context.router.history.push(`/accounts/${this.props.to.get('id')}`);
+    }
+
+    e.stopPropagation();
+  }
+
+  render () {
+    const { from, to } = this.props;
+    const displayNameHtml = { __html: from.get('display_name_html') };
+
+    return (
+      <div className='account__moved-note'>
+        <div className='account__moved-note__message'>
+          <div className='account__moved-note__icon-wrapper'><i className='fa fa-fw fa-suitcase account__moved-note__icon' /></div>
+          <FormattedMessage id='account.moved_to' defaultMessage='{name} has moved to:' values={{ name: <strong dangerouslySetInnerHTML={displayNameHtml} /> }} />
+        </div>
+
+        <a href={to.get('url')} onClick={this.handleAccountClick} className='detailed-status__display-name'>
+          <div className='detailed-status__display-avatar'><AvatarOverlay account={to} friend={from} /></div>
+          <DisplayName account={to} />
+        </a>
+      </div>
+    );
+  }
+
+}