2022-06-27 03:30:15 -04:00
|
|
|
import PropTypes from 'prop-types';
|
2023-05-28 10:38:10 -04:00
|
|
|
|
2023-05-07 15:43:25 -04:00
|
|
|
import { FormattedMessage } from 'react-intl';
|
2023-05-28 10:38:10 -04:00
|
|
|
|
|
|
|
import classNames from 'classnames';
|
2023-10-19 13:44:55 -04:00
|
|
|
import { withRouter } from 'react-router-dom';
|
2023-05-28 10:38:10 -04:00
|
|
|
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2022-06-27 03:30:15 -04:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2023-05-28 10:38:10 -04:00
|
|
|
|
2022-06-27 03:30:15 -04:00
|
|
|
import { HotKeys } from 'react-hotkeys';
|
2023-05-28 10:38:10 -04:00
|
|
|
|
|
|
|
import { Icon } from 'flavours/glitch/components/icon';
|
2022-06-27 03:30:15 -04:00
|
|
|
import Permalink from 'flavours/glitch/components/permalink';
|
2023-10-19 13:44:55 -04:00
|
|
|
import { WithRouterPropTypes } from 'flavours/glitch/utils/react_router';
|
2023-05-28 10:38:10 -04:00
|
|
|
|
2022-06-27 03:30:15 -04:00
|
|
|
import NotificationOverlayContainer from '../containers/overlay_container';
|
2023-05-28 10:38:10 -04:00
|
|
|
|
2022-06-27 03:30:15 -04:00
|
|
|
import Report from './report';
|
|
|
|
|
2023-10-19 13:44:55 -04:00
|
|
|
class AdminReport extends ImmutablePureComponent {
|
2022-06-27 03:30:15 -04:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
hidden: PropTypes.bool,
|
|
|
|
id: PropTypes.string.isRequired,
|
|
|
|
account: ImmutablePropTypes.map.isRequired,
|
|
|
|
notification: ImmutablePropTypes.map.isRequired,
|
|
|
|
unread: PropTypes.bool,
|
|
|
|
report: ImmutablePropTypes.map.isRequired,
|
2023-10-19 13:44:55 -04:00
|
|
|
...WithRouterPropTypes,
|
2022-06-27 03:30:15 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
handleMoveUp = () => {
|
|
|
|
const { notification, onMoveUp } = this.props;
|
|
|
|
onMoveUp(notification.get('id'));
|
2023-02-03 14:52:07 -05:00
|
|
|
};
|
2022-06-27 03:30:15 -04:00
|
|
|
|
|
|
|
handleMoveDown = () => {
|
|
|
|
const { notification, onMoveDown } = this.props;
|
|
|
|
onMoveDown(notification.get('id'));
|
2023-02-03 14:52:07 -05:00
|
|
|
};
|
2022-06-27 03:30:15 -04:00
|
|
|
|
|
|
|
handleOpen = () => {
|
|
|
|
this.handleOpenProfile();
|
2023-02-03 14:52:07 -05:00
|
|
|
};
|
2022-06-27 03:30:15 -04:00
|
|
|
|
|
|
|
handleOpenProfile = () => {
|
2023-10-19 13:44:55 -04:00
|
|
|
const { history, notification } = this.props;
|
|
|
|
history.push(`/@${notification.getIn(['account', 'acct'])}`);
|
2023-02-03 14:52:07 -05:00
|
|
|
};
|
2022-06-27 03:30:15 -04:00
|
|
|
|
|
|
|
handleMention = e => {
|
|
|
|
e.preventDefault();
|
|
|
|
|
2023-10-19 13:44:55 -04:00
|
|
|
const { history, notification, onMention } = this.props;
|
|
|
|
onMention(notification.get('account'), history);
|
2023-02-03 14:52:07 -05:00
|
|
|
};
|
2022-06-27 03:30:15 -04:00
|
|
|
|
|
|
|
getHandlers () {
|
|
|
|
return {
|
|
|
|
moveUp: this.handleMoveUp,
|
|
|
|
moveDown: this.handleMoveDown,
|
|
|
|
open: this.handleOpen,
|
|
|
|
openProfile: this.handleOpenProfile,
|
|
|
|
mention: this.handleMention,
|
|
|
|
reply: this.handleMention,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
2023-05-07 15:43:25 -04:00
|
|
|
const { account, notification, unread, report } = this.props;
|
2022-06-27 03:30:15 -04:00
|
|
|
|
2022-10-26 20:10:54 -04:00
|
|
|
if (!report) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-06-27 03:30:15 -04:00
|
|
|
// Links to the display name.
|
|
|
|
const displayName = account.get('display_name_html') || account.get('username');
|
|
|
|
const link = (
|
|
|
|
<bdi><Permalink
|
|
|
|
className='notification__display-name'
|
|
|
|
href={account.get('url')}
|
|
|
|
title={account.get('acct')}
|
|
|
|
to={`/@${account.get('acct')}`}
|
|
|
|
dangerouslySetInnerHTML={{ __html: displayName }}
|
|
|
|
/></bdi>
|
|
|
|
);
|
|
|
|
|
|
|
|
const targetAccount = report.get('target_account');
|
|
|
|
const targetDisplayNameHtml = { __html: targetAccount.get('display_name_html') };
|
|
|
|
const targetLink = <bdi><Permalink className='notification__display-name' href={targetAccount.get('url')} title={targetAccount.get('acct')} to={`/@${targetAccount.get('acct')}`} dangerouslySetInnerHTML={targetDisplayNameHtml} /></bdi>;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<HotKeys handlers={this.getHandlers()}>
|
2023-04-04 10:33:44 -04:00
|
|
|
<div className={classNames('notification notification-admin-report focusable', { unread })} tabIndex={0}>
|
2022-06-27 03:30:15 -04:00
|
|
|
<div className='notification__message'>
|
|
|
|
<div className='notification__favourite-icon-wrapper'>
|
|
|
|
<Icon id='flag' fixedWidth />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<span title={notification.get('created_at')}>
|
|
|
|
<FormattedMessage id='notification.admin.report' defaultMessage='{name} reported {target}' values={{ name: link, target: targetLink }} />
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<Report account={account} report={notification.get('report')} hidden={this.props.hidden} />
|
|
|
|
<NotificationOverlayContainer notification={notification} />
|
|
|
|
</div>
|
|
|
|
</HotKeys>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2023-10-19 13:44:55 -04:00
|
|
|
|
|
|
|
export default withRouter(AdminReport);
|