Skip to content

Commit e61d172

Browse files
committed
Redesign follow request notification
1 parent 159c4ba commit e61d172

4 files changed

Lines changed: 90 additions & 10 deletions

File tree

app/javascript/mastodon/features/follow_requests/components/account_authorize.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,11 @@ class AccountAuthorize extends ImmutablePureComponent {
2020
account: ImmutablePropTypes.map.isRequired,
2121
onAuthorize: PropTypes.func.isRequired,
2222
onReject: PropTypes.func.isRequired,
23-
withNote: PropTypes.bool,
2423
intl: PropTypes.object.isRequired,
2524
};
2625

27-
static defaultProps = {
28-
showNote: true,
29-
};
30-
3126
render () {
32-
const { intl, account, onAuthorize, onReject, withNote } = this.props;
27+
const { intl, account, onAuthorize, onReject } = this.props;
3328
const content = { __html: account.get('note_emojified') };
3429

3530
return (
@@ -40,7 +35,7 @@ class AccountAuthorize extends ImmutablePureComponent {
4035
<DisplayName account={account} />
4136
</Permalink>
4237

43-
{withNote && <div className='account__header__content' dangerouslySetInnerHTML={content} />}
38+
<div className='account__header__content' dangerouslySetInnerHTML={content} />
4439
</div>
4540

4641
<div className='account--panel'>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import React, { Fragment } from 'react';
2+
import ImmutablePropTypes from 'react-immutable-proptypes';
3+
import PropTypes from 'prop-types';
4+
import Avatar from 'mastodon/components/avatar';
5+
import DisplayName from 'mastodon/components/display_name';
6+
import Permalink from 'mastodon/components/permalink';
7+
import IconButton from 'mastodon/components/icon_button';
8+
import { defineMessages, injectIntl } from 'react-intl';
9+
import ImmutablePureComponent from 'react-immutable-pure-component';
10+
11+
const messages = defineMessages({
12+
authorize: { id: 'follow_request.authorize', defaultMessage: 'Authorize' },
13+
reject: { id: 'follow_request.reject', defaultMessage: 'Reject' },
14+
});
15+
16+
export default @injectIntl
17+
class FollowRequest extends ImmutablePureComponent {
18+
19+
static propTypes = {
20+
account: ImmutablePropTypes.map.isRequired,
21+
onAuthorize: PropTypes.func.isRequired,
22+
onReject: PropTypes.func.isRequired,
23+
intl: PropTypes.object.isRequired,
24+
};
25+
26+
render () {
27+
const { intl, hidden, account, onAuthorize, onReject } = this.props;
28+
29+
if (!account) {
30+
return <div />;
31+
}
32+
33+
if (hidden) {
34+
return (
35+
<Fragment>
36+
{account.get('display_name')}
37+
{account.get('username')}
38+
</Fragment>
39+
);
40+
}
41+
42+
return (
43+
<div className='account'>
44+
<div className='account__wrapper'>
45+
<Permalink key={account.get('id')} className='account__display-name' title={account.get('acct')} href={account.get('url')} to={`/accounts/${account.get('id')}`}>
46+
<div className='account__avatar-wrapper'><Avatar account={account} size={36} /></div>
47+
<DisplayName account={account} />
48+
</Permalink>
49+
50+
<div className='account__relationship'>
51+
<IconButton title={intl.formatMessage(messages.authorize)} icon='check' onClick={onAuthorize} />
52+
<IconButton title={intl.formatMessage(messages.reject)} icon='times' onClick={onReject} />
53+
</div>
54+
</div>
55+
</div>
56+
);
57+
}
58+
59+
}

app/javascript/mastodon/features/notifications/components/notification.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
77
import { me } from 'mastodon/initial_state';
88
import StatusContainer from 'mastodon/containers/status_container';
99
import AccountContainer from 'mastodon/containers/account_container';
10-
import AccountAuthorizeContainer from 'mastodon/features/follow_requests/containers/account_authorize_container';
10+
import FollowRequestContainer from '../containers/follow_request_container';
1111
import Icon from 'mastodon/components/icon';
1212
import Permalink from 'mastodon/components/permalink';
1313

@@ -128,7 +128,7 @@ class Notification extends ImmutablePureComponent {
128128
</span>
129129
</div>
130130

131-
<AccountContainer id={account.get('id')} withNote={false} hidden={this.props.hidden} />
131+
<AccountContainer id={account.get('id')} hidden={this.props.hidden} />
132132
</div>
133133
</HotKeys>
134134
);
@@ -150,7 +150,7 @@ class Notification extends ImmutablePureComponent {
150150
</span>
151151
</div>
152152

153-
<AccountAuthorizeContainer id={account.get('id')} withNote={false} hidden={this.props.hidden} />
153+
<FollowRequestContainer id={account.get('id')} withNote={false} hidden={this.props.hidden} />
154154
</div>
155155
</HotKeys>
156156
);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { connect } from 'react-redux';
2+
import { makeGetAccount } from 'mastodon/selectors';
3+
import FollowRequest from '../components/follow_request';
4+
import { authorizeFollowRequest, rejectFollowRequest } from 'mastodon/actions/accounts';
5+
6+
const makeMapStateToProps = () => {
7+
const getAccount = makeGetAccount();
8+
9+
const mapStateToProps = (state, props) => ({
10+
account: getAccount(state, props.id),
11+
});
12+
13+
return mapStateToProps;
14+
};
15+
16+
const mapDispatchToProps = (dispatch, { id }) => ({
17+
onAuthorize () {
18+
dispatch(authorizeFollowRequest(id));
19+
},
20+
21+
onReject () {
22+
dispatch(rejectFollowRequest(id));
23+
},
24+
});
25+
26+
export default connect(makeMapStateToProps, mapDispatchToProps)(FollowRequest);

0 commit comments

Comments
 (0)