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.

47 lines
1.8 KiB

  1. import React from 'react';
  2. import Icon from 'mastodon/components/icon';
  3. import Button from 'mastodon/components/button';
  4. import IconButton from 'mastodon/components/icon_button';
  5. import { requestBrowserPermission, dismissBrowserPermission } from 'mastodon/actions/notifications';
  6. import { connect } from 'react-redux';
  7. import PropTypes from 'prop-types';
  8. import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
  9. const messages = defineMessages({
  10. close: { id: 'lightbox.close', defaultMessage: 'Close' },
  11. });
  12. export default @connect()
  13. @injectIntl
  14. class NotificationsPermissionBanner extends React.PureComponent {
  15. static propTypes = {
  16. dispatch: PropTypes.func.isRequired,
  17. intl: PropTypes.object.isRequired,
  18. };
  19. handleClick = () => {
  20. this.props.dispatch(requestBrowserPermission());
  21. }
  22. handleClose = () => {
  23. this.props.dispatch(dismissBrowserPermission());
  24. }
  25. render () {
  26. const { intl } = this.props;
  27. return (
  28. <div className='notifications-permission-banner'>
  29. <div className='notifications-permission-banner__close'>
  30. <IconButton icon='times' onClick={this.handleClose} title={intl.formatMessage(messages.close)} />
  31. </div>
  32. <h2><FormattedMessage id='notifications_permission_banner.title' defaultMessage='Never miss a thing' /></h2>
  33. <p><FormattedMessage id='notifications_permission_banner.how_to_control' defaultMessage="To receive notifications when Mastodon isn't open, enable desktop notifications. You can control precisely which types of interactions generate desktop notifications through the {icon} button above once they're enabled." values={{ icon: <Icon id='sliders' /> }} /></p>
  34. <Button onClick={this.handleClick}><FormattedMessage id='notifications_permission_banner.enable' defaultMessage='Enable desktop notifications' /></Button>
  35. </div>
  36. );
  37. }
  38. }