Save settings on key verification to prevent data loss

[MAILPOET-2991]
This commit is contained in:
Jan Jakeš
2020-06-25 10:25:15 +02:00
committed by Veljko V
parent 94cabf2100
commit 136b1d4588
4 changed files with 10 additions and 3 deletions

View File

@ -17,6 +17,7 @@ export default function KeyActivation() {
const { notices } = useContext<any>(GlobalContext);
const state = useSelector('getKeyActivationState')();
const setState = useAction('updateKeyActivationState');
const saveSettings = useAction('saveSettings');
const verifyMssKey = useAction('verifyMssKey');
const verifyPremiumKey = useAction('verifyPremiumKey');
const installPremiumPlugin = useAction('installPremiumPlugin');
@ -103,6 +104,7 @@ export default function KeyActivation() {
});
MailPoet.Modal.loading(true);
setState({ inProgress: true });
await saveSettings();
await verifyMssKey(state.key);
await sendCongratulatoryMssEmail();
await verifyPremiumKey(state.key);

View File

@ -73,7 +73,11 @@ class Settings extends APIEndpoint {
$this->onSettingsChange($oldSettings, $this->settings->getAll());
// when pending approval, leave this to cron / Key Activation tab logic
if (!$this->servicesChecker->isMailPoetAPIKeyPendingApproval()) {
$this->bridge->onSettingsSave($settings);
}
$this->authorizedEmailsController->onSettingsSave($settings);
if ($signupConfirmation !== $this->settings->get('signup_confirmation.enabled')) {
Form::updateSuccessMessages();

View File

@ -180,6 +180,7 @@ class AddSendingKeyCest {
// ensure status is running
$i->amOnMailpoetPage('Help#/systemStatus');
$i->scrollTo('.mailpoet-tab-content');
$i->waitForText('Status running');
}
}

View File

@ -37,7 +37,7 @@ class SettingsTest extends \MailPoetTest {
new Bridge,
$this->make(AuthorizedEmailsController::class, ['onSettingsSave' => true ]),
$this->make(TransactionalEmails::class),
$this->make(ServicesChecker::class)
$this->make(ServicesChecker::class, ['isMailPoetAPIKeyPendingApproval' => false])
);
}
@ -70,7 +70,7 @@ class SettingsTest extends \MailPoetTest {
$this->make(Bridge::class, ['onSettingsSave' => Expected::once()]),
$this->make(AuthorizedEmailsController::class, ['onSettingsSave' => Expected::once()]),
$this->make(TransactionalEmails::class),
$this->make(ServicesChecker::class)
$this->make(ServicesChecker::class, ['isMailPoetAPIKeyPendingApproval' => false])
);
$response = $this->endpoint->set(/* missing data */);