diff --git a/app/javascript/flavours/glitch/features/notifications/components/notification.jsx b/app/javascript/flavours/glitch/features/notifications/components/notification.jsx index 4aac5e8d6d..c0d0a30eeb 100644 --- a/app/javascript/flavours/glitch/features/notifications/components/notification.jsx +++ b/app/javascript/flavours/glitch/features/notifications/components/notification.jsx @@ -11,6 +11,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component'; import { HotKeys } from 'react-hotkeys'; 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 PersonAddIcon from '@/material-icons/400-24px/person_add-fill.svg?react'; 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 NotificationOverlayContainer from '../containers/overlay_container'; +import RelationshipsSeveranceEvent from './relationships_severance_event'; import Report from './report'; const messages = defineMessages({ 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' }, 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 ( + +
+
+ + + + + +
+ + +
+
+ ); + } + renderAdminSignUp (notification, account, link) { const { intl, unread } = this.props; @@ -396,6 +423,8 @@ class Notification extends ImmutablePureComponent { return this.renderUpdate(notification); case 'poll': return this.renderPoll(notification); + case 'severed_relationships': + return this.renderRelationshipsSevered(notification); case 'admin.sign_up': return this.renderAdminSignUp(notification, account, link); case 'admin.report': diff --git a/app/javascript/flavours/glitch/features/notifications/components/relationships_severance_event.jsx b/app/javascript/flavours/glitch/features/notifications/components/relationships_severance_event.jsx new file mode 100644 index 0000000000..62da3102fb --- /dev/null +++ b/app/javascript/flavours/glitch/features/notifications/components/relationships_severance_event.jsx @@ -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 ( +
+
+
+ + {' ยท '} + { event.get('purged') ? ( + + ) : ( + + )} +
+ {intl.formatMessage(messages[event.get('type')])} +
+ +
+ + + +
+
+
+ ); + +}; + +RelationshipsSeveranceEvent.propTypes = { + event: ImmutablePropTypes.map.isRequired, + hidden: PropTypes.bool, +}; + +export default RelationshipsSeveranceEvent; diff --git a/app/javascript/flavours/glitch/reducers/notifications.js b/app/javascript/flavours/glitch/reducers/notifications.js index c6d70945ba..14862bef07 100644 --- a/app/javascript/flavours/glitch/reducers/notifications.js +++ b/app/javascript/flavours/glitch/reducers/notifications.js @@ -61,6 +61,7 @@ export const notificationToMap = (notification, markForDelete = false) => Immuta markedForDelete: markForDelete, status: notification.status ? notification.status.id : null, report: notification.report ? fromJS(notification.report) : null, + event: notification.event ? fromJS(notification.event) : null, }); const normalizeNotification = (state, notification, usePendingItems) => {