diff --git a/app/javascript/mastodon/components/dropdown_menu.jsx b/app/javascript/mastodon/components/dropdown_menu.jsx index 524dbb927b4..2cf145fc4e1 100644 --- a/app/javascript/mastodon/components/dropdown_menu.jsx +++ b/app/javascript/mastodon/components/dropdown_menu.jsx @@ -179,6 +179,7 @@ class Dropdown extends PureComponent { renderItem: PropTypes.func, renderHeader: PropTypes.func, onItemClick: PropTypes.func, + className: PropTypes.string, ...WithRouterPropTypes }; @@ -284,6 +285,7 @@ class Dropdown extends PureComponent { children, renderItem, renderHeader, + className, } = this.props; const open = this.state.id === openDropdownId; @@ -296,6 +298,7 @@ class Dropdown extends PureComponent { ref: this.setTargetRef, }) : ( { @@ -39,6 +50,54 @@ export const NotificationRequests = ({ multiColumn }) => { dispatch(fetchNotificationRequests()); }, [dispatch]); + const handleAcceptAll = useCallback(() => { + dispatch(openModal({ + modalType: 'CONFIRM', + modalProps: { + title: intl.formatMessage(messages.confirm_accept_all_title), + message: intl.formatMessage(messages.confirm_accept_all_message, { count: notificationRequests.size }), + confirm: intl.formatMessage(messages.confirm_accept_all_button), + onConfirm: () => { + notificationRequests.forEach((request) => + dispatch(acceptNotificationRequest(request.get('id'))) + ); + }, + }, + })); + }, [dispatch, notificationRequests, intl]); + + const handleDismissAll = useCallback(() => { + dispatch(openModal({ + modalType: 'CONFIRM', + modalProps: { + title: intl.formatMessage(messages.confirm_dismiss_all_title), + message: intl.formatMessage(messages.confirm_dismiss_all_message, { count: notificationRequests.size }), + confirm: intl.formatMessage(messages.confirm_dismiss_all_button), + onConfirm: () => { + notificationRequests.forEach((request) => + dispatch(dismissNotificationRequest(request.get('id'))) + ); + }, + } + })); + }, [dispatch, notificationRequests, intl]); + + const menu = [ + { text: intl.formatMessage(messages.accept_all), action: handleAcceptAll }, + { text: intl.formatMessage(messages.dismiss_all), action: handleDismissAll, dangerous: true }, + ]; + + const dropDownMenu = ( + + ); + return ( { title={intl.formatMessage(messages.title)} onClick={handleHeaderClick} multiColumn={multiColumn} + extraButton={dropDownMenu} showBackButton />