Use get settings selector in the form placement

[MAILPOET-2740]
This commit is contained in:
Pavel Dohnal
2020-04-13 12:00:13 +02:00
committed by Veljko V
parent 68c4f96966
commit 734cc5a378
4 changed files with 23 additions and 63 deletions

View File

@@ -7,15 +7,13 @@ import Toggle from '../../../../common/toggle';
import Icon from './below_pages_icon';
const BelowPages = () => {
const placeFormBellowAllPages = useSelect(
(select) => select('mailpoet-form-editor').placeFormBellowAllPages(),
const formSettings = useSelect(
(select) => select('mailpoet-form-editor').getFormSettings(),
[]
);
const placeFormBellowAllPages = formSettings.placeFormBellowAllPages || false;
const placeFormBellowAllPosts = formSettings.placeFormBellowAllPosts || false;
const placeFormBellowAllPosts = useSelect(
(select) => select('mailpoet-form-editor').placeFormBellowAllPosts(),
[]
);
const { setPlaceFormBellowAllPages, setPlaceFormBellowAllPosts } = useDispatch('mailpoet-form-editor');
const [

View File

@@ -10,24 +10,17 @@ import Icon from './fixed_bar_icon';
const delayValues = [0, 15, 30, 60, 120, 180, 240];
const FixedBar = () => {
const fixedBarFormDelay = useSelect(
(select) => select('mailpoet-form-editor').getFixedBarFormDelay(),
[]
);
const fixedBarFormPosition = useSelect(
(select) => select('mailpoet-form-editor').getFixedBarFormPosition(),
const formSettings = useSelect(
(select) => select('mailpoet-form-editor').getFormSettings(),
[]
);
const fixedBarFormDelay = formSettings.fixedBarFormDelay === undefined
? 15
: formSettings.fixedBarFormDelay;
const fixedBarFormPosition = formSettings.fixedBarFormPosition === undefined ? 'top' : formSettings.fixedBarFormPosition;
const placeFixedBarFormOnAllPages = formSettings.placeFixedBarFormOnAllPages || false;
const placeFixedBarFormOnAllPosts = formSettings.placeFixedBarFormOnAllPosts || false;
const placeFixedBarFormOnAllPages = useSelect(
(select) => select('mailpoet-form-editor').placeFixedBarFormOnAllPages(),
[]
);
const placeFixedBarFormOnAllPosts = useSelect(
(select) => select('mailpoet-form-editor').placeFixedBarFormOnAllPosts(),
[]
);
const {
setPlaceFixedBarFormOnAllPages,
setPlaceFixedBarFormOnAllPosts,
@@ -46,11 +39,11 @@ const FixedBar = () => {
const [
localDelay,
setLocalDelay,
] = useState(fixedBarFormDelay === undefined ? 15 : fixedBarFormDelay);
] = useState(fixedBarFormDelay);
const [
localPosition,
setLocalPosition,
] = useState(fixedBarFormPosition === undefined ? 'top' : fixedBarFormPosition);
] = useState(fixedBarFormPosition);
const save = () => {
setPlaceFixedBarFormOnAllPages(localPlaceFixedBarFormOnAllPages);
@@ -69,7 +62,7 @@ const FixedBar = () => {
>
<div className="mailpoet-toggle-list">
<div className="mailpoet-toggle-list-description">
{MailPoet.I18n.t('placeFixedBarFormOnPages')}
{MailPoet.I18n.t('placeFormBellowAllPages')}
</div>
<div className="mailpoet-toggle-list-toggle">
<Toggle

View File

@@ -10,20 +10,16 @@ import Icon from './popup_icon';
const delayValues = [0, 15, 30, 60, 120, 180, 240];
const Popup = () => {
const popupFormDelay = useSelect(
(select) => select('mailpoet-form-editor').getPopupFormDelay(),
const formSettings = useSelect(
(select) => select('mailpoet-form-editor').getFormSettings(),
[]
);
const popupFormDelay = formSettings.popupFormDelay === undefined
? 15
: formSettings.fixedBarFormDelay;
const placePopupFormOnAllPages = formSettings.placePopupFormOnAllPages || false;
const placePopupFormOnAllPosts = formSettings.placePopupFormOnAllPosts || false;
const placePopupFormOnAllPages = useSelect(
(select) => select('mailpoet-form-editor').placePopupFormOnAllPages(),
[]
);
const placePopupFormOnAllPosts = useSelect(
(select) => select('mailpoet-form-editor').placePopupFormOnAllPosts(),
[]
);
const {
setPlacePopupFormOnAllPages,
setPlacePopupFormOnAllPosts,
@@ -41,7 +37,7 @@ const Popup = () => {
const [
localDelay,
setLocalDelay,
] = useState(popupFormDelay === undefined ? 15 : popupFormDelay);
] = useState(popupFormDelay);
const save = () => {
setPlacePopupFormOnAllPages(localPlacePopupFormOnAllPages);

View File

@@ -34,33 +34,6 @@ export default {
getFormSettings(state) {
return state.formData.settings;
},
placeFormBellowAllPages(state) {
return state.formData.settings.placeFormBellowAllPages || false;
},
placeFormBellowAllPosts(state) {
return state.formData.settings.placeFormBellowAllPosts || false;
},
placePopupFormOnAllPages(state) {
return state.formData.settings.placePopupFormOnAllPages || false;
},
placePopupFormOnAllPosts(state) {
return state.formData.settings.placePopupFormOnAllPosts || false;
},
getPopupFormDelay(state) {
return state.formData.settings.popupFormDelay;
},
placeFixedBarFormOnAllPages(state) {
return state.formData.settings.placeFixedBarFormOnAllPages || false;
},
placeFixedBarFormOnAllPosts(state) {
return state.formData.settings.placeFixedBarFormOnAllPosts || false;
},
getFixedBarFormDelay(state) {
return state.formData.settings.fixedBarFormDelay;
},
getFixedBarFormPosition(state) {
return state.formData.settings.fixedBarFormPosition;
},
getAllAvailableSegments(state) {
return state.segments;
},