~cytrogen/masto-fe

ref: 1a4a23b5c8a8e0beacded9bc44354e3f8778ae26 masto-fe/app/javascript/mastodon/features/report/statuses.jsx -rw-r--r-- 2.3 KiB
1a4a23b5 — Claire Merge pull request #2439 from ClearlyClaire/glitch-soc/merge-upstream 2 years 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
import PropTypes from 'prop-types';
import { PureComponent } from 'react';

import { FormattedMessage } from 'react-intl';

import { OrderedSet } from 'immutable';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { connect } from 'react-redux';

import Button from 'mastodon/components/button';
import { LoadingIndicator } from 'mastodon/components/loading_indicator';
import StatusCheckBox from 'mastodon/features/report/containers/status_check_box_container';

const mapStateToProps = (state, { accountId }) => ({
  availableStatusIds: OrderedSet(state.getIn(['timelines', `account:${accountId}:with_replies`, 'items'])),
  isLoading: state.getIn(['timelines', `account:${accountId}:with_replies`, 'isLoading']),
});

class Statuses extends PureComponent {

  static propTypes = {
    onNextStep: PropTypes.func.isRequired,
    accountId: PropTypes.string.isRequired,
    availableStatusIds: ImmutablePropTypes.set.isRequired,
    selectedStatusIds: ImmutablePropTypes.set.isRequired,
    isLoading: PropTypes.bool,
    onToggle: PropTypes.func.isRequired,
  };

  handleNextClick = () => {
    const { onNextStep } = this.props;
    onNextStep('comment');
  };

  render () {
    const { availableStatusIds, selectedStatusIds, onToggle, isLoading } = this.props;

    return (
      <>
        <h3 className='report-dialog-modal__title'><FormattedMessage id='report.statuses.title' defaultMessage='Are there any posts that back up this report?' /></h3>
        <p className='report-dialog-modal__lead'><FormattedMessage id='report.statuses.subtitle' defaultMessage='Select all that apply' /></p>

        <div className='report-dialog-modal__statuses'>
          {isLoading ? <LoadingIndicator /> : availableStatusIds.union(selectedStatusIds).map(statusId => (
            <StatusCheckBox
              id={statusId}
              key={statusId}
              checked={selectedStatusIds.includes(statusId)}
              onToggle={onToggle}
            />
          ))}
        </div>

        <div className='flex-spacer' />

        <div className='report-dialog-modal__actions'>
          <Button onClick={this.handleNextClick}><FormattedMessage id='report.next' defaultMessage='Next' /></Button>
        </div>
      </>
    );
  }

}

export default connect(mapStateToProps)(Statuses);