diff --git a/assets/css/src/admin.scss b/assets/css/src/admin.scss index 7d595d0017..fac7062ad4 100644 --- a/assets/css/src/admin.scss +++ b/assets/css/src/admin.scss @@ -34,7 +34,6 @@ @import 'components/welcomeWizard'; @import 'components/intro'; @import 'components/featureAnnouncement'; -@import 'components/inAppAnnouncements'; @import 'components/newsletterCongratulate.scss'; @import 'components/discounts'; @import 'components/reviewRequest'; diff --git a/assets/css/src/components/_inAppAnnouncements.scss b/assets/css/src/components/_inAppAnnouncements.scss deleted file mode 100644 index 08d8a615ee..0000000000 --- a/assets/css/src/components/_inAppAnnouncements.scss +++ /dev/null @@ -1,27 +0,0 @@ -.mailpoet_in_app_announcement_pulsing_dot { - display: inline-block; - width: 10px; - height: 10px; - border-radius: 50%; - background: #ff5301; - cursor: pointer; - box-shadow: 0 0 0 rgba(255, 83, 1, 0.4); - animation: mailpoet_in_app_dot_pulse 2s infinite; -} - -@keyframes mailpoet_in_app_dot_pulse { - 0% { box-shadow: 0 0 0 0 rgba(255, 83, 1, 0.4); } - 70% { box-shadow: 0 0 0 10px rgba(255, 83, 1, 0); } - 100% { box-shadow: 0 0 0 0 rgba(255, 83, 1, 0); } -} - -.mailpoet_drag_and_drop_tutorial { - text-align: center; -} - -.new_subscriber_notification_announcement { - h2 { - font-size: 28px; - } - text-align: center; -} diff --git a/assets/js/src/announcements/in_app_announcement.jsx b/assets/js/src/announcements/in_app_announcement.jsx deleted file mode 100644 index 81910dc5a9..0000000000 --- a/assets/js/src/announcements/in_app_announcement.jsx +++ /dev/null @@ -1,122 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import MailPoet from 'mailpoet'; -import InAppAnnouncementDot from './in_app_announcement_dot.jsx'; - -class InAppAnnouncement extends React.Component { - constructor(props) { - super(props); - this.saveDisplayed = this.saveDisplayed.bind(this); - - this.state = { - announcementsSettings: window.mailpoet_in_app_announcements || null, - }; - } - - saveDisplayed() { - const settings = Object.assign({}, this.state.announcementsSettings); - settings.displayed.push(this.props.showOnlyOnceSlug); - return MailPoet.Ajax.post({ - api_version: window.mailpoet_api_version, - endpoint: 'settings', - action: 'set', - data: { in_app_announcements: settings }, - }).always(() => (this.setState({ announcementsSettings: settings }))); - } - - render() { - if (this.props.showToNewUser !== null - && window.mailpoet_is_new_user !== this.props.showToNewUser - ) { - return null; - } - - if (this.props.validUntil !== null - && this.props.validUntil < new Date() - ) { - return null; - } - - if (this.props.showToPremiumUser !== null - && window.mailpoet_premium_active !== this.props.showToPremiumUser - ) { - return null; - } - - if (this.props.showOnlyOnceSlug - && this.state.announcementsSettings.displayed.includes(this.props.showOnlyOnceSlug) - ) { - return null; - } - - return ( - { - if (!this.props.showOnlyOnceSlug) { return; } - this.saveDisplayed(); - }} - > - {this.props.children} - - ); - } -} - -const validateBooleanWithWindowDependency = (props, propName, componentName, windowProperty) => { - const propValue = props[propName]; - if (propValue !== null && propValue !== true && propValue !== false) { - return new Error(`Invalid property in ${componentName}. newUser must be of type boolean`); - } - if (propValue !== null && typeof window[windowProperty] === 'undefined') { - return new Error( - `Missing data for evaluation of ${componentName} display condition. ${propName} requires window.${windowProperty}` - ); - } - return null; -}; - -InAppAnnouncement.propTypes = { - width: PropTypes.string, - height: PropTypes.string, - className: PropTypes.string, - children: PropTypes.element.isRequired, - validUntil: PropTypes.instanceOf(Date), - showToNewUser: (props, propName, componentName) => ( - validateBooleanWithWindowDependency(props, propName, componentName, 'mailpoet_is_new_user') - ), - showToPremiumUser: (props, propName, componentName) => ( - validateBooleanWithWindowDependency(props, propName, componentName, 'mailpoet_premium_active') - ), - showOnlyOnceSlug: (props, propName, componentName) => { - const propValue = props[propName]; - if (propValue !== null && typeof propValue !== 'string') { - return new Error(`Invalid property in ${componentName}. ${propName} must be of type string`); - } - if (propValue === null) { - return null; - } - if ( - typeof window.mailpoet_in_app_announcements === 'undefined' - ) { - return new Error( - `Missing data for evaluation of ${componentName} display condition. ${propName} requires window.mailpoet_in_app_announcements` - ); - } - return null; - }, -}; - -InAppAnnouncement.defaultProps = { - width: '900px', - height: '600px', - className: null, - validUntil: null, - showToNewUser: null, - showToPremiumUser: null, - showOnlyOnceSlug: null, -}; - -export default InAppAnnouncement; diff --git a/assets/js/src/announcements/in_app_announcement_dot.jsx b/assets/js/src/announcements/in_app_announcement_dot.jsx deleted file mode 100644 index 13f6a9b71a..0000000000 --- a/assets/js/src/announcements/in_app_announcement_dot.jsx +++ /dev/null @@ -1,48 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import ReactDOMServer from 'react-dom/server'; -import classNames from 'classnames'; -import MailPoet from 'mailpoet'; - -const InAppAnnouncementDot = (props) => { - const onClick = () => { - MailPoet.Modal.popup({ - template: ReactDOMServer.renderToString(props.children), - width: props.width, - height: props.height, - }); - if (props.onUserTrigger) props.onUserTrigger(); - }; - return ( - { - if ((['keydown', 'keypress'].includes(event.type) && ['Enter', ' '].includes(event.key)) - ) { - event.preventDefault(); - onClick(); - } - }} - onClick={onClick} - /> - ); -}; - -InAppAnnouncementDot.propTypes = { - children: PropTypes.element.isRequired, - width: PropTypes.string, - height: PropTypes.string, - className: PropTypes.string, - onUserTrigger: PropTypes.func, -}; - -InAppAnnouncementDot.defaultProps = { - width: 'auto', - height: 'auto', - className: null, - onUserTrigger: null, -}; - -export default InAppAnnouncementDot; diff --git a/assets/js/src/settings/announcement.jsx b/assets/js/src/settings/announcement.jsx deleted file mode 100644 index 09bb9b21a3..0000000000 --- a/assets/js/src/settings/announcement.jsx +++ /dev/null @@ -1,14 +0,0 @@ -import ReactDOM from 'react-dom'; -import React from 'react'; -import Announcement from './new_subscriber_announcement.jsx'; - -const container = document.getElementById('new_subscriber_announcement'); - -if (container) { - ReactDOM.render( - , container - ); -} diff --git a/assets/js/src/settings/new_subscriber_announcement.jsx b/assets/js/src/settings/new_subscriber_announcement.jsx deleted file mode 100644 index 46aa419e6c..0000000000 --- a/assets/js/src/settings/new_subscriber_announcement.jsx +++ /dev/null @@ -1,31 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import MailPoet from 'mailpoet'; -import moment from 'moment'; -import InAppAnnouncement from 'announcements/in_app_announcement.jsx'; - -const NewSubscriberNotificationAnnouncement = props => ( - - - {MailPoet.I18n.t('announcementHeader')} - - - {MailPoet.I18n.t('announcementParagraph1')} - - {MailPoet.I18n.t('announcementParagraph2')} - - - -); - -NewSubscriberNotificationAnnouncement.propTypes = { - installedAt: PropTypes.string.isRequired, - imageUrl: PropTypes.string.isRequired, -}; - -export default NewSubscriberNotificationAnnouncement; diff --git a/assets/js/src/webpack_admin_index.jsx b/assets/js/src/webpack_admin_index.jsx index 918f8ef083..68594c273c 100644 --- a/assets/js/src/webpack_admin_index.jsx +++ b/assets/js/src/webpack_admin_index.jsx @@ -17,5 +17,4 @@ import 'settings/reinstall_from_scratch.js'; // side effect - adds event handler import 'subscribers/importExport/import.jsx'; // side effect - executes on doc ready, adds events import 'subscribers/importExport/export.js'; // side effect - executes on doc ready import 'welcome_wizard/wizard.jsx'; // side effect - renders ReactDOM to document -import 'settings/announcement.jsx'; // side effect - renders ReactDOM to document import 'nps_poll.jsx'; // side effect - calls setImmediate() diff --git a/lib/Settings/SettingsController.php b/lib/Settings/SettingsController.php index 73f6893066..d2704d1741 100644 --- a/lib/Settings/SettingsController.php +++ b/lib/Settings/SettingsController.php @@ -64,9 +64,6 @@ class SettingsController { 'analytics' => [ 'enabled' => false, ], - 'in_app_announcements' => [ - 'displayed' => [] - ], 'display_nps_poll' => true, ]; } diff --git a/views/settings.html b/views/settings.html index 06255696df..3cbececd27 100644 --- a/views/settings.html +++ b/views/settings.html @@ -217,9 +217,6 @@ }); }); }); - var mailpoet_in_app_announcements = <%= json_encode(settings.in_app_announcements) %>; - var mailpoet_new_subscriber_announcement_image = '<%= cdn_url('in-app-announcements/new-subscriber-notification.20181121-1440.png') %>'; - var mailpoet_installed_at = <%= json_encode(settings.installed_at) %>; <% set newUser = (is_new_user == true) ? 'true' : 'false' %> var mailpoet_is_new_user = <%= newUser %>; var mailpoet_settings_sender_name = "<%= settings.sender.name %>"; diff --git a/views/settings/basics.html b/views/settings/basics.html index 688850b476..aaf2445905 100644 --- a/views/settings/basics.html +++ b/views/settings/basics.html @@ -321,7 +321,7 @@ - <%= __('New subscriber notifications') %> + <%= __('New subscriber notifications') %> <%= __('Enter the email address that should receive notifications when someone subscribes.') %>
- {MailPoet.I18n.t('announcementParagraph1')} - - {MailPoet.I18n.t('announcementParagraph2')} -
<%= __('Enter the email address that should receive notifications when someone subscribes.') %>