Add reinstall button
This commit is contained in:
committed by
Veljko V
parent
9e3826a46a
commit
7fe1d30cb7
@@ -7,6 +7,7 @@ import Transactional from './transactional';
|
|||||||
import InactiveSubscribers from './inactive_subscribers';
|
import InactiveSubscribers from './inactive_subscribers';
|
||||||
import ShareData from './share_data';
|
import ShareData from './share_data';
|
||||||
import Captcha from './captcha';
|
import Captcha from './captcha';
|
||||||
|
import Reinstall from './reinstall';
|
||||||
|
|
||||||
export default function Advanced() {
|
export default function Advanced() {
|
||||||
return (
|
return (
|
||||||
@@ -19,6 +20,7 @@ export default function Advanced() {
|
|||||||
<InactiveSubscribers />
|
<InactiveSubscribers />
|
||||||
<ShareData />
|
<ShareData />
|
||||||
<Captcha />
|
<Captcha />
|
||||||
|
<Reinstall />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
34
assets/js/src/settings/pages/advanced/reinstall.tsx
Normal file
34
assets/js/src/settings/pages/advanced/reinstall.tsx
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import { t } from 'common/functions';
|
||||||
|
import { GlobalContext } from 'context';
|
||||||
|
import { useAction } from 'settings/store/hooks';
|
||||||
|
import { Label, Inputs } from 'settings/components';
|
||||||
|
|
||||||
|
export default function Reinstall() {
|
||||||
|
const reinstall = useAction('reinstall');
|
||||||
|
const { notices } = React.useContext<any>(GlobalContext);
|
||||||
|
const onClick = async () => {
|
||||||
|
if (window.confirm(t('reinstallConfirmation'))) { // eslint-disable-line
|
||||||
|
type Result = { type: 'SAVE_FAILED' | 'SAVE_DONE', error?: any }
|
||||||
|
const action = (await reinstall()) as any as Result;
|
||||||
|
if (action.type === 'SAVE_FAILED') {
|
||||||
|
notices.error(action.error.map((err) => <p>{err}</p>), { scroll: true });
|
||||||
|
} else {
|
||||||
|
window.location.href = 'admin.php?page=mailpoet-newsletters';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Label
|
||||||
|
title={t('reinstallTitle')}
|
||||||
|
description={t('reinstallDescription')}
|
||||||
|
htmlFor=""
|
||||||
|
/>
|
||||||
|
<Inputs>
|
||||||
|
<button type="button" className="button" onClick={onClick}>{t('reinstallNow')}</button>
|
||||||
|
</Inputs>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
@@ -188,3 +188,18 @@ export function* installPremiumPlugin() {
|
|||||||
}
|
}
|
||||||
return yield* activatePremiumPlugin(true);
|
return yield* activatePremiumPlugin(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function* reinstall() {
|
||||||
|
MailPoet.Modal.loading(true);
|
||||||
|
const { success, error } = yield {
|
||||||
|
type: 'CALL_API',
|
||||||
|
endpoint: 'setup',
|
||||||
|
action: 'reset',
|
||||||
|
};
|
||||||
|
MailPoet.Modal.loading(false);
|
||||||
|
if (!success) {
|
||||||
|
return { type: 'SAVE_FAILED', error };
|
||||||
|
}
|
||||||
|
yield { type: 'TRACK_REINSTALLED' };
|
||||||
|
return { type: 'SAVE_DONE' };
|
||||||
|
}
|
||||||
|
@@ -31,3 +31,10 @@ export function TRACK_SETTINGS_SAVED() {
|
|||||||
}
|
}
|
||||||
MailPoet.trackEvent('User has saved Settings', data);
|
MailPoet.trackEvent('User has saved Settings', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function TRACK_REINSTALLED() {
|
||||||
|
MailPoet.trackEvent(
|
||||||
|
'User has reinstalled MailPoet via Settings',
|
||||||
|
{ 'MailPoet Free version': MailPoet.version }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user