Change design of notification about lost connections in web UI (#29731)
This commit is contained in:
		
					parent
					
						
							
								dd061291b1
							
						
					
				
			
			
				commit
				
					
						29f9dc742e
					
				
			
		
					 4 changed files with 79 additions and 60 deletions
				
			
		|  | @ -12,7 +12,6 @@ import { HotKeys } from 'react-hotkeys'; | |||
| 
 | ||||
| import EditIcon from '@/material-icons/400-24px/edit.svg?react'; | ||||
| import FlagIcon from '@/material-icons/400-24px/flag-fill.svg?react'; | ||||
| import HeartBrokenIcon from '@/material-icons/400-24px/heart_broken-fill.svg?react'; | ||||
| import HomeIcon from '@/material-icons/400-24px/home-fill.svg?react'; | ||||
| import InsertChartIcon from '@/material-icons/400-24px/insert_chart.svg?react'; | ||||
| import PersonIcon from '@/material-icons/400-24px/person-fill.svg?react'; | ||||
|  | @ -27,7 +26,7 @@ import { WithRouterPropTypes } from 'mastodon/utils/react_router'; | |||
| 
 | ||||
| import FollowRequestContainer from '../containers/follow_request_container'; | ||||
| 
 | ||||
| import RelationshipsSeveranceEvent from './relationships_severance_event'; | ||||
| import { RelationshipsSeveranceEvent } from './relationships_severance_event'; | ||||
| import Report from './report'; | ||||
| 
 | ||||
| const messages = defineMessages({ | ||||
|  | @ -40,6 +39,7 @@ const messages = defineMessages({ | |||
|   update: { id: 'notification.update', defaultMessage: '{name} edited a post' }, | ||||
|   adminSignUp: { id: 'notification.admin.sign_up', defaultMessage: '{name} signed up' }, | ||||
|   adminReport: { id: 'notification.admin.report', defaultMessage: '{name} reported {target}' }, | ||||
|   relationshipsSevered: { id: 'notification.relationships_severance_event', defaultMessage: 'Lost connections with {name}' }, | ||||
| }); | ||||
| 
 | ||||
| const notificationForScreenReader = (intl, message, timestamp) => { | ||||
|  | @ -361,24 +361,23 @@ class Notification extends ImmutablePureComponent { | |||
|   } | ||||
| 
 | ||||
|   renderRelationshipsSevered (notification) { | ||||
|     const { intl, unread } = this.props; | ||||
|     const { intl, unread, hidden } = this.props; | ||||
|     const event = notification.get('event'); | ||||
| 
 | ||||
|     if (!notification.get('event')) { | ||||
|     if (!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='heart_broken' icon={HeartBrokenIcon} /> | ||||
| 
 | ||||
|             <span title={notification.get('created_at')}> | ||||
|               <FormattedMessage id='notification.severed_relationships' defaultMessage='Relationships with {name} severed' values={{ name: notification.getIn(['event', 'target_name']) }} /> | ||||
|             </span> | ||||
|           </div> | ||||
| 
 | ||||
|           <RelationshipsSeveranceEvent event={notification.get('event')} /> | ||||
|         <div className={classNames('notification notification-severed-relationships focusable', { unread })} tabIndex={0} aria-label={notificationForScreenReader(intl, intl.formatMessage(messages.relationshipsSevered, { name: notification.getIn(['event', 'target_name']) }), notification.get('created_at'))}> | ||||
|           <RelationshipsSeveranceEvent | ||||
|             type={event.get('type')} | ||||
|             target={event.get('target_name')} | ||||
|             followersCount={event.get('followers_count')} | ||||
|             followingCount={event.get('following_count')} | ||||
|             hidden={hidden} | ||||
|           /> | ||||
|         </div> | ||||
|       </HotKeys> | ||||
|     ); | ||||
|  |  | |||
|  | @ -2,60 +2,44 @@ import PropTypes from 'prop-types'; | |||
| 
 | ||||
| import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; | ||||
| 
 | ||||
| import ImmutablePropTypes from 'react-immutable-proptypes'; | ||||
| import HeartBrokenIcon from '@/material-icons/400-24px/heart_broken-fill.svg?react'; | ||||
| import { Icon }  from 'mastodon/components/icon'; | ||||
| import { domain } from 'mastodon/initial_state'; | ||||
| 
 | ||||
| import { RelativeTimestamp } from 'mastodon/components/relative_timestamp'; | ||||
| 
 | ||||
| // This needs to be kept in sync with app/models/relationship_severance_event.rb | ||||
| // This needs to be kept in sync with app/models/relationships_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' }, | ||||
|   account_suspension: { id: 'notification.relationships_severance_event.account_suspension', defaultMessage: 'An admin from {from} has suspended {target}, which means you can no longer receive updates from them or interact with them.' }, | ||||
|   domain_block: { id: 'notification.relationships_severance_event.domain_block', defaultMessage: 'An admin from {from} has blocked {target}, including {followersCount} of your followers and {followingCount, plural, one {# account} other {# accounts}} you follow.' }, | ||||
|   user_domain_block: { id: 'notification.relationships_severance_event.user_domain_block', defaultMessage: 'You have blocked {target}, removing {followersCount} of your followers and {followingCount, plural, one {# account} other {# accounts}} you follow.' }, | ||||
| }); | ||||
| 
 | ||||
| const RelationshipsSeveranceEvent = ({ event, hidden }) => { | ||||
| export const RelationshipsSeveranceEvent = ({ type, target, followingCount, followersCount, hidden }) => { | ||||
|   const intl = useIntl(); | ||||
| 
 | ||||
|   if (hidden || !event) { | ||||
|   if (hidden) { | ||||
|     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('followers_count', 0) + event.get('following_count', 0) }} | ||||
|             /> | ||||
|           )} | ||||
|           <br /> | ||||
|           <strong>{intl.formatMessage(messages[event.get('type')])}</strong> | ||||
|         </div> | ||||
|     <a href='/severed_relationships' target='_blank' rel='noopener noreferrer' className='notification__relationships-severance-event'> | ||||
|       <Icon id='heart_broken' icon={HeartBrokenIcon} /> | ||||
| 
 | ||||
|         <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 className='notification__relationships-severance-event__content'> | ||||
|         <p>{intl.formatMessage(messages[type], { from: <strong>{domain}</strong>, target: <strong>{target}</strong>, followingCount, followersCount })}</p> | ||||
|         <span className='link-button'><FormattedMessage id='notification.relationships_severance_event.learn_more' defaultMessage='Learn more' /></span> | ||||
|       </div> | ||||
|     </div> | ||||
|     </a> | ||||
|   ); | ||||
| 
 | ||||
| }; | ||||
| 
 | ||||
| RelationshipsSeveranceEvent.propTypes = { | ||||
|   event: ImmutablePropTypes.map.isRequired, | ||||
|   type: PropTypes.oneOf([ | ||||
|     'account_suspension', | ||||
|     'domain_block', | ||||
|     'user_domain_block', | ||||
|   ]).isRequired, | ||||
|   target: PropTypes.string.isRequired, | ||||
|   followersCount: PropTypes.number.isRequired, | ||||
|   followingCount: PropTypes.number.isRequired, | ||||
|   hidden: PropTypes.bool, | ||||
| }; | ||||
| 
 | ||||
| export default RelationshipsSeveranceEvent; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue