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.

32 lines
1.1 KiB

  1. import { openDropdownMenu, closeDropdownMenu } from 'flavours/glitch/actions/dropdown_menu';
  2. import { openModal, closeModal } from 'flavours/glitch/actions/modal';
  3. import { connect } from 'react-redux';
  4. import DropdownMenu from 'flavours/glitch/components/dropdown_menu';
  5. import { isUserTouching } from 'flavours/glitch/util/is_mobile';
  6. const mapStateToProps = state => ({
  7. isModalOpen: state.get('modal').modalType === 'ACTIONS',
  8. dropdownPlacement: state.getIn(['dropdown_menu', 'placement']),
  9. openDropdownId: state.getIn(['dropdown_menu', 'openId']),
  10. });
  11. const mapDispatchToProps = (dispatch, { status, items }) => ({
  12. onOpen(id, onItemClick, dropdownPlacement) {
  13. dispatch(isUserTouching() ? openModal('ACTIONS', {
  14. status,
  15. actions: items.map(
  16. (item, i) => item ? {
  17. ...item,
  18. name: `${item.text}-${i}`,
  19. onClick: (e) => { return onItemClick(i, e) },
  20. } : null
  21. ),
  22. }) : openDropdownMenu(id, dropdownPlacement));
  23. },
  24. onClose(id) {
  25. dispatch(closeModal());
  26. dispatch(closeDropdownMenu(id));
  27. },
  28. });
  29. export default connect(mapStateToProps, mapDispatchToProps)(DropdownMenu);