mastodon/app/javascript/glitch/components/notification/follow.js

73 lines
2 KiB
JavaScript
Raw Normal View History

2017-09-20 21:51:45 +00:00
// `<NotificationFollow>`
// ======================
2017-07-14 18:13:02 +00:00
2017-09-20 21:51:45 +00:00
// * * * * * * * //
2017-07-14 18:13:02 +00:00
2017-09-20 21:51:45 +00:00
// Imports
// -------
2017-07-14 18:13:02 +00:00
2017-09-20 21:51:45 +00:00
// Package imports.
2017-07-14 18:13:02 +00:00
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
2017-07-14 18:13:02 +00:00
import ImmutablePureComponent from 'react-immutable-pure-component';
2017-09-20 21:51:45 +00:00
// Mastodon imports.
2017-07-14 18:13:02 +00:00
import Permalink from '../../../mastodon/components/permalink';
import AccountContainer from '../../../mastodon/containers/account_container';
2017-09-20 21:51:45 +00:00
// Our imports.
import NotificationOverlayContainer from '../notification/overlay/container';
2017-07-14 18:13:02 +00:00
2017-09-20 21:51:45 +00:00
// * * * * * * * //
2017-07-14 18:13:02 +00:00
2017-09-20 21:51:45 +00:00
// Implementation
// --------------
2017-07-14 18:13:02 +00:00
export default class NotificationFollow extends ImmutablePureComponent {
static propTypes = {
id : PropTypes.string.isRequired,
2017-07-14 18:13:02 +00:00
account : ImmutablePropTypes.map.isRequired,
notification : ImmutablePropTypes.map.isRequired,
2017-07-14 18:13:02 +00:00
};
render () {
const { account, notification } = this.props;
2017-07-14 18:13:02 +00:00
2017-09-20 21:51:45 +00:00
// Links to the display name.
const displayName = account.get('display_name_html') || account.get('username');
2017-07-14 18:13:02 +00:00
const link = (
<Permalink
className='notification__display-name'
href={account.get('url')}
title={account.get('acct')}
to={`/accounts/${account.get('id')}`}
dangerouslySetInnerHTML={{ __html: displayName }}
2017-07-14 18:13:02 +00:00
/>
);
2017-09-20 21:51:45 +00:00
// Renders.
2017-07-14 18:13:02 +00:00
return (
<div className='notification notification-follow'>
<div className='notification__message'>
<div className='notification__favourite-icon-wrapper'>
<i className='fa fa-fw fa-user-plus' />
</div>
<FormattedMessage
id='notification.follow'
defaultMessage='{name} followed you'
values={{ name: link }}
/>
</div>
<AccountContainer id={account.get('id')} withNote={false} />
<NotificationOverlayContainer notification={notification} />
2017-07-14 18:13:02 +00:00
</div>
);
}
}