@capillarytech/creatives-library 9.2.0 → 9.2.1-alpha.sprint-cap-214249.42
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/constants/unified.js +0 -1
- package/package.json +1 -1
- package/utils/common.js +0 -6
- package/utils/createMobilePushPayload.js +56 -51
- package/utils/tests/createMobilePushPayload.test.js +162 -10
- package/v2Components/CapMpushCTA/index.js +47 -57
- package/v2Components/CapMpushCTA/index.scss +43 -5
- package/v2Components/CapMpushCTA/tests/index.test.js +150 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +11 -8
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +13 -1
- package/v2Components/CommonTestAndPreview/constants.js +2 -0
- package/v2Components/CommonTestAndPreview/index.js +48 -10
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +83 -5
- package/v2Components/CommonTestAndPreview/tests/index.test.js +86 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +12 -2
- package/v2Components/TemplatePreview/index.js +14 -12
- package/v2Components/TemplatePreview/tests/index.test.js +69 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -6
- package/v2Containers/CreativesContainer/index.js +2 -1
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +43 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +314 -222
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +161 -130
- package/v2Containers/MobilePushNew/components/TapLinkActions.js +76 -0
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +30 -208
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +484 -123
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +152 -46
- package/v2Containers/MobilePushNew/constants.js +12 -0
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +78 -0
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +40 -1
- package/v2Containers/MobilePushNew/hooks/useUpload.js +42 -46
- package/v2Containers/MobilePushNew/index.js +503 -273
- package/v2Containers/MobilePushNew/index.scss +215 -4
- package/v2Containers/MobilePushNew/messages.js +106 -6
- package/v2Containers/MobilePushNew/tests/index.test.js +482 -1
- package/v2Containers/MobilePushNew/tests/utils.test.js +122 -0
- package/v2Containers/MobilePushNew/utils.js +107 -0
- package/v2Containers/Templates/_templates.scss +10 -2
- package/v2Containers/Templates/index.js +83 -81
- package/v2Containers/Templates/tests/index.test.js +68 -0
|
@@ -19,10 +19,12 @@ 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";
|
|
22
23
|
import { intlShape, FormattedMessage } from "react-intl";
|
|
23
24
|
import "./index.scss";
|
|
24
25
|
import { GA } from "@capillarytech/cap-ui-utils";
|
|
25
26
|
import CapNotification from "@capillarytech/cap-ui-library/CapNotification";
|
|
27
|
+
import CapModal from "@capillarytech/cap-ui-library/CapModal";
|
|
26
28
|
import { DAEMON } from "@capillarytech/vulcan-react-sdk/utils/sagaInjectorTypes";
|
|
27
29
|
import globalMessages from "../Cap/messages";
|
|
28
30
|
import * as actions from "./actions";
|
|
@@ -30,6 +32,7 @@ import {
|
|
|
30
32
|
MEDIA_TYPES_OPTIONS,
|
|
31
33
|
ANDROID,
|
|
32
34
|
IOS,
|
|
35
|
+
BOTH_PLATFORMS,
|
|
33
36
|
MOBILE_PUSH_CHANNEL,
|
|
34
37
|
INITIAL_CONTENT,
|
|
35
38
|
BIG_PICTURE,
|
|
@@ -75,7 +78,6 @@ import {
|
|
|
75
78
|
import withCreatives from "../../hoc/withCreatives";
|
|
76
79
|
import { BIG_TEXT, DEEP_LINK, DEVICE_SUPPORTED } from "../InApp/constants";
|
|
77
80
|
import { v2MobilePushSagas } from "./sagas";
|
|
78
|
-
import { getContent } from "../MobilePush/commonMethods";
|
|
79
81
|
import { getMessageObject } from "../../utils/messageUtils";
|
|
80
82
|
import { gtmPush } from "../../utils/gtmTrackers";
|
|
81
83
|
import mobilePushReducer from "./reducer";
|
|
@@ -88,36 +90,21 @@ import useUpload from "./hooks/useUpload";
|
|
|
88
90
|
import { validateTags } from "../../utils/tagValidations";
|
|
89
91
|
import { PlatformContentFields } from "./components";
|
|
90
92
|
import { CREATE, EDIT, TRACK_CREATE_MPUSH } from "../App/constants";
|
|
91
|
-
import {
|
|
93
|
+
import {
|
|
94
|
+
validateExternalLink, validateDeepLink, isPlatformFieldsMissing, getContent, getCarouselCardIssue,
|
|
95
|
+
extractDeepLinkParams, appendDeepLinkParams, hasAllDeepLinkParams,
|
|
96
|
+
} from "./utils";
|
|
92
97
|
import messages from "./messages";
|
|
93
98
|
import { EXTERNAL_URL, MOBILE_PUSH } from "../CreativesContainer/constants";
|
|
94
|
-
import createMobilePushPayloadWithIntl from "../../utils/createMobilePushPayload";
|
|
99
|
+
import createMobilePushPayloadWithIntl, { buildCarouselCards, buildPlatformContent } from "../../utils/createMobilePushPayload";
|
|
95
100
|
import { MOBILEPUSH } from "../../v2Components/CapVideoUpload/constants";
|
|
96
101
|
import { StyledCapTab } from "./style";
|
|
97
102
|
import TestAndPreviewSlidebox from "../../v2Components/TestAndPreviewSlidebox";
|
|
98
103
|
|
|
99
104
|
import creativesMessages from "../CreativesContainer/messages";
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
};
|
|
105
|
+
|
|
106
|
+
// Saved deep link params as "key=value" entries, e.g. "?testing_purpose=abc" -> ["testing_purpose=abc"]
|
|
107
|
+
const extractDeepLinkKeys = (deepLinkValue) => extractDeepLinkParams(deepLinkValue);
|
|
121
108
|
|
|
122
109
|
// Helper function to process media type from various sources
|
|
123
110
|
/**
|
|
@@ -276,8 +263,44 @@ const processCtaButtons = (ctas, deepLink) => {
|
|
|
276
263
|
};
|
|
277
264
|
};
|
|
278
265
|
|
|
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
|
+
|
|
279
302
|
// Helper function to create content data object
|
|
280
|
-
const createContentData =
|
|
303
|
+
const createContentData =(contentType, mediaInfo, buttons, deepLink, processCarouselDataForDeepLinks) => {
|
|
281
304
|
const {
|
|
282
305
|
mediaType,
|
|
283
306
|
imageSrc,
|
|
@@ -503,6 +526,9 @@ export const MobilePushNew = ({
|
|
|
503
526
|
supportedTags = [],
|
|
504
527
|
globalActions: globalActionsProps,
|
|
505
528
|
handleClose,
|
|
529
|
+
// Edit mode: footer Test & Preview button lives in CreativesContainer
|
|
530
|
+
showTestAndPreviewSlidebox: propsShowTestAndPreviewSlidebox,
|
|
531
|
+
handleCloseTestAndPreview: propsHandleCloseTestAndPreview,
|
|
506
532
|
fetchingLiquidValidation,
|
|
507
533
|
createTemplateError,
|
|
508
534
|
isGetFormData,
|
|
@@ -519,11 +545,30 @@ export const MobilePushNew = ({
|
|
|
519
545
|
const templateId = params?.id || templateData?._id || templateData?.id;
|
|
520
546
|
const isEditMode = !!templateId;
|
|
521
547
|
const computedCreativesMode = isEditMode || templateData?.type === MOBILEPUSH ? 'edit' : 'create';
|
|
522
|
-
|
|
548
|
+
// The checkbox tick; only syncs while both platforms are shown (see sameContent below)
|
|
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;
|
|
523
566
|
const [templateName, setTemplateName] = useState("");
|
|
524
567
|
const [spin, setSpin] = useState(false);
|
|
525
568
|
const [activeTab, setActiveTab] = useState(ANDROID);
|
|
526
569
|
const [templateNameError, setTemplateNameError] = useState(false);
|
|
570
|
+
// "Same content" tick waiting on the Replace confirm
|
|
571
|
+
const [isReplaceConfirmOpen, setIsReplaceConfirmOpen] = useState(false);
|
|
527
572
|
// Replace ctaData with platform-specific state
|
|
528
573
|
const [ctaDataAndroid, setCtaDataAndroid] = useState([]);
|
|
529
574
|
const [ctaDataIos, setCtaDataIos] = useState([]);
|
|
@@ -652,52 +697,9 @@ export const MobilePushNew = ({
|
|
|
652
697
|
const createTimeoutRef = useRef(null);
|
|
653
698
|
|
|
654
699
|
// Function to validate carousel data completeness
|
|
655
|
-
const validateCarouselData = useCallback((carouselData = []) =>
|
|
656
|
-
|
|
657
|
-
|
|
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]);
|
|
700
|
+
const validateCarouselData = useCallback((carouselData = []) => (
|
|
701
|
+
carouselData?.length > 0 && carouselData.every((card) => !getCarouselCardIssue(card, deepLink))
|
|
702
|
+
), [deepLink]);
|
|
701
703
|
|
|
702
704
|
// Function to check if carousel data is valid for both platforms
|
|
703
705
|
const isCarouselDataValid = useCallback(() => {
|
|
@@ -753,6 +755,9 @@ export const MobilePushNew = ({
|
|
|
753
755
|
setPrimaryButtonIos(false);
|
|
754
756
|
setSecondaryButtonIos(false);
|
|
755
757
|
setSameContent(false);
|
|
758
|
+
setPlatformSelection(BOTH_PLATFORMS);
|
|
759
|
+
setPendingPlatformSelection(null);
|
|
760
|
+
setPlatformToClear(null);
|
|
756
761
|
setTemplateNameError(false);
|
|
757
762
|
setAndroidTitleError("");
|
|
758
763
|
setAndroidMessageError("");
|
|
@@ -969,6 +974,8 @@ export const MobilePushNew = ({
|
|
|
969
974
|
templateNameRef.current = name;
|
|
970
975
|
});
|
|
971
976
|
|
|
977
|
+
stateUpdates.push(() => setPlatformSelection(getSavedPlatformSelection(editContent)));
|
|
978
|
+
|
|
972
979
|
// Process Android content
|
|
973
980
|
const androidContentType = editContent?.ANDROID;
|
|
974
981
|
if (!isEmpty(androidContentType)) {
|
|
@@ -1104,6 +1111,8 @@ export const MobilePushNew = ({
|
|
|
1104
1111
|
templateNameRef.current = name;
|
|
1105
1112
|
});
|
|
1106
1113
|
|
|
1114
|
+
stateUpdates.push(() => setPlatformSelection(getSavedPlatformSelection(templateContent)));
|
|
1115
|
+
|
|
1107
1116
|
// Process Android content
|
|
1108
1117
|
const androidContentType = templateContent?.ANDROID;
|
|
1109
1118
|
if (!isEmpty(androidContentType)) {
|
|
@@ -1739,10 +1748,6 @@ export const MobilePushNew = ({
|
|
|
1739
1748
|
setSpin(false);
|
|
1740
1749
|
}, [templateData, isFullMode, deepLink, setUpdateMpushImageSrc, setUpdateMpushVideoSrc]);
|
|
1741
1750
|
|
|
1742
|
-
// Determine platform support from accountData
|
|
1743
|
-
const isAndroidSupported = accountData?.configs?.android === '1';
|
|
1744
|
-
const isIosSupported = accountData?.configs?.ios === '1';
|
|
1745
|
-
|
|
1746
1751
|
// Notify parent when personalization tokens are added/removed (for anonymous user flow)
|
|
1747
1752
|
useEffect(() => {
|
|
1748
1753
|
if (!restrictPersonalization || typeof onPersonalizationTokensChange !== 'function') return;
|
|
@@ -1751,8 +1756,8 @@ export const MobilePushNew = ({
|
|
|
1751
1756
|
|| (value.includes('[') && value.includes(']'))
|
|
1752
1757
|
);
|
|
1753
1758
|
const hasTokens = (
|
|
1754
|
-
(
|
|
1755
|
-
|| (
|
|
1759
|
+
(showAndroid && (hasToken(androidContent?.title) || hasToken(androidContent?.message)))
|
|
1760
|
+
|| (showIos && (hasToken(iosContent?.title) || hasToken(iosContent?.message)))
|
|
1756
1761
|
);
|
|
1757
1762
|
onPersonalizationTokensChange(hasTokens);
|
|
1758
1763
|
}, [
|
|
@@ -1761,18 +1766,21 @@ export const MobilePushNew = ({
|
|
|
1761
1766
|
androidContent?.message,
|
|
1762
1767
|
iosContent?.title,
|
|
1763
1768
|
iosContent?.message,
|
|
1764
|
-
|
|
1765
|
-
|
|
1769
|
+
showAndroid,
|
|
1770
|
+
showIos,
|
|
1766
1771
|
onPersonalizationTokensChange,
|
|
1767
1772
|
]);
|
|
1768
1773
|
|
|
1769
|
-
// Validation logic for template creation/update.
|
|
1770
|
-
const isAndroidFieldsMissing = isPlatformFieldsMissing(
|
|
1771
|
-
const isIosFieldsMissing = isPlatformFieldsMissing(
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1774
|
+
// Validation logic for template creation/update; a platform left out by the dropdown is never missing.
|
|
1775
|
+
const isAndroidFieldsMissing = isPlatformFieldsMissing(showAndroid, androidContent);
|
|
1776
|
+
const isIosFieldsMissing = isPlatformFieldsMissing(showIos, iosContent);
|
|
1777
|
+
// Every shown platform needs a title and message before Save
|
|
1778
|
+
const isMobilePushContentMissing = isAndroidFieldsMissing || isIosFieldsMissing;
|
|
1779
|
+
// Test & Preview only needs one platform filled
|
|
1780
|
+
const isAllContentMissing = (
|
|
1781
|
+
(showAndroid || showIos)
|
|
1782
|
+
&& (!showAndroid || isAndroidFieldsMissing)
|
|
1783
|
+
&& (!showIos || isIosFieldsMissing)
|
|
1776
1784
|
);
|
|
1777
1785
|
|
|
1778
1786
|
// Ref to dedupe reporting of content emptiness to the parent, so we only
|
|
@@ -1796,8 +1804,7 @@ export const MobilePushNew = ({
|
|
|
1796
1804
|
handleMessageChange,
|
|
1797
1805
|
handleTagSelect,
|
|
1798
1806
|
handleMediaTypeChange,
|
|
1799
|
-
|
|
1800
|
-
handleLinkTypeChange,
|
|
1807
|
+
handleTapActionChange,
|
|
1801
1808
|
} = usePlatformSync({
|
|
1802
1809
|
setAndroidContent,
|
|
1803
1810
|
setIosContent,
|
|
@@ -1869,9 +1876,21 @@ export const MobilePushNew = ({
|
|
|
1869
1876
|
}
|
|
1870
1877
|
}, [sameContent]);
|
|
1871
1878
|
|
|
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
|
+
|
|
1872
1891
|
const handleExternalLinkChange = useCallback((platform, externalLinkValue) => {
|
|
1873
1892
|
// Validate URL
|
|
1874
|
-
const urlError =
|
|
1893
|
+
const urlError = getTapUrlError(externalLinkValue);
|
|
1875
1894
|
|
|
1876
1895
|
const updateContent = {
|
|
1877
1896
|
externalLinkValue,
|
|
@@ -1898,7 +1917,7 @@ export const MobilePushNew = ({
|
|
|
1898
1917
|
setAndroidExternalLinkError(urlError || "");
|
|
1899
1918
|
}
|
|
1900
1919
|
}
|
|
1901
|
-
}, [
|
|
1920
|
+
}, [getTapUrlError, sameContent]);
|
|
1902
1921
|
|
|
1903
1922
|
// Carousel data handler for platform-specific carousel management
|
|
1904
1923
|
const updateCarouselLinkError = useCallback((cardIndex, field, error) => {
|
|
@@ -2045,11 +2064,20 @@ export const MobilePushNew = ({
|
|
|
2045
2064
|
handleTitleChange,
|
|
2046
2065
|
handleMessageChange,
|
|
2047
2066
|
handleMediaTypeChange,
|
|
2048
|
-
|
|
2049
|
-
|
|
2067
|
+
handleTapActionChange: (value) => {
|
|
2068
|
+
handleTapActionChange(platform, value);
|
|
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
|
+
},
|
|
2050
2077
|
handleDeepLinkChange: (value) => handleDeepLinkChange(platform, value),
|
|
2051
2078
|
handleDeepLinkKeysChange: (value) => handleDeepLinkKeysChange(platform, value),
|
|
2052
2079
|
handleExternalLinkChange: (value) => handleExternalLinkChange(platform, value),
|
|
2080
|
+
handleTapLinkSavedChange: (isSaved) => handleTapLinkSavedChange(platform, isSaved),
|
|
2053
2081
|
onTagSelect,
|
|
2054
2082
|
handleOnTagsContextChange,
|
|
2055
2083
|
};
|
|
@@ -2169,7 +2197,7 @@ export const MobilePushNew = ({
|
|
|
2169
2197
|
restrictPersonalization={restrictPersonalization}
|
|
2170
2198
|
/>
|
|
2171
2199
|
);
|
|
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,
|
|
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, handleTapActionChange, handleDeepLinkChange, handleDeepLinkKeysChange, handleExternalLinkChange, handleTapLinkSavedChange, onTagSelect, handleOnTagsContextChange, setUpdateMpushImageSrc, updateOnMpushImageReUpload, setUpdateMpushVideoSrc, updateOnMpushVideoReUpload, clearImageDataByMediaType, handleCarouselDataChange, updateCarouselLinkError, sameContent, updateHandler, deleteHandler]
|
|
2173
2201
|
);
|
|
2174
2202
|
|
|
2175
2203
|
// PANES: Only render enabled platforms
|
|
@@ -2179,8 +2207,8 @@ export const MobilePushNew = ({
|
|
|
2179
2207
|
panes.push({
|
|
2180
2208
|
key: ANDROID,
|
|
2181
2209
|
tab: (
|
|
2182
|
-
<CapRow
|
|
2183
|
-
<CapIcon type="android" />
|
|
2210
|
+
<CapRow type="flex" align="middle" noWrap className="tab-label">
|
|
2211
|
+
<CapIcon type="android" size="s" />
|
|
2184
2212
|
{formatMessage(messages.android)}
|
|
2185
2213
|
</CapRow>
|
|
2186
2214
|
),
|
|
@@ -2191,8 +2219,8 @@ export const MobilePushNew = ({
|
|
|
2191
2219
|
panes.push({
|
|
2192
2220
|
key: IOS,
|
|
2193
2221
|
tab: (
|
|
2194
|
-
<CapRow
|
|
2195
|
-
<CapIcon type="ios" />
|
|
2222
|
+
<CapRow type="flex" align="middle" noWrap className="tab-label">
|
|
2223
|
+
<CapIcon type="ios" size="s" />
|
|
2196
2224
|
{formatMessage(messages.ios)}
|
|
2197
2225
|
</CapRow>
|
|
2198
2226
|
),
|
|
@@ -2205,25 +2233,42 @@ export const MobilePushNew = ({
|
|
|
2205
2233
|
const errorInTitle = activeTab === ANDROID ? androidTitleError : iosTitleError;
|
|
2206
2234
|
const errorInMessage = activeTab === ANDROID ? androidMessageError : iosMessageError;
|
|
2207
2235
|
|
|
2208
|
-
//
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2236
|
+
// A tap link (notification or carousel card) opened but its Save not clicked yet
|
|
2237
|
+
const hasUnsavedTapLink = [showAndroid && androidContent, showIos && iosContent].some((content) => {
|
|
2238
|
+
if (!content) return false;
|
|
2239
|
+
if (content.mediaType === CAROUSEL) {
|
|
2240
|
+
return (content.carouselData || []).some((card) => card?.buttons?.some((button) => button?.actionOnClick && button?.isSaved === false));
|
|
2241
|
+
}
|
|
2242
|
+
return content.actionOnClick && content.tapLinkSaved === false;
|
|
2243
|
+
});
|
|
2244
|
+
|
|
2245
|
+
const hasFormErrors = (
|
|
2246
|
+
templateNameError
|
|
2213
2247
|
|| Object.values(carouselLinkErrors).some((error) => error !== null && error !== "")
|
|
2214
2248
|
|| !isCarouselDataValid()
|
|
2249
|
+
|| hasUnsavedTapLink
|
|
2215
2250
|
|| errorInTitle || errorInMessage
|
|
2216
2251
|
);
|
|
2252
|
+
// Save needs every shown platform filled
|
|
2253
|
+
const isSaveDisabled = isMobilePushContentMissing || hasFormErrors;
|
|
2254
|
+
const isTestAndPreviewDisabled = isAllContentMissing || hasFormErrors;
|
|
2217
2255
|
|
|
2218
|
-
// Validation in handleSave:
|
|
2219
|
-
// allow saving with just one supported platform filled in.
|
|
2256
|
+
// Validation in handleSave: every shown platform needs a title and message (no save-without dialog)
|
|
2220
2257
|
const handleSave = useCallback(() => {
|
|
2221
2258
|
if (isMobilePushContentMissing) {
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2259
|
+
const missingPlatforms = [
|
|
2260
|
+
[ANDROID, isAndroidFieldsMissing, androidContent],
|
|
2261
|
+
[IOS, isIosFieldsMissing, iosContent],
|
|
2262
|
+
].filter(([, isMissing]) => isMissing);
|
|
2263
|
+
missingPlatforms.forEach(([platform, , content]) => {
|
|
2264
|
+
const isAndroid = platform === ANDROID;
|
|
2265
|
+
(isAndroid ? setAndroidTitleError : setIosTitleError)(validateTitle(content?.title));
|
|
2266
|
+
(isAndroid ? setAndroidMessageError : setIosMessageError)(validateMessage(content?.message));
|
|
2226
2267
|
});
|
|
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
|
+
}
|
|
2227
2272
|
if (onValidationFail) onValidationFail();
|
|
2228
2273
|
return;
|
|
2229
2274
|
}
|
|
@@ -2247,32 +2292,38 @@ export const MobilePushNew = ({
|
|
|
2247
2292
|
// Use ref to get the latest template name value to avoid closure issues
|
|
2248
2293
|
let finalTemplateName = templateNameRef.current || templateName;
|
|
2249
2294
|
if (!isFullMode && (!finalTemplateName || !finalTemplateName.trim())) {
|
|
2250
|
-
if (androidContent?.title && androidContent.title.trim()) {
|
|
2295
|
+
if (showAndroid && androidContent?.title && androidContent.title.trim()) {
|
|
2251
2296
|
finalTemplateName = androidContent.title.trim();
|
|
2252
|
-
} else if (iosContent?.title && iosContent.title.trim()) {
|
|
2297
|
+
} else if (showIos && iosContent?.title && iosContent.title.trim()) {
|
|
2253
2298
|
finalTemplateName = iosContent.title.trim();
|
|
2254
2299
|
} else {
|
|
2255
2300
|
finalTemplateName = '';
|
|
2256
2301
|
}
|
|
2257
2302
|
}
|
|
2258
2303
|
|
|
2259
|
-
// Validate
|
|
2260
|
-
const
|
|
2261
|
-
const
|
|
2304
|
+
// Validate the notification tap URL (only platforms that are saved, only when External link is chosen)
|
|
2305
|
+
const isTapExternalLink = (content) => content?.actionOnClick && content?.linkType === EXTERNAL_LINK;
|
|
2306
|
+
const androidUrlError = showAndroid && isTapExternalLink(androidContent) && getTapUrlError(androidContent.externalLinkValue);
|
|
2307
|
+
const iosUrlError = showIos && isTapExternalLink(iosContent) && getTapUrlError(iosContent.externalLinkValue);
|
|
2262
2308
|
|
|
2263
2309
|
setAndroidExternalLinkError(androidUrlError || "");
|
|
2264
2310
|
setIosExternalLinkError(iosUrlError || "");
|
|
2265
2311
|
|
|
2266
|
-
// Validate deep links
|
|
2267
|
-
const
|
|
2268
|
-
|
|
2312
|
+
// Validate deep links; Deep link chosen as the tap action needs one picked
|
|
2313
|
+
const getTapDeepLinkError = (content) => (
|
|
2314
|
+
content?.actionOnClick && content?.linkType === DEEP_LINK && !content?.deepLinkValue
|
|
2315
|
+
? formatMessage(messages.deepLinkRequired)
|
|
2316
|
+
: validateDeepLink(content?.deepLinkValue, formatMessage, messages)
|
|
2317
|
+
);
|
|
2318
|
+
const androidDeepLinkUrlError = showAndroid && getTapDeepLinkError(androidContent);
|
|
2319
|
+
const iosDeepLinkUrlError = showIos && getTapDeepLinkError(iosContent);
|
|
2269
2320
|
|
|
2270
2321
|
setAndroidDeepLinkError(androidDeepLinkUrlError || "");
|
|
2271
2322
|
setIosDeepLinkError(iosDeepLinkUrlError || "");
|
|
2272
2323
|
|
|
2273
2324
|
// Validate deep link keys - only require keys if the selected deep link has keys defined
|
|
2274
2325
|
const androidDeepLinkKeysErrorMsg = (() => {
|
|
2275
|
-
if (androidContent?.linkType === DEEP_LINK && androidContent?.deepLinkValue) {
|
|
2326
|
+
if (showAndroid && androidContent?.linkType === DEEP_LINK && androidContent?.deepLinkValue) {
|
|
2276
2327
|
// Use the same matching logic as deep link value extraction
|
|
2277
2328
|
let selectedDeepLink = null;
|
|
2278
2329
|
|
|
@@ -2287,8 +2338,8 @@ export const MobilePushNew = ({
|
|
|
2287
2338
|
|
|
2288
2339
|
const hasKeysDefined = selectedDeepLink?.keys?.length > 0;
|
|
2289
2340
|
|
|
2290
|
-
//
|
|
2291
|
-
if (hasKeysDefined &&
|
|
2341
|
+
// Every configured key of the selected deep link needs a value
|
|
2342
|
+
if (hasKeysDefined && !hasAllDeepLinkParams(androidContent?.deepLinkKeysValue, selectedDeepLink?.keys)) {
|
|
2292
2343
|
return formatMessage(messages.deepLinkKeysRequired);
|
|
2293
2344
|
}
|
|
2294
2345
|
}
|
|
@@ -2296,7 +2347,7 @@ export const MobilePushNew = ({
|
|
|
2296
2347
|
})();
|
|
2297
2348
|
|
|
2298
2349
|
const iosDeepLinkKeysErrorMsg = (() => {
|
|
2299
|
-
if (iosContent?.linkType === DEEP_LINK && iosContent?.deepLinkValue) {
|
|
2350
|
+
if (showIos && iosContent?.linkType === DEEP_LINK && iosContent?.deepLinkValue) {
|
|
2300
2351
|
// Use the same matching logic as deep link value extraction
|
|
2301
2352
|
let selectedDeepLink = null;
|
|
2302
2353
|
|
|
@@ -2311,8 +2362,8 @@ export const MobilePushNew = ({
|
|
|
2311
2362
|
|
|
2312
2363
|
const hasKeysDefined = selectedDeepLink?.keys?.length > 0;
|
|
2313
2364
|
|
|
2314
|
-
//
|
|
2315
|
-
if (hasKeysDefined &&
|
|
2365
|
+
// Every configured key of the selected deep link needs a value
|
|
2366
|
+
if (hasKeysDefined && !hasAllDeepLinkParams(iosContent?.deepLinkKeysValue, selectedDeepLink?.keys)) {
|
|
2316
2367
|
return formatMessage(messages.deepLinkKeysRequired);
|
|
2317
2368
|
}
|
|
2318
2369
|
}
|
|
@@ -2325,6 +2376,15 @@ export const MobilePushNew = ({
|
|
|
2325
2376
|
// Check for carousel link errors
|
|
2326
2377
|
const hasCarouselErrors = Object.values(carouselLinkErrors).some((error) => error !== null && error !== "");
|
|
2327
2378
|
|
|
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
|
+
|
|
2328
2388
|
if (androidUrlError || iosUrlError || androidDeepLinkUrlError || iosDeepLinkUrlError || androidDeepLinkKeysErrorMsg || iosDeepLinkKeysErrorMsg || hasCarouselErrors) {
|
|
2329
2389
|
CapNotification.error({
|
|
2330
2390
|
message: formatMessage(messages.invalidUrl),
|
|
@@ -2341,74 +2401,34 @@ export const MobilePushNew = ({
|
|
|
2341
2401
|
const processedIosContent = { ...iosContent };
|
|
2342
2402
|
|
|
2343
2403
|
// Process button CTA data if it exists
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
processedAndroidContent.expandableDetails
|
|
2348
|
-
|
|
2349
|
-
|
|
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
|
-
}
|
|
2404
|
+
const savedAndroidCtas = toSavedCtas(ctaDataAndroid);
|
|
2405
|
+
if (savedAndroidCtas.length > 0) {
|
|
2406
|
+
processedAndroidContent.expandableDetails = {
|
|
2407
|
+
...processedAndroidContent.expandableDetails,
|
|
2408
|
+
ctas: savedAndroidCtas,
|
|
2409
|
+
};
|
|
2371
2410
|
}
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
processedIosContent.expandableDetails
|
|
2376
|
-
|
|
2377
|
-
|
|
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
|
-
}
|
|
2411
|
+
const savedIosCtas = toSavedCtas(ctaDataIos);
|
|
2412
|
+
if (savedIosCtas.length > 0) {
|
|
2413
|
+
processedIosContent.expandableDetails = {
|
|
2414
|
+
...processedIosContent.expandableDetails,
|
|
2415
|
+
ctas: savedIosCtas,
|
|
2416
|
+
};
|
|
2399
2417
|
}
|
|
2400
2418
|
|
|
2401
2419
|
// Create payload with enabled platform content and intl
|
|
2402
2420
|
const payload = createMobilePushPayloadWithIntl({
|
|
2403
2421
|
templateName: finalTemplateName,
|
|
2404
|
-
androidContent:
|
|
2405
|
-
iosContent:
|
|
2422
|
+
androidContent: showAndroid ? processedAndroidContent : undefined,
|
|
2423
|
+
iosContent: showIos ? processedIosContent : undefined,
|
|
2406
2424
|
imageSrc,
|
|
2407
2425
|
mpushVideoSrcAndPreview,
|
|
2408
2426
|
accountData,
|
|
2409
2427
|
sameContent,
|
|
2410
2428
|
options: {
|
|
2411
2429
|
mode: params?.mode,
|
|
2430
|
+
// One platform chosen: leave the other platform's key out of versions.base
|
|
2431
|
+
skipPlatform: singlePlatform ? getOtherPlatform(singlePlatform) : undefined,
|
|
2412
2432
|
},
|
|
2413
2433
|
intl,
|
|
2414
2434
|
});
|
|
@@ -2599,7 +2619,7 @@ export const MobilePushNew = ({
|
|
|
2599
2619
|
globalActionsProps,
|
|
2600
2620
|
onValidationFail,
|
|
2601
2621
|
resetFormData,
|
|
2602
|
-
|
|
2622
|
+
getTapUrlError,
|
|
2603
2623
|
ctaDataAndroid,
|
|
2604
2624
|
ctaDataIos,
|
|
2605
2625
|
intl,
|
|
@@ -2607,8 +2627,17 @@ export const MobilePushNew = ({
|
|
|
2607
2627
|
createTimeoutRef,
|
|
2608
2628
|
isAndroidSupported,
|
|
2609
2629
|
isIosSupported,
|
|
2630
|
+
showAndroid,
|
|
2631
|
+
showIos,
|
|
2632
|
+
singlePlatform,
|
|
2633
|
+
activeTab,
|
|
2634
|
+
validateTitle,
|
|
2635
|
+
validateMessage,
|
|
2610
2636
|
isMobilePushContentMissing,
|
|
2637
|
+
isAndroidFieldsMissing,
|
|
2638
|
+
isIosFieldsMissing,
|
|
2611
2639
|
isCarouselDataValid,
|
|
2640
|
+
hasUnsavedTapLink,
|
|
2612
2641
|
isFullMode,
|
|
2613
2642
|
templateId,
|
|
2614
2643
|
savedTemplateId,
|
|
@@ -2703,38 +2732,30 @@ export const MobilePushNew = ({
|
|
|
2703
2732
|
getLiquidTags: globalActionsProps.getLiquidTags,
|
|
2704
2733
|
formatMessage,
|
|
2705
2734
|
messages: formBuilderMessages,
|
|
2706
|
-
|
|
2735
|
+
// One platform chosen: validate only that platform
|
|
2736
|
+
singleTab: singlePlatform || getSingleTab(accountData),
|
|
2707
2737
|
});
|
|
2708
2738
|
}, [
|
|
2709
2739
|
androidContent,
|
|
2710
2740
|
iosContent,
|
|
2711
2741
|
activeTab,
|
|
2742
|
+
singlePlatform,
|
|
2712
2743
|
globalActionsProps,
|
|
2713
2744
|
formatMessage,
|
|
2714
2745
|
accountData,
|
|
2715
2746
|
isFullMode,
|
|
2716
2747
|
]);
|
|
2717
2748
|
|
|
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
|
+
|
|
2718
2752
|
useEffect(() => {
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
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]);
|
|
2753
|
+
setAndroidContent((prevContent) => ({ ...prevContent, buttons: toPreviewButtons(ctaDataAndroid) }));
|
|
2754
|
+
}, [ctaDataAndroid]);
|
|
2755
|
+
|
|
2756
|
+
useEffect(() => {
|
|
2757
|
+
setIosContent((prevContent) => ({ ...prevContent, buttons: toPreviewButtons(ctaDataIos) }));
|
|
2758
|
+
}, [ctaDataIos]);
|
|
2738
2759
|
|
|
2739
2760
|
// Sync button data and state from active tab to other platform when sameContent is enabled
|
|
2740
2761
|
useEffect(() => {
|
|
@@ -2760,12 +2781,141 @@ export const MobilePushNew = ({
|
|
|
2760
2781
|
}
|
|
2761
2782
|
}, [sameContent, activeTab]);
|
|
2762
2783
|
|
|
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
|
+
|
|
2763
2803
|
const handleSameContentChange = useCallback((e) => {
|
|
2764
2804
|
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
|
+
}
|
|
2765
2811
|
syncPlatformContent(isCurrentPlatformAndroid ? androidContent : iosContent, isCurrentPlatformAndroid ? ANDROID : IOS);
|
|
2766
2812
|
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);
|
|
2767
2819
|
}, [activeTab, androidContent, iosContent]);
|
|
2768
2820
|
|
|
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
|
+
|
|
2769
2919
|
const getContentType = useCallback(
|
|
2770
2920
|
(content) => {
|
|
2771
2921
|
// Get image source from multiple possible locations
|
|
@@ -2888,23 +3038,34 @@ export const MobilePushNew = ({
|
|
|
2888
3038
|
const androidPreview = getContentType(androidContent);
|
|
2889
3039
|
const iosPreview = getContentType(iosContent);
|
|
2890
3040
|
|
|
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
|
+
|
|
2891
3053
|
// Convert Android content to formData format
|
|
2892
3054
|
const androidFormData = {
|
|
2893
3055
|
'message-title': androidPreview?.header || androidContent?.title || '',
|
|
2894
3056
|
'message-editor': androidPreview?.bodyText || androidContent?.message || '',
|
|
2895
3057
|
image: androidPreview?.bodyImage || androidContent?.expandableDetails?.image || '',
|
|
2896
|
-
//
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
'cta-deeplink-label': androidContent.cta.actionText || '',
|
|
2902
|
-
}),
|
|
3058
|
+
// Video only for now. This tab's own videoSrc: the preview falls back to the visible tab's video
|
|
3059
|
+
video: androidContent?.mediaType === VIDEO ? (androidContent?.videoSrc || '') : '',
|
|
3060
|
+
// Same cards Save sends
|
|
3061
|
+
carouselData: androidContent?.mediaType === CAROUSEL ? buildCarouselCards(androidContent?.carouselData) : [],
|
|
3062
|
+
...getTapFormFields(androidContent, ''),
|
|
2903
3063
|
};
|
|
2904
3064
|
|
|
2905
|
-
//
|
|
2906
|
-
|
|
2907
|
-
|
|
3065
|
+
// Buttons live in ctaData state, not in androidContent
|
|
3066
|
+
const androidCtas = toSavedCtas(ctaDataAndroid);
|
|
3067
|
+
if (androidCtas.length > 0) {
|
|
3068
|
+
androidCtas.forEach((cta, index) => {
|
|
2908
3069
|
if (index === 0) {
|
|
2909
3070
|
androidFormData['secondary-cta-0-label'] = cta.actionText || '';
|
|
2910
3071
|
androidFormData['cta-deeplink-secondary-cta-0'] = cta.type === DEEP_LINK ? 'Deeplink' : 'External Link';
|
|
@@ -2925,18 +3086,14 @@ export const MobilePushNew = ({
|
|
|
2925
3086
|
'message-title2': iosPreview?.header || iosContent?.title || '',
|
|
2926
3087
|
'message-editor2': iosPreview?.bodyText || iosContent?.message || '',
|
|
2927
3088
|
image: iosPreview?.bodyImage || iosContent?.expandableDetails?.image || '',
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
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
|
-
}),
|
|
3089
|
+
video: iosContent?.mediaType === VIDEO ? (iosContent?.videoSrc || '') : '',
|
|
3090
|
+
carouselData: iosContent?.mediaType === CAROUSEL ? buildCarouselCards(iosContent?.carouselData) : [],
|
|
3091
|
+
...getTapFormFields(iosContent, '2'),
|
|
2935
3092
|
};
|
|
2936
3093
|
|
|
2937
|
-
|
|
2938
|
-
if (
|
|
2939
|
-
|
|
3094
|
+
const iosCtas = toSavedCtas(ctaDataIos);
|
|
3095
|
+
if (iosCtas.length > 0) {
|
|
3096
|
+
iosCtas.forEach((cta, index) => {
|
|
2940
3097
|
if (index === 0) {
|
|
2941
3098
|
iosFormData['secondary-cta-1-label'] = cta.actionText || '';
|
|
2942
3099
|
iosFormData['cta-deeplink-secondary-cta-1'] = cta.type === DEEP_LINK ? 'Deeplink' : 'External Link';
|
|
@@ -2949,7 +3106,7 @@ export const MobilePushNew = ({
|
|
|
2949
3106
|
|
|
2950
3107
|
// Return in formData array format [androidData, iosData]
|
|
2951
3108
|
return [androidFormData, iosFormData];
|
|
2952
|
-
}, [androidContent, iosContent, getContentType]);
|
|
3109
|
+
}, [androidContent, iosContent, getContentType, ctaDataAndroid, ctaDataIos]);
|
|
2953
3110
|
|
|
2954
3111
|
// Handle Test and Preview button click
|
|
2955
3112
|
const handleTestAndPreview = useCallback(() => {
|
|
@@ -2959,7 +3116,8 @@ export const MobilePushNew = ({
|
|
|
2959
3116
|
// Handle close Test and Preview slidebox
|
|
2960
3117
|
const handleCloseTestAndPreview = useCallback(() => {
|
|
2961
3118
|
setShowTestAndPreviewSlidebox(false);
|
|
2962
|
-
|
|
3119
|
+
if (propsHandleCloseTestAndPreview) propsHandleCloseTestAndPreview();
|
|
3120
|
+
}, [propsHandleCloseTestAndPreview]);
|
|
2963
3121
|
|
|
2964
3122
|
// Add useEffect to handle isGetFormData prop changes (e.g. Done clicked in footer)
|
|
2965
3123
|
// In library mode: run liquid validation (extractTags) first; on success liquidMiddleWare calls handleSave
|
|
@@ -3085,24 +3243,46 @@ export const MobilePushNew = ({
|
|
|
3085
3243
|
<CapRow className="mobile-push-container">
|
|
3086
3244
|
<CapColumn className="content-section" span={14}>
|
|
3087
3245
|
{createModeContent()}
|
|
3088
|
-
{
|
|
3089
|
-
<
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3246
|
+
{canChoosePlatforms && (
|
|
3247
|
+
<CapRow type="flex" vertical noWrap className="input-group creative-name-container">
|
|
3248
|
+
<CapSelect.CapCustomSelect
|
|
3249
|
+
id="mobile-push-platform-select"
|
|
3250
|
+
className="mobile-push-platform-select"
|
|
3251
|
+
label={formatMessage(messages.platforms)}
|
|
3252
|
+
width="100%"
|
|
3253
|
+
options={platformOptions}
|
|
3254
|
+
value={platformSelection}
|
|
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
|
+
</>
|
|
3097
3285
|
)}
|
|
3098
|
-
<CapRow className="platform-header">
|
|
3099
|
-
<StyledCapTab
|
|
3100
|
-
className="platform-tabs"
|
|
3101
|
-
activeKey={activeTab}
|
|
3102
|
-
onChange={setActiveTab}
|
|
3103
|
-
panes={PANES}
|
|
3104
|
-
/>
|
|
3105
|
-
</CapRow>
|
|
3106
3286
|
<CapRow>
|
|
3107
3287
|
<CapColumn span={24}>
|
|
3108
3288
|
<ErrorInfoNote
|
|
@@ -3112,39 +3292,6 @@ export const MobilePushNew = ({
|
|
|
3112
3292
|
STANDARD_ERROR_MSG: errorMessage?.STANDARD_ERROR_MSG,
|
|
3113
3293
|
}}
|
|
3114
3294
|
/>
|
|
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
|
-
|
|
3148
3295
|
</CapColumn>
|
|
3149
3296
|
</CapRow>
|
|
3150
3297
|
</CapColumn>
|
|
@@ -3157,8 +3304,87 @@ export const MobilePushNew = ({
|
|
|
3157
3304
|
/>
|
|
3158
3305
|
</CapColumn>
|
|
3159
3306
|
</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
|
+
/>
|
|
3160
3386
|
<TestAndPreviewSlidebox
|
|
3161
|
-
show={showTestAndPreviewSlidebox}
|
|
3387
|
+
show={propsShowTestAndPreviewSlidebox || showTestAndPreviewSlidebox}
|
|
3162
3388
|
onClose={handleCloseTestAndPreview}
|
|
3163
3389
|
formData={getFormDataForPayload()} // Pass formData structure for payload building
|
|
3164
3390
|
content={getTemplateContent()} // Also pass content for preview
|
|
@@ -3194,6 +3420,8 @@ MobilePushNew.propTypes = {
|
|
|
3194
3420
|
globalActions: PropTypes.object,
|
|
3195
3421
|
fetchingLiquidValidation: PropTypes.bool,
|
|
3196
3422
|
handleClose: PropTypes.func,
|
|
3423
|
+
showTestAndPreviewSlidebox: PropTypes.bool,
|
|
3424
|
+
handleCloseTestAndPreview: PropTypes.func,
|
|
3197
3425
|
createTemplateError: PropTypes.any,
|
|
3198
3426
|
isGetFormData: PropTypes.bool,
|
|
3199
3427
|
getTemplateDetailsInProgress: PropTypes.bool,
|
|
@@ -3226,6 +3454,8 @@ MobilePushNew.defaultProps = {
|
|
|
3226
3454
|
globalActions: {},
|
|
3227
3455
|
fetchingLiquidValidation: false,
|
|
3228
3456
|
handleClose: () => {},
|
|
3457
|
+
showTestAndPreviewSlidebox: false,
|
|
3458
|
+
handleCloseTestAndPreview: undefined,
|
|
3229
3459
|
createTemplateError: null,
|
|
3230
3460
|
isGetFormData: false,
|
|
3231
3461
|
getTemplateDetailsInProgress: false,
|