@capillarytech/creatives-library 9.2.1-alpha.sprint-cap-214249.42 → 9.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AppRoot.js +4 -7
- package/constants/unified.js +1 -0
- package/package.json +1 -1
- package/utils/beePluginLoader.js +106 -0
- package/utils/common.js +6 -0
- package/utils/createMobilePushPayload.js +51 -56
- package/utils/tests/beePluginLoader.test.js +199 -0
- package/utils/tests/createMobilePushPayload.test.js +10 -162
- package/v2Components/CapMpushCTA/index.js +57 -47
- package/v2Components/CapMpushCTA/index.scss +5 -43
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +8 -11
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
- package/v2Components/CommonTestAndPreview/constants.js +0 -2
- package/v2Components/CommonTestAndPreview/index.js +10 -48
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -83
- package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
- package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
- package/v2Components/TemplatePreview/index.js +12 -14
- package/v2Components/TemplatePreview/tests/index.test.js +0 -69
- package/v2Containers/BeeEditor/index.js +49 -22
- package/v2Containers/BeeEditor/index.scss +12 -0
- package/v2Containers/BeeEditor/messages.js +8 -0
- package/v2Containers/BeeEditor/test/index.test.js +78 -0
- package/v2Containers/BeePopupEditor/index.js +22 -11
- package/v2Containers/CreativesContainer/SlideBoxContent.js +9 -5
- package/v2Containers/CreativesContainer/index.js +1 -2
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -43
- package/v2Containers/Email/index.js +2 -2
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +25 -23
- package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +222 -314
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +130 -161
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +123 -484
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +46 -152
- package/v2Containers/MobilePushNew/constants.js +0 -12
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -78
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -40
- package/v2Containers/MobilePushNew/hooks/useUpload.js +46 -42
- package/v2Containers/MobilePushNew/index.js +273 -503
- package/v2Containers/MobilePushNew/index.scss +4 -215
- package/v2Containers/MobilePushNew/messages.js +6 -106
- package/v2Containers/MobilePushNew/tests/index.test.js +1 -482
- package/v2Containers/MobilePushNew/tests/utils.test.js +0 -122
- package/v2Containers/MobilePushNew/utils.js +0 -107
- package/v2Containers/Templates/_templates.scss +2 -10
- package/v2Containers/Templates/index.js +81 -83
- package/v2Containers/Templates/tests/index.test.js +0 -68
- package/v2Components/CapMpushCTA/tests/index.test.js +0 -150
- package/v2Containers/MobilePushNew/components/TapLinkActions.js +0 -76
|
@@ -19,12 +19,10 @@ import CapSpin from "@capillarytech/cap-ui-library/CapSpin";
|
|
|
19
19
|
import CapTab from "@capillarytech/cap-ui-library/CapTab";
|
|
20
20
|
import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
|
|
21
21
|
import CapColumn from "@capillarytech/cap-ui-library/CapColumn";
|
|
22
|
-
import CapSelect from "@capillarytech/cap-ui-library/CapSelect";
|
|
23
22
|
import { intlShape, FormattedMessage } from "react-intl";
|
|
24
23
|
import "./index.scss";
|
|
25
24
|
import { GA } from "@capillarytech/cap-ui-utils";
|
|
26
25
|
import CapNotification from "@capillarytech/cap-ui-library/CapNotification";
|
|
27
|
-
import CapModal from "@capillarytech/cap-ui-library/CapModal";
|
|
28
26
|
import { DAEMON } from "@capillarytech/vulcan-react-sdk/utils/sagaInjectorTypes";
|
|
29
27
|
import globalMessages from "../Cap/messages";
|
|
30
28
|
import * as actions from "./actions";
|
|
@@ -32,7 +30,6 @@ import {
|
|
|
32
30
|
MEDIA_TYPES_OPTIONS,
|
|
33
31
|
ANDROID,
|
|
34
32
|
IOS,
|
|
35
|
-
BOTH_PLATFORMS,
|
|
36
33
|
MOBILE_PUSH_CHANNEL,
|
|
37
34
|
INITIAL_CONTENT,
|
|
38
35
|
BIG_PICTURE,
|
|
@@ -78,6 +75,7 @@ import {
|
|
|
78
75
|
import withCreatives from "../../hoc/withCreatives";
|
|
79
76
|
import { BIG_TEXT, DEEP_LINK, DEVICE_SUPPORTED } from "../InApp/constants";
|
|
80
77
|
import { v2MobilePushSagas } from "./sagas";
|
|
78
|
+
import { getContent } from "../MobilePush/commonMethods";
|
|
81
79
|
import { getMessageObject } from "../../utils/messageUtils";
|
|
82
80
|
import { gtmPush } from "../../utils/gtmTrackers";
|
|
83
81
|
import mobilePushReducer from "./reducer";
|
|
@@ -90,21 +88,36 @@ import useUpload from "./hooks/useUpload";
|
|
|
90
88
|
import { validateTags } from "../../utils/tagValidations";
|
|
91
89
|
import { PlatformContentFields } from "./components";
|
|
92
90
|
import { CREATE, EDIT, TRACK_CREATE_MPUSH } from "../App/constants";
|
|
93
|
-
import {
|
|
94
|
-
validateExternalLink, validateDeepLink, isPlatformFieldsMissing, getContent, getCarouselCardIssue,
|
|
95
|
-
extractDeepLinkParams, appendDeepLinkParams, hasAllDeepLinkParams,
|
|
96
|
-
} from "./utils";
|
|
91
|
+
import { validateExternalLink, validateDeepLink, isPlatformFieldsMissing } from "./utils";
|
|
97
92
|
import messages from "./messages";
|
|
98
93
|
import { EXTERNAL_URL, MOBILE_PUSH } from "../CreativesContainer/constants";
|
|
99
|
-
import createMobilePushPayloadWithIntl
|
|
94
|
+
import createMobilePushPayloadWithIntl from "../../utils/createMobilePushPayload";
|
|
100
95
|
import { MOBILEPUSH } from "../../v2Components/CapVideoUpload/constants";
|
|
101
96
|
import { StyledCapTab } from "./style";
|
|
102
97
|
import TestAndPreviewSlidebox from "../../v2Components/TestAndPreviewSlidebox";
|
|
103
98
|
|
|
104
99
|
import creativesMessages from "../CreativesContainer/messages";
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
100
|
+
import { error } from "jquery";
|
|
101
|
+
|
|
102
|
+
// Helper function to extract deep link keys from URL where value equals key
|
|
103
|
+
const extractDeepLinkKeys = (deepLinkValue) => {
|
|
104
|
+
try {
|
|
105
|
+
if (deepLinkValue?.includes('?')) {
|
|
106
|
+
const queryString = deepLinkValue.split('?')[1];
|
|
107
|
+
const searchParams = new URLSearchParams(queryString);
|
|
108
|
+
const extractedKeys = [];
|
|
109
|
+
searchParams.forEach((value, key) => {
|
|
110
|
+
if (value === key) { // Only extract keys where value equals key
|
|
111
|
+
extractedKeys.push(key);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return extractedKeys;
|
|
115
|
+
}
|
|
116
|
+
return [];
|
|
117
|
+
} catch (error) {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
};
|
|
108
121
|
|
|
109
122
|
// Helper function to process media type from various sources
|
|
110
123
|
/**
|
|
@@ -263,44 +276,8 @@ const processCtaButtons = (ctas, deepLink) => {
|
|
|
263
276
|
};
|
|
264
277
|
};
|
|
265
278
|
|
|
266
|
-
const getOtherPlatform = (platform) => (platform === ANDROID ? IOS : ANDROID);
|
|
267
|
-
|
|
268
|
-
// Title, message or media entered for a platform
|
|
269
|
-
const hasPlatformContent = (content) => !!(
|
|
270
|
-
content?.title?.trim()
|
|
271
|
-
|| content?.message?.trim()
|
|
272
|
-
|| (content?.mediaType && content.mediaType !== NONE)
|
|
273
|
-
);
|
|
274
|
-
|
|
275
|
-
// Platforms dropdown value for a saved template: whichever of ANDROID / IOS it has
|
|
276
|
-
const getSavedPlatformSelection = (base = {}) => {
|
|
277
|
-
const hasAndroid = !isEmpty(base?.ANDROID);
|
|
278
|
-
const hasIos = !isEmpty(base?.IOS);
|
|
279
|
-
if (hasAndroid && !hasIos) return ANDROID;
|
|
280
|
-
if (hasIos && !hasAndroid) return IOS;
|
|
281
|
-
return BOTH_PLATFORMS;
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
// Saved buttons in backend shape { actionText, type, actionLink }; used by Save and Test & Preview
|
|
285
|
-
const toSavedCtas = (ctaData = []) => (ctaData || [])
|
|
286
|
-
.filter((cta) => cta?.isSaved)
|
|
287
|
-
.map((cta) => {
|
|
288
|
-
let actionLink = cta?.url;
|
|
289
|
-
|
|
290
|
-
// Append deep link params ("key=value") to the URL
|
|
291
|
-
if (cta?.urlType === DEEP_LINK && cta?.deepLinkKeys?.length > 0) {
|
|
292
|
-
actionLink = appendDeepLinkParams(actionLink, cta?.deepLinkKeys);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
return {
|
|
296
|
-
actionText: cta?.text,
|
|
297
|
-
type: cta?.urlType || DEEP_LINK,
|
|
298
|
-
actionLink,
|
|
299
|
-
};
|
|
300
|
-
});
|
|
301
|
-
|
|
302
279
|
// Helper function to create content data object
|
|
303
|
-
const createContentData =(contentType, mediaInfo, buttons, deepLink, processCarouselDataForDeepLinks) => {
|
|
280
|
+
const createContentData = (contentType, mediaInfo, buttons, deepLink, processCarouselDataForDeepLinks) => {
|
|
304
281
|
const {
|
|
305
282
|
mediaType,
|
|
306
283
|
imageSrc,
|
|
@@ -526,9 +503,6 @@ export const MobilePushNew = ({
|
|
|
526
503
|
supportedTags = [],
|
|
527
504
|
globalActions: globalActionsProps,
|
|
528
505
|
handleClose,
|
|
529
|
-
// Edit mode: footer Test & Preview button lives in CreativesContainer
|
|
530
|
-
showTestAndPreviewSlidebox: propsShowTestAndPreviewSlidebox,
|
|
531
|
-
handleCloseTestAndPreview: propsHandleCloseTestAndPreview,
|
|
532
506
|
fetchingLiquidValidation,
|
|
533
507
|
createTemplateError,
|
|
534
508
|
isGetFormData,
|
|
@@ -545,30 +519,11 @@ export const MobilePushNew = ({
|
|
|
545
519
|
const templateId = params?.id || templateData?._id || templateData?.id;
|
|
546
520
|
const isEditMode = !!templateId;
|
|
547
521
|
const computedCreativesMode = isEditMode || templateData?.type === MOBILEPUSH ? 'edit' : 'create';
|
|
548
|
-
|
|
549
|
-
const [sameContentChecked, setSameContent] = useState(false);
|
|
550
|
-
// Platforms dropdown: BOTH_PLATFORMS, ANDROID or IOS
|
|
551
|
-
const [platformSelection, setPlatformSelection] = useState(BOTH_PLATFORMS);
|
|
552
|
-
// Single platform waiting on the "Remove content" confirm
|
|
553
|
-
const [pendingPlatformSelection, setPendingPlatformSelection] = useState(null);
|
|
554
|
-
// Platform dropped by Both -> single; cleared after the switch, once sync is off
|
|
555
|
-
const [platformToClear, setPlatformToClear] = useState(null);
|
|
556
|
-
// Determine platform support from accountData
|
|
557
|
-
const isAndroidSupported = accountData?.configs?.android === '1';
|
|
558
|
-
const isIosSupported = accountData?.configs?.ios === '1';
|
|
559
|
-
// The Platforms dropdown only applies when the account supports both
|
|
560
|
-
const canChoosePlatforms = isAndroidSupported && isIosSupported;
|
|
561
|
-
// ANDROID or IOS when one platform is chosen, else null
|
|
562
|
-
const singlePlatform = canChoosePlatforms && platformSelection !== BOTH_PLATFORMS ? platformSelection : null;
|
|
563
|
-
const showAndroid = isAndroidSupported && singlePlatform !== IOS;
|
|
564
|
-
const showIos = isIosSupported && singlePlatform !== ANDROID;
|
|
565
|
-
const sameContent = sameContentChecked && !singlePlatform;
|
|
522
|
+
const [sameContent, setSameContent] = useState(false);
|
|
566
523
|
const [templateName, setTemplateName] = useState("");
|
|
567
524
|
const [spin, setSpin] = useState(false);
|
|
568
525
|
const [activeTab, setActiveTab] = useState(ANDROID);
|
|
569
526
|
const [templateNameError, setTemplateNameError] = useState(false);
|
|
570
|
-
// "Same content" tick waiting on the Replace confirm
|
|
571
|
-
const [isReplaceConfirmOpen, setIsReplaceConfirmOpen] = useState(false);
|
|
572
527
|
// Replace ctaData with platform-specific state
|
|
573
528
|
const [ctaDataAndroid, setCtaDataAndroid] = useState([]);
|
|
574
529
|
const [ctaDataIos, setCtaDataIos] = useState([]);
|
|
@@ -697,9 +652,52 @@ export const MobilePushNew = ({
|
|
|
697
652
|
const createTimeoutRef = useRef(null);
|
|
698
653
|
|
|
699
654
|
// Function to validate carousel data completeness
|
|
700
|
-
const validateCarouselData = useCallback((carouselData = []) =>
|
|
701
|
-
carouselData?.length
|
|
702
|
-
|
|
655
|
+
const validateCarouselData = useCallback((carouselData = []) => {
|
|
656
|
+
if (!carouselData || carouselData?.length === 0) {
|
|
657
|
+
return false;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
return carouselData.every((card) => {
|
|
661
|
+
// Check if image is uploaded (currently only image media type is supported)
|
|
662
|
+
if (card.mediaType === IMAGE.toLowerCase() && !card.imageUrl) {
|
|
663
|
+
return false;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// Check if buttons have proper link data when actionOnClick is true
|
|
667
|
+
if (card?.buttons?.length > 0) {
|
|
668
|
+
return card?.buttons?.every((button) => {
|
|
669
|
+
if (button.actionOnClick) {
|
|
670
|
+
// Check if link is provided based on link type
|
|
671
|
+
if (button.linkType === DEEP_LINK && !button.deepLinkValue) {
|
|
672
|
+
return false;
|
|
673
|
+
}
|
|
674
|
+
if (button.linkType === DEEP_LINK && button.deepLinkValue) {
|
|
675
|
+
// Check if the selected deep link has keys, and if so, require them
|
|
676
|
+
const selectedDeepLink = deepLink?.find((link) => link?.value === button.deepLinkValue);
|
|
677
|
+
const deepLinkKeysFromSelection = selectedDeepLink?.keys;
|
|
678
|
+
let deepLinkKeysFromSelectionArray = [];
|
|
679
|
+
if (Array.isArray(deepLinkKeysFromSelection)) {
|
|
680
|
+
deepLinkKeysFromSelectionArray = deepLinkKeysFromSelection;
|
|
681
|
+
} else if (deepLinkKeysFromSelection) {
|
|
682
|
+
deepLinkKeysFromSelectionArray = [deepLinkKeysFromSelection];
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// Only require deep link keys if the selected deep link has keys defined
|
|
686
|
+
if (deepLinkKeysFromSelectionArray?.length > 0 && (!Array.isArray(button?.deepLinkKeys) || button?.deepLinkKeys?.length === 0)) {
|
|
687
|
+
return false;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
if (button.linkType === EXTERNAL_LINK && !button.externalLinkValue) {
|
|
691
|
+
return false;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
return true;
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
return true;
|
|
699
|
+
});
|
|
700
|
+
}, [deepLink]);
|
|
703
701
|
|
|
704
702
|
// Function to check if carousel data is valid for both platforms
|
|
705
703
|
const isCarouselDataValid = useCallback(() => {
|
|
@@ -755,9 +753,6 @@ export const MobilePushNew = ({
|
|
|
755
753
|
setPrimaryButtonIos(false);
|
|
756
754
|
setSecondaryButtonIos(false);
|
|
757
755
|
setSameContent(false);
|
|
758
|
-
setPlatformSelection(BOTH_PLATFORMS);
|
|
759
|
-
setPendingPlatformSelection(null);
|
|
760
|
-
setPlatformToClear(null);
|
|
761
756
|
setTemplateNameError(false);
|
|
762
757
|
setAndroidTitleError("");
|
|
763
758
|
setAndroidMessageError("");
|
|
@@ -974,8 +969,6 @@ export const MobilePushNew = ({
|
|
|
974
969
|
templateNameRef.current = name;
|
|
975
970
|
});
|
|
976
971
|
|
|
977
|
-
stateUpdates.push(() => setPlatformSelection(getSavedPlatformSelection(editContent)));
|
|
978
|
-
|
|
979
972
|
// Process Android content
|
|
980
973
|
const androidContentType = editContent?.ANDROID;
|
|
981
974
|
if (!isEmpty(androidContentType)) {
|
|
@@ -1111,8 +1104,6 @@ export const MobilePushNew = ({
|
|
|
1111
1104
|
templateNameRef.current = name;
|
|
1112
1105
|
});
|
|
1113
1106
|
|
|
1114
|
-
stateUpdates.push(() => setPlatformSelection(getSavedPlatformSelection(templateContent)));
|
|
1115
|
-
|
|
1116
1107
|
// Process Android content
|
|
1117
1108
|
const androidContentType = templateContent?.ANDROID;
|
|
1118
1109
|
if (!isEmpty(androidContentType)) {
|
|
@@ -1748,6 +1739,10 @@ export const MobilePushNew = ({
|
|
|
1748
1739
|
setSpin(false);
|
|
1749
1740
|
}, [templateData, isFullMode, deepLink, setUpdateMpushImageSrc, setUpdateMpushVideoSrc]);
|
|
1750
1741
|
|
|
1742
|
+
// Determine platform support from accountData
|
|
1743
|
+
const isAndroidSupported = accountData?.configs?.android === '1';
|
|
1744
|
+
const isIosSupported = accountData?.configs?.ios === '1';
|
|
1745
|
+
|
|
1751
1746
|
// Notify parent when personalization tokens are added/removed (for anonymous user flow)
|
|
1752
1747
|
useEffect(() => {
|
|
1753
1748
|
if (!restrictPersonalization || typeof onPersonalizationTokensChange !== 'function') return;
|
|
@@ -1756,8 +1751,8 @@ export const MobilePushNew = ({
|
|
|
1756
1751
|
|| (value.includes('[') && value.includes(']'))
|
|
1757
1752
|
);
|
|
1758
1753
|
const hasTokens = (
|
|
1759
|
-
(
|
|
1760
|
-
|| (
|
|
1754
|
+
(isAndroidSupported && (hasToken(androidContent?.title) || hasToken(androidContent?.message)))
|
|
1755
|
+
|| (isIosSupported && (hasToken(iosContent?.title) || hasToken(iosContent?.message)))
|
|
1761
1756
|
);
|
|
1762
1757
|
onPersonalizationTokensChange(hasTokens);
|
|
1763
1758
|
}, [
|
|
@@ -1766,21 +1761,18 @@ export const MobilePushNew = ({
|
|
|
1766
1761
|
androidContent?.message,
|
|
1767
1762
|
iosContent?.title,
|
|
1768
1763
|
iosContent?.message,
|
|
1769
|
-
|
|
1770
|
-
|
|
1764
|
+
isAndroidSupported,
|
|
1765
|
+
isIosSupported,
|
|
1771
1766
|
onPersonalizationTokensChange,
|
|
1772
1767
|
]);
|
|
1773
1768
|
|
|
1774
|
-
// Validation logic for template creation/update
|
|
1775
|
-
const isAndroidFieldsMissing = isPlatformFieldsMissing(
|
|
1776
|
-
const isIosFieldsMissing = isPlatformFieldsMissing(
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
(showAndroid || showIos)
|
|
1782
|
-
&& (!showAndroid || isAndroidFieldsMissing)
|
|
1783
|
-
&& (!showIos || isIosFieldsMissing)
|
|
1769
|
+
// Validation logic for template creation/update.
|
|
1770
|
+
const isAndroidFieldsMissing = isPlatformFieldsMissing(isAndroidSupported, androidContent);
|
|
1771
|
+
const isIosFieldsMissing = isPlatformFieldsMissing(isIosSupported, iosContent);
|
|
1772
|
+
const isMobilePushContentMissing = (
|
|
1773
|
+
(isAndroidSupported || isIosSupported)
|
|
1774
|
+
&& (!isAndroidSupported || isAndroidFieldsMissing)
|
|
1775
|
+
&& (!isIosSupported || isIosFieldsMissing)
|
|
1784
1776
|
);
|
|
1785
1777
|
|
|
1786
1778
|
// Ref to dedupe reporting of content emptiness to the parent, so we only
|
|
@@ -1804,7 +1796,8 @@ export const MobilePushNew = ({
|
|
|
1804
1796
|
handleMessageChange,
|
|
1805
1797
|
handleTagSelect,
|
|
1806
1798
|
handleMediaTypeChange,
|
|
1807
|
-
|
|
1799
|
+
handleActionOnClickChange,
|
|
1800
|
+
handleLinkTypeChange,
|
|
1808
1801
|
} = usePlatformSync({
|
|
1809
1802
|
setAndroidContent,
|
|
1810
1803
|
setIosContent,
|
|
@@ -1876,21 +1869,9 @@ export const MobilePushNew = ({
|
|
|
1876
1869
|
}
|
|
1877
1870
|
}, [sameContent]);
|
|
1878
1871
|
|
|
1879
|
-
// Notification tap link Save / edit (both tabs when synced)
|
|
1880
|
-
const handleTapLinkSavedChange = useCallback((platform, tapLinkSaved) => {
|
|
1881
|
-
const update = (prev) => ({ ...prev, tapLinkSaved });
|
|
1882
|
-
if (platform === ANDROID || sameContent) setAndroidContent(update);
|
|
1883
|
-
if (platform === IOS || sameContent) setIosContent(update);
|
|
1884
|
-
}, [sameContent]);
|
|
1885
|
-
|
|
1886
|
-
// Notification tap URL: required once External link is chosen; same message as the button form
|
|
1887
|
-
const getTapUrlError = useCallback((url) => (
|
|
1888
|
-
!url?.trim() || validateExternalLink(url, formatMessage, messages) ? formatMessage(messages.urlNotValid) : ""
|
|
1889
|
-
), [formatMessage]);
|
|
1890
|
-
|
|
1891
1872
|
const handleExternalLinkChange = useCallback((platform, externalLinkValue) => {
|
|
1892
1873
|
// Validate URL
|
|
1893
|
-
const urlError =
|
|
1874
|
+
const urlError = validateExternalLink(externalLinkValue, formatMessage, messages);
|
|
1894
1875
|
|
|
1895
1876
|
const updateContent = {
|
|
1896
1877
|
externalLinkValue,
|
|
@@ -1917,7 +1898,7 @@ export const MobilePushNew = ({
|
|
|
1917
1898
|
setAndroidExternalLinkError(urlError || "");
|
|
1918
1899
|
}
|
|
1919
1900
|
}
|
|
1920
|
-
}, [
|
|
1901
|
+
}, [validateExternalLink, sameContent]);
|
|
1921
1902
|
|
|
1922
1903
|
// Carousel data handler for platform-specific carousel management
|
|
1923
1904
|
const updateCarouselLinkError = useCallback((cardIndex, field, error) => {
|
|
@@ -2064,20 +2045,11 @@ export const MobilePushNew = ({
|
|
|
2064
2045
|
handleTitleChange,
|
|
2065
2046
|
handleMessageChange,
|
|
2066
2047
|
handleMediaTypeChange,
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
// The old link field is gone, so are its errors (on both tabs when synced)
|
|
2070
|
-
[platform, ...(sameContent ? [getOtherPlatform(platform)] : [])].forEach((target) => {
|
|
2071
|
-
const isAndroidTarget = target === ANDROID;
|
|
2072
|
-
(isAndroidTarget ? setAndroidExternalLinkError : setIosExternalLinkError)("");
|
|
2073
|
-
(isAndroidTarget ? setAndroidDeepLinkError : setIosDeepLinkError)("");
|
|
2074
|
-
(isAndroidTarget ? setAndroidDeepLinkKeysError : setIosDeepLinkKeysError)("");
|
|
2075
|
-
});
|
|
2076
|
-
},
|
|
2048
|
+
handleActionOnClickChange,
|
|
2049
|
+
handleLinkTypeChange,
|
|
2077
2050
|
handleDeepLinkChange: (value) => handleDeepLinkChange(platform, value),
|
|
2078
2051
|
handleDeepLinkKeysChange: (value) => handleDeepLinkKeysChange(platform, value),
|
|
2079
2052
|
handleExternalLinkChange: (value) => handleExternalLinkChange(platform, value),
|
|
2080
|
-
handleTapLinkSavedChange: (isSaved) => handleTapLinkSavedChange(platform, isSaved),
|
|
2081
2053
|
onTagSelect,
|
|
2082
2054
|
handleOnTagsContextChange,
|
|
2083
2055
|
};
|
|
@@ -2197,7 +2169,7 @@ export const MobilePushNew = ({
|
|
|
2197
2169
|
restrictPersonalization={restrictPersonalization}
|
|
2198
2170
|
/>
|
|
2199
2171
|
);
|
|
2200
|
-
}, [androidContent, iosContent, androidTitleError, iosTitleError, androidMessageError, iosMessageError, androidExternalLinkError, iosExternalLinkError, androidDeepLinkError, iosDeepLinkError, androidDeepLinkKeysError, iosDeepLinkKeysError, formatMessage, activeTab, imageSrc, isFullMode, imageData, androidAssetList, iosAssetList, videoState, videoData, location, tags, injectedTags, selectedOfferDetails, primaryButtonAndroid, secondaryButtonAndroid, primaryButtonIos, secondaryButtonIos, ctaData, deepLink, mobilePushActions, carouselActiveTabIndex, carouselLinkErrors, handleTitleChange, handleMessageChange, handleMediaTypeChange,
|
|
2172
|
+
}, [androidContent, iosContent, androidTitleError, iosTitleError, androidMessageError, iosMessageError, androidExternalLinkError, iosExternalLinkError, androidDeepLinkError, iosDeepLinkError, androidDeepLinkKeysError, iosDeepLinkKeysError, formatMessage, activeTab, imageSrc, isFullMode, imageData, androidAssetList, iosAssetList, videoState, videoData, location, tags, injectedTags, selectedOfferDetails, primaryButtonAndroid, secondaryButtonAndroid, primaryButtonIos, secondaryButtonIos, ctaData, deepLink, mobilePushActions, carouselActiveTabIndex, carouselLinkErrors, handleTitleChange, handleMessageChange, handleMediaTypeChange, handleActionOnClickChange, handleLinkTypeChange, handleDeepLinkChange, handleDeepLinkKeysChange, handleExternalLinkChange, onTagSelect, handleOnTagsContextChange, setUpdateMpushImageSrc, updateOnMpushImageReUpload, setUpdateMpushVideoSrc, updateOnMpushVideoReUpload, clearImageDataByMediaType, handleCarouselDataChange, updateCarouselLinkError, sameContent, updateHandler, deleteHandler]
|
|
2201
2173
|
);
|
|
2202
2174
|
|
|
2203
2175
|
// PANES: Only render enabled platforms
|
|
@@ -2207,8 +2179,8 @@ export const MobilePushNew = ({
|
|
|
2207
2179
|
panes.push({
|
|
2208
2180
|
key: ANDROID,
|
|
2209
2181
|
tab: (
|
|
2210
|
-
<CapRow
|
|
2211
|
-
<CapIcon type="android"
|
|
2182
|
+
<CapRow useLegacy>
|
|
2183
|
+
<CapIcon type="android" />
|
|
2212
2184
|
{formatMessage(messages.android)}
|
|
2213
2185
|
</CapRow>
|
|
2214
2186
|
),
|
|
@@ -2219,8 +2191,8 @@ export const MobilePushNew = ({
|
|
|
2219
2191
|
panes.push({
|
|
2220
2192
|
key: IOS,
|
|
2221
2193
|
tab: (
|
|
2222
|
-
<CapRow
|
|
2223
|
-
<CapIcon type="ios"
|
|
2194
|
+
<CapRow useLegacy>
|
|
2195
|
+
<CapIcon type="ios" />
|
|
2224
2196
|
{formatMessage(messages.ios)}
|
|
2225
2197
|
</CapRow>
|
|
2226
2198
|
),
|
|
@@ -2233,42 +2205,25 @@ export const MobilePushNew = ({
|
|
|
2233
2205
|
const errorInTitle = activeTab === ANDROID ? androidTitleError : iosTitleError;
|
|
2234
2206
|
const errorInMessage = activeTab === ANDROID ? androidMessageError : iosMessageError;
|
|
2235
2207
|
|
|
2236
|
-
//
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
}
|
|
2242
|
-
return content.actionOnClick && content.tapLinkSaved === false;
|
|
2243
|
-
});
|
|
2244
|
-
|
|
2245
|
-
const hasFormErrors = (
|
|
2246
|
-
templateNameError
|
|
2208
|
+
// Save button disabled logic: only check enabled platforms, and allow
|
|
2209
|
+
// saving with just one supported platform filled in (see isMobilePushContentMissing).
|
|
2210
|
+
const isSaveDisabled = (
|
|
2211
|
+
isMobilePushContentMissing
|
|
2212
|
+
|| templateNameError
|
|
2247
2213
|
|| Object.values(carouselLinkErrors).some((error) => error !== null && error !== "")
|
|
2248
2214
|
|| !isCarouselDataValid()
|
|
2249
|
-
|| hasUnsavedTapLink
|
|
2250
2215
|
|| errorInTitle || errorInMessage
|
|
2251
2216
|
);
|
|
2252
|
-
// Save needs every shown platform filled
|
|
2253
|
-
const isSaveDisabled = isMobilePushContentMissing || hasFormErrors;
|
|
2254
|
-
const isTestAndPreviewDisabled = isAllContentMissing || hasFormErrors;
|
|
2255
2217
|
|
|
2256
|
-
// Validation in handleSave:
|
|
2218
|
+
// Validation in handleSave: only enforce content on enabled platforms, and
|
|
2219
|
+
// allow saving with just one supported platform filled in.
|
|
2257
2220
|
const handleSave = useCallback(() => {
|
|
2258
2221
|
if (isMobilePushContentMissing) {
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
missingPlatforms.forEach(([platform, , content]) => {
|
|
2264
|
-
const isAndroid = platform === ANDROID;
|
|
2265
|
-
(isAndroid ? setAndroidTitleError : setIosTitleError)(validateTitle(content?.title));
|
|
2266
|
-
(isAndroid ? setAndroidMessageError : setIosMessageError)(validateMessage(content?.message));
|
|
2222
|
+
CapNotification.error({
|
|
2223
|
+
message: formatMessage(
|
|
2224
|
+
isAndroidSupported ? messages.androidValidationError : messages.iosValidationError,
|
|
2225
|
+
),
|
|
2267
2226
|
});
|
|
2268
|
-
// Open a tab that has the errors, unless the open one already does
|
|
2269
|
-
if (!missingPlatforms.some(([platform]) => platform === activeTab)) {
|
|
2270
|
-
setActiveTab(missingPlatforms[0][0]);
|
|
2271
|
-
}
|
|
2272
2227
|
if (onValidationFail) onValidationFail();
|
|
2273
2228
|
return;
|
|
2274
2229
|
}
|
|
@@ -2292,38 +2247,32 @@ export const MobilePushNew = ({
|
|
|
2292
2247
|
// Use ref to get the latest template name value to avoid closure issues
|
|
2293
2248
|
let finalTemplateName = templateNameRef.current || templateName;
|
|
2294
2249
|
if (!isFullMode && (!finalTemplateName || !finalTemplateName.trim())) {
|
|
2295
|
-
if (
|
|
2250
|
+
if (androidContent?.title && androidContent.title.trim()) {
|
|
2296
2251
|
finalTemplateName = androidContent.title.trim();
|
|
2297
|
-
} else if (
|
|
2252
|
+
} else if (iosContent?.title && iosContent.title.trim()) {
|
|
2298
2253
|
finalTemplateName = iosContent.title.trim();
|
|
2299
2254
|
} else {
|
|
2300
2255
|
finalTemplateName = '';
|
|
2301
2256
|
}
|
|
2302
2257
|
}
|
|
2303
2258
|
|
|
2304
|
-
// Validate
|
|
2305
|
-
const
|
|
2306
|
-
const
|
|
2307
|
-
const iosUrlError = showIos && isTapExternalLink(iosContent) && getTapUrlError(iosContent.externalLinkValue);
|
|
2259
|
+
// Validate external links
|
|
2260
|
+
const androidUrlError = validateExternalLink(androidContent.externalLinkValue, formatMessage, messages);
|
|
2261
|
+
const iosUrlError = validateExternalLink(iosContent.externalLinkValue, formatMessage, messages);
|
|
2308
2262
|
|
|
2309
2263
|
setAndroidExternalLinkError(androidUrlError || "");
|
|
2310
2264
|
setIosExternalLinkError(iosUrlError || "");
|
|
2311
2265
|
|
|
2312
|
-
// Validate deep links
|
|
2313
|
-
const
|
|
2314
|
-
|
|
2315
|
-
? formatMessage(messages.deepLinkRequired)
|
|
2316
|
-
: validateDeepLink(content?.deepLinkValue, formatMessage, messages)
|
|
2317
|
-
);
|
|
2318
|
-
const androidDeepLinkUrlError = showAndroid && getTapDeepLinkError(androidContent);
|
|
2319
|
-
const iosDeepLinkUrlError = showIos && getTapDeepLinkError(iosContent);
|
|
2266
|
+
// Validate deep links
|
|
2267
|
+
const androidDeepLinkUrlError = validateDeepLink(androidContent.deepLinkValue, formatMessage, messages);
|
|
2268
|
+
const iosDeepLinkUrlError = validateDeepLink(iosContent.deepLinkValue, formatMessage, messages);
|
|
2320
2269
|
|
|
2321
2270
|
setAndroidDeepLinkError(androidDeepLinkUrlError || "");
|
|
2322
2271
|
setIosDeepLinkError(iosDeepLinkUrlError || "");
|
|
2323
2272
|
|
|
2324
2273
|
// Validate deep link keys - only require keys if the selected deep link has keys defined
|
|
2325
2274
|
const androidDeepLinkKeysErrorMsg = (() => {
|
|
2326
|
-
if (
|
|
2275
|
+
if (androidContent?.linkType === DEEP_LINK && androidContent?.deepLinkValue) {
|
|
2327
2276
|
// Use the same matching logic as deep link value extraction
|
|
2328
2277
|
let selectedDeepLink = null;
|
|
2329
2278
|
|
|
@@ -2338,8 +2287,8 @@ export const MobilePushNew = ({
|
|
|
2338
2287
|
|
|
2339
2288
|
const hasKeysDefined = selectedDeepLink?.keys?.length > 0;
|
|
2340
2289
|
|
|
2341
|
-
//
|
|
2342
|
-
if (hasKeysDefined && !
|
|
2290
|
+
// Only require keys if the selected deep link has keys defined
|
|
2291
|
+
if (hasKeysDefined && (!Array.isArray(androidContent?.deepLinkKeysValue) || androidContent?.deepLinkKeysValue?.length === 0)) {
|
|
2343
2292
|
return formatMessage(messages.deepLinkKeysRequired);
|
|
2344
2293
|
}
|
|
2345
2294
|
}
|
|
@@ -2347,7 +2296,7 @@ export const MobilePushNew = ({
|
|
|
2347
2296
|
})();
|
|
2348
2297
|
|
|
2349
2298
|
const iosDeepLinkKeysErrorMsg = (() => {
|
|
2350
|
-
if (
|
|
2299
|
+
if (iosContent?.linkType === DEEP_LINK && iosContent?.deepLinkValue) {
|
|
2351
2300
|
// Use the same matching logic as deep link value extraction
|
|
2352
2301
|
let selectedDeepLink = null;
|
|
2353
2302
|
|
|
@@ -2362,8 +2311,8 @@ export const MobilePushNew = ({
|
|
|
2362
2311
|
|
|
2363
2312
|
const hasKeysDefined = selectedDeepLink?.keys?.length > 0;
|
|
2364
2313
|
|
|
2365
|
-
//
|
|
2366
|
-
if (hasKeysDefined && !
|
|
2314
|
+
// Only require keys if the selected deep link has keys defined
|
|
2315
|
+
if (hasKeysDefined && (!Array.isArray(iosContent?.deepLinkKeysValue) || iosContent?.deepLinkKeysValue?.length === 0)) {
|
|
2367
2316
|
return formatMessage(messages.deepLinkKeysRequired);
|
|
2368
2317
|
}
|
|
2369
2318
|
}
|
|
@@ -2376,15 +2325,6 @@ export const MobilePushNew = ({
|
|
|
2376
2325
|
// Check for carousel link errors
|
|
2377
2326
|
const hasCarouselErrors = Object.values(carouselLinkErrors).some((error) => error !== null && error !== "");
|
|
2378
2327
|
|
|
2379
|
-
// The host can trigger save without the (disabled) Save button
|
|
2380
|
-
if (hasUnsavedTapLink) {
|
|
2381
|
-
CapNotification.error({ message: formatMessage(messages.saveTapLinkFirst) });
|
|
2382
|
-
if (onValidationFail) {
|
|
2383
|
-
onValidationFail();
|
|
2384
|
-
}
|
|
2385
|
-
return;
|
|
2386
|
-
}
|
|
2387
|
-
|
|
2388
2328
|
if (androidUrlError || iosUrlError || androidDeepLinkUrlError || iosDeepLinkUrlError || androidDeepLinkKeysErrorMsg || iosDeepLinkKeysErrorMsg || hasCarouselErrors) {
|
|
2389
2329
|
CapNotification.error({
|
|
2390
2330
|
message: formatMessage(messages.invalidUrl),
|
|
@@ -2401,34 +2341,74 @@ export const MobilePushNew = ({
|
|
|
2401
2341
|
const processedIosContent = { ...iosContent };
|
|
2402
2342
|
|
|
2403
2343
|
// Process button CTA data if it exists
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2344
|
+
if (ctaDataAndroid?.length > 0) {
|
|
2345
|
+
const savedCtas = ctaDataAndroid.filter((cta) => cta.isSaved);
|
|
2346
|
+
if (savedCtas?.length > 0) {
|
|
2347
|
+
processedAndroidContent.expandableDetails = {
|
|
2348
|
+
...processedAndroidContent.expandableDetails,
|
|
2349
|
+
ctas: savedCtas.map((cta) => {
|
|
2350
|
+
let actionLink = cta?.url;
|
|
2351
|
+
|
|
2352
|
+
// Append deep link keys to URL if they exist
|
|
2353
|
+
if (cta?.urlType === DEEP_LINK && cta?.deepLinkKeys?.length > 0) {
|
|
2354
|
+
const deepLinkKeysArray = Array.isArray(cta?.deepLinkKeys) ? cta?.deepLinkKeys : [cta?.deepLinkKeys];
|
|
2355
|
+
const validKeys = deepLinkKeysArray.filter((key) => typeof key === 'string' && key?.length > 0);
|
|
2356
|
+
if (validKeys?.length > 0) {
|
|
2357
|
+
const separator = actionLink.includes('?') ? '&' : '?';
|
|
2358
|
+
const keyParams = validKeys.map((key) => `${key}=${key}`).join('&');
|
|
2359
|
+
actionLink = `${actionLink}${separator}${keyParams}`;
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
return {
|
|
2364
|
+
actionText: cta?.text,
|
|
2365
|
+
type: cta?.urlType || DEEP_LINK,
|
|
2366
|
+
actionLink,
|
|
2367
|
+
};
|
|
2368
|
+
}),
|
|
2369
|
+
};
|
|
2370
|
+
}
|
|
2410
2371
|
}
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2372
|
+
if (ctaDataIos?.length > 0) {
|
|
2373
|
+
const savedCtas = ctaDataIos.filter((cta) => cta.isSaved);
|
|
2374
|
+
if (savedCtas?.length > 0) {
|
|
2375
|
+
processedIosContent.expandableDetails = {
|
|
2376
|
+
...processedIosContent.expandableDetails,
|
|
2377
|
+
ctas: savedCtas.map((cta) => {
|
|
2378
|
+
let actionLink = cta?.url;
|
|
2379
|
+
|
|
2380
|
+
// Append deep link keys to URL if they exist
|
|
2381
|
+
if (cta?.urlType === DEEP_LINK && cta?.deepLinkKeys?.length > 0) {
|
|
2382
|
+
const deepLinkKeysArray = Array.isArray(cta?.deepLinkKeys) ? cta?.deepLinkKeys : [cta?.deepLinkKeys];
|
|
2383
|
+
const validKeys = deepLinkKeysArray.filter((key) => typeof key === 'string' && key?.length > 0);
|
|
2384
|
+
if (validKeys?.length > 0) {
|
|
2385
|
+
const separator = actionLink.includes('?') ? '&' : '?';
|
|
2386
|
+
const keyParams = validKeys.map((key) => `${key}=${key}`).join('&');
|
|
2387
|
+
actionLink = `${actionLink}${separator}${keyParams}`;
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
|
|
2391
|
+
return {
|
|
2392
|
+
actionText: cta?.text,
|
|
2393
|
+
type: cta?.urlType || DEEP_LINK,
|
|
2394
|
+
actionLink,
|
|
2395
|
+
};
|
|
2396
|
+
}),
|
|
2397
|
+
};
|
|
2398
|
+
}
|
|
2417
2399
|
}
|
|
2418
2400
|
|
|
2419
2401
|
// Create payload with enabled platform content and intl
|
|
2420
2402
|
const payload = createMobilePushPayloadWithIntl({
|
|
2421
2403
|
templateName: finalTemplateName,
|
|
2422
|
-
androidContent:
|
|
2423
|
-
iosContent:
|
|
2404
|
+
androidContent: isAndroidSupported ? processedAndroidContent : undefined,
|
|
2405
|
+
iosContent: isIosSupported ? processedIosContent : undefined,
|
|
2424
2406
|
imageSrc,
|
|
2425
2407
|
mpushVideoSrcAndPreview,
|
|
2426
2408
|
accountData,
|
|
2427
2409
|
sameContent,
|
|
2428
2410
|
options: {
|
|
2429
2411
|
mode: params?.mode,
|
|
2430
|
-
// One platform chosen: leave the other platform's key out of versions.base
|
|
2431
|
-
skipPlatform: singlePlatform ? getOtherPlatform(singlePlatform) : undefined,
|
|
2432
2412
|
},
|
|
2433
2413
|
intl,
|
|
2434
2414
|
});
|
|
@@ -2619,7 +2599,7 @@ export const MobilePushNew = ({
|
|
|
2619
2599
|
globalActionsProps,
|
|
2620
2600
|
onValidationFail,
|
|
2621
2601
|
resetFormData,
|
|
2622
|
-
|
|
2602
|
+
validateExternalLink,
|
|
2623
2603
|
ctaDataAndroid,
|
|
2624
2604
|
ctaDataIos,
|
|
2625
2605
|
intl,
|
|
@@ -2627,17 +2607,8 @@ export const MobilePushNew = ({
|
|
|
2627
2607
|
createTimeoutRef,
|
|
2628
2608
|
isAndroidSupported,
|
|
2629
2609
|
isIosSupported,
|
|
2630
|
-
showAndroid,
|
|
2631
|
-
showIos,
|
|
2632
|
-
singlePlatform,
|
|
2633
|
-
activeTab,
|
|
2634
|
-
validateTitle,
|
|
2635
|
-
validateMessage,
|
|
2636
2610
|
isMobilePushContentMissing,
|
|
2637
|
-
isAndroidFieldsMissing,
|
|
2638
|
-
isIosFieldsMissing,
|
|
2639
2611
|
isCarouselDataValid,
|
|
2640
|
-
hasUnsavedTapLink,
|
|
2641
2612
|
isFullMode,
|
|
2642
2613
|
templateId,
|
|
2643
2614
|
savedTemplateId,
|
|
@@ -2732,30 +2703,38 @@ export const MobilePushNew = ({
|
|
|
2732
2703
|
getLiquidTags: globalActionsProps.getLiquidTags,
|
|
2733
2704
|
formatMessage,
|
|
2734
2705
|
messages: formBuilderMessages,
|
|
2735
|
-
|
|
2736
|
-
singleTab: singlePlatform || getSingleTab(accountData),
|
|
2706
|
+
singleTab: getSingleTab(accountData),
|
|
2737
2707
|
});
|
|
2738
2708
|
}, [
|
|
2739
2709
|
androidContent,
|
|
2740
2710
|
iosContent,
|
|
2741
2711
|
activeTab,
|
|
2742
|
-
singlePlatform,
|
|
2743
2712
|
globalActionsProps,
|
|
2744
2713
|
formatMessage,
|
|
2745
2714
|
accountData,
|
|
2746
2715
|
isFullMode,
|
|
2747
2716
|
]);
|
|
2748
2717
|
|
|
2749
|
-
// Each platform's preview buttons follow its own ctaData, so iOS shows before its tab is opened
|
|
2750
|
-
const toPreviewButtons = (ctas) => (Array.isArray(ctas) ? ctas.map((data) => ({ label: data?.text || '' })) : []);
|
|
2751
|
-
|
|
2752
2718
|
useEffect(() => {
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2719
|
+
// Always map to { label } for both platforms
|
|
2720
|
+
const newButtons = Array.isArray(ctaData)
|
|
2721
|
+
? ctaData.map((data) => ({
|
|
2722
|
+
label: data?.text || '',
|
|
2723
|
+
}))
|
|
2724
|
+
: [];
|
|
2725
|
+
|
|
2726
|
+
if (activeTab === ANDROID) {
|
|
2727
|
+
setAndroidContent((prevContent) => ({
|
|
2728
|
+
...prevContent,
|
|
2729
|
+
buttons: newButtons,
|
|
2730
|
+
}));
|
|
2731
|
+
} else if (activeTab === IOS) {
|
|
2732
|
+
setIosContent((prevContent) => ({
|
|
2733
|
+
...prevContent,
|
|
2734
|
+
buttons: newButtons,
|
|
2735
|
+
}));
|
|
2736
|
+
}
|
|
2737
|
+
}, [ctaData, activeTab]);
|
|
2759
2738
|
|
|
2760
2739
|
// Sync button data and state from active tab to other platform when sameContent is enabled
|
|
2761
2740
|
useEffect(() => {
|
|
@@ -2781,141 +2760,12 @@ export const MobilePushNew = ({
|
|
|
2781
2760
|
}
|
|
2782
2761
|
}, [sameContent, activeTab]);
|
|
2783
2762
|
|
|
2784
|
-
// What ticking "Same content" would copy over: text, media, links and buttons
|
|
2785
|
-
const getPlatformSnapshot = (platform) => {
|
|
2786
|
-
const isAndroid = platform === ANDROID;
|
|
2787
|
-
const content = isAndroid ? androidContent : iosContent;
|
|
2788
|
-
return JSON.stringify({
|
|
2789
|
-
title: content?.title || '',
|
|
2790
|
-
message: content?.message || '',
|
|
2791
|
-
mediaType: content?.mediaType || NONE,
|
|
2792
|
-
carouselData: content?.carouselData || [],
|
|
2793
|
-
actionOnClick: !!content?.actionOnClick,
|
|
2794
|
-
linkType: content?.linkType || '',
|
|
2795
|
-
deepLinkValue: content?.deepLinkValue || '',
|
|
2796
|
-
externalLinkValue: content?.externalLinkValue || '',
|
|
2797
|
-
image: (isAndroid ? imageSrc?.androidImageSrc : imageSrc?.iosImageSrc) || '',
|
|
2798
|
-
video: (isAndroid ? videoState?.androidVideoSrc : videoState?.iosVideoSrc) || '',
|
|
2799
|
-
buttons: toSavedCtas(isAndroid ? ctaDataAndroid : ctaDataIos),
|
|
2800
|
-
});
|
|
2801
|
-
};
|
|
2802
|
-
|
|
2803
2763
|
const handleSameContentChange = useCallback((e) => {
|
|
2804
2764
|
const isCurrentPlatformAndroid = activeTab === ANDROID;
|
|
2805
|
-
const otherContent = isCurrentPlatformAndroid ? iosContent : androidContent;
|
|
2806
|
-
// Ticking replaces the other tab: confirm when it has different content, not when it is empty
|
|
2807
|
-
if (e.target.checked && hasPlatformContent(otherContent) && getPlatformSnapshot(ANDROID) !== getPlatformSnapshot(IOS)) {
|
|
2808
|
-
setIsReplaceConfirmOpen(true);
|
|
2809
|
-
return;
|
|
2810
|
-
}
|
|
2811
2765
|
syncPlatformContent(isCurrentPlatformAndroid ? androidContent : iosContent, isCurrentPlatformAndroid ? ANDROID : IOS);
|
|
2812
2766
|
setSameContent(e.target.checked);
|
|
2813
|
-
}, [activeTab, androidContent, iosContent, imageSrc, videoState, ctaDataAndroid, ctaDataIos]);
|
|
2814
|
-
|
|
2815
|
-
const confirmSameContent = useCallback(() => {
|
|
2816
|
-
setIsReplaceConfirmOpen(false);
|
|
2817
|
-
syncPlatformContent(activeTab === ANDROID ? androidContent : iosContent, activeTab);
|
|
2818
|
-
setSameContent(true);
|
|
2819
2767
|
}, [activeTab, androidContent, iosContent]);
|
|
2820
2768
|
|
|
2821
|
-
// One platform chosen: its form is the only one shown, and the upload/button handlers follow activeTab
|
|
2822
|
-
useEffect(() => {
|
|
2823
|
-
if (singlePlatform && activeTab !== singlePlatform) {
|
|
2824
|
-
setActiveTab(singlePlatform);
|
|
2825
|
-
}
|
|
2826
|
-
}, [singlePlatform, activeTab]);
|
|
2827
|
-
|
|
2828
|
-
// Both -> single: empty the dropped platform. Runs after the switch so sync is off
|
|
2829
|
-
// and the kept platform's media stays.
|
|
2830
|
-
useEffect(() => {
|
|
2831
|
-
if (!platformToClear) return;
|
|
2832
|
-
const isAndroid = platformToClear === ANDROID;
|
|
2833
|
-
const platformIndex = isAndroid ? 0 : 1;
|
|
2834
|
-
clearImageDataByMediaType(IMAGE, platformToClear);
|
|
2835
|
-
clearImageDataByMediaType(VIDEO, platformToClear);
|
|
2836
|
-
// Uploaded-video list read by the upload box
|
|
2837
|
-
setUpdateMpushVideoSrc(platformIndex, {}, true);
|
|
2838
|
-
(isAndroid ? setAndroidContent : setIosContent)(INITIAL_CONTENT);
|
|
2839
|
-
(isAndroid ? setCtaDataAndroid : setCtaDataIos)([]);
|
|
2840
|
-
(isAndroid ? setPrimaryButtonAndroid : setPrimaryButtonIos)(false);
|
|
2841
|
-
(isAndroid ? setSecondaryButtonAndroid : setSecondaryButtonIos)(false);
|
|
2842
|
-
(isAndroid ? setAndroidTitleError : setIosTitleError)("");
|
|
2843
|
-
(isAndroid ? setAndroidMessageError : setIosMessageError)("");
|
|
2844
|
-
(isAndroid ? setAndroidExternalLinkError : setIosExternalLinkError)("");
|
|
2845
|
-
(isAndroid ? setAndroidDeepLinkError : setIosDeepLinkError)("");
|
|
2846
|
-
(isAndroid ? setAndroidDeepLinkKeysError : setIosDeepLinkKeysError)("");
|
|
2847
|
-
setPlatformToClear(null);
|
|
2848
|
-
}, [platformToClear, clearImageDataByMediaType, setUpdateMpushVideoSrc]);
|
|
2849
|
-
|
|
2850
|
-
// Android only <-> iOS only: give the empty target the current platform's content, buttons and media
|
|
2851
|
-
const copyPlatformContent = useCallback((source, target) => {
|
|
2852
|
-
const fromAndroid = source === ANDROID;
|
|
2853
|
-
const targetIndex = target === ANDROID ? 0 : 1;
|
|
2854
|
-
syncPlatformContent(fromAndroid ? androidContent : iosContent, source);
|
|
2855
|
-
(fromAndroid ? setCtaDataIos : setCtaDataAndroid)(cloneDeep(fromAndroid ? ctaDataAndroid : ctaDataIos));
|
|
2856
|
-
(fromAndroid ? setPrimaryButtonIos : setPrimaryButtonAndroid)(fromAndroid ? primaryButtonAndroid : primaryButtonIos);
|
|
2857
|
-
(fromAndroid ? setSecondaryButtonIos : setSecondaryButtonAndroid)(fromAndroid ? secondaryButtonAndroid : secondaryButtonIos);
|
|
2858
|
-
// Uploaded image/video live in the upload hook, per platform
|
|
2859
|
-
const sourceImage = fromAndroid ? imageSrc?.androidImageSrc : imageSrc?.iosImageSrc;
|
|
2860
|
-
if (sourceImage) {
|
|
2861
|
-
setUpdateMpushImageSrc(sourceImage, targetIndex, IMAGE);
|
|
2862
|
-
}
|
|
2863
|
-
const sourceVideo = fromAndroid ? videoState?.androidVideoSrc : videoState?.iosVideoSrc;
|
|
2864
|
-
if (sourceVideo) {
|
|
2865
|
-
setUpdateMpushVideoSrc(targetIndex, {
|
|
2866
|
-
...(fromAndroid ? androidAssetList : iosAssetList),
|
|
2867
|
-
videoSrc: sourceVideo,
|
|
2868
|
-
previewUrl: (fromAndroid ? videoState?.androidVideoPreview : videoState?.iosVideoPreview) || '',
|
|
2869
|
-
videoDuration: (fromAndroid ? videoState?.androidVideoDuration : videoState?.iosVideoDuration) || 0,
|
|
2870
|
-
}, true);
|
|
2871
|
-
}
|
|
2872
|
-
}, [androidContent, iosContent, ctaDataAndroid, ctaDataIos, primaryButtonAndroid, primaryButtonIos, secondaryButtonAndroid, secondaryButtonIos, imageSrc, videoState, androidAssetList, iosAssetList, setUpdateMpushImageSrc, setUpdateMpushVideoSrc]);
|
|
2873
|
-
|
|
2874
|
-
const handlePlatformChange = useCallback((value) => {
|
|
2875
|
-
if (value === platformSelection) return;
|
|
2876
|
-
const getPlatformContent = (platform) => (platform === ANDROID ? androidContent : iosContent);
|
|
2877
|
-
|
|
2878
|
-
if (platformSelection === BOTH_PLATFORMS) {
|
|
2879
|
-
// Both -> single: confirm before dropping a platform that has content
|
|
2880
|
-
if (hasPlatformContent(getPlatformContent(getOtherPlatform(value)))) {
|
|
2881
|
-
setPendingPlatformSelection(value);
|
|
2882
|
-
return;
|
|
2883
|
-
}
|
|
2884
|
-
setPlatformSelection(value);
|
|
2885
|
-
setPlatformToClear(getOtherPlatform(value));
|
|
2886
|
-
return;
|
|
2887
|
-
}
|
|
2888
|
-
|
|
2889
|
-
if (value === BOTH_PLATFORMS) {
|
|
2890
|
-
// Single -> Both: content stays in its tab; a ticked "Same content" syncs it to the other tab
|
|
2891
|
-
// (media and buttons follow through the existing on-tick effects)
|
|
2892
|
-
if (sameContentChecked) {
|
|
2893
|
-
syncPlatformContent(getPlatformContent(platformSelection), platformSelection);
|
|
2894
|
-
}
|
|
2895
|
-
setPlatformSelection(value);
|
|
2896
|
-
return;
|
|
2897
|
-
}
|
|
2898
|
-
|
|
2899
|
-
// Android only <-> iOS only: an empty target takes the current content
|
|
2900
|
-
if (!hasPlatformContent(getPlatformContent(value)) && hasPlatformContent(getPlatformContent(platformSelection))) {
|
|
2901
|
-
copyPlatformContent(platformSelection, value);
|
|
2902
|
-
}
|
|
2903
|
-
setPlatformSelection(value);
|
|
2904
|
-
}, [platformSelection, androidContent, iosContent, sameContentChecked, copyPlatformContent]);
|
|
2905
|
-
|
|
2906
|
-
const confirmPlatformRemoval = useCallback(() => {
|
|
2907
|
-
const value = pendingPlatformSelection;
|
|
2908
|
-
setPendingPlatformSelection(null);
|
|
2909
|
-
setPlatformSelection(value);
|
|
2910
|
-
setPlatformToClear(getOtherPlatform(value));
|
|
2911
|
-
}, [pendingPlatformSelection]);
|
|
2912
|
-
|
|
2913
|
-
const platformOptions = useMemo(() => [
|
|
2914
|
-
{ label: formatMessage(messages.androidAndIos), value: BOTH_PLATFORMS },
|
|
2915
|
-
{ label: formatMessage(messages.androidOnly), value: ANDROID },
|
|
2916
|
-
{ label: formatMessage(messages.iosOnly), value: IOS },
|
|
2917
|
-
], [formatMessage]);
|
|
2918
|
-
|
|
2919
2769
|
const getContentType = useCallback(
|
|
2920
2770
|
(content) => {
|
|
2921
2771
|
// Get image source from multiple possible locations
|
|
@@ -3038,34 +2888,23 @@ export const MobilePushNew = ({
|
|
|
3038
2888
|
const androidPreview = getContentType(androidContent);
|
|
3039
2889
|
const iosPreview = getContentType(iosContent);
|
|
3040
2890
|
|
|
3041
|
-
// Notification tap as Save sends it (same builder), in the keys Test & Preview reads; '' for Android, '2' for iOS
|
|
3042
|
-
const getTapFormFields = (content, keySuffix) => {
|
|
3043
|
-
const { cta } = buildPlatformContent(content, '', {}, ANDROID);
|
|
3044
|
-
if (!cta) return {};
|
|
3045
|
-
const isDeepLink = cta.type === DEEP_LINK;
|
|
3046
|
-
return {
|
|
3047
|
-
[`cta-deeplink${keySuffix}`]: isDeepLink ? 'Deeplink' : 'External Link',
|
|
3048
|
-
[`cta-deeplink${keySuffix}-select`]: isDeepLink ? cta.actionLink : '',
|
|
3049
|
-
[`cta-deeplink${keySuffix}-text`]: isDeepLink ? '' : cta.actionLink,
|
|
3050
|
-
};
|
|
3051
|
-
};
|
|
3052
|
-
|
|
3053
2891
|
// Convert Android content to formData format
|
|
3054
2892
|
const androidFormData = {
|
|
3055
2893
|
'message-title': androidPreview?.header || androidContent?.title || '',
|
|
3056
2894
|
'message-editor': androidPreview?.bodyText || androidContent?.message || '',
|
|
3057
2895
|
image: androidPreview?.bodyImage || androidContent?.expandableDetails?.image || '',
|
|
3058
|
-
//
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
2896
|
+
// Extract primary CTA
|
|
2897
|
+
...(androidContent?.cta && {
|
|
2898
|
+
'cta-deeplink': androidContent.cta.type === DEEP_LINK ? 'Deeplink' : 'External Link',
|
|
2899
|
+
'cta-deeplink-select': androidContent.cta.type === DEEP_LINK ? (androidContent.cta.actionLink || '') : '',
|
|
2900
|
+
'cta-deeplink-text': androidContent.cta.type !== DEEP_LINK ? (androidContent.cta.actionLink || '') : '',
|
|
2901
|
+
'cta-deeplink-label': androidContent.cta.actionText || '',
|
|
2902
|
+
}),
|
|
3063
2903
|
};
|
|
3064
2904
|
|
|
3065
|
-
//
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
androidCtas.forEach((cta, index) => {
|
|
2905
|
+
// Extract secondary CTAs from expandableDetails
|
|
2906
|
+
if (androidContent?.expandableDetails?.ctas && androidContent.expandableDetails.ctas.length > 0) {
|
|
2907
|
+
androidContent.expandableDetails.ctas.forEach((cta, index) => {
|
|
3069
2908
|
if (index === 0) {
|
|
3070
2909
|
androidFormData['secondary-cta-0-label'] = cta.actionText || '';
|
|
3071
2910
|
androidFormData['cta-deeplink-secondary-cta-0'] = cta.type === DEEP_LINK ? 'Deeplink' : 'External Link';
|
|
@@ -3086,14 +2925,18 @@ export const MobilePushNew = ({
|
|
|
3086
2925
|
'message-title2': iosPreview?.header || iosContent?.title || '',
|
|
3087
2926
|
'message-editor2': iosPreview?.bodyText || iosContent?.message || '',
|
|
3088
2927
|
image: iosPreview?.bodyImage || iosContent?.expandableDetails?.image || '',
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
2928
|
+
// Extract primary CTA
|
|
2929
|
+
...(iosContent?.cta && {
|
|
2930
|
+
'cta-deeplink2': iosContent.cta.type === DEEP_LINK ? 'Deeplink' : 'External Link',
|
|
2931
|
+
'cta-deeplink2-select': iosContent.cta.type === DEEP_LINK ? (iosContent.cta.actionLink || '') : '',
|
|
2932
|
+
'cta-deeplink2-text': iosContent.cta.type !== DEEP_LINK ? (iosContent.cta.actionLink || '') : '',
|
|
2933
|
+
'cta-deeplink2-label': iosContent.cta.actionText || '',
|
|
2934
|
+
}),
|
|
3092
2935
|
};
|
|
3093
2936
|
|
|
3094
|
-
|
|
3095
|
-
if (
|
|
3096
|
-
|
|
2937
|
+
// Extract secondary CTAs from expandableDetails
|
|
2938
|
+
if (iosContent?.expandableDetails?.ctas && iosContent.expandableDetails.ctas.length > 0) {
|
|
2939
|
+
iosContent.expandableDetails.ctas.forEach((cta, index) => {
|
|
3097
2940
|
if (index === 0) {
|
|
3098
2941
|
iosFormData['secondary-cta-1-label'] = cta.actionText || '';
|
|
3099
2942
|
iosFormData['cta-deeplink-secondary-cta-1'] = cta.type === DEEP_LINK ? 'Deeplink' : 'External Link';
|
|
@@ -3106,7 +2949,7 @@ export const MobilePushNew = ({
|
|
|
3106
2949
|
|
|
3107
2950
|
// Return in formData array format [androidData, iosData]
|
|
3108
2951
|
return [androidFormData, iosFormData];
|
|
3109
|
-
}, [androidContent, iosContent, getContentType
|
|
2952
|
+
}, [androidContent, iosContent, getContentType]);
|
|
3110
2953
|
|
|
3111
2954
|
// Handle Test and Preview button click
|
|
3112
2955
|
const handleTestAndPreview = useCallback(() => {
|
|
@@ -3116,8 +2959,7 @@ export const MobilePushNew = ({
|
|
|
3116
2959
|
// Handle close Test and Preview slidebox
|
|
3117
2960
|
const handleCloseTestAndPreview = useCallback(() => {
|
|
3118
2961
|
setShowTestAndPreviewSlidebox(false);
|
|
3119
|
-
|
|
3120
|
-
}, [propsHandleCloseTestAndPreview]);
|
|
2962
|
+
}, []);
|
|
3121
2963
|
|
|
3122
2964
|
// Add useEffect to handle isGetFormData prop changes (e.g. Done clicked in footer)
|
|
3123
2965
|
// In library mode: run liquid validation (extractTags) first; on success liquidMiddleWare calls handleSave
|
|
@@ -3243,46 +3085,24 @@ export const MobilePushNew = ({
|
|
|
3243
3085
|
<CapRow className="mobile-push-container">
|
|
3244
3086
|
<CapColumn className="content-section" span={14}>
|
|
3245
3087
|
{createModeContent()}
|
|
3246
|
-
{
|
|
3247
|
-
<
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
onChange={handlePlatformChange}
|
|
3256
|
-
/>
|
|
3257
|
-
</CapRow>
|
|
3258
|
-
)}
|
|
3259
|
-
{singlePlatform ? (
|
|
3260
|
-
// One platform: its form only, no tabs or "Same content" checkbox
|
|
3261
|
-
<CapRow className="platform-header">
|
|
3262
|
-
{renderContentFields(singlePlatform)}
|
|
3263
|
-
</CapRow>
|
|
3264
|
-
) : (
|
|
3265
|
-
<>
|
|
3266
|
-
{isAndroidSupported && isIosSupported && (
|
|
3267
|
-
<CapCheckbox
|
|
3268
|
-
className="same-content-checkbox"
|
|
3269
|
-
checked={sameContent}
|
|
3270
|
-
onChange={handleSameContentChange}
|
|
3271
|
-
key={`same-content-${sameContent}`}
|
|
3272
|
-
>
|
|
3273
|
-
{formatMessage(messages.sameContentForBothChannels)}
|
|
3274
|
-
</CapCheckbox>
|
|
3275
|
-
)}
|
|
3276
|
-
<CapRow className="platform-header">
|
|
3277
|
-
<StyledCapTab
|
|
3278
|
-
className="platform-tabs"
|
|
3279
|
-
activeKey={activeTab}
|
|
3280
|
-
onChange={setActiveTab}
|
|
3281
|
-
panes={PANES}
|
|
3282
|
-
/>
|
|
3283
|
-
</CapRow>
|
|
3284
|
-
</>
|
|
3088
|
+
{isAndroidSupported && isIosSupported && (
|
|
3089
|
+
<CapCheckbox
|
|
3090
|
+
className="same-content-checkbox"
|
|
3091
|
+
checked={sameContent}
|
|
3092
|
+
onChange={handleSameContentChange}
|
|
3093
|
+
key={`same-content-${sameContent}`}
|
|
3094
|
+
>
|
|
3095
|
+
{formatMessage(messages.sameContentForBothChannels)}
|
|
3096
|
+
</CapCheckbox>
|
|
3285
3097
|
)}
|
|
3098
|
+
<CapRow className="platform-header">
|
|
3099
|
+
<StyledCapTab
|
|
3100
|
+
className="platform-tabs"
|
|
3101
|
+
activeKey={activeTab}
|
|
3102
|
+
onChange={setActiveTab}
|
|
3103
|
+
panes={PANES}
|
|
3104
|
+
/>
|
|
3105
|
+
</CapRow>
|
|
3286
3106
|
<CapRow>
|
|
3287
3107
|
<CapColumn span={24}>
|
|
3288
3108
|
<ErrorInfoNote
|
|
@@ -3292,6 +3112,39 @@ export const MobilePushNew = ({
|
|
|
3292
3112
|
STANDARD_ERROR_MSG: errorMessage?.STANDARD_ERROR_MSG,
|
|
3293
3113
|
}}
|
|
3294
3114
|
/>
|
|
3115
|
+
|
|
3116
|
+
{/* In library mode, only show save button in create mode (edit mode has Done button from FormBuilder). In full mode, keep old logic. */}
|
|
3117
|
+
{((!isFullMode && computedCreativesMode !== 'edit') || (isFullMode && !isEditMode && computedCreativesMode === 'create')) && (
|
|
3118
|
+
<CapRow className="save-section">
|
|
3119
|
+
<CapColumn span={24}>
|
|
3120
|
+
<CapButton
|
|
3121
|
+
type="primary"
|
|
3122
|
+
onClick={() => {
|
|
3123
|
+
// Liquid validation (extractTags) only in library mode
|
|
3124
|
+
if (!isFullMode) {
|
|
3125
|
+
liquidMiddleWare();
|
|
3126
|
+
} else {
|
|
3127
|
+
handleSave();
|
|
3128
|
+
}
|
|
3129
|
+
}}
|
|
3130
|
+
className="save-button"
|
|
3131
|
+
disabled={isSaveDisabled}
|
|
3132
|
+
>
|
|
3133
|
+
{formatMessage(messages.saveTemplate)}
|
|
3134
|
+
</CapButton>
|
|
3135
|
+
<CapButton
|
|
3136
|
+
onClick={handleTestAndPreview}
|
|
3137
|
+
className="mobilepush-test-preview-btn"
|
|
3138
|
+
type="secondary"
|
|
3139
|
+
style={{ marginLeft: '8px' }}
|
|
3140
|
+
disabled={isSaveDisabled}
|
|
3141
|
+
>
|
|
3142
|
+
<FormattedMessage {...creativesMessages.testAndPreview} />
|
|
3143
|
+
</CapButton>
|
|
3144
|
+
</CapColumn>
|
|
3145
|
+
</CapRow>
|
|
3146
|
+
)}
|
|
3147
|
+
|
|
3295
3148
|
</CapColumn>
|
|
3296
3149
|
</CapRow>
|
|
3297
3150
|
</CapColumn>
|
|
@@ -3304,87 +3157,8 @@ export const MobilePushNew = ({
|
|
|
3304
3157
|
/>
|
|
3305
3158
|
</CapColumn>
|
|
3306
3159
|
</CapRow>
|
|
3307
|
-
{/* In library mode, only show save button in create mode (edit mode has Done button from FormBuilder). In full mode, keep old logic. */}
|
|
3308
|
-
{/* Kept outside the content row so the sticky footer can stick across the whole scroll area */}
|
|
3309
|
-
{((!isFullMode && computedCreativesMode !== 'edit') || (isFullMode && !isEditMode && computedCreativesMode === 'create')) && (
|
|
3310
|
-
<CapRow className="save-section mpush-save-section">
|
|
3311
|
-
<CapColumn span={24}>
|
|
3312
|
-
<CapButton
|
|
3313
|
-
type="primary"
|
|
3314
|
-
onClick={() => {
|
|
3315
|
-
// Liquid validation (extractTags) only in library mode
|
|
3316
|
-
if (!isFullMode) {
|
|
3317
|
-
liquidMiddleWare();
|
|
3318
|
-
} else {
|
|
3319
|
-
handleSave();
|
|
3320
|
-
}
|
|
3321
|
-
}}
|
|
3322
|
-
className="save-button"
|
|
3323
|
-
disabled={isSaveDisabled}
|
|
3324
|
-
>
|
|
3325
|
-
{formatMessage(messages.saveTemplate)}
|
|
3326
|
-
</CapButton>
|
|
3327
|
-
<CapButton
|
|
3328
|
-
onClick={handleTestAndPreview}
|
|
3329
|
-
className="mobilepush-test-preview-btn"
|
|
3330
|
-
type="secondary"
|
|
3331
|
-
style={{ marginLeft: '8px' }}
|
|
3332
|
-
disabled={isTestAndPreviewDisabled}
|
|
3333
|
-
>
|
|
3334
|
-
<FormattedMessage {...creativesMessages.testAndPreview} />
|
|
3335
|
-
</CapButton>
|
|
3336
|
-
</CapColumn>
|
|
3337
|
-
</CapRow>
|
|
3338
|
-
)}
|
|
3339
|
-
<CapModal
|
|
3340
|
-
open={isReplaceConfirmOpen}
|
|
3341
|
-
centered
|
|
3342
|
-
width={520}
|
|
3343
|
-
title={formatMessage(messages.replacePlatformContent, { platform: formatMessage(activeTab === ANDROID ? messages.ios : messages.android) })}
|
|
3344
|
-
onCancel={() => setIsReplaceConfirmOpen(false)}
|
|
3345
|
-
footer={[
|
|
3346
|
-
<CapButton key="cancel" type="secondary" onClick={() => setIsReplaceConfirmOpen(false)}>
|
|
3347
|
-
{formatMessage(globalMessages.cancel)}
|
|
3348
|
-
</CapButton>,
|
|
3349
|
-
<CapButton
|
|
3350
|
-
key="replace"
|
|
3351
|
-
type="primary"
|
|
3352
|
-
className="mpush-replace-platform-content"
|
|
3353
|
-
onClick={confirmSameContent}
|
|
3354
|
-
>
|
|
3355
|
-
{formatMessage(messages.replace)}
|
|
3356
|
-
</CapButton>,
|
|
3357
|
-
]}
|
|
3358
|
-
>
|
|
3359
|
-
{formatMessage(messages.replacePlatformContentBody, {
|
|
3360
|
-
platform: formatMessage(activeTab === ANDROID ? messages.ios : messages.android),
|
|
3361
|
-
source: formatMessage(activeTab === ANDROID ? messages.android : messages.ios),
|
|
3362
|
-
})}
|
|
3363
|
-
</CapModal>
|
|
3364
|
-
<CapModal
|
|
3365
|
-
open={!!pendingPlatformSelection}
|
|
3366
|
-
centered
|
|
3367
|
-
width={520}
|
|
3368
|
-
title={formatMessage(messages.removePlatformContent, {
|
|
3369
|
-
platform: formatMessage(pendingPlatformSelection === ANDROID ? messages.ios : messages.android),
|
|
3370
|
-
})}
|
|
3371
|
-
onCancel={() => setPendingPlatformSelection(null)}
|
|
3372
|
-
footer={[
|
|
3373
|
-
<CapButton key="cancel" type="secondary" onClick={() => setPendingPlatformSelection(null)}>
|
|
3374
|
-
{formatMessage(globalMessages.cancel)}
|
|
3375
|
-
</CapButton>,
|
|
3376
|
-
<CapButton
|
|
3377
|
-
key="remove"
|
|
3378
|
-
type="primary"
|
|
3379
|
-
className="mpush-remove-platform-content"
|
|
3380
|
-
onClick={confirmPlatformRemoval}
|
|
3381
|
-
>
|
|
3382
|
-
{formatMessage(messages.removeContent)}
|
|
3383
|
-
</CapButton>,
|
|
3384
|
-
]}
|
|
3385
|
-
/>
|
|
3386
3160
|
<TestAndPreviewSlidebox
|
|
3387
|
-
show={
|
|
3161
|
+
show={showTestAndPreviewSlidebox}
|
|
3388
3162
|
onClose={handleCloseTestAndPreview}
|
|
3389
3163
|
formData={getFormDataForPayload()} // Pass formData structure for payload building
|
|
3390
3164
|
content={getTemplateContent()} // Also pass content for preview
|
|
@@ -3420,8 +3194,6 @@ MobilePushNew.propTypes = {
|
|
|
3420
3194
|
globalActions: PropTypes.object,
|
|
3421
3195
|
fetchingLiquidValidation: PropTypes.bool,
|
|
3422
3196
|
handleClose: PropTypes.func,
|
|
3423
|
-
showTestAndPreviewSlidebox: PropTypes.bool,
|
|
3424
|
-
handleCloseTestAndPreview: PropTypes.func,
|
|
3425
3197
|
createTemplateError: PropTypes.any,
|
|
3426
3198
|
isGetFormData: PropTypes.bool,
|
|
3427
3199
|
getTemplateDetailsInProgress: PropTypes.bool,
|
|
@@ -3454,8 +3226,6 @@ MobilePushNew.defaultProps = {
|
|
|
3454
3226
|
globalActions: {},
|
|
3455
3227
|
fetchingLiquidValidation: false,
|
|
3456
3228
|
handleClose: () => {},
|
|
3457
|
-
showTestAndPreviewSlidebox: false,
|
|
3458
|
-
handleCloseTestAndPreview: undefined,
|
|
3459
3229
|
createTemplateError: null,
|
|
3460
3230
|
isGetFormData: false,
|
|
3461
3231
|
getTemplateDetailsInProgress: false,
|