diff --git a/app/soapbox/components/dropdown_menu.js b/app/soapbox/components/dropdown_menu.tsx similarity index 56% rename from app/soapbox/components/dropdown_menu.js rename to app/soapbox/components/dropdown_menu.tsx index c471ac27b8..7d13d6829f 100644 Binary files a/app/soapbox/components/dropdown_menu.js and b/app/soapbox/components/dropdown_menu.tsx differ diff --git a/app/soapbox/components/status_action_bar.tsx b/app/soapbox/components/status_action_bar.tsx index b98f017a95..558d96bb78 100644 --- a/app/soapbox/components/status_action_bar.tsx +++ b/app/soapbox/components/status_action_bar.tsx @@ -24,6 +24,7 @@ import { IconButton, Hoverable } from './ui'; import type { History } from 'history'; import type { AnyAction, Dispatch } from 'redux'; +import type { Menu } from 'soapbox/components/dropdown_menu'; import type { RootState } from 'soapbox/store'; import type { Status } from 'soapbox/types/entities'; import type { Features } from 'soapbox/utils/features'; @@ -367,7 +368,7 @@ class StatusActionBar extends ImmutablePureComponent event.stopPropagation(), + action: (event) => event.stopPropagation(), }); menu.push({ text: intl.formatMessage(messages.admin_status), href: `/pleroma/admin/#/statuses/${status.get('id')}/`, icon: require('@tabler/icons/icons/pencil.svg'), - action: (event: Event) => event.stopPropagation(), + action: (event) => event.stopPropagation(), }); } @@ -607,13 +608,11 @@ class StatusActionBar extends ImmutablePureComponent ); @@ -714,11 +713,9 @@ class StatusActionBar extends ImmutablePureComponent diff --git a/app/soapbox/components/ui/icon-button/icon-button.tsx b/app/soapbox/components/ui/icon-button/icon-button.tsx index 2d8c27b7f3..291b0b4f8a 100644 --- a/app/soapbox/components/ui/icon-button/icon-button.tsx +++ b/app/soapbox/components/ui/icon-button/icon-button.tsx @@ -4,15 +4,10 @@ import InlineSVG from 'react-inlinesvg'; import Text from '../text/text'; -interface IIconButton { - alt?: string, - className?: string, +interface IIconButton extends React.ButtonHTMLAttributes { iconClassName?: string, - disabled?: boolean, src: string, - onClick?: React.EventHandler, text?: string, - title?: string, transparent?: boolean } diff --git a/app/soapbox/containers/dropdown_menu_container.js b/app/soapbox/containers/dropdown_menu_container.js deleted file mode 100644 index 57f4d5468b..0000000000 Binary files a/app/soapbox/containers/dropdown_menu_container.js and /dev/null differ diff --git a/app/soapbox/containers/dropdown_menu_container.ts b/app/soapbox/containers/dropdown_menu_container.ts new file mode 100644 index 0000000000..fa149d0f44 --- /dev/null +++ b/app/soapbox/containers/dropdown_menu_container.ts @@ -0,0 +1,38 @@ +import { connect } from 'react-redux'; + +import { openDropdownMenu, closeDropdownMenu } from '../actions/dropdown_menu'; +import { openModal, closeModal } from '../actions/modals'; +import DropdownMenu from '../components/dropdown_menu'; +import { isUserTouching } from '../is_mobile'; + +import type { Dispatch } from 'redux'; +import type { DropdownPlacement, IDropdown } from 'soapbox/components/dropdown_menu'; +import type { RootState } from 'soapbox/store'; + +const mapStateToProps = (state: RootState) => ({ + isModalOpen: Boolean(state.modals.size && state.modals.last().modalType === 'ACTIONS'), + dropdownPlacement: state.dropdown_menu.get('placement'), + openDropdownId: state.dropdown_menu.get('openId'), + openedViaKeyboard: state.dropdown_menu.get('keyboard'), +}); + +const mapDispatchToProps = (dispatch: Dispatch, { status, items }: Partial) => ({ + onOpen( + id: number, + onItemClick: React.EventHandler, + dropdownPlacement: DropdownPlacement, + keyboard: boolean, + ) { + dispatch(isUserTouching() ? openModal('ACTIONS', { + status, + actions: items, + onClick: onItemClick, + }) : openDropdownMenu(id, dropdownPlacement, keyboard)); + }, + onClose(id: number) { + dispatch(closeModal('ACTIONS')); + dispatch(closeDropdownMenu(id)); + }, +}); + +export default connect(mapStateToProps, mapDispatchToProps)(DropdownMenu);