2022-02-24 06:03:46 +11:00
|
|
|
import PropTypes from 'prop-types';
|
2023-05-24 01:15:17 +10:00
|
|
|
import { PureComponent } from 'react';
|
|
|
|
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
2022-02-24 06:03:46 +11:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import { connect } from 'react-redux';
|
2023-05-24 01:15:17 +10:00
|
|
|
|
2022-02-24 06:03:46 +11:00
|
|
|
import Button from 'mastodon/components/button';
|
2023-05-24 01:15:17 +10:00
|
|
|
|
2022-02-24 06:03:46 +11:00
|
|
|
import Option from './components/option';
|
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
2022-10-13 23:42:37 +11:00
|
|
|
rules: state.getIn(['server', 'server', 'rules']),
|
2022-02-24 06:03:46 +11:00
|
|
|
});
|
|
|
|
|
2023-05-23 18:52:27 +10:00
|
|
|
class Rules extends PureComponent {
|
2022-02-24 06:03:46 +11:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
onNextStep: PropTypes.func.isRequired,
|
|
|
|
rules: ImmutablePropTypes.list,
|
|
|
|
selectedRuleIds: ImmutablePropTypes.set.isRequired,
|
|
|
|
onToggle: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
handleNextClick = () => {
|
|
|
|
const { onNextStep } = this.props;
|
|
|
|
onNextStep('statuses');
|
|
|
|
};
|
|
|
|
|
|
|
|
handleRulesToggle = (value, checked) => {
|
|
|
|
const { onToggle } = this.props;
|
|
|
|
onToggle(value, checked);
|
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { rules, selectedRuleIds } = this.props;
|
|
|
|
|
|
|
|
return (
|
2023-05-23 19:47:36 +10:00
|
|
|
<>
|
2022-02-24 06:03:46 +11:00
|
|
|
<h3 className='report-dialog-modal__title'><FormattedMessage id='report.rules.title' defaultMessage='Which rules are being violated?' /></h3>
|
|
|
|
<p className='report-dialog-modal__lead'><FormattedMessage id='report.rules.subtitle' defaultMessage='Select all that apply' /></p>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
{rules.map(item => (
|
|
|
|
<Option
|
|
|
|
key={item.get('id')}
|
|
|
|
name='rule_ids'
|
|
|
|
value={item.get('id')}
|
|
|
|
checked={selectedRuleIds.includes(item.get('id'))}
|
|
|
|
onToggle={this.handleRulesToggle}
|
|
|
|
label={item.get('text')}
|
|
|
|
multiple
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className='flex-spacer' />
|
|
|
|
|
|
|
|
<div className='report-dialog-modal__actions'>
|
|
|
|
<Button onClick={this.handleNextClick} disabled={selectedRuleIds.size < 1}><FormattedMessage id='report.next' defaultMessage='Next' /></Button>
|
|
|
|
</div>
|
2023-05-23 19:47:36 +10:00
|
|
|
</>
|
2022-02-24 06:03:46 +11:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2023-03-24 13:17:53 +11:00
|
|
|
|
|
|
|
export default connect(mapStateToProps)(Rules);
|