You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
914 B

  1. import { connect } from 'react-redux';
  2. import ColumnSettings from '../components/column_settings';
  3. import { changeSetting } from '../../../actions/settings';
  4. import { changeColumnParams } from '../../../actions/columns';
  5. const mapStateToProps = (state, { columnId }) => {
  6. const uuid = columnId;
  7. const columns = state.getIn(['settings', 'columns']);
  8. const index = columns.findIndex(c => c.get('uuid') === uuid);
  9. return {
  10. settings: (uuid && index >= 0) ? columns.get(index).get('params') : state.getIn(['settings', 'community']),
  11. };
  12. };
  13. const mapDispatchToProps = (dispatch, { columnId }) => {
  14. return {
  15. onChange (key, checked) {
  16. if (columnId) {
  17. dispatch(changeColumnParams(columnId, key, checked));
  18. } else {
  19. dispatch(changeSetting(['community', ...key], checked));
  20. }
  21. },
  22. };
  23. };
  24. export default connect(mapStateToProps, mapDispatchToProps)(ColumnSettings);