@capillarytech/creatives-library 9.1.8-alpha.sprint-cap-214249.39 → 9.2.0
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 +4 -0
- package/package.json +1 -1
- package/translations/en.json +1 -0
- package/translations/ja-JP.json +1 -0
- package/translations/zh.json +1 -0
- package/utils/common.js +6 -0
- package/utils/createMobilePushPayload.js +33 -50
- package/utils/tagValidations.js +35 -4
- package/utils/templateVarUtils.js +49 -0
- package/utils/tests/createMobilePushPayload.test.js +8 -113
- package/utils/tests/tagValidations.test.js +48 -0
- package/utils/tests/templateVarUtils.test.js +89 -0
- package/v2Components/CapMpushCTA/index.js +9 -10
- package/v2Components/CapMpushCTA/index.scss +3 -29
- package/v2Components/CapTagList/TagFallbackPanel.js +124 -0
- package/v2Components/CapTagList/constants.js +5 -0
- package/v2Components/CapTagList/index.js +46 -7
- package/v2Components/CapTagList/messages.js +44 -0
- package/v2Components/CapTagList/style.scss +113 -1
- package/v2Components/CapTagList/tests/TagFallback.test.js +222 -0
- package/v2Components/CapTagList/utils.js +17 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +12 -20
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
- package/v2Components/CommonTestAndPreview/constants.js +3 -2
- package/v2Components/CommonTestAndPreview/index.js +61 -61
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -81
- package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
- package/v2Components/CommonTestAndPreview/tests/utils.test.js +102 -0
- package/v2Components/CommonTestAndPreview/utils.js +42 -3
- package/v2Components/FormBuilder/Classic.js +24 -14
- package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +1 -0
- package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
- package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +57 -0
- package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
- package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +3 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +5 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +6 -0
- package/v2Components/FormBuilder/Functional/channels/sms/validate.js +3 -1
- package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +3 -0
- package/v2Components/FormBuilder/Functional/tests/mpushRenderers.test.js +22 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
- package/v2Components/TemplatePreview/index.js +16 -24
- package/v2Components/TemplatePreview/tests/index.test.js +0 -68
- package/v2Containers/Cap/messages.js +4 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +6 -4
- package/v2Containers/CreativesContainer/index.js +1 -2
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -43
- package/v2Containers/InApp/index.js +4 -1
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
- package/v2Containers/Line/Container/Text/index.js +3 -1
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +16 -0
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +18 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +216 -297
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +125 -158
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +108 -464
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +35 -106
- package/v2Containers/MobilePushNew/constants.js +0 -5
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -52
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -40
- package/v2Containers/MobilePushNew/hooks/useUpload.js +39 -29
- package/v2Containers/MobilePushNew/index.js +239 -488
- package/v2Containers/MobilePushNew/index.scss +4 -205
- package/v2Containers/MobilePushNew/messages.js +6 -106
- package/v2Containers/MobilePushNew/tests/index.test.js +1 -469
- package/v2Containers/MobilePushNew/tests/utils.test.js +0 -70
- package/v2Containers/MobilePushNew/utils.js +0 -56
- package/v2Containers/Rcs/index.js +8 -1
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +59 -0
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -0
- package/v2Containers/SmsTrai/Edit/index.js +17 -7
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +42 -0
- package/v2Containers/Templates/_templates.scss +2 -10
- package/v2Containers/Templates/index.js +81 -83
- package/v2Containers/Templates/tests/index.test.js +0 -68
- package/v2Containers/Viber/index.js +3 -1
- package/v2Containers/WebPush/Create/utils/validation.js +6 -0
- package/v2Containers/WebPush/Create/utils/validation.test.js +50 -0
- package/v2Containers/Whatsapp/index.js +9 -5
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
- package/v2Containers/Zalo/index.js +4 -1
- package/v2Components/CapMpushCTA/tests/index.test.js +0 -89
- 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,17 +88,16 @@ 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
|
-
} from "./utils";
|
|
91
|
+
import { validateExternalLink, validateDeepLink, isPlatformFieldsMissing } from "./utils";
|
|
96
92
|
import messages from "./messages";
|
|
97
93
|
import { EXTERNAL_URL, MOBILE_PUSH } from "../CreativesContainer/constants";
|
|
98
|
-
import createMobilePushPayloadWithIntl
|
|
94
|
+
import createMobilePushPayloadWithIntl from "../../utils/createMobilePushPayload";
|
|
99
95
|
import { MOBILEPUSH } from "../../v2Components/CapVideoUpload/constants";
|
|
100
96
|
import { StyledCapTab } from "./style";
|
|
101
97
|
import TestAndPreviewSlidebox from "../../v2Components/TestAndPreviewSlidebox";
|
|
102
98
|
|
|
103
99
|
import creativesMessages from "../CreativesContainer/messages";
|
|
100
|
+
import { error } from "jquery";
|
|
104
101
|
|
|
105
102
|
// Helper function to extract deep link keys from URL where value equals key
|
|
106
103
|
const extractDeepLinkKeys = (deepLinkValue) => {
|
|
@@ -279,50 +276,8 @@ const processCtaButtons = (ctas, deepLink) => {
|
|
|
279
276
|
};
|
|
280
277
|
};
|
|
281
278
|
|
|
282
|
-
const getOtherPlatform = (platform) => (platform === ANDROID ? IOS : ANDROID);
|
|
283
|
-
|
|
284
|
-
// Title, message or media entered for a platform
|
|
285
|
-
const hasPlatformContent = (content) => !!(
|
|
286
|
-
content?.title?.trim()
|
|
287
|
-
|| content?.message?.trim()
|
|
288
|
-
|| (content?.mediaType && content.mediaType !== NONE)
|
|
289
|
-
);
|
|
290
|
-
|
|
291
|
-
// Platforms dropdown value for a saved template: whichever of ANDROID / IOS it has
|
|
292
|
-
const getSavedPlatformSelection = (base = {}) => {
|
|
293
|
-
const hasAndroid = !isEmpty(base?.ANDROID);
|
|
294
|
-
const hasIos = !isEmpty(base?.IOS);
|
|
295
|
-
if (hasAndroid && !hasIos) return ANDROID;
|
|
296
|
-
if (hasIos && !hasAndroid) return IOS;
|
|
297
|
-
return BOTH_PLATFORMS;
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
// Saved buttons in backend shape { actionText, type, actionLink }; used by Save and Test & Preview
|
|
301
|
-
const toSavedCtas = (ctaData = []) => (ctaData || [])
|
|
302
|
-
.filter((cta) => cta?.isSaved)
|
|
303
|
-
.map((cta) => {
|
|
304
|
-
let actionLink = cta?.url;
|
|
305
|
-
|
|
306
|
-
// Append deep link keys to URL if they exist
|
|
307
|
-
if (cta?.urlType === DEEP_LINK && cta?.deepLinkKeys?.length > 0) {
|
|
308
|
-
const deepLinkKeysArray = Array.isArray(cta?.deepLinkKeys) ? cta?.deepLinkKeys : [cta?.deepLinkKeys];
|
|
309
|
-
const validKeys = deepLinkKeysArray.filter((key) => typeof key === 'string' && key?.length > 0);
|
|
310
|
-
if (validKeys?.length > 0) {
|
|
311
|
-
const separator = actionLink.includes('?') ? '&' : '?';
|
|
312
|
-
const keyParams = validKeys.map((key) => `${key}=${key}`).join('&');
|
|
313
|
-
actionLink = `${actionLink}${separator}${keyParams}`;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
return {
|
|
318
|
-
actionText: cta?.text,
|
|
319
|
-
type: cta?.urlType || DEEP_LINK,
|
|
320
|
-
actionLink,
|
|
321
|
-
};
|
|
322
|
-
});
|
|
323
|
-
|
|
324
279
|
// Helper function to create content data object
|
|
325
|
-
const createContentData =(contentType, mediaInfo, buttons, deepLink, processCarouselDataForDeepLinks) => {
|
|
280
|
+
const createContentData = (contentType, mediaInfo, buttons, deepLink, processCarouselDataForDeepLinks) => {
|
|
326
281
|
const {
|
|
327
282
|
mediaType,
|
|
328
283
|
imageSrc,
|
|
@@ -548,9 +503,6 @@ export const MobilePushNew = ({
|
|
|
548
503
|
supportedTags = [],
|
|
549
504
|
globalActions: globalActionsProps,
|
|
550
505
|
handleClose,
|
|
551
|
-
// Edit mode: footer Test & Preview button lives in CreativesContainer
|
|
552
|
-
showTestAndPreviewSlidebox: propsShowTestAndPreviewSlidebox,
|
|
553
|
-
handleCloseTestAndPreview: propsHandleCloseTestAndPreview,
|
|
554
506
|
fetchingLiquidValidation,
|
|
555
507
|
createTemplateError,
|
|
556
508
|
isGetFormData,
|
|
@@ -567,30 +519,11 @@ export const MobilePushNew = ({
|
|
|
567
519
|
const templateId = params?.id || templateData?._id || templateData?.id;
|
|
568
520
|
const isEditMode = !!templateId;
|
|
569
521
|
const computedCreativesMode = isEditMode || templateData?.type === MOBILEPUSH ? 'edit' : 'create';
|
|
570
|
-
|
|
571
|
-
const [sameContentChecked, setSameContent] = useState(false);
|
|
572
|
-
// Platforms dropdown: BOTH_PLATFORMS, ANDROID or IOS
|
|
573
|
-
const [platformSelection, setPlatformSelection] = useState(BOTH_PLATFORMS);
|
|
574
|
-
// Single platform waiting on the "Remove content" confirm
|
|
575
|
-
const [pendingPlatformSelection, setPendingPlatformSelection] = useState(null);
|
|
576
|
-
// Platform dropped by Both -> single; cleared after the switch, once sync is off
|
|
577
|
-
const [platformToClear, setPlatformToClear] = useState(null);
|
|
578
|
-
// Determine platform support from accountData
|
|
579
|
-
const isAndroidSupported = accountData?.configs?.android === '1';
|
|
580
|
-
const isIosSupported = accountData?.configs?.ios === '1';
|
|
581
|
-
// The Platforms dropdown only applies when the account supports both
|
|
582
|
-
const canChoosePlatforms = isAndroidSupported && isIosSupported;
|
|
583
|
-
// ANDROID or IOS when one platform is chosen, else null
|
|
584
|
-
const singlePlatform = canChoosePlatforms && platformSelection !== BOTH_PLATFORMS ? platformSelection : null;
|
|
585
|
-
const showAndroid = isAndroidSupported && singlePlatform !== IOS;
|
|
586
|
-
const showIos = isIosSupported && singlePlatform !== ANDROID;
|
|
587
|
-
const sameContent = sameContentChecked && !singlePlatform;
|
|
522
|
+
const [sameContent, setSameContent] = useState(false);
|
|
588
523
|
const [templateName, setTemplateName] = useState("");
|
|
589
524
|
const [spin, setSpin] = useState(false);
|
|
590
525
|
const [activeTab, setActiveTab] = useState(ANDROID);
|
|
591
526
|
const [templateNameError, setTemplateNameError] = useState(false);
|
|
592
|
-
// "Same content" tick waiting on the Replace confirm
|
|
593
|
-
const [isReplaceConfirmOpen, setIsReplaceConfirmOpen] = useState(false);
|
|
594
527
|
// Replace ctaData with platform-specific state
|
|
595
528
|
const [ctaDataAndroid, setCtaDataAndroid] = useState([]);
|
|
596
529
|
const [ctaDataIos, setCtaDataIos] = useState([]);
|
|
@@ -719,9 +652,52 @@ export const MobilePushNew = ({
|
|
|
719
652
|
const createTimeoutRef = useRef(null);
|
|
720
653
|
|
|
721
654
|
// Function to validate carousel data completeness
|
|
722
|
-
const validateCarouselData = useCallback((carouselData = []) =>
|
|
723
|
-
carouselData?.length
|
|
724
|
-
|
|
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]);
|
|
725
701
|
|
|
726
702
|
// Function to check if carousel data is valid for both platforms
|
|
727
703
|
const isCarouselDataValid = useCallback(() => {
|
|
@@ -777,9 +753,6 @@ export const MobilePushNew = ({
|
|
|
777
753
|
setPrimaryButtonIos(false);
|
|
778
754
|
setSecondaryButtonIos(false);
|
|
779
755
|
setSameContent(false);
|
|
780
|
-
setPlatformSelection(BOTH_PLATFORMS);
|
|
781
|
-
setPendingPlatformSelection(null);
|
|
782
|
-
setPlatformToClear(null);
|
|
783
756
|
setTemplateNameError(false);
|
|
784
757
|
setAndroidTitleError("");
|
|
785
758
|
setAndroidMessageError("");
|
|
@@ -835,7 +808,7 @@ export const MobilePushNew = ({
|
|
|
835
808
|
(value) => {
|
|
836
809
|
let errorTemplateDescMessage = "";
|
|
837
810
|
|
|
838
|
-
const { isBraceError } = validateTags({
|
|
811
|
+
const { isBraceError, isDefaultQuoteError } = validateTags({
|
|
839
812
|
content: value,
|
|
840
813
|
tagsParam: tags,
|
|
841
814
|
location,
|
|
@@ -852,6 +825,9 @@ export const MobilePushNew = ({
|
|
|
852
825
|
globalMessages.unbalanacedCurlyBraces
|
|
853
826
|
);
|
|
854
827
|
}
|
|
828
|
+
if (isDefaultQuoteError) {
|
|
829
|
+
errorTemplateDescMessage = formatMessage(globalMessages.unquotedTagDefaultValue);
|
|
830
|
+
}
|
|
855
831
|
return errorTemplateDescMessage;
|
|
856
832
|
},
|
|
857
833
|
[tags, injectedTags, location, getDefaultTags, formatMessage]
|
|
@@ -993,8 +969,6 @@ export const MobilePushNew = ({
|
|
|
993
969
|
templateNameRef.current = name;
|
|
994
970
|
});
|
|
995
971
|
|
|
996
|
-
stateUpdates.push(() => setPlatformSelection(getSavedPlatformSelection(editContent)));
|
|
997
|
-
|
|
998
972
|
// Process Android content
|
|
999
973
|
const androidContentType = editContent?.ANDROID;
|
|
1000
974
|
if (!isEmpty(androidContentType)) {
|
|
@@ -1130,8 +1104,6 @@ export const MobilePushNew = ({
|
|
|
1130
1104
|
templateNameRef.current = name;
|
|
1131
1105
|
});
|
|
1132
1106
|
|
|
1133
|
-
stateUpdates.push(() => setPlatformSelection(getSavedPlatformSelection(templateContent)));
|
|
1134
|
-
|
|
1135
1107
|
// Process Android content
|
|
1136
1108
|
const androidContentType = templateContent?.ANDROID;
|
|
1137
1109
|
if (!isEmpty(androidContentType)) {
|
|
@@ -1767,6 +1739,10 @@ export const MobilePushNew = ({
|
|
|
1767
1739
|
setSpin(false);
|
|
1768
1740
|
}, [templateData, isFullMode, deepLink, setUpdateMpushImageSrc, setUpdateMpushVideoSrc]);
|
|
1769
1741
|
|
|
1742
|
+
// Determine platform support from accountData
|
|
1743
|
+
const isAndroidSupported = accountData?.configs?.android === '1';
|
|
1744
|
+
const isIosSupported = accountData?.configs?.ios === '1';
|
|
1745
|
+
|
|
1770
1746
|
// Notify parent when personalization tokens are added/removed (for anonymous user flow)
|
|
1771
1747
|
useEffect(() => {
|
|
1772
1748
|
if (!restrictPersonalization || typeof onPersonalizationTokensChange !== 'function') return;
|
|
@@ -1775,8 +1751,8 @@ export const MobilePushNew = ({
|
|
|
1775
1751
|
|| (value.includes('[') && value.includes(']'))
|
|
1776
1752
|
);
|
|
1777
1753
|
const hasTokens = (
|
|
1778
|
-
(
|
|
1779
|
-
|| (
|
|
1754
|
+
(isAndroidSupported && (hasToken(androidContent?.title) || hasToken(androidContent?.message)))
|
|
1755
|
+
|| (isIosSupported && (hasToken(iosContent?.title) || hasToken(iosContent?.message)))
|
|
1780
1756
|
);
|
|
1781
1757
|
onPersonalizationTokensChange(hasTokens);
|
|
1782
1758
|
}, [
|
|
@@ -1785,21 +1761,18 @@ export const MobilePushNew = ({
|
|
|
1785
1761
|
androidContent?.message,
|
|
1786
1762
|
iosContent?.title,
|
|
1787
1763
|
iosContent?.message,
|
|
1788
|
-
|
|
1789
|
-
|
|
1764
|
+
isAndroidSupported,
|
|
1765
|
+
isIosSupported,
|
|
1790
1766
|
onPersonalizationTokensChange,
|
|
1791
1767
|
]);
|
|
1792
1768
|
|
|
1793
|
-
// Validation logic for template creation/update
|
|
1794
|
-
const isAndroidFieldsMissing = isPlatformFieldsMissing(
|
|
1795
|
-
const isIosFieldsMissing = isPlatformFieldsMissing(
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
(showAndroid || showIos)
|
|
1801
|
-
&& (!showAndroid || isAndroidFieldsMissing)
|
|
1802
|
-
&& (!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)
|
|
1803
1776
|
);
|
|
1804
1777
|
|
|
1805
1778
|
// Ref to dedupe reporting of content emptiness to the parent, so we only
|
|
@@ -1823,7 +1796,8 @@ export const MobilePushNew = ({
|
|
|
1823
1796
|
handleMessageChange,
|
|
1824
1797
|
handleTagSelect,
|
|
1825
1798
|
handleMediaTypeChange,
|
|
1826
|
-
|
|
1799
|
+
handleActionOnClickChange,
|
|
1800
|
+
handleLinkTypeChange,
|
|
1827
1801
|
} = usePlatformSync({
|
|
1828
1802
|
setAndroidContent,
|
|
1829
1803
|
setIosContent,
|
|
@@ -1895,21 +1869,9 @@ export const MobilePushNew = ({
|
|
|
1895
1869
|
}
|
|
1896
1870
|
}, [sameContent]);
|
|
1897
1871
|
|
|
1898
|
-
// Notification tap link Save / edit (both tabs when synced)
|
|
1899
|
-
const handleTapLinkSavedChange = useCallback((platform, tapLinkSaved) => {
|
|
1900
|
-
const update = (prev) => ({ ...prev, tapLinkSaved });
|
|
1901
|
-
if (platform === ANDROID || sameContent) setAndroidContent(update);
|
|
1902
|
-
if (platform === IOS || sameContent) setIosContent(update);
|
|
1903
|
-
}, [sameContent]);
|
|
1904
|
-
|
|
1905
|
-
// Notification tap URL: required once External link is chosen; same message as the button form
|
|
1906
|
-
const getTapUrlError = useCallback((url) => (
|
|
1907
|
-
!url?.trim() || validateExternalLink(url, formatMessage, messages) ? formatMessage(messages.urlNotValid) : ""
|
|
1908
|
-
), [formatMessage]);
|
|
1909
|
-
|
|
1910
1872
|
const handleExternalLinkChange = useCallback((platform, externalLinkValue) => {
|
|
1911
1873
|
// Validate URL
|
|
1912
|
-
const urlError =
|
|
1874
|
+
const urlError = validateExternalLink(externalLinkValue, formatMessage, messages);
|
|
1913
1875
|
|
|
1914
1876
|
const updateContent = {
|
|
1915
1877
|
externalLinkValue,
|
|
@@ -1936,7 +1898,7 @@ export const MobilePushNew = ({
|
|
|
1936
1898
|
setAndroidExternalLinkError(urlError || "");
|
|
1937
1899
|
}
|
|
1938
1900
|
}
|
|
1939
|
-
}, [
|
|
1901
|
+
}, [validateExternalLink, sameContent]);
|
|
1940
1902
|
|
|
1941
1903
|
// Carousel data handler for platform-specific carousel management
|
|
1942
1904
|
const updateCarouselLinkError = useCallback((cardIndex, field, error) => {
|
|
@@ -2083,20 +2045,11 @@ export const MobilePushNew = ({
|
|
|
2083
2045
|
handleTitleChange,
|
|
2084
2046
|
handleMessageChange,
|
|
2085
2047
|
handleMediaTypeChange,
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
// The old link field is gone, so are its errors (on both tabs when synced)
|
|
2089
|
-
[platform, ...(sameContent ? [getOtherPlatform(platform)] : [])].forEach((target) => {
|
|
2090
|
-
const isAndroidTarget = target === ANDROID;
|
|
2091
|
-
(isAndroidTarget ? setAndroidExternalLinkError : setIosExternalLinkError)("");
|
|
2092
|
-
(isAndroidTarget ? setAndroidDeepLinkError : setIosDeepLinkError)("");
|
|
2093
|
-
(isAndroidTarget ? setAndroidDeepLinkKeysError : setIosDeepLinkKeysError)("");
|
|
2094
|
-
});
|
|
2095
|
-
},
|
|
2048
|
+
handleActionOnClickChange,
|
|
2049
|
+
handleLinkTypeChange,
|
|
2096
2050
|
handleDeepLinkChange: (value) => handleDeepLinkChange(platform, value),
|
|
2097
2051
|
handleDeepLinkKeysChange: (value) => handleDeepLinkKeysChange(platform, value),
|
|
2098
2052
|
handleExternalLinkChange: (value) => handleExternalLinkChange(platform, value),
|
|
2099
|
-
handleTapLinkSavedChange: (isSaved) => handleTapLinkSavedChange(platform, isSaved),
|
|
2100
2053
|
onTagSelect,
|
|
2101
2054
|
handleOnTagsContextChange,
|
|
2102
2055
|
};
|
|
@@ -2216,7 +2169,7 @@ export const MobilePushNew = ({
|
|
|
2216
2169
|
restrictPersonalization={restrictPersonalization}
|
|
2217
2170
|
/>
|
|
2218
2171
|
);
|
|
2219
|
-
}, [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]
|
|
2220
2173
|
);
|
|
2221
2174
|
|
|
2222
2175
|
// PANES: Only render enabled platforms
|
|
@@ -2226,8 +2179,8 @@ export const MobilePushNew = ({
|
|
|
2226
2179
|
panes.push({
|
|
2227
2180
|
key: ANDROID,
|
|
2228
2181
|
tab: (
|
|
2229
|
-
<CapRow
|
|
2230
|
-
<CapIcon type="android"
|
|
2182
|
+
<CapRow useLegacy>
|
|
2183
|
+
<CapIcon type="android" />
|
|
2231
2184
|
{formatMessage(messages.android)}
|
|
2232
2185
|
</CapRow>
|
|
2233
2186
|
),
|
|
@@ -2238,8 +2191,8 @@ export const MobilePushNew = ({
|
|
|
2238
2191
|
panes.push({
|
|
2239
2192
|
key: IOS,
|
|
2240
2193
|
tab: (
|
|
2241
|
-
<CapRow
|
|
2242
|
-
<CapIcon type="ios"
|
|
2194
|
+
<CapRow useLegacy>
|
|
2195
|
+
<CapIcon type="ios" />
|
|
2243
2196
|
{formatMessage(messages.ios)}
|
|
2244
2197
|
</CapRow>
|
|
2245
2198
|
),
|
|
@@ -2252,42 +2205,25 @@ export const MobilePushNew = ({
|
|
|
2252
2205
|
const errorInTitle = activeTab === ANDROID ? androidTitleError : iosTitleError;
|
|
2253
2206
|
const errorInMessage = activeTab === ANDROID ? androidMessageError : iosMessageError;
|
|
2254
2207
|
|
|
2255
|
-
//
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
}
|
|
2261
|
-
return content.actionOnClick && content.tapLinkSaved === false;
|
|
2262
|
-
});
|
|
2263
|
-
|
|
2264
|
-
const hasFormErrors = (
|
|
2265
|
-
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
|
|
2266
2213
|
|| Object.values(carouselLinkErrors).some((error) => error !== null && error !== "")
|
|
2267
2214
|
|| !isCarouselDataValid()
|
|
2268
|
-
|| hasUnsavedTapLink
|
|
2269
2215
|
|| errorInTitle || errorInMessage
|
|
2270
2216
|
);
|
|
2271
|
-
// Save needs every shown platform filled
|
|
2272
|
-
const isSaveDisabled = isMobilePushContentMissing || hasFormErrors;
|
|
2273
|
-
const isTestAndPreviewDisabled = isAllContentMissing || hasFormErrors;
|
|
2274
2217
|
|
|
2275
|
-
// Validation in handleSave:
|
|
2218
|
+
// Validation in handleSave: only enforce content on enabled platforms, and
|
|
2219
|
+
// allow saving with just one supported platform filled in.
|
|
2276
2220
|
const handleSave = useCallback(() => {
|
|
2277
2221
|
if (isMobilePushContentMissing) {
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
missingPlatforms.forEach(([platform, , content]) => {
|
|
2283
|
-
const isAndroid = platform === ANDROID;
|
|
2284
|
-
(isAndroid ? setAndroidTitleError : setIosTitleError)(validateTitle(content?.title));
|
|
2285
|
-
(isAndroid ? setAndroidMessageError : setIosMessageError)(validateMessage(content?.message));
|
|
2222
|
+
CapNotification.error({
|
|
2223
|
+
message: formatMessage(
|
|
2224
|
+
isAndroidSupported ? messages.androidValidationError : messages.iosValidationError,
|
|
2225
|
+
),
|
|
2286
2226
|
});
|
|
2287
|
-
// Open a tab that has the errors, unless the open one already does
|
|
2288
|
-
if (!missingPlatforms.some(([platform]) => platform === activeTab)) {
|
|
2289
|
-
setActiveTab(missingPlatforms[0][0]);
|
|
2290
|
-
}
|
|
2291
2227
|
if (onValidationFail) onValidationFail();
|
|
2292
2228
|
return;
|
|
2293
2229
|
}
|
|
@@ -2311,38 +2247,32 @@ export const MobilePushNew = ({
|
|
|
2311
2247
|
// Use ref to get the latest template name value to avoid closure issues
|
|
2312
2248
|
let finalTemplateName = templateNameRef.current || templateName;
|
|
2313
2249
|
if (!isFullMode && (!finalTemplateName || !finalTemplateName.trim())) {
|
|
2314
|
-
if (
|
|
2250
|
+
if (androidContent?.title && androidContent.title.trim()) {
|
|
2315
2251
|
finalTemplateName = androidContent.title.trim();
|
|
2316
|
-
} else if (
|
|
2252
|
+
} else if (iosContent?.title && iosContent.title.trim()) {
|
|
2317
2253
|
finalTemplateName = iosContent.title.trim();
|
|
2318
2254
|
} else {
|
|
2319
2255
|
finalTemplateName = '';
|
|
2320
2256
|
}
|
|
2321
2257
|
}
|
|
2322
2258
|
|
|
2323
|
-
// Validate
|
|
2324
|
-
const
|
|
2325
|
-
const
|
|
2326
|
-
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);
|
|
2327
2262
|
|
|
2328
2263
|
setAndroidExternalLinkError(androidUrlError || "");
|
|
2329
2264
|
setIosExternalLinkError(iosUrlError || "");
|
|
2330
2265
|
|
|
2331
|
-
// Validate deep links
|
|
2332
|
-
const
|
|
2333
|
-
|
|
2334
|
-
? formatMessage(messages.deepLinkRequired)
|
|
2335
|
-
: validateDeepLink(content?.deepLinkValue, formatMessage, messages)
|
|
2336
|
-
);
|
|
2337
|
-
const androidDeepLinkUrlError = showAndroid && getTapDeepLinkError(androidContent);
|
|
2338
|
-
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);
|
|
2339
2269
|
|
|
2340
2270
|
setAndroidDeepLinkError(androidDeepLinkUrlError || "");
|
|
2341
2271
|
setIosDeepLinkError(iosDeepLinkUrlError || "");
|
|
2342
2272
|
|
|
2343
2273
|
// Validate deep link keys - only require keys if the selected deep link has keys defined
|
|
2344
2274
|
const androidDeepLinkKeysErrorMsg = (() => {
|
|
2345
|
-
if (
|
|
2275
|
+
if (androidContent?.linkType === DEEP_LINK && androidContent?.deepLinkValue) {
|
|
2346
2276
|
// Use the same matching logic as deep link value extraction
|
|
2347
2277
|
let selectedDeepLink = null;
|
|
2348
2278
|
|
|
@@ -2366,7 +2296,7 @@ export const MobilePushNew = ({
|
|
|
2366
2296
|
})();
|
|
2367
2297
|
|
|
2368
2298
|
const iosDeepLinkKeysErrorMsg = (() => {
|
|
2369
|
-
if (
|
|
2299
|
+
if (iosContent?.linkType === DEEP_LINK && iosContent?.deepLinkValue) {
|
|
2370
2300
|
// Use the same matching logic as deep link value extraction
|
|
2371
2301
|
let selectedDeepLink = null;
|
|
2372
2302
|
|
|
@@ -2395,15 +2325,6 @@ export const MobilePushNew = ({
|
|
|
2395
2325
|
// Check for carousel link errors
|
|
2396
2326
|
const hasCarouselErrors = Object.values(carouselLinkErrors).some((error) => error !== null && error !== "");
|
|
2397
2327
|
|
|
2398
|
-
// The host can trigger save without the (disabled) Save button
|
|
2399
|
-
if (hasUnsavedTapLink) {
|
|
2400
|
-
CapNotification.error({ message: formatMessage(messages.saveTapLinkFirst) });
|
|
2401
|
-
if (onValidationFail) {
|
|
2402
|
-
onValidationFail();
|
|
2403
|
-
}
|
|
2404
|
-
return;
|
|
2405
|
-
}
|
|
2406
|
-
|
|
2407
2328
|
if (androidUrlError || iosUrlError || androidDeepLinkUrlError || iosDeepLinkUrlError || androidDeepLinkKeysErrorMsg || iosDeepLinkKeysErrorMsg || hasCarouselErrors) {
|
|
2408
2329
|
CapNotification.error({
|
|
2409
2330
|
message: formatMessage(messages.invalidUrl),
|
|
@@ -2420,34 +2341,74 @@ export const MobilePushNew = ({
|
|
|
2420
2341
|
const processedIosContent = { ...iosContent };
|
|
2421
2342
|
|
|
2422
2343
|
// Process button CTA data if it exists
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
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
|
+
}
|
|
2429
2371
|
}
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
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
|
+
}
|
|
2436
2399
|
}
|
|
2437
2400
|
|
|
2438
2401
|
// Create payload with enabled platform content and intl
|
|
2439
2402
|
const payload = createMobilePushPayloadWithIntl({
|
|
2440
2403
|
templateName: finalTemplateName,
|
|
2441
|
-
androidContent:
|
|
2442
|
-
iosContent:
|
|
2404
|
+
androidContent: isAndroidSupported ? processedAndroidContent : undefined,
|
|
2405
|
+
iosContent: isIosSupported ? processedIosContent : undefined,
|
|
2443
2406
|
imageSrc,
|
|
2444
2407
|
mpushVideoSrcAndPreview,
|
|
2445
2408
|
accountData,
|
|
2446
2409
|
sameContent,
|
|
2447
2410
|
options: {
|
|
2448
2411
|
mode: params?.mode,
|
|
2449
|
-
// One platform chosen: leave the other platform's key out of versions.base
|
|
2450
|
-
skipPlatform: singlePlatform ? getOtherPlatform(singlePlatform) : undefined,
|
|
2451
2412
|
},
|
|
2452
2413
|
intl,
|
|
2453
2414
|
});
|
|
@@ -2638,7 +2599,7 @@ export const MobilePushNew = ({
|
|
|
2638
2599
|
globalActionsProps,
|
|
2639
2600
|
onValidationFail,
|
|
2640
2601
|
resetFormData,
|
|
2641
|
-
|
|
2602
|
+
validateExternalLink,
|
|
2642
2603
|
ctaDataAndroid,
|
|
2643
2604
|
ctaDataIos,
|
|
2644
2605
|
intl,
|
|
@@ -2646,17 +2607,8 @@ export const MobilePushNew = ({
|
|
|
2646
2607
|
createTimeoutRef,
|
|
2647
2608
|
isAndroidSupported,
|
|
2648
2609
|
isIosSupported,
|
|
2649
|
-
showAndroid,
|
|
2650
|
-
showIos,
|
|
2651
|
-
singlePlatform,
|
|
2652
|
-
activeTab,
|
|
2653
|
-
validateTitle,
|
|
2654
|
-
validateMessage,
|
|
2655
2610
|
isMobilePushContentMissing,
|
|
2656
|
-
isAndroidFieldsMissing,
|
|
2657
|
-
isIosFieldsMissing,
|
|
2658
2611
|
isCarouselDataValid,
|
|
2659
|
-
hasUnsavedTapLink,
|
|
2660
2612
|
isFullMode,
|
|
2661
2613
|
templateId,
|
|
2662
2614
|
savedTemplateId,
|
|
@@ -2751,30 +2703,38 @@ export const MobilePushNew = ({
|
|
|
2751
2703
|
getLiquidTags: globalActionsProps.getLiquidTags,
|
|
2752
2704
|
formatMessage,
|
|
2753
2705
|
messages: formBuilderMessages,
|
|
2754
|
-
|
|
2755
|
-
singleTab: singlePlatform || getSingleTab(accountData),
|
|
2706
|
+
singleTab: getSingleTab(accountData),
|
|
2756
2707
|
});
|
|
2757
2708
|
}, [
|
|
2758
2709
|
androidContent,
|
|
2759
2710
|
iosContent,
|
|
2760
2711
|
activeTab,
|
|
2761
|
-
singlePlatform,
|
|
2762
2712
|
globalActionsProps,
|
|
2763
2713
|
formatMessage,
|
|
2764
2714
|
accountData,
|
|
2765
2715
|
isFullMode,
|
|
2766
2716
|
]);
|
|
2767
2717
|
|
|
2768
|
-
// Each platform's preview buttons follow its own ctaData, so iOS shows before its tab is opened
|
|
2769
|
-
const toPreviewButtons = (ctas) => (Array.isArray(ctas) ? ctas.map((data) => ({ label: data?.text || '' })) : []);
|
|
2770
|
-
|
|
2771
|
-
useEffect(() => {
|
|
2772
|
-
setAndroidContent((prevContent) => ({ ...prevContent, buttons: toPreviewButtons(ctaDataAndroid) }));
|
|
2773
|
-
}, [ctaDataAndroid]);
|
|
2774
|
-
|
|
2775
2718
|
useEffect(() => {
|
|
2776
|
-
|
|
2777
|
-
|
|
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]);
|
|
2778
2738
|
|
|
2779
2739
|
// Sync button data and state from active tab to other platform when sameContent is enabled
|
|
2780
2740
|
useEffect(() => {
|
|
@@ -2800,141 +2760,12 @@ export const MobilePushNew = ({
|
|
|
2800
2760
|
}
|
|
2801
2761
|
}, [sameContent, activeTab]);
|
|
2802
2762
|
|
|
2803
|
-
// What ticking "Same content" would copy over: text, media, links and buttons
|
|
2804
|
-
const getPlatformSnapshot = (platform) => {
|
|
2805
|
-
const isAndroid = platform === ANDROID;
|
|
2806
|
-
const content = isAndroid ? androidContent : iosContent;
|
|
2807
|
-
return JSON.stringify({
|
|
2808
|
-
title: content?.title || '',
|
|
2809
|
-
message: content?.message || '',
|
|
2810
|
-
mediaType: content?.mediaType || NONE,
|
|
2811
|
-
carouselData: content?.carouselData || [],
|
|
2812
|
-
actionOnClick: !!content?.actionOnClick,
|
|
2813
|
-
linkType: content?.linkType || '',
|
|
2814
|
-
deepLinkValue: content?.deepLinkValue || '',
|
|
2815
|
-
externalLinkValue: content?.externalLinkValue || '',
|
|
2816
|
-
image: (isAndroid ? imageSrc?.androidImageSrc : imageSrc?.iosImageSrc) || '',
|
|
2817
|
-
video: (isAndroid ? videoState?.androidVideoSrc : videoState?.iosVideoSrc) || '',
|
|
2818
|
-
buttons: toSavedCtas(isAndroid ? ctaDataAndroid : ctaDataIos),
|
|
2819
|
-
});
|
|
2820
|
-
};
|
|
2821
|
-
|
|
2822
2763
|
const handleSameContentChange = useCallback((e) => {
|
|
2823
2764
|
const isCurrentPlatformAndroid = activeTab === ANDROID;
|
|
2824
|
-
const otherContent = isCurrentPlatformAndroid ? iosContent : androidContent;
|
|
2825
|
-
// Ticking replaces the other tab: confirm when it has different content, not when it is empty
|
|
2826
|
-
if (e.target.checked && hasPlatformContent(otherContent) && getPlatformSnapshot(ANDROID) !== getPlatformSnapshot(IOS)) {
|
|
2827
|
-
setIsReplaceConfirmOpen(true);
|
|
2828
|
-
return;
|
|
2829
|
-
}
|
|
2830
2765
|
syncPlatformContent(isCurrentPlatformAndroid ? androidContent : iosContent, isCurrentPlatformAndroid ? ANDROID : IOS);
|
|
2831
2766
|
setSameContent(e.target.checked);
|
|
2832
|
-
}, [activeTab, androidContent, iosContent, imageSrc, videoState, ctaDataAndroid, ctaDataIos]);
|
|
2833
|
-
|
|
2834
|
-
const confirmSameContent = useCallback(() => {
|
|
2835
|
-
setIsReplaceConfirmOpen(false);
|
|
2836
|
-
syncPlatformContent(activeTab === ANDROID ? androidContent : iosContent, activeTab);
|
|
2837
|
-
setSameContent(true);
|
|
2838
2767
|
}, [activeTab, androidContent, iosContent]);
|
|
2839
2768
|
|
|
2840
|
-
// One platform chosen: its form is the only one shown, and the upload/button handlers follow activeTab
|
|
2841
|
-
useEffect(() => {
|
|
2842
|
-
if (singlePlatform && activeTab !== singlePlatform) {
|
|
2843
|
-
setActiveTab(singlePlatform);
|
|
2844
|
-
}
|
|
2845
|
-
}, [singlePlatform, activeTab]);
|
|
2846
|
-
|
|
2847
|
-
// Both -> single: empty the dropped platform. Runs after the switch so sync is off
|
|
2848
|
-
// and the kept platform's media stays.
|
|
2849
|
-
useEffect(() => {
|
|
2850
|
-
if (!platformToClear) return;
|
|
2851
|
-
const isAndroid = platformToClear === ANDROID;
|
|
2852
|
-
const platformIndex = isAndroid ? 0 : 1;
|
|
2853
|
-
clearImageDataByMediaType(IMAGE, platformToClear);
|
|
2854
|
-
clearImageDataByMediaType(VIDEO, platformToClear);
|
|
2855
|
-
// Uploaded-video list read by the upload box
|
|
2856
|
-
setUpdateMpushVideoSrc(platformIndex, {}, true);
|
|
2857
|
-
(isAndroid ? setAndroidContent : setIosContent)(INITIAL_CONTENT);
|
|
2858
|
-
(isAndroid ? setCtaDataAndroid : setCtaDataIos)([]);
|
|
2859
|
-
(isAndroid ? setPrimaryButtonAndroid : setPrimaryButtonIos)(false);
|
|
2860
|
-
(isAndroid ? setSecondaryButtonAndroid : setSecondaryButtonIos)(false);
|
|
2861
|
-
(isAndroid ? setAndroidTitleError : setIosTitleError)("");
|
|
2862
|
-
(isAndroid ? setAndroidMessageError : setIosMessageError)("");
|
|
2863
|
-
(isAndroid ? setAndroidExternalLinkError : setIosExternalLinkError)("");
|
|
2864
|
-
(isAndroid ? setAndroidDeepLinkError : setIosDeepLinkError)("");
|
|
2865
|
-
(isAndroid ? setAndroidDeepLinkKeysError : setIosDeepLinkKeysError)("");
|
|
2866
|
-
setPlatformToClear(null);
|
|
2867
|
-
}, [platformToClear, clearImageDataByMediaType, setUpdateMpushVideoSrc]);
|
|
2868
|
-
|
|
2869
|
-
// Android only <-> iOS only: give the empty target the current platform's content, buttons and media
|
|
2870
|
-
const copyPlatformContent = useCallback((source, target) => {
|
|
2871
|
-
const fromAndroid = source === ANDROID;
|
|
2872
|
-
const targetIndex = target === ANDROID ? 0 : 1;
|
|
2873
|
-
syncPlatformContent(fromAndroid ? androidContent : iosContent, source);
|
|
2874
|
-
(fromAndroid ? setCtaDataIos : setCtaDataAndroid)(cloneDeep(fromAndroid ? ctaDataAndroid : ctaDataIos));
|
|
2875
|
-
(fromAndroid ? setPrimaryButtonIos : setPrimaryButtonAndroid)(fromAndroid ? primaryButtonAndroid : primaryButtonIos);
|
|
2876
|
-
(fromAndroid ? setSecondaryButtonIos : setSecondaryButtonAndroid)(fromAndroid ? secondaryButtonAndroid : secondaryButtonIos);
|
|
2877
|
-
// Uploaded image/video live in the upload hook, per platform
|
|
2878
|
-
const sourceImage = fromAndroid ? imageSrc?.androidImageSrc : imageSrc?.iosImageSrc;
|
|
2879
|
-
if (sourceImage) {
|
|
2880
|
-
setUpdateMpushImageSrc(sourceImage, targetIndex, IMAGE);
|
|
2881
|
-
}
|
|
2882
|
-
const sourceVideo = fromAndroid ? videoState?.androidVideoSrc : videoState?.iosVideoSrc;
|
|
2883
|
-
if (sourceVideo) {
|
|
2884
|
-
setUpdateMpushVideoSrc(targetIndex, {
|
|
2885
|
-
...(fromAndroid ? androidAssetList : iosAssetList),
|
|
2886
|
-
videoSrc: sourceVideo,
|
|
2887
|
-
previewUrl: (fromAndroid ? videoState?.androidVideoPreview : videoState?.iosVideoPreview) || '',
|
|
2888
|
-
videoDuration: (fromAndroid ? videoState?.androidVideoDuration : videoState?.iosVideoDuration) || 0,
|
|
2889
|
-
}, true);
|
|
2890
|
-
}
|
|
2891
|
-
}, [androidContent, iosContent, ctaDataAndroid, ctaDataIos, primaryButtonAndroid, primaryButtonIos, secondaryButtonAndroid, secondaryButtonIos, imageSrc, videoState, androidAssetList, iosAssetList, setUpdateMpushImageSrc, setUpdateMpushVideoSrc]);
|
|
2892
|
-
|
|
2893
|
-
const handlePlatformChange = useCallback((value) => {
|
|
2894
|
-
if (value === platformSelection) return;
|
|
2895
|
-
const getPlatformContent = (platform) => (platform === ANDROID ? androidContent : iosContent);
|
|
2896
|
-
|
|
2897
|
-
if (platformSelection === BOTH_PLATFORMS) {
|
|
2898
|
-
// Both -> single: confirm before dropping a platform that has content
|
|
2899
|
-
if (hasPlatformContent(getPlatformContent(getOtherPlatform(value)))) {
|
|
2900
|
-
setPendingPlatformSelection(value);
|
|
2901
|
-
return;
|
|
2902
|
-
}
|
|
2903
|
-
setPlatformSelection(value);
|
|
2904
|
-
setPlatformToClear(getOtherPlatform(value));
|
|
2905
|
-
return;
|
|
2906
|
-
}
|
|
2907
|
-
|
|
2908
|
-
if (value === BOTH_PLATFORMS) {
|
|
2909
|
-
// Single -> Both: content stays in its tab; a ticked "Same content" syncs it to the other tab
|
|
2910
|
-
// (media and buttons follow through the existing on-tick effects)
|
|
2911
|
-
if (sameContentChecked) {
|
|
2912
|
-
syncPlatformContent(getPlatformContent(platformSelection), platformSelection);
|
|
2913
|
-
}
|
|
2914
|
-
setPlatformSelection(value);
|
|
2915
|
-
return;
|
|
2916
|
-
}
|
|
2917
|
-
|
|
2918
|
-
// Android only <-> iOS only: an empty target takes the current content
|
|
2919
|
-
if (!hasPlatformContent(getPlatformContent(value)) && hasPlatformContent(getPlatformContent(platformSelection))) {
|
|
2920
|
-
copyPlatformContent(platformSelection, value);
|
|
2921
|
-
}
|
|
2922
|
-
setPlatformSelection(value);
|
|
2923
|
-
}, [platformSelection, androidContent, iosContent, sameContentChecked, copyPlatformContent]);
|
|
2924
|
-
|
|
2925
|
-
const confirmPlatformRemoval = useCallback(() => {
|
|
2926
|
-
const value = pendingPlatformSelection;
|
|
2927
|
-
setPendingPlatformSelection(null);
|
|
2928
|
-
setPlatformSelection(value);
|
|
2929
|
-
setPlatformToClear(getOtherPlatform(value));
|
|
2930
|
-
}, [pendingPlatformSelection]);
|
|
2931
|
-
|
|
2932
|
-
const platformOptions = useMemo(() => [
|
|
2933
|
-
{ label: formatMessage(messages.androidAndIos), value: BOTH_PLATFORMS },
|
|
2934
|
-
{ label: formatMessage(messages.androidOnly), value: ANDROID },
|
|
2935
|
-
{ label: formatMessage(messages.iosOnly), value: IOS },
|
|
2936
|
-
], [formatMessage]);
|
|
2937
|
-
|
|
2938
2769
|
const getContentType = useCallback(
|
|
2939
2770
|
(content) => {
|
|
2940
2771
|
// Get image source from multiple possible locations
|
|
@@ -3062,10 +2893,6 @@ export const MobilePushNew = ({
|
|
|
3062
2893
|
'message-title': androidPreview?.header || androidContent?.title || '',
|
|
3063
2894
|
'message-editor': androidPreview?.bodyText || androidContent?.message || '',
|
|
3064
2895
|
image: androidPreview?.bodyImage || androidContent?.expandableDetails?.image || '',
|
|
3065
|
-
// Video only for now. This tab's own videoSrc: the preview falls back to the visible tab's video
|
|
3066
|
-
video: androidContent?.mediaType === VIDEO ? (androidContent?.videoSrc || '') : '',
|
|
3067
|
-
// Same cards Save sends
|
|
3068
|
-
carouselData: androidContent?.mediaType === CAROUSEL ? buildCarouselCards(androidContent?.carouselData) : [],
|
|
3069
2896
|
// Extract primary CTA
|
|
3070
2897
|
...(androidContent?.cta && {
|
|
3071
2898
|
'cta-deeplink': androidContent.cta.type === DEEP_LINK ? 'Deeplink' : 'External Link',
|
|
@@ -3075,10 +2902,9 @@ export const MobilePushNew = ({
|
|
|
3075
2902
|
}),
|
|
3076
2903
|
};
|
|
3077
2904
|
|
|
3078
|
-
//
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
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) => {
|
|
3082
2908
|
if (index === 0) {
|
|
3083
2909
|
androidFormData['secondary-cta-0-label'] = cta.actionText || '';
|
|
3084
2910
|
androidFormData['cta-deeplink-secondary-cta-0'] = cta.type === DEEP_LINK ? 'Deeplink' : 'External Link';
|
|
@@ -3099,8 +2925,6 @@ export const MobilePushNew = ({
|
|
|
3099
2925
|
'message-title2': iosPreview?.header || iosContent?.title || '',
|
|
3100
2926
|
'message-editor2': iosPreview?.bodyText || iosContent?.message || '',
|
|
3101
2927
|
image: iosPreview?.bodyImage || iosContent?.expandableDetails?.image || '',
|
|
3102
|
-
video: iosContent?.mediaType === VIDEO ? (iosContent?.videoSrc || '') : '',
|
|
3103
|
-
carouselData: iosContent?.mediaType === CAROUSEL ? buildCarouselCards(iosContent?.carouselData) : [],
|
|
3104
2928
|
// Extract primary CTA
|
|
3105
2929
|
...(iosContent?.cta && {
|
|
3106
2930
|
'cta-deeplink2': iosContent.cta.type === DEEP_LINK ? 'Deeplink' : 'External Link',
|
|
@@ -3110,9 +2934,9 @@ export const MobilePushNew = ({
|
|
|
3110
2934
|
}),
|
|
3111
2935
|
};
|
|
3112
2936
|
|
|
3113
|
-
|
|
3114
|
-
if (
|
|
3115
|
-
|
|
2937
|
+
// Extract secondary CTAs from expandableDetails
|
|
2938
|
+
if (iosContent?.expandableDetails?.ctas && iosContent.expandableDetails.ctas.length > 0) {
|
|
2939
|
+
iosContent.expandableDetails.ctas.forEach((cta, index) => {
|
|
3116
2940
|
if (index === 0) {
|
|
3117
2941
|
iosFormData['secondary-cta-1-label'] = cta.actionText || '';
|
|
3118
2942
|
iosFormData['cta-deeplink-secondary-cta-1'] = cta.type === DEEP_LINK ? 'Deeplink' : 'External Link';
|
|
@@ -3125,7 +2949,7 @@ export const MobilePushNew = ({
|
|
|
3125
2949
|
|
|
3126
2950
|
// Return in formData array format [androidData, iosData]
|
|
3127
2951
|
return [androidFormData, iosFormData];
|
|
3128
|
-
}, [androidContent, iosContent, getContentType
|
|
2952
|
+
}, [androidContent, iosContent, getContentType]);
|
|
3129
2953
|
|
|
3130
2954
|
// Handle Test and Preview button click
|
|
3131
2955
|
const handleTestAndPreview = useCallback(() => {
|
|
@@ -3135,8 +2959,7 @@ export const MobilePushNew = ({
|
|
|
3135
2959
|
// Handle close Test and Preview slidebox
|
|
3136
2960
|
const handleCloseTestAndPreview = useCallback(() => {
|
|
3137
2961
|
setShowTestAndPreviewSlidebox(false);
|
|
3138
|
-
|
|
3139
|
-
}, [propsHandleCloseTestAndPreview]);
|
|
2962
|
+
}, []);
|
|
3140
2963
|
|
|
3141
2964
|
// Add useEffect to handle isGetFormData prop changes (e.g. Done clicked in footer)
|
|
3142
2965
|
// In library mode: run liquid validation (extractTags) first; on success liquidMiddleWare calls handleSave
|
|
@@ -3262,46 +3085,24 @@ export const MobilePushNew = ({
|
|
|
3262
3085
|
<CapRow className="mobile-push-container">
|
|
3263
3086
|
<CapColumn className="content-section" span={14}>
|
|
3264
3087
|
{createModeContent()}
|
|
3265
|
-
{
|
|
3266
|
-
<
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
onChange={handlePlatformChange}
|
|
3275
|
-
/>
|
|
3276
|
-
</CapRow>
|
|
3277
|
-
)}
|
|
3278
|
-
{singlePlatform ? (
|
|
3279
|
-
// One platform: its form only, no tabs or "Same content" checkbox
|
|
3280
|
-
<CapRow className="platform-header">
|
|
3281
|
-
{renderContentFields(singlePlatform)}
|
|
3282
|
-
</CapRow>
|
|
3283
|
-
) : (
|
|
3284
|
-
<>
|
|
3285
|
-
{isAndroidSupported && isIosSupported && (
|
|
3286
|
-
<CapCheckbox
|
|
3287
|
-
className="same-content-checkbox"
|
|
3288
|
-
checked={sameContent}
|
|
3289
|
-
onChange={handleSameContentChange}
|
|
3290
|
-
key={`same-content-${sameContent}`}
|
|
3291
|
-
>
|
|
3292
|
-
{formatMessage(messages.sameContentForBothChannels)}
|
|
3293
|
-
</CapCheckbox>
|
|
3294
|
-
)}
|
|
3295
|
-
<CapRow className="platform-header">
|
|
3296
|
-
<StyledCapTab
|
|
3297
|
-
className="platform-tabs"
|
|
3298
|
-
activeKey={activeTab}
|
|
3299
|
-
onChange={setActiveTab}
|
|
3300
|
-
panes={PANES}
|
|
3301
|
-
/>
|
|
3302
|
-
</CapRow>
|
|
3303
|
-
</>
|
|
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>
|
|
3304
3097
|
)}
|
|
3098
|
+
<CapRow className="platform-header">
|
|
3099
|
+
<StyledCapTab
|
|
3100
|
+
className="platform-tabs"
|
|
3101
|
+
activeKey={activeTab}
|
|
3102
|
+
onChange={setActiveTab}
|
|
3103
|
+
panes={PANES}
|
|
3104
|
+
/>
|
|
3105
|
+
</CapRow>
|
|
3305
3106
|
<CapRow>
|
|
3306
3107
|
<CapColumn span={24}>
|
|
3307
3108
|
<ErrorInfoNote
|
|
@@ -3311,6 +3112,39 @@ export const MobilePushNew = ({
|
|
|
3311
3112
|
STANDARD_ERROR_MSG: errorMessage?.STANDARD_ERROR_MSG,
|
|
3312
3113
|
}}
|
|
3313
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
|
+
|
|
3314
3148
|
</CapColumn>
|
|
3315
3149
|
</CapRow>
|
|
3316
3150
|
</CapColumn>
|
|
@@ -3323,87 +3157,8 @@ export const MobilePushNew = ({
|
|
|
3323
3157
|
/>
|
|
3324
3158
|
</CapColumn>
|
|
3325
3159
|
</CapRow>
|
|
3326
|
-
{/* In library mode, only show save button in create mode (edit mode has Done button from FormBuilder). In full mode, keep old logic. */}
|
|
3327
|
-
{/* Kept outside the content row so the sticky footer can stick across the whole scroll area */}
|
|
3328
|
-
{((!isFullMode && computedCreativesMode !== 'edit') || (isFullMode && !isEditMode && computedCreativesMode === 'create')) && (
|
|
3329
|
-
<CapRow className="save-section mpush-save-section">
|
|
3330
|
-
<CapColumn span={24}>
|
|
3331
|
-
<CapButton
|
|
3332
|
-
type="primary"
|
|
3333
|
-
onClick={() => {
|
|
3334
|
-
// Liquid validation (extractTags) only in library mode
|
|
3335
|
-
if (!isFullMode) {
|
|
3336
|
-
liquidMiddleWare();
|
|
3337
|
-
} else {
|
|
3338
|
-
handleSave();
|
|
3339
|
-
}
|
|
3340
|
-
}}
|
|
3341
|
-
className="save-button"
|
|
3342
|
-
disabled={isSaveDisabled}
|
|
3343
|
-
>
|
|
3344
|
-
{formatMessage(messages.saveTemplate)}
|
|
3345
|
-
</CapButton>
|
|
3346
|
-
<CapButton
|
|
3347
|
-
onClick={handleTestAndPreview}
|
|
3348
|
-
className="mobilepush-test-preview-btn"
|
|
3349
|
-
type="secondary"
|
|
3350
|
-
style={{ marginLeft: '8px' }}
|
|
3351
|
-
disabled={isTestAndPreviewDisabled}
|
|
3352
|
-
>
|
|
3353
|
-
<FormattedMessage {...creativesMessages.testAndPreview} />
|
|
3354
|
-
</CapButton>
|
|
3355
|
-
</CapColumn>
|
|
3356
|
-
</CapRow>
|
|
3357
|
-
)}
|
|
3358
|
-
<CapModal
|
|
3359
|
-
open={isReplaceConfirmOpen}
|
|
3360
|
-
centered
|
|
3361
|
-
width={520}
|
|
3362
|
-
title={formatMessage(messages.replacePlatformContent, { platform: formatMessage(activeTab === ANDROID ? messages.ios : messages.android) })}
|
|
3363
|
-
onCancel={() => setIsReplaceConfirmOpen(false)}
|
|
3364
|
-
footer={[
|
|
3365
|
-
<CapButton key="cancel" type="secondary" onClick={() => setIsReplaceConfirmOpen(false)}>
|
|
3366
|
-
{formatMessage(globalMessages.cancel)}
|
|
3367
|
-
</CapButton>,
|
|
3368
|
-
<CapButton
|
|
3369
|
-
key="replace"
|
|
3370
|
-
type="primary"
|
|
3371
|
-
className="mpush-replace-platform-content"
|
|
3372
|
-
onClick={confirmSameContent}
|
|
3373
|
-
>
|
|
3374
|
-
{formatMessage(messages.replace)}
|
|
3375
|
-
</CapButton>,
|
|
3376
|
-
]}
|
|
3377
|
-
>
|
|
3378
|
-
{formatMessage(messages.replacePlatformContentBody, {
|
|
3379
|
-
platform: formatMessage(activeTab === ANDROID ? messages.ios : messages.android),
|
|
3380
|
-
source: formatMessage(activeTab === ANDROID ? messages.android : messages.ios),
|
|
3381
|
-
})}
|
|
3382
|
-
</CapModal>
|
|
3383
|
-
<CapModal
|
|
3384
|
-
open={!!pendingPlatformSelection}
|
|
3385
|
-
centered
|
|
3386
|
-
width={520}
|
|
3387
|
-
title={formatMessage(messages.removePlatformContent, {
|
|
3388
|
-
platform: formatMessage(pendingPlatformSelection === ANDROID ? messages.ios : messages.android),
|
|
3389
|
-
})}
|
|
3390
|
-
onCancel={() => setPendingPlatformSelection(null)}
|
|
3391
|
-
footer={[
|
|
3392
|
-
<CapButton key="cancel" type="secondary" onClick={() => setPendingPlatformSelection(null)}>
|
|
3393
|
-
{formatMessage(globalMessages.cancel)}
|
|
3394
|
-
</CapButton>,
|
|
3395
|
-
<CapButton
|
|
3396
|
-
key="remove"
|
|
3397
|
-
type="primary"
|
|
3398
|
-
className="mpush-remove-platform-content"
|
|
3399
|
-
onClick={confirmPlatformRemoval}
|
|
3400
|
-
>
|
|
3401
|
-
{formatMessage(messages.removeContent)}
|
|
3402
|
-
</CapButton>,
|
|
3403
|
-
]}
|
|
3404
|
-
/>
|
|
3405
3160
|
<TestAndPreviewSlidebox
|
|
3406
|
-
show={
|
|
3161
|
+
show={showTestAndPreviewSlidebox}
|
|
3407
3162
|
onClose={handleCloseTestAndPreview}
|
|
3408
3163
|
formData={getFormDataForPayload()} // Pass formData structure for payload building
|
|
3409
3164
|
content={getTemplateContent()} // Also pass content for preview
|
|
@@ -3439,8 +3194,6 @@ MobilePushNew.propTypes = {
|
|
|
3439
3194
|
globalActions: PropTypes.object,
|
|
3440
3195
|
fetchingLiquidValidation: PropTypes.bool,
|
|
3441
3196
|
handleClose: PropTypes.func,
|
|
3442
|
-
showTestAndPreviewSlidebox: PropTypes.bool,
|
|
3443
|
-
handleCloseTestAndPreview: PropTypes.func,
|
|
3444
3197
|
createTemplateError: PropTypes.any,
|
|
3445
3198
|
isGetFormData: PropTypes.bool,
|
|
3446
3199
|
getTemplateDetailsInProgress: PropTypes.bool,
|
|
@@ -3473,8 +3226,6 @@ MobilePushNew.defaultProps = {
|
|
|
3473
3226
|
globalActions: {},
|
|
3474
3227
|
fetchingLiquidValidation: false,
|
|
3475
3228
|
handleClose: () => {},
|
|
3476
|
-
showTestAndPreviewSlidebox: false,
|
|
3477
|
-
handleCloseTestAndPreview: undefined,
|
|
3478
3229
|
createTemplateError: null,
|
|
3479
3230
|
isGetFormData: false,
|
|
3480
3231
|
getTemplateDetailsInProgress: false,
|