Merge pull request #218 from mailpoet/listings_bugfix
Listings bugfixes & Welcome page
This commit is contained in:
@@ -96,7 +96,7 @@ class RoboFile extends \Robo\Tasks {
|
|||||||
function testUnit($file = null) {
|
function testUnit($file = null) {
|
||||||
$this->loadEnv();
|
$this->loadEnv();
|
||||||
$this->_exec('vendor/bin/codecept build');
|
$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() {
|
function testJavascript() {
|
||||||
|
@@ -90,15 +90,15 @@ define(
|
|||||||
|
|
||||||
if(response.result === true) {
|
if(response.result === true) {
|
||||||
if(this.props.onSuccess !== undefined) {
|
if(this.props.onSuccess !== undefined) {
|
||||||
this.props.onSuccess()
|
this.props.onSuccess();
|
||||||
} else {
|
} else {
|
||||||
this.history.pushState(null, '/')
|
this.history.pushState(null, '/')
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.props.params.id !== undefined) {
|
if(this.props.params.id !== undefined) {
|
||||||
this.props.messages['updated']();
|
this.props.messages.onUpdate();
|
||||||
} else {
|
} else {
|
||||||
this.props.messages['created']();
|
this.props.messages.onCreate();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(response.result === false) {
|
if(response.result === false) {
|
||||||
|
@@ -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 (
|
|
||||||
<div>
|
|
||||||
<h2 className="title">
|
|
||||||
Form <a
|
|
||||||
href="javascript:;"
|
|
||||||
className="add-new-h2"
|
|
||||||
onClick={ this.history.goBack }
|
|
||||||
>Back to list</a>
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<Form
|
|
||||||
endpoint="forms"
|
|
||||||
fields={ fields }
|
|
||||||
params={ this.props.params }
|
|
||||||
messages={ messages }
|
|
||||||
onSuccess={ this.history.goBack } />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = FormForm
|
|
@@ -2,7 +2,6 @@ import React from 'react'
|
|||||||
import ReactDOM from 'react-dom'
|
import ReactDOM from 'react-dom'
|
||||||
import { Router, Route, IndexRoute } from 'react-router'
|
import { Router, Route, IndexRoute } from 'react-router'
|
||||||
import FormList from 'forms/list.jsx'
|
import FormList from 'forms/list.jsx'
|
||||||
import FormForm from 'forms/form.jsx'
|
|
||||||
import createHashHistory from 'history/lib/createHashHistory'
|
import createHashHistory from 'history/lib/createHashHistory'
|
||||||
|
|
||||||
let history = createHashHistory({ queryKey: false })
|
let history = createHashHistory({ queryKey: false })
|
||||||
@@ -20,8 +19,6 @@ if(container) {
|
|||||||
<Router history={ history }>
|
<Router history={ history }>
|
||||||
<Route path="/" component={ App }>
|
<Route path="/" component={ App }>
|
||||||
<IndexRoute component={ FormList } />
|
<IndexRoute component={ FormList } />
|
||||||
<Route path="new" component={ FormForm } />
|
|
||||||
<Route path="edit/:id" component={ FormForm } />
|
|
||||||
<Route path="*" component={ FormList } />
|
<Route path="*" component={ FormList } />
|
||||||
</Route>
|
</Route>
|
||||||
</Router>
|
</Router>
|
||||||
|
@@ -85,7 +85,12 @@ function(
|
|||||||
Select bulk action
|
Select bulk action
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<select ref="action" value={ this.state.action } onChange={this.handleChangeAction}>
|
<select
|
||||||
|
name="bulk_actions"
|
||||||
|
ref="action"
|
||||||
|
value={ this.state.action }
|
||||||
|
onChange={this.handleChangeAction}
|
||||||
|
>
|
||||||
<option value="">Bulk Actions</option>
|
<option value="">Bulk Actions</option>
|
||||||
{ this.props.bulk_actions.map(function(action, index) {
|
{ this.props.bulk_actions.map(function(action, index) {
|
||||||
return (
|
return (
|
||||||
|
@@ -11,7 +11,7 @@ define(['react', 'classnames'], function(React, classNames) {
|
|||||||
column.is_primary = (index === 0);
|
column.is_primary = (index === 0);
|
||||||
column.sorted = (this.props.sort_by === column.name)
|
column.sorted = (this.props.sort_by === column.name)
|
||||||
? this.props.sort_order
|
? this.props.sort_order
|
||||||
: 'asc';
|
: 'desc';
|
||||||
return (
|
return (
|
||||||
<ListingColumn
|
<ListingColumn
|
||||||
onSort={this.props.onSort}
|
onSort={this.props.onSort}
|
||||||
@@ -32,6 +32,7 @@ define(['react', 'classnames'], function(React, classNames) {
|
|||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
|
name="select_all"
|
||||||
ref="toggle"
|
ref="toggle"
|
||||||
checked={ this.props.selection }
|
checked={ this.props.selection }
|
||||||
onChange={ this.handleSelectItems } />
|
onChange={ this.handleSelectItems } />
|
||||||
|
@@ -26,10 +26,10 @@ define(
|
|||||||
];
|
];
|
||||||
|
|
||||||
var messages = {
|
var messages = {
|
||||||
updated: function() {
|
onUpdate: function() {
|
||||||
MailPoet.Notice.success('Segment successfully updated!');
|
MailPoet.Notice.success('Segment successfully updated!');
|
||||||
},
|
},
|
||||||
created: function() {
|
onCreate: function() {
|
||||||
MailPoet.Notice.success('Segment successfully added!');
|
MailPoet.Notice.success('Segment successfully added!');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -54,7 +54,7 @@ define(
|
|||||||
fields={ fields }
|
fields={ fields }
|
||||||
params={ this.props.params }
|
params={ this.props.params }
|
||||||
messages={ messages }
|
messages={ messages }
|
||||||
onSuccess={ this.history.goBack } />
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -52,10 +52,10 @@ define(
|
|||||||
];
|
];
|
||||||
|
|
||||||
var messages = {
|
var messages = {
|
||||||
updated: function() {
|
onUpdate: function() {
|
||||||
MailPoet.Notice.success('Subscriber successfully updated!');
|
MailPoet.Notice.success('Subscriber successfully updated!');
|
||||||
},
|
},
|
||||||
created: function() {
|
onCreate: function() {
|
||||||
MailPoet.Notice.success('Subscriber successfully added!');
|
MailPoet.Notice.success('Subscriber successfully added!');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -82,7 +82,7 @@ define(
|
|||||||
fields={ fields }
|
fields={ fields }
|
||||||
params={ this.props.params }
|
params={ this.props.params }
|
||||||
messages={ messages }
|
messages={ messages }
|
||||||
onSuccess={ this.history.goBack } />
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,7 @@ class Menu {
|
|||||||
'MailPoet',
|
'MailPoet',
|
||||||
'manage_options',
|
'manage_options',
|
||||||
'mailpoet',
|
'mailpoet',
|
||||||
array($this, 'home'),
|
array($this, 'welcome'),
|
||||||
$this->assets_url . '/img/menu_icon.png',
|
$this->assets_url . '/img/menu_icon.png',
|
||||||
30
|
30
|
||||||
);
|
);
|
||||||
@@ -100,6 +100,7 @@ class Menu {
|
|||||||
function registered_pages() {
|
function registered_pages() {
|
||||||
global $_registered_pages;
|
global $_registered_pages;
|
||||||
$pages = array(
|
$pages = array(
|
||||||
|
'mailpoet-welcome' => array($this, 'welcome'),
|
||||||
'mailpoet-form-editor' => array($this, 'formEditor'),
|
'mailpoet-form-editor' => array($this, 'formEditor'),
|
||||||
'mailpoet-newsletter-editor' => array($this, 'newletterEditor')
|
'mailpoet-newsletter-editor' => array($this, 'newletterEditor')
|
||||||
);
|
);
|
||||||
@@ -117,26 +118,16 @@ class Menu {
|
|||||||
echo $this->renderer->render('index.html', $data);
|
echo $this->renderer->render('index.html', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function settings() {
|
function welcome() {
|
||||||
// flags (available features on WP install)
|
$data = array(
|
||||||
$flags = array();
|
'settings' => Setting::getAll(),
|
||||||
|
'current_user' => wp_get_current_user()
|
||||||
if(is_multisite()) {
|
|
||||||
// get multisite registration option
|
|
||||||
$registration = apply_filters(
|
|
||||||
'wpmu_registration_enabled',
|
|
||||||
get_site_option('registration', 'all')
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// check if users can register
|
echo $this->renderer->render('welcome.html', $data);
|
||||||
$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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function settings() {
|
||||||
$settings = Setting::getAll();
|
$settings = Setting::getAll();
|
||||||
|
|
||||||
// dkim: check if public/private keys have been generated
|
// dkim: check if public/private keys have been generated
|
||||||
@@ -158,7 +149,7 @@ class Menu {
|
|||||||
'settings' => $settings,
|
'settings' => $settings,
|
||||||
'segments' => Segment::getPublished()->findArray(),
|
'segments' => Segment::getPublished()->findArray(),
|
||||||
'pages' => Pages::getAll(),
|
'pages' => Pages::getAll(),
|
||||||
'flags' => $flags,
|
'flags' => $this->_getFlags(),
|
||||||
'charsets' => Charsets::getAll(),
|
'charsets' => Charsets::getAll(),
|
||||||
'current_user' => wp_get_current_user(),
|
'current_user' => wp_get_current_user(),
|
||||||
'permissions' => Permissions::getAll(),
|
'permissions' => Permissions::getAll(),
|
||||||
@@ -171,6 +162,29 @@ class Menu {
|
|||||||
echo $this->renderer->render('settings.html', $data);
|
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() {
|
function subscribers() {
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
|
@@ -4,17 +4,17 @@ namespace MailPoet\Settings;
|
|||||||
class Pages {
|
class Pages {
|
||||||
|
|
||||||
static function getAll() {
|
static function getAll() {
|
||||||
$mailpoet_pages = get_posts(array(
|
$mailpoet_pages = \get_posts(array(
|
||||||
'post_type' => 'mailpoet_page'
|
'post_type' => 'mailpoet_page'
|
||||||
));
|
));
|
||||||
|
|
||||||
$pages = array();
|
$pages = array();
|
||||||
foreach(array_merge($mailpoet_pages, get_pages()) as $page) {
|
foreach(array_merge($mailpoet_pages, \get_pages()) as $page) {
|
||||||
$pages[] = array(
|
$pages[] = array(
|
||||||
'id' => $page->ID,
|
'id' => $page->ID,
|
||||||
'title' => $page->post_title,
|
'title' => $page->post_title,
|
||||||
'preview_url' => get_permalink($page->ID),
|
'preview_url' => \get_permalink($page->ID),
|
||||||
'edit_url' => get_edit_post_link($page->ID)
|
'edit_url' => \get_edit_post_link($page->ID)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$console = new \Codeception\Lib\Console\Output([]);
|
$wp_load_file = getenv('WP_TEST_PATH').'/wp-load.php';
|
||||||
|
require_once($wp_load_file);
|
||||||
|
|
||||||
$console->writeln('Loading WP core...');
|
$console = new \Codeception\Lib\Console\Output([]);
|
||||||
require_once(getenv('WP_TEST_PATH') . '/wp-load.php');
|
$console->writeln('Loading WP core... ('.$wp_load_file.')');
|
||||||
|
|
||||||
$console->writeln('Cleaning up database...');
|
$console->writeln('Cleaning up database...');
|
||||||
$models = array(
|
$models = array(
|
||||||
|
@@ -171,5 +171,9 @@ class SegmentCest {
|
|||||||
->deleteMany();
|
->deleteMany();
|
||||||
ORM::forTable(SubscriberSegment::$_table)
|
ORM::forTable(SubscriberSegment::$_table)
|
||||||
->deleteMany();
|
->deleteMany();
|
||||||
|
ORM::forTable(Newsletter::$_table)
|
||||||
|
->deleteMany();
|
||||||
|
ORM::forTable(NewsletterSegment::$_table)
|
||||||
|
->deleteMany();
|
||||||
}
|
}
|
||||||
}
|
}
|
13
views/welcome.html
Normal file
13
views/welcome.html
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<% extends 'layout.html' %>
|
||||||
|
|
||||||
|
<% block content %>
|
||||||
|
<div id="mailpoet_welcome">
|
||||||
|
<h2><%= __('Welcome welcome welcome!') %></h2>
|
||||||
|
|
||||||
|
<h3>Settings:</h3>
|
||||||
|
<%= dump(settings) %>
|
||||||
|
|
||||||
|
<h3>Current user:</h3>
|
||||||
|
<%= dump(current_user) %>
|
||||||
|
</div>
|
||||||
|
<% endblock %>
|
Reference in New Issue
Block a user