Remove select form template feature switch

[MAILPOET-2988]
This commit is contained in:
Rostislav Wolny
2020-09-30 11:13:16 +02:00
committed by Veljko V
parent bd08cfd6a0
commit ec2e2418fd
4 changed files with 38 additions and 75 deletions

View File

@ -5,7 +5,6 @@ import jQuery from 'jquery';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import Listing from 'listing/listing.jsx'; import Listing from 'listing/listing.jsx';
import withNpsPoll from 'nps_poll.jsx'; import withNpsPoll from 'nps_poll.jsx';
import { GlobalContext } from 'context/index.jsx';
const columns = [ const columns = [
{ {
@ -153,35 +152,10 @@ const itemActions = [
]; ];
class FormList extends React.Component { class FormList extends React.Component {
createForm = (templatesEnabled) => { goToSelectTemplate = () => {
if (templatesEnabled) { setTimeout(() => {
MailPoet.trackEvent('Forms > Add New', { window.location = window.mailpoet_form_template_selection_url;
'MailPoet Free version': window.mailpoet_version, }, 200); // leave some time for the event to track
});
setTimeout(() => {
window.location = window.mailpoet_form_template_selection_url;
}, 200); // leave some time for the event to track
} else {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'forms',
action: 'create',
}).done((response) => {
MailPoet.trackEvent('Forms > Add New', {
'MailPoet Free version': window.mailpoet_version,
});
setTimeout(() => {
window.location = window.mailpoet_form_edit_url + response.data.id;
}, 200);
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map((error) => error.message),
{ scroll: true }
);
}
});
}
}; };
updateStatus = (e) => { updateStatus = (e) => {
@ -280,37 +254,33 @@ class FormList extends React.Component {
render() { render() {
return ( return (
<GlobalContext.Consumer> <div>
{(value) => ( <h1 className="title">
<div> {MailPoet.I18n.t('pageTitle')}
<h1 className="title"> {' '}
{MailPoet.I18n.t('pageTitle')} <button
{' '} className="page-title-action"
<button onClick={() => this.goToSelectTemplate()}
className="page-title-action" data-automation-id="create_new_form"
onClick={() => this.createForm(value.features.isSupported('templates-selection'))} type="button"
data-automation-id="create_new_form" >
type="button" {MailPoet.I18n.t('new')}
> </button>
{MailPoet.I18n.t('new')} </h1>
</button>
</h1>
<Listing <Listing
limit={window.mailpoet_listing_per_page} limit={window.mailpoet_listing_per_page}
location={this.props.location} location={this.props.location}
params={this.props.match.params} params={this.props.match.params}
messages={messages} messages={messages}
search={false} search={false}
endpoint="forms" endpoint="forms"
onRenderItem={this.renderItem} onRenderItem={this.renderItem}
columns={columns} columns={columns}
bulk_actions={bulkActions} bulk_actions={bulkActions}
item_actions={itemActions} item_actions={itemActions}
/> />
</div> </div>
)}
</GlobalContext.Consumer>
); );
} }
} }

View File

@ -6,15 +6,9 @@ use MailPoetVendor\Doctrine\DBAL\Exception\TableNotFoundException;
class FeaturesController { class FeaturesController {
// Define features below in the following form:
// const FEATURE_NAME_OF_FEATURE = 'name-of-feature';
const TEMPLATES_SELECTION = 'templates-selection';
// Define feature defaults in the array below in the following form: // Define feature defaults in the array below in the following form:
// self::FEATURE_NAME_OF_FEATURE => true, // self::FEATURE_NAME_OF_FEATURE => true,
private $defaults = [ private $defaults = [];
self::TEMPLATES_SELECTION => false,
];
/** @var array */ /** @var array */
private $flags; private $flags;

View File

@ -2,16 +2,9 @@
namespace MailPoet\Test\Acceptance; namespace MailPoet\Test\Acceptance;
use MailPoet\Features\FeaturesController;
use MailPoet\Test\DataFactories\Features;
use MailPoet\Test\DataFactories\Segment; use MailPoet\Test\DataFactories\Segment;
class CreateFormUsingTemplateCest { class CreateFormUsingTemplateCest {
public function _before() {
$features = new Features();
$features->withFeatureEnabled(FeaturesController::TEMPLATES_SELECTION);
}
public function createFormUsingTemplate(\AcceptanceTester $i) { public function createFormUsingTemplate(\AcceptanceTester $i) {
$segmentFactory = new Segment(); $segmentFactory = new Segment();
$segmentName = 'Fancy List'; $segmentName = 'Fancy List';
@ -23,7 +16,11 @@ class CreateFormUsingTemplateCest {
$i->click('[data-automation-id="create_new_form"]'); $i->click('[data-automation-id="create_new_form"]');
$i->waitForElement('[data-automation-id="template_selection_list"]'); $i->waitForElement('[data-automation-id="template_selection_list"]');
$i->click('[data-automation-id="select_template_template_1_popup"]'); $i->waitForElement('[data-automation-id="select_template_template_1_popup"]');
$i->wantTo('Switch template category and crete a form');
$i->click('[data-title="Fixed bar"]');
$i->waitForElement('[data-automation-id="select_template_template_1_fixed_bar"]');
$i->click('[data-automation-id="select_template_template_1_fixed_bar"]');
$i->waitForElement('[data-automation-id="form_title_input"]', 20); $i->waitForElement('[data-automation-id="form_title_input"]', 20);
$i->selectOptionInSelect2($segmentName); $i->selectOptionInSelect2($segmentName);

View File

@ -43,6 +43,8 @@ class FormEditorUpdateNewFormCest {
$formName = 'My awesome form'; $formName = 'My awesome form';
$updatedFormName = 'My updated awesome form'; $updatedFormName = 'My updated awesome form';
$i->click('[data-automation-id="create_new_form"]'); $i->click('[data-automation-id="create_new_form"]');
$i->waitForElement('[data-automation-id="template_selection_list"]');
$i->click('[data-automation-id="select_template_template_1_popup"]');
$i->waitForElement('[data-automation-id="form_title_input"]'); $i->waitForElement('[data-automation-id="form_title_input"]');
$i->fillField('[data-automation-id="form_title_input"]', $formName); $i->fillField('[data-automation-id="form_title_input"]', $formName);
// Try saving form without selected list // Try saving form without selected list