From 0c585d15e152fdfa959414b37af6aac91f8d576a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tautvidas=20Sipavi=C4=8Dius?= Date: Tue, 15 May 2018 21:11:24 +0300 Subject: [PATCH] Refactor events_list.jsx to suppress lint6 warnings Likely happened due to updated package-lock.json --- .../types/automatic_emails/event.jsx | 78 +++++++++++++++++++ .../types/automatic_emails/events_list.jsx | 61 +++------------ 2 files changed, 88 insertions(+), 51 deletions(-) create mode 100644 assets/js/src/newsletters/types/automatic_emails/event.jsx diff --git a/assets/js/src/newsletters/types/automatic_emails/event.jsx b/assets/js/src/newsletters/types/automatic_emails/event.jsx new file mode 100644 index 0000000000..752390f7e9 --- /dev/null +++ b/assets/js/src/newsletters/types/automatic_emails/event.jsx @@ -0,0 +1,78 @@ +import React from 'react'; +import MailPoet from 'mailpoet'; +import _ from 'underscore'; +import PropTypes from 'prop-types'; + +class AutomaticEmailEvent extends React.PureComponent { + render() { + const event = this.props.event; + let action; + + if (this.props.premium) { + action = ( + + {MailPoet.I18n.t('premiumFeatureLink')} + + ); + } else { + const disabled = event.soon; + + action = ( + + {event.actionButtonTitle || MailPoet.I18n.t('setUp')} + + ); + } + + return ( +
  • +
    +
    + {event.thumbnailImage ? : null} +
    +
    +
    +

    {event.title} {event.soon ? `(${MailPoet.I18n.t('soon').toLowerCase()})` : ''}

    + {event.badge ? ( + + {event.badge.text} + + ) : '' + } +
    +

    {event.description}

    +
    +
    + {action} +
    +
    +
  • + ); + } +} + +AutomaticEmailEvent.propTypes = { + premium: PropTypes.bool.isRequired, + eventsConfigurator: PropTypes.func.isRequired, + event: PropTypes.shape({ + slug: PropTypes.string.isRequired, + thumbnailImage: PropTypes.string, + title: PropTypes.string.isRequired, + soon: PropTypes.bool, + badge: PropTypes.shape({ + style: PropTypes.string, + text: PropTypes.string, + }), + description: PropTypes.string.isRequired, + actionButtonTitle: PropTypes.string, + }).isRequired, +}; + +module.exports = AutomaticEmailEvent; diff --git a/assets/js/src/newsletters/types/automatic_emails/events_list.jsx b/assets/js/src/newsletters/types/automatic_emails/events_list.jsx index 7883897abf..6093359875 100644 --- a/assets/js/src/newsletters/types/automatic_emails/events_list.jsx +++ b/assets/js/src/newsletters/types/automatic_emails/events_list.jsx @@ -1,5 +1,6 @@ import React from 'react'; import AutomaticEmailsBreadcrumb from 'newsletters/types/automatic_emails/breadcrumb.jsx'; +import AutomaticEmailEvent from 'newsletters/types/automatic_emails/event.jsx'; import MailPoet from 'mailpoet'; import _ from 'underscore'; import PropTypes from 'prop-types'; @@ -17,57 +18,15 @@ class AutomaticEmailEventsList extends React.Component { } displayEvents() { - const events = _.map(this.emailEvents, (event, index) => { - let action; - - if (this.email.premium) { - action = ( - - {MailPoet.I18n.t('premiumFeatureLink')} - - ); - } else { - const disabled = event.soon; - - action = ( - - {event.actionButtonTitle || MailPoet.I18n.t('setUp')} - - ); - } - - return ( -
  • -
    -
    - {event.thumbnailImage ? : null} -
    -
    -
    -

    {event.title} {event.soon ? `(${MailPoet.I18n.t('soon').toLowerCase()})` : ''}

    - {event.badge ? ( - - {event.badge.text} - - ) : '' - } -
    -

    {event.description}

    -
    -
    - {action} -
    -
    -
  • - ); - }); + const events = _.map(this.emailEvents, (event, index) => ( + + ) + ); return (