2022-02-23 19:03:46 +00:00
import PropTypes from 'prop-types' ;
2023-05-23 15:15:17 +00:00
import { PureComponent } from 'react' ;
import { FormattedMessage } from 'react-intl' ;
import { OrderedSet } from 'immutable' ;
2022-02-23 19:03:46 +00:00
import ImmutablePropTypes from 'react-immutable-proptypes' ;
import { connect } from 'react-redux' ;
2023-05-23 15:15:17 +00:00
2023-10-23 07:43:00 +00:00
import { Button } from 'mastodon/components/button' ;
2023-06-13 17:26:25 +00:00
import { LoadingIndicator } from 'mastodon/components/loading_indicator' ;
2023-05-23 15:15:17 +00:00
import StatusCheckBox from 'mastodon/features/report/containers/status_check_box_container' ;
2022-02-23 19:03:46 +00:00
const mapStateToProps = ( state , { accountId } ) => ( {
availableStatusIds : OrderedSet ( state . getIn ( [ 'timelines' , ` account: ${ accountId } :with_replies ` , 'items' ] ) ) ,
2022-02-27 06:37:00 +00:00
isLoading : state . getIn ( [ 'timelines' , ` account: ${ accountId } :with_replies ` , 'isLoading' ] ) ,
2022-02-23 19:03:46 +00:00
} ) ;
2023-05-23 08:52:27 +00:00
class Statuses extends PureComponent {
2022-02-23 19:03:46 +00:00
static propTypes = {
onNextStep : PropTypes . func . isRequired ,
accountId : PropTypes . string . isRequired ,
availableStatusIds : ImmutablePropTypes . set . isRequired ,
selectedStatusIds : ImmutablePropTypes . set . isRequired ,
2022-02-27 06:37:00 +00:00
isLoading : PropTypes . bool ,
2022-02-23 19:03:46 +00:00
onToggle : PropTypes . func . isRequired ,
} ;
handleNextClick = ( ) => {
const { onNextStep } = this . props ;
onNextStep ( 'comment' ) ;
} ;
render ( ) {
2022-02-27 06:37:00 +00:00
const { availableStatusIds , selectedStatusIds , onToggle , isLoading } = this . props ;
2022-02-23 19:03:46 +00:00
return (
2023-05-23 09:47:36 +00:00
< >
2022-02-23 19:03:46 +00:00
< 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' >
2022-02-27 06:37:00 +00:00
{ isLoading ? < LoadingIndicator / > : availableStatusIds . union ( selectedStatusIds ) . map ( statusId => (
2022-02-23 19:03:46 +00:00
< 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 >
2023-05-23 09:47:36 +00:00
< / >
2022-02-23 19:03:46 +00:00
) ;
}
}
2023-03-24 02:17:53 +00:00
export default connect ( mapStateToProps ) ( Statuses ) ;