2022-06-27 16:30:15 +09:00
import PropTypes from 'prop-types' ;
2023-05-24 00:15:17 +09:00
2022-06-27 16:30:15 +09:00
import { defineMessages , FormattedMessage , injectIntl } from 'react-intl' ;
2023-05-24 00:15:17 +09:00
import ImmutablePropTypes from 'react-immutable-proptypes' ;
2022-06-27 16:30:15 +09:00
import ImmutablePureComponent from 'react-immutable-pure-component' ;
2023-05-24 00:15:17 +09:00
2023-05-09 10:11:56 +09:00
import { AvatarOverlay } from 'mastodon/components/avatar_overlay' ;
import { RelativeTimestamp } from 'mastodon/components/relative_timestamp' ;
2022-06-27 16:30:15 +09:00
2023-06-13 22:05:40 +09:00
// This needs to be kept in sync with app/models/report.rb
2022-06-27 16:30:15 +09:00
const messages = defineMessages ( {
openReport : { id : 'report_notification.open' , defaultMessage : 'Open report' } ,
other : { id : 'report_notification.categories.other' , defaultMessage : 'Other' } ,
spam : { id : 'report_notification.categories.spam' , defaultMessage : 'Spam' } ,
2023-06-13 22:05:40 +09:00
legal : { id : 'report_notification.categories.legal' , defaultMessage : 'Legal' } ,
2022-06-27 16:30:15 +09:00
violation : { id : 'report_notification.categories.violation' , defaultMessage : 'Rule violation' } ,
} ) ;
class Report extends ImmutablePureComponent {
static propTypes = {
2023-11-04 00:00:03 +09:00
account : ImmutablePropTypes . record . isRequired ,
2022-06-27 16:30:15 +09:00
report : ImmutablePropTypes . map . isRequired ,
hidden : PropTypes . bool ,
intl : PropTypes . object . isRequired ,
} ;
render ( ) {
const { intl , hidden , report , account } = this . props ;
if ( ! report ) {
return null ;
}
if ( hidden ) {
return (
2023-05-23 18:47:36 +09:00
< >
2022-06-27 16:30:15 +09:00
{ report . get ( 'id' ) }
2023-05-23 18:47:36 +09:00
< / >
2022-06-27 16:30:15 +09:00
) ;
}
return (
< div className = 'notification__report' >
< div className = 'notification__report__avatar' >
< AvatarOverlay account = { report . get ( 'target_account' ) } friend = { account } / >
< / div >
< div className = 'notification__report__details' >
< div >
2023-04-24 15:07:19 +09:00
< RelativeTimestamp timestamp = { report . get ( 'created_at' ) } short = { false } / > · < FormattedMessage id = 'report_notification.attached_statuses' defaultMessage = '{count, plural, one {# post} other {# posts}} attached' values = { { count : report . get ( 'status_ids' ) . size } } / >
2022-06-27 16:30:15 +09:00
< br / >
< strong > { intl . formatMessage ( messages [ report . get ( 'category' ) ] ) } < / strong >
< / div >
< div className = 'notification__report__actions' >
< a href = { ` /admin/reports/ ${ report . get ( 'id' ) } ` } className = 'button' target = '_blank' rel = 'noopener noreferrer' > { intl . formatMessage ( messages . openReport ) } < / a >
< / div >
< / div >
< / div >
) ;
}
}
2023-03-24 11:17:53 +09:00
export default injectIntl ( Report ) ;