mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-25 06:13:43 +01:00
[Glitch] Add notifications of severed relationships
Port 44bf7b8128
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
f2b23aa5f3
commit
0f966209ca
3 changed files with 91 additions and 0 deletions
|
@ -11,6 +11,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
import { HotKeys } from 'react-hotkeys';
|
import { HotKeys } from 'react-hotkeys';
|
||||||
|
|
||||||
import FlagIcon from '@/material-icons/400-24px/flag-fill.svg?react';
|
import FlagIcon from '@/material-icons/400-24px/flag-fill.svg?react';
|
||||||
|
import LinkOffIcon from '@/material-icons/400-24px/link_off.svg?react';
|
||||||
import PersonIcon from '@/material-icons/400-24px/person-fill.svg?react';
|
import PersonIcon from '@/material-icons/400-24px/person-fill.svg?react';
|
||||||
import PersonAddIcon from '@/material-icons/400-24px/person_add-fill.svg?react';
|
import PersonAddIcon from '@/material-icons/400-24px/person_add-fill.svg?react';
|
||||||
import { Icon } from 'flavours/glitch/components/icon';
|
import { Icon } from 'flavours/glitch/components/icon';
|
||||||
|
@ -22,10 +23,12 @@ import { WithRouterPropTypes } from 'flavours/glitch/utils/react_router';
|
||||||
import FollowRequestContainer from '../containers/follow_request_container';
|
import FollowRequestContainer from '../containers/follow_request_container';
|
||||||
import NotificationOverlayContainer from '../containers/overlay_container';
|
import NotificationOverlayContainer from '../containers/overlay_container';
|
||||||
|
|
||||||
|
import RelationshipsSeveranceEvent from './relationships_severance_event';
|
||||||
import Report from './report';
|
import Report from './report';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
follow: { id: 'notification.follow', defaultMessage: '{name} followed you' },
|
follow: { id: 'notification.follow', defaultMessage: '{name} followed you' },
|
||||||
|
severedRelationships: { id: 'notification.severed_relationships', defaultMessage: 'Relationships with {name} severed' },
|
||||||
adminSignUp: { id: 'notification.admin.sign_up', defaultMessage: '{name} signed up' },
|
adminSignUp: { id: 'notification.admin.sign_up', defaultMessage: '{name} signed up' },
|
||||||
adminReport: { id: 'notification.admin.report', defaultMessage: '{name} reported {target}' },
|
adminReport: { id: 'notification.admin.report', defaultMessage: '{name} reported {target}' },
|
||||||
});
|
});
|
||||||
|
@ -303,6 +306,30 @@ class Notification extends ImmutablePureComponent {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderRelationshipsSevered (notification) {
|
||||||
|
const { intl, unread } = this.props;
|
||||||
|
|
||||||
|
if (!notification.get('event')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<HotKeys handlers={this.getHandlers()}>
|
||||||
|
<div className={classNames('notification notification-severed-relationships focusable', { unread })} tabIndex={0} aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.adminReport, { name: notification.getIn(['event', 'target_name']) }), notification.get('created_at'))}>
|
||||||
|
<div className='notification__message'>
|
||||||
|
<Icon id='unlink' icon={LinkOffIcon} />
|
||||||
|
|
||||||
|
<span title={notification.get('created_at')}>
|
||||||
|
<FormattedMessage id='notification.severedRelationships' defaultMessage='Relationships with {name} severed' values={{ name: notification.getIn(['event', 'target_name']) }} />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<RelationshipsSeveranceEvent event={notification.get('event')} />
|
||||||
|
</div>
|
||||||
|
</HotKeys>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
renderAdminSignUp (notification, account, link) {
|
renderAdminSignUp (notification, account, link) {
|
||||||
const { intl, unread } = this.props;
|
const { intl, unread } = this.props;
|
||||||
|
|
||||||
|
@ -396,6 +423,8 @@ class Notification extends ImmutablePureComponent {
|
||||||
return this.renderUpdate(notification);
|
return this.renderUpdate(notification);
|
||||||
case 'poll':
|
case 'poll':
|
||||||
return this.renderPoll(notification);
|
return this.renderPoll(notification);
|
||||||
|
case 'severed_relationships':
|
||||||
|
return this.renderRelationshipsSevered(notification);
|
||||||
case 'admin.sign_up':
|
case 'admin.sign_up':
|
||||||
return this.renderAdminSignUp(notification, account, link);
|
return this.renderAdminSignUp(notification, account, link);
|
||||||
case 'admin.report':
|
case 'admin.report':
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
||||||
|
|
||||||
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
|
||||||
|
import { RelativeTimestamp } from 'flavours/glitch/components/relative_timestamp';
|
||||||
|
|
||||||
|
// This needs to be kept in sync with app/models/relationship_severance_event.rb
|
||||||
|
const messages = defineMessages({
|
||||||
|
account_suspension: { id: 'relationship_severance_notification.types.account_suspension', defaultMessage: 'Account has been suspended' },
|
||||||
|
domain_block: { id: 'relationship_severance_notification.types.domain_block', defaultMessage: 'Domain has been suspended' },
|
||||||
|
user_domain_block: { id: 'relationship_severance_notification.types.user_domain_block', defaultMessage: 'You blocked this domain' },
|
||||||
|
});
|
||||||
|
|
||||||
|
const RelationshipsSeveranceEvent = ({ event, hidden }) => {
|
||||||
|
const intl = useIntl();
|
||||||
|
|
||||||
|
if (hidden || !event) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='notification__report'>
|
||||||
|
<div className='notification__report__details'>
|
||||||
|
<div>
|
||||||
|
<RelativeTimestamp timestamp={event.get('created_at')} short={false} />
|
||||||
|
{' · '}
|
||||||
|
{ event.get('purged') ? (
|
||||||
|
<FormattedMessage
|
||||||
|
id='relationship_severance_notification.purged_data'
|
||||||
|
defaultMessage='purged by administrators'
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<FormattedMessage
|
||||||
|
id='relationship_severance_notification.relationships'
|
||||||
|
defaultMessage='{count, plural, one {# relationship} other {# relationships}}'
|
||||||
|
values={{ count: event.get('relationships_count', 0) }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<br />
|
||||||
|
<strong>{intl.formatMessage(messages[event.get('type')])}</strong>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='notification__report__actions'>
|
||||||
|
<a href='/severed_relationships' className='button' target='_blank' rel='noopener noreferrer'>
|
||||||
|
<FormattedMessage id='relationship_severance_notification.view' defaultMessage='View' />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
RelationshipsSeveranceEvent.propTypes = {
|
||||||
|
event: ImmutablePropTypes.map.isRequired,
|
||||||
|
hidden: PropTypes.bool,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default RelationshipsSeveranceEvent;
|
|
@ -61,6 +61,7 @@ export const notificationToMap = (notification, markForDelete = false) => Immuta
|
||||||
markedForDelete: markForDelete,
|
markedForDelete: markForDelete,
|
||||||
status: notification.status ? notification.status.id : null,
|
status: notification.status ? notification.status.id : null,
|
||||||
report: notification.report ? fromJS(notification.report) : null,
|
report: notification.report ? fromJS(notification.report) : null,
|
||||||
|
event: notification.event ? fromJS(notification.event) : null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const normalizeNotification = (state, notification, usePendingItems) => {
|
const normalizeNotification = (state, notification, usePendingItems) => {
|
||||||
|
|
Loading…
Reference in a new issue