~cytrogen/masto-fe

ref: f8dc013b0d81d5d463c086e291ce99ab1d796a9d masto-fe/app/javascript/flavours/glitch/features/notifications/components/report.jsx -rw-r--r-- 2.3 KiB
f8dc013b — Cytrogen [feature] Add language selector to local settings 8 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import PropTypes from "prop-types";

import { defineMessages, FormattedMessage, injectIntl } from "react-intl";

import ImmutablePropTypes from "react-immutable-proptypes";
import ImmutablePureComponent from "react-immutable-pure-component";

import AvatarOverlay from "flavours/glitch/components/avatar_overlay";
import { RelativeTimestamp } from "flavours/glitch/components/relative_timestamp";

// This needs to be kept in sync with app/models/report.rb
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" },
  legal: { id: "report_notification.categories.legal", defaultMessage: "Legal" },
  violation: { id: "report_notification.categories.violation", defaultMessage: "Rule violation" },
});

class Report extends ImmutablePureComponent {

  static propTypes = {
    account: ImmutablePropTypes.map.isRequired,
    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 (
        <>
          {report.get("id")}
        </>
      );
    }

    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>
            <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 }} />
            <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>
    );
  }

}

export default injectIntl(Report);