Add Manage subscription page
[MAILPOET-2677]
This commit is contained in:
committed by
Veljko V
parent
48c6fcce37
commit
6026327b1f
@@ -3,3 +3,4 @@ export { default as Label } from './label';
|
|||||||
export { default as Inputs } from './inputs';
|
export { default as Inputs } from './inputs';
|
||||||
export { default as SaveButton } from './save_button';
|
export { default as SaveButton } from './save_button';
|
||||||
export { default as SegmentsSelect } from './segments_select';
|
export { default as SegmentsSelect } from './segments_select';
|
||||||
|
export { default as PagesSelect } from './pages_select';
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import React from 'react';
|
import React, { ReactNode } from 'react';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
title: string
|
title: string
|
||||||
description: string
|
description: ReactNode
|
||||||
htmlFor: string
|
htmlFor: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
39
assets/js/src/settings/components/pages_select.tsx
Normal file
39
assets/js/src/settings/components/pages_select.tsx
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { onChange, t } from 'settings/utils';
|
||||||
|
import { useSelector } from 'settings/store/hooks';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
id?: string
|
||||||
|
value: string
|
||||||
|
linkAutomationId?: string
|
||||||
|
setValue: (x: string) => any
|
||||||
|
preview: 'manage' | 'unsubscribe' | 'confirm'
|
||||||
|
}
|
||||||
|
|
||||||
|
export default (props: Props) => {
|
||||||
|
const pages = useSelector('getPages')();
|
||||||
|
const selectedPage = props.value
|
||||||
|
? pages.find((x) => x.id === parseInt(props.value, 10))
|
||||||
|
: pages[0];
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<select id={props.id} value={props.value} onChange={onChange(props.setValue)}>
|
||||||
|
{pages.map((page) => (
|
||||||
|
<option key={page.id} value={page.id}>
|
||||||
|
{`${page.title}`}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
{' '}
|
||||||
|
<a
|
||||||
|
target="_blank"
|
||||||
|
title={t`previewPage`}
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
href={selectedPage.url[props.preview]}
|
||||||
|
data-automation-id={props.linkAutomationId}
|
||||||
|
>
|
||||||
|
{t`preview`}
|
||||||
|
</a>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
@@ -4,7 +4,7 @@ import 'select2';
|
|||||||
import { useSelector } from 'settings/store/hooks';
|
import { useSelector } from 'settings/store/hooks';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
id?: string
|
id: string
|
||||||
value: string[]
|
value: string[]
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
setValue: (x: string[]) => any
|
setValue: (x: string[]) => any
|
||||||
|
@@ -3,6 +3,7 @@ import { SaveButton } from 'settings/components';
|
|||||||
import { t } from 'settings/utils';
|
import { t } from 'settings/utils';
|
||||||
import DefaultSender from './default_sender';
|
import DefaultSender from './default_sender';
|
||||||
import SubscribeOn from './subscribe_on';
|
import SubscribeOn from './subscribe_on';
|
||||||
|
import ManageSubscription from './manage_subscription';
|
||||||
|
|
||||||
export default function Basics() {
|
export default function Basics() {
|
||||||
return (
|
return (
|
||||||
@@ -18,6 +19,7 @@ export default function Basics() {
|
|||||||
title={t`subscribeInRegistrationTitle`}
|
title={t`subscribeInRegistrationTitle`}
|
||||||
description={t`subscribeInRegistrationDescription`}
|
description={t`subscribeInRegistrationDescription`}
|
||||||
/>
|
/>
|
||||||
|
<ManageSubscription />
|
||||||
<SaveButton />
|
<SaveButton />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
44
assets/js/src/settings/pages/basics/manage_subscription.tsx
Normal file
44
assets/js/src/settings/pages/basics/manage_subscription.tsx
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { t } from 'settings/utils';
|
||||||
|
import { useSetting } from 'settings/store/hooks';
|
||||||
|
import {
|
||||||
|
Label, Inputs, SegmentsSelect, PagesSelect,
|
||||||
|
} from 'settings/components';
|
||||||
|
|
||||||
|
export default function ManageSubscription() {
|
||||||
|
const [page, setPage] = useSetting('subscription', 'pages', 'manage');
|
||||||
|
const [segments, setSegments] = useSetting('subscription', 'segments');
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Label
|
||||||
|
title={t`manageSubTitle`}
|
||||||
|
description={(
|
||||||
|
<>
|
||||||
|
{t`manageSubDescription1`}
|
||||||
|
<br />
|
||||||
|
{t`manageSubDescription2`}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
htmlFor="subscription-pages-manage"
|
||||||
|
/>
|
||||||
|
<Inputs>
|
||||||
|
<PagesSelect
|
||||||
|
value={page}
|
||||||
|
preview="manage"
|
||||||
|
setValue={setPage}
|
||||||
|
id="subscription-pages-manage"
|
||||||
|
linkAutomationId="preview_manage_subscription_page_link"
|
||||||
|
/>
|
||||||
|
<br />
|
||||||
|
<label htmlFor="subscription-segments">{t`subscribersCanChooseFrom`}</label>
|
||||||
|
<br />
|
||||||
|
<SegmentsSelect
|
||||||
|
id="subscription-segments"
|
||||||
|
value={segments}
|
||||||
|
setValue={setSegments}
|
||||||
|
placeholder={t`leaveEmptyToDisplayAll`}
|
||||||
|
/>
|
||||||
|
</Inputs>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
@@ -12,5 +12,6 @@ export default function makeDefaultState(window: any): State {
|
|||||||
},
|
},
|
||||||
data: window.mailpoet_settings,
|
data: window.mailpoet_settings,
|
||||||
segments: window.mailpoet_segments,
|
segments: window.mailpoet_segments,
|
||||||
|
pages: window.mailpoet_pages,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -36,3 +36,7 @@ export function isMssActive(state: State) {
|
|||||||
export function getSegments(state: State) {
|
export function getSegments(state: State) {
|
||||||
return state.segments;
|
return state.segments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getPages(state: State) {
|
||||||
|
return state.pages;
|
||||||
|
}
|
||||||
|
@@ -45,10 +45,19 @@ type Segment = {
|
|||||||
name: string
|
name: string
|
||||||
subscribers: string
|
subscribers: string
|
||||||
}
|
}
|
||||||
|
type Page = {
|
||||||
|
id: number
|
||||||
|
title: string
|
||||||
|
url: {
|
||||||
|
unsubscribe: string
|
||||||
|
manage: string
|
||||||
|
confirm: string
|
||||||
|
}
|
||||||
|
}
|
||||||
export type State = {
|
export type State = {
|
||||||
data: Settings
|
data: Settings
|
||||||
segments: Segment[]
|
segments: Segment[]
|
||||||
|
pages: Page[]
|
||||||
flags: {
|
flags: {
|
||||||
woocommerce: boolean
|
woocommerce: boolean
|
||||||
newUser: boolean
|
newUser: boolean
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
var mailpoet_is_new_user = <%= json_encode(is_new_user == true) %>;
|
var mailpoet_is_new_user = <%= json_encode(is_new_user == true) %>;
|
||||||
var mailpoet_settings = <%= json_encode(settings) %>;
|
var mailpoet_settings = <%= json_encode(settings) %>;
|
||||||
var mailpoet_segments = <%= json_encode(segments) %>;
|
var mailpoet_segments = <%= json_encode(segments) %>;
|
||||||
|
var mailpoet_pages = <%= json_encode(pages) %>;
|
||||||
<% endautoescape %>
|
<% endautoescape %>
|
||||||
var mailpoet_beacon_articles = [
|
var mailpoet_beacon_articles = [
|
||||||
'57f71d49c697911f2d323486',
|
'57f71d49c697911f2d323486',
|
||||||
@@ -49,6 +50,15 @@
|
|||||||
'yesAddMe': __('Yes, add me to your mailing list'),
|
'yesAddMe': __('Yes, add me to your mailing list'),
|
||||||
'chooseList': __('Choose a list'),
|
'chooseList': __('Choose a list'),
|
||||||
|
|
||||||
|
'manageSubTitle': __('Manage Subscription page'),
|
||||||
|
'manageSubDescription1': __('When your subscribers click the "Manage your subscription" link, they will be directed to this page.'),
|
||||||
|
'manageSubDescription2': __('If you want to use a custom Subscription page, simply paste this shortcode on to a WordPress page: [mailpoet_manage_subscription]'),
|
||||||
|
'previewPage': __('Preview page'),
|
||||||
|
'preview': __('Preview'),
|
||||||
|
'subscribersCanChooseFrom': __('Subscribers can choose from these lists:'),
|
||||||
|
'leaveEmptyToDisplayAll': __('Leave this field empty to display all lists'),
|
||||||
|
|
||||||
|
|
||||||
'reinstallConfirmation': __('Are you sure? All of your MailPoet data will be permanently erased (newsletters, statistics, subscribers, etc.).'),
|
'reinstallConfirmation': __('Are you sure? All of your MailPoet data will be permanently erased (newsletters, statistics, subscribers, etc.).'),
|
||||||
'announcementHeader': __('Get notified when someone subscribes'),
|
'announcementHeader': __('Get notified when someone subscribes'),
|
||||||
'announcementParagraph1': __('It’s been a popular feature request from our users, we hope you get lots of emails about all your new subscribers!'),
|
'announcementParagraph1': __('It’s been a popular feature request from our users, we hope you get lots of emails about all your new subscribers!'),
|
||||||
|
Reference in New Issue
Block a user