diff --git a/RoboFile.php b/RoboFile.php index b02c7a3b2e..1432f9f87e 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -96,7 +96,7 @@ class RoboFile extends \Robo\Tasks { function testUnit($file = null) { $this->loadEnv(); $this->_exec('vendor/bin/codecept build'); - $this->_exec('vendor/bin/codecept run unit -f '.(($file) ? $file : '')); + $this->_exec('vendor/bin/codecept run unit '.(($file) ? $file : '')); } function testJavascript() { diff --git a/assets/js/src/form/form.jsx b/assets/js/src/form/form.jsx index 6c228ce31c..5ca7fdc936 100644 --- a/assets/js/src/form/form.jsx +++ b/assets/js/src/form/form.jsx @@ -90,15 +90,15 @@ define( if(response.result === true) { if(this.props.onSuccess !== undefined) { - this.props.onSuccess() + this.props.onSuccess(); } else { this.history.pushState(null, '/') } if(this.props.params.id !== undefined) { - this.props.messages['updated'](); + this.props.messages.onUpdate(); } else { - this.props.messages['created'](); + this.props.messages.onCreate(); } } else { if(response.result === false) { diff --git a/assets/js/src/forms/form.jsx b/assets/js/src/forms/form.jsx deleted file mode 100644 index a57d5d72f9..0000000000 --- a/assets/js/src/forms/form.jsx +++ /dev/null @@ -1,57 +0,0 @@ -import React from 'react' -import ReactDOM from 'react-dom' -import { Router, History } from 'react-router' -import MailPoet from 'mailpoet' -import Form from 'form/form.jsx' - -const fields = [ - { - name: 'name', - label: 'Name', - type: 'text' - }, - { - name: 'segments', - label: 'Lists', - type: 'selection', - endpoint: 'segments', - multiple: true - } -] - -const messages = { - updated: function() { - MailPoet.Notice.success('Form successfully updated!'); - }, - created: function() { - MailPoet.Notice.success('Form successfully added!'); - } -} - -const FormForm = React.createClass({ - mixins: [ - History - ], - render() { - return ( -
-

- Form Back to list -

- -
-
- ); - } -}); - -module.exports = FormForm \ No newline at end of file diff --git a/assets/js/src/forms/forms.jsx b/assets/js/src/forms/forms.jsx index 2388b491c6..5099d122bd 100644 --- a/assets/js/src/forms/forms.jsx +++ b/assets/js/src/forms/forms.jsx @@ -2,7 +2,6 @@ import React from 'react' import ReactDOM from 'react-dom' import { Router, Route, IndexRoute } from 'react-router' import FormList from 'forms/list.jsx' -import FormForm from 'forms/form.jsx' import createHashHistory from 'history/lib/createHashHistory' let history = createHashHistory({ queryKey: false }) @@ -20,8 +19,6 @@ if(container) { - - diff --git a/assets/js/src/listing/bulk_actions.jsx b/assets/js/src/listing/bulk_actions.jsx index 22fd3f730d..449596a332 100644 --- a/assets/js/src/listing/bulk_actions.jsx +++ b/assets/js/src/listing/bulk_actions.jsx @@ -85,7 +85,12 @@ function( Select bulk action - { this.props.bulk_actions.map(function(action, index) { return ( diff --git a/assets/js/src/listing/header.jsx b/assets/js/src/listing/header.jsx index 1c737da03a..39e32984fe 100644 --- a/assets/js/src/listing/header.jsx +++ b/assets/js/src/listing/header.jsx @@ -11,7 +11,7 @@ define(['react', 'classnames'], function(React, classNames) { column.is_primary = (index === 0); column.sorted = (this.props.sort_by === column.name) ? this.props.sort_order - : 'asc'; + : 'desc'; return ( diff --git a/assets/js/src/segments/form.jsx b/assets/js/src/segments/form.jsx index e9bfc19566..b339f60825 100644 --- a/assets/js/src/segments/form.jsx +++ b/assets/js/src/segments/form.jsx @@ -26,10 +26,10 @@ define( ]; var messages = { - updated: function() { + onUpdate: function() { MailPoet.Notice.success('Segment successfully updated!'); }, - created: function() { + onCreate: function() { MailPoet.Notice.success('Segment successfully added!'); } }; @@ -54,7 +54,7 @@ define( fields={ fields } params={ this.props.params } messages={ messages } - onSuccess={ this.history.goBack } /> + /> ); } diff --git a/assets/js/src/subscribers/form.jsx b/assets/js/src/subscribers/form.jsx index 78e4a4b425..f961b1ac35 100644 --- a/assets/js/src/subscribers/form.jsx +++ b/assets/js/src/subscribers/form.jsx @@ -52,10 +52,10 @@ define( ]; var messages = { - updated: function() { + onUpdate: function() { MailPoet.Notice.success('Subscriber successfully updated!'); }, - created: function() { + onCreate: function() { MailPoet.Notice.success('Subscriber successfully added!'); } }; @@ -82,7 +82,7 @@ define( fields={ fields } params={ this.props.params } messages={ messages } - onSuccess={ this.history.goBack } /> + /> ); } diff --git a/lib/Config/Menu.php b/lib/Config/Menu.php index 803c378f56..da62cbd96c 100644 --- a/lib/Config/Menu.php +++ b/lib/Config/Menu.php @@ -34,7 +34,7 @@ class Menu { 'MailPoet', 'manage_options', 'mailpoet', - array($this, 'home'), + array($this, 'welcome'), $this->assets_url . '/img/menu_icon.png', 30 ); @@ -100,6 +100,7 @@ class Menu { function registered_pages() { global $_registered_pages; $pages = array( + 'mailpoet-welcome' => array($this, 'welcome'), 'mailpoet-form-editor' => array($this, 'formEditor'), 'mailpoet-newsletter-editor' => array($this, 'newletterEditor') ); @@ -117,26 +118,16 @@ class Menu { echo $this->renderer->render('index.html', $data); } + function welcome() { + $data = array( + 'settings' => Setting::getAll(), + 'current_user' => wp_get_current_user() + ); + + echo $this->renderer->render('welcome.html', $data); + } + function settings() { - // flags (available features on WP install) - $flags = array(); - - if(is_multisite()) { - // get multisite registration option - $registration = apply_filters( - 'wpmu_registration_enabled', - get_site_option('registration', 'all') - ); - - // check if users can register - $flags['registration_enabled'] = - !(in_array($registration, array('none', 'blog'))); - } else { - // check if users can register - $flags['registration_enabled'] = - (bool)get_option('users_can_register', false); - } - $settings = Setting::getAll(); // dkim: check if public/private keys have been generated @@ -158,7 +149,7 @@ class Menu { 'settings' => $settings, 'segments' => Segment::getPublished()->findArray(), 'pages' => Pages::getAll(), - 'flags' => $flags, + 'flags' => $this->_getFlags(), 'charsets' => Charsets::getAll(), 'current_user' => wp_get_current_user(), 'permissions' => Permissions::getAll(), @@ -171,6 +162,29 @@ class Menu { echo $this->renderer->render('settings.html', $data); } + private function _getFlags() { + // flags (available features on WP install) + $flags = array(); + + if(is_multisite()) { + // get multisite registration option + $registration = apply_filters( + 'wpmu_registration_enabled', + get_site_option('registration', 'all') + ); + + // check if users can register + $flags['registration_enabled'] = + !(in_array($registration, array('none', 'blog'))); + } else { + // check if users can register + $flags['registration_enabled'] = + (bool)get_option('users_can_register', false); + } + + return $flags; + } + function subscribers() { $data = array(); diff --git a/lib/Settings/Pages.php b/lib/Settings/Pages.php index 4175c762bd..e55eec6a01 100644 --- a/lib/Settings/Pages.php +++ b/lib/Settings/Pages.php @@ -4,17 +4,17 @@ namespace MailPoet\Settings; class Pages { static function getAll() { - $mailpoet_pages = get_posts(array( + $mailpoet_pages = \get_posts(array( 'post_type' => 'mailpoet_page' )); $pages = array(); - foreach(array_merge($mailpoet_pages, get_pages()) as $page) { + foreach(array_merge($mailpoet_pages, \get_pages()) as $page) { $pages[] = array( 'id' => $page->ID, 'title' => $page->post_title, - 'preview_url' => get_permalink($page->ID), - 'edit_url' => get_edit_post_link($page->ID) + 'preview_url' => \get_permalink($page->ID), + 'edit_url' => \get_edit_post_link($page->ID) ); } diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index 3cd690db70..5a291fc163 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -1,9 +1,10 @@ writeln('Loading WP core...'); -require_once(getenv('WP_TEST_PATH') . '/wp-load.php'); +$console = new \Codeception\Lib\Console\Output([]); +$console->writeln('Loading WP core... ('.$wp_load_file.')'); $console->writeln('Cleaning up database...'); $models = array( diff --git a/tests/unit/Models/SegmentCest.php b/tests/unit/Models/SegmentCest.php index 926b57d6d5..b7d687d9a4 100644 --- a/tests/unit/Models/SegmentCest.php +++ b/tests/unit/Models/SegmentCest.php @@ -171,5 +171,9 @@ class SegmentCest { ->deleteMany(); ORM::forTable(SubscriberSegment::$_table) ->deleteMany(); + ORM::forTable(Newsletter::$_table) + ->deleteMany(); + ORM::forTable(NewsletterSegment::$_table) + ->deleteMany(); } -} \ No newline at end of file +} diff --git a/views/welcome.html b/views/welcome.html new file mode 100644 index 0000000000..9fb09e764a --- /dev/null +++ b/views/welcome.html @@ -0,0 +1,13 @@ +<% extends 'layout.html' %> + +<% block content %> +
+

<%= __('Welcome welcome welcome!') %>

+ +

Settings:

+ <%= dump(settings) %> + +

Current user:

+ <%= dump(current_user) %> +
+<% endblock %>