@capillarytech/creatives-library 9.2.2 → 9.2.4-alpha.feature-rcs-multi-account.51
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 +50 -56
- package/utils/tests/createMobilePushPayload.test.js +177 -168
- 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 +59 -14
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +83 -5
- package/v2Components/CommonTestAndPreview/tests/index.test.js +158 -0
- package/v2Components/MobilePushPreviewV2/_mobilePushPreviewV2.scss +7 -0
- package/v2Components/MobilePushPreviewV2/index.js +22 -9
- package/v2Components/MobilePushPreviewV2/tests/index.test.js +55 -0
- package/v2Components/TemplatePreview/_mobilePushPhone.scss +72 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +18 -2
- package/v2Components/TemplatePreview/index.js +20 -18
- package/v2Components/TemplatePreview/tests/index.test.js +69 -0
- package/v2Components/TestAndPreviewSlidebox/index.js +2 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/extractContentForPreview.test.js +45 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/extractContentForPreview.js +12 -2
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.js +16 -3
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.js +7 -2
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/deliverySettingsConfig.test.js +44 -0
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/deliverySettingsConfig.js +21 -8
- package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -6
- package/v2Containers/CreativesContainer/index.js +18 -1
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +43 -0
- package/v2Containers/CreativesContainer/tests/index.test.js +66 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +105 -345
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +127 -105
- 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 +305 -1482
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +165 -59
- 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 +498 -289
- package/v2Containers/MobilePushNew/index.scss +151 -4
- package/v2Containers/MobilePushNew/messages.js +106 -6
- package/v2Containers/MobilePushNew/tests/index.test.js +483 -1
- package/v2Containers/MobilePushNew/tests/utils.test.js +110 -0
- package/v2Containers/MobilePushNew/utils.js +83 -0
- package/v2Containers/Rcs/accountUtils.js +20 -0
- package/v2Containers/Rcs/index.js +18 -1
- package/v2Containers/Rcs/tests/accountUtils.test.js +24 -0
- package/v2Containers/Rcs/tests/index.test.js +23 -0
- package/v2Containers/Templates/ChannelTypeIllustration.js +12 -0
- package/v2Containers/Templates/_templates.scss +10 -2
- package/v2Containers/Templates/index.js +94 -85
- package/v2Containers/Templates/messages.js +4 -0
- package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +14 -2
- package/v2Containers/Templates/tests/index.test.js +182 -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([]);
|
|
@@ -646,58 +691,14 @@ export const MobilePushNew = ({
|
|
|
646
691
|
const [iosDeepLinkError, setIosDeepLinkError] = useState("");
|
|
647
692
|
const [androidDeepLinkKeysError, setAndroidDeepLinkKeysError] = useState("");
|
|
648
693
|
const [iosDeepLinkKeysError, setIosDeepLinkKeysError] = useState("");
|
|
649
|
-
const [carouselLinkErrors, setCarouselLinkErrors] = useState({});
|
|
650
694
|
|
|
651
695
|
// Ref for create timeout fallback
|
|
652
696
|
const createTimeoutRef = useRef(null);
|
|
653
697
|
|
|
654
698
|
// 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]);
|
|
699
|
+
const validateCarouselData = useCallback((carouselData = []) => (
|
|
700
|
+
carouselData?.length > 0 && carouselData.every((card) => !getCarouselCardIssue(card))
|
|
701
|
+
), []);
|
|
701
702
|
|
|
702
703
|
// Function to check if carousel data is valid for both platforms
|
|
703
704
|
const isCarouselDataValid = useCallback(() => {
|
|
@@ -753,6 +754,9 @@ export const MobilePushNew = ({
|
|
|
753
754
|
setPrimaryButtonIos(false);
|
|
754
755
|
setSecondaryButtonIos(false);
|
|
755
756
|
setSameContent(false);
|
|
757
|
+
setPlatformSelection(BOTH_PLATFORMS);
|
|
758
|
+
setPendingPlatformSelection(null);
|
|
759
|
+
setPlatformToClear(null);
|
|
756
760
|
setTemplateNameError(false);
|
|
757
761
|
setAndroidTitleError("");
|
|
758
762
|
setAndroidMessageError("");
|
|
@@ -762,7 +766,6 @@ export const MobilePushNew = ({
|
|
|
762
766
|
setIosExternalLinkError("");
|
|
763
767
|
setAndroidDeepLinkError("");
|
|
764
768
|
setIosDeepLinkError("");
|
|
765
|
-
setCarouselLinkErrors({});
|
|
766
769
|
resetUploadStates();
|
|
767
770
|
}, [resetUploadStates]);
|
|
768
771
|
|
|
@@ -966,6 +969,8 @@ export const MobilePushNew = ({
|
|
|
966
969
|
templateNameRef.current = name;
|
|
967
970
|
});
|
|
968
971
|
|
|
972
|
+
stateUpdates.push(() => setPlatformSelection(getSavedPlatformSelection(editContent)));
|
|
973
|
+
|
|
969
974
|
// Process Android content
|
|
970
975
|
const androidContentType = editContent?.ANDROID;
|
|
971
976
|
if (!isEmpty(androidContentType)) {
|
|
@@ -1101,6 +1106,8 @@ export const MobilePushNew = ({
|
|
|
1101
1106
|
templateNameRef.current = name;
|
|
1102
1107
|
});
|
|
1103
1108
|
|
|
1109
|
+
stateUpdates.push(() => setPlatformSelection(getSavedPlatformSelection(templateContent)));
|
|
1110
|
+
|
|
1104
1111
|
// Process Android content
|
|
1105
1112
|
const androidContentType = templateContent?.ANDROID;
|
|
1106
1113
|
if (!isEmpty(androidContentType)) {
|
|
@@ -1736,10 +1743,6 @@ export const MobilePushNew = ({
|
|
|
1736
1743
|
setSpin(false);
|
|
1737
1744
|
}, [templateData, isFullMode, deepLink, setUpdateMpushImageSrc, setUpdateMpushVideoSrc]);
|
|
1738
1745
|
|
|
1739
|
-
// Determine platform support from accountData
|
|
1740
|
-
const isAndroidSupported = accountData?.configs?.android === '1';
|
|
1741
|
-
const isIosSupported = accountData?.configs?.ios === '1';
|
|
1742
|
-
|
|
1743
1746
|
// Notify parent when personalization tokens are added/removed (for anonymous user flow)
|
|
1744
1747
|
useEffect(() => {
|
|
1745
1748
|
if (!restrictPersonalization || typeof onPersonalizationTokensChange !== 'function') return;
|
|
@@ -1748,8 +1751,8 @@ export const MobilePushNew = ({
|
|
|
1748
1751
|
|| (value.includes('[') && value.includes(']'))
|
|
1749
1752
|
);
|
|
1750
1753
|
const hasTokens = (
|
|
1751
|
-
(
|
|
1752
|
-
|| (
|
|
1754
|
+
(showAndroid && (hasToken(androidContent?.title) || hasToken(androidContent?.message)))
|
|
1755
|
+
|| (showIos && (hasToken(iosContent?.title) || hasToken(iosContent?.message)))
|
|
1753
1756
|
);
|
|
1754
1757
|
onPersonalizationTokensChange(hasTokens);
|
|
1755
1758
|
}, [
|
|
@@ -1758,18 +1761,21 @@ export const MobilePushNew = ({
|
|
|
1758
1761
|
androidContent?.message,
|
|
1759
1762
|
iosContent?.title,
|
|
1760
1763
|
iosContent?.message,
|
|
1761
|
-
|
|
1762
|
-
|
|
1764
|
+
showAndroid,
|
|
1765
|
+
showIos,
|
|
1763
1766
|
onPersonalizationTokensChange,
|
|
1764
1767
|
]);
|
|
1765
1768
|
|
|
1766
|
-
// Validation logic for template creation/update.
|
|
1767
|
-
const isAndroidFieldsMissing = isPlatformFieldsMissing(
|
|
1768
|
-
const isIosFieldsMissing = isPlatformFieldsMissing(
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1769
|
+
// Validation logic for template creation/update; a platform left out by the dropdown is never missing.
|
|
1770
|
+
const isAndroidFieldsMissing = isPlatformFieldsMissing(showAndroid, androidContent);
|
|
1771
|
+
const isIosFieldsMissing = isPlatformFieldsMissing(showIos, iosContent);
|
|
1772
|
+
// Every shown platform needs a title and message before Save
|
|
1773
|
+
const isMobilePushContentMissing = isAndroidFieldsMissing || isIosFieldsMissing;
|
|
1774
|
+
// Test & Preview only needs one platform filled
|
|
1775
|
+
const isAllContentMissing = (
|
|
1776
|
+
(showAndroid || showIos)
|
|
1777
|
+
&& (!showAndroid || isAndroidFieldsMissing)
|
|
1778
|
+
&& (!showIos || isIosFieldsMissing)
|
|
1773
1779
|
);
|
|
1774
1780
|
|
|
1775
1781
|
// Ref to dedupe reporting of content emptiness to the parent, so we only
|
|
@@ -1793,8 +1799,7 @@ export const MobilePushNew = ({
|
|
|
1793
1799
|
handleMessageChange,
|
|
1794
1800
|
handleTagSelect,
|
|
1795
1801
|
handleMediaTypeChange,
|
|
1796
|
-
|
|
1797
|
-
handleLinkTypeChange,
|
|
1802
|
+
handleTapActionChange,
|
|
1798
1803
|
} = usePlatformSync({
|
|
1799
1804
|
setAndroidContent,
|
|
1800
1805
|
setIosContent,
|
|
@@ -1866,9 +1871,21 @@ export const MobilePushNew = ({
|
|
|
1866
1871
|
}
|
|
1867
1872
|
}, [sameContent]);
|
|
1868
1873
|
|
|
1874
|
+
// Notification tap link Save / edit (both tabs when synced)
|
|
1875
|
+
const handleTapLinkSavedChange = useCallback((platform, tapLinkSaved) => {
|
|
1876
|
+
const update = (prev) => ({ ...prev, tapLinkSaved });
|
|
1877
|
+
if (platform === ANDROID || sameContent) setAndroidContent(update);
|
|
1878
|
+
if (platform === IOS || sameContent) setIosContent(update);
|
|
1879
|
+
}, [sameContent]);
|
|
1880
|
+
|
|
1881
|
+
// Notification tap URL: required once External link is chosen; same message as the button form
|
|
1882
|
+
const getTapUrlError = useCallback((url) => (
|
|
1883
|
+
!url?.trim() || validateExternalLink(url, formatMessage, messages) ? formatMessage(messages.urlNotValid) : ""
|
|
1884
|
+
), [formatMessage]);
|
|
1885
|
+
|
|
1869
1886
|
const handleExternalLinkChange = useCallback((platform, externalLinkValue) => {
|
|
1870
1887
|
// Validate URL
|
|
1871
|
-
const urlError =
|
|
1888
|
+
const urlError = getTapUrlError(externalLinkValue);
|
|
1872
1889
|
|
|
1873
1890
|
const updateContent = {
|
|
1874
1891
|
externalLinkValue,
|
|
@@ -1895,16 +1912,9 @@ export const MobilePushNew = ({
|
|
|
1895
1912
|
setAndroidExternalLinkError(urlError || "");
|
|
1896
1913
|
}
|
|
1897
1914
|
}
|
|
1898
|
-
}, [
|
|
1915
|
+
}, [getTapUrlError, sameContent]);
|
|
1899
1916
|
|
|
1900
1917
|
// Carousel data handler for platform-specific carousel management
|
|
1901
|
-
const updateCarouselLinkError = useCallback((cardIndex, field, error) => {
|
|
1902
|
-
setCarouselLinkErrors((prev) => ({
|
|
1903
|
-
...prev,
|
|
1904
|
-
[`${cardIndex}-${field}`]: error,
|
|
1905
|
-
}));
|
|
1906
|
-
}, []);
|
|
1907
|
-
|
|
1908
1918
|
const handleCarouselDataChange = useCallback((platform, carouselData) => {
|
|
1909
1919
|
if (platform === ANDROID) {
|
|
1910
1920
|
setAndroidContent((prev) => {
|
|
@@ -2042,11 +2052,20 @@ export const MobilePushNew = ({
|
|
|
2042
2052
|
handleTitleChange,
|
|
2043
2053
|
handleMessageChange,
|
|
2044
2054
|
handleMediaTypeChange,
|
|
2045
|
-
|
|
2046
|
-
|
|
2055
|
+
handleTapActionChange: (value) => {
|
|
2056
|
+
handleTapActionChange(platform, value);
|
|
2057
|
+
// The old link field is gone, so are its errors (on both tabs when synced)
|
|
2058
|
+
[platform, ...(sameContent ? [getOtherPlatform(platform)] : [])].forEach((target) => {
|
|
2059
|
+
const isAndroidTarget = target === ANDROID;
|
|
2060
|
+
(isAndroidTarget ? setAndroidExternalLinkError : setIosExternalLinkError)("");
|
|
2061
|
+
(isAndroidTarget ? setAndroidDeepLinkError : setIosDeepLinkError)("");
|
|
2062
|
+
(isAndroidTarget ? setAndroidDeepLinkKeysError : setIosDeepLinkKeysError)("");
|
|
2063
|
+
});
|
|
2064
|
+
},
|
|
2047
2065
|
handleDeepLinkChange: (value) => handleDeepLinkChange(platform, value),
|
|
2048
2066
|
handleDeepLinkKeysChange: (value) => handleDeepLinkKeysChange(platform, value),
|
|
2049
2067
|
handleExternalLinkChange: (value) => handleExternalLinkChange(platform, value),
|
|
2068
|
+
handleTapLinkSavedChange: (isSaved) => handleTapLinkSavedChange(platform, isSaved),
|
|
2050
2069
|
onTagSelect,
|
|
2051
2070
|
handleOnTagsContextChange,
|
|
2052
2071
|
};
|
|
@@ -2111,9 +2130,6 @@ export const MobilePushNew = ({
|
|
|
2111
2130
|
mobilePushActions,
|
|
2112
2131
|
carouselActiveTabIndex,
|
|
2113
2132
|
setCarouselActiveTabIndex,
|
|
2114
|
-
carouselLinkErrors,
|
|
2115
|
-
updateCarouselLinkError,
|
|
2116
|
-
linkProps: { deepLink },
|
|
2117
2133
|
videoPreviewKey: videoState?.videoPreviewKey,
|
|
2118
2134
|
};
|
|
2119
2135
|
|
|
@@ -2166,7 +2182,7 @@ export const MobilePushNew = ({
|
|
|
2166
2182
|
restrictPersonalization={restrictPersonalization}
|
|
2167
2183
|
/>
|
|
2168
2184
|
);
|
|
2169
|
-
}, [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,
|
|
2185
|
+
}, [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, handleTitleChange, handleMessageChange, handleMediaTypeChange, handleTapActionChange, handleDeepLinkChange, handleDeepLinkKeysChange, handleExternalLinkChange, handleTapLinkSavedChange, onTagSelect, handleOnTagsContextChange, setUpdateMpushImageSrc, updateOnMpushImageReUpload, setUpdateMpushVideoSrc, updateOnMpushVideoReUpload, clearImageDataByMediaType, handleCarouselDataChange, sameContent, updateHandler, deleteHandler]
|
|
2170
2186
|
);
|
|
2171
2187
|
|
|
2172
2188
|
// PANES: Only render enabled platforms
|
|
@@ -2176,8 +2192,8 @@ export const MobilePushNew = ({
|
|
|
2176
2192
|
panes.push({
|
|
2177
2193
|
key: ANDROID,
|
|
2178
2194
|
tab: (
|
|
2179
|
-
<CapRow
|
|
2180
|
-
<CapIcon type="android" />
|
|
2195
|
+
<CapRow type="flex" align="middle" noWrap className="tab-label">
|
|
2196
|
+
<CapIcon type="android" size="s" />
|
|
2181
2197
|
{formatMessage(messages.android)}
|
|
2182
2198
|
</CapRow>
|
|
2183
2199
|
),
|
|
@@ -2188,8 +2204,8 @@ export const MobilePushNew = ({
|
|
|
2188
2204
|
panes.push({
|
|
2189
2205
|
key: IOS,
|
|
2190
2206
|
tab: (
|
|
2191
|
-
<CapRow
|
|
2192
|
-
<CapIcon type="ios" />
|
|
2207
|
+
<CapRow type="flex" align="middle" noWrap className="tab-label">
|
|
2208
|
+
<CapIcon type="ios" size="s" />
|
|
2193
2209
|
{formatMessage(messages.ios)}
|
|
2194
2210
|
</CapRow>
|
|
2195
2211
|
),
|
|
@@ -2202,25 +2218,37 @@ export const MobilePushNew = ({
|
|
|
2202
2218
|
const errorInTitle = activeTab === ANDROID ? androidTitleError : iosTitleError;
|
|
2203
2219
|
const errorInMessage = activeTab === ANDROID ? androidMessageError : iosMessageError;
|
|
2204
2220
|
|
|
2205
|
-
// Save
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2221
|
+
// Notification tap link opened but its Save not clicked yet (every media type, carousel included)
|
|
2222
|
+
const hasUnsavedTapLink = [showAndroid && androidContent, showIos && iosContent].some(
|
|
2223
|
+
(content) => content && content.actionOnClick && content.tapLinkSaved === false,
|
|
2224
|
+
);
|
|
2225
|
+
|
|
2226
|
+
const hasFormErrors = (
|
|
2227
|
+
templateNameError
|
|
2211
2228
|
|| !isCarouselDataValid()
|
|
2229
|
+
|| hasUnsavedTapLink
|
|
2212
2230
|
|| errorInTitle || errorInMessage
|
|
2213
2231
|
);
|
|
2232
|
+
// Save needs every shown platform filled
|
|
2233
|
+
const isSaveDisabled = isMobilePushContentMissing || hasFormErrors;
|
|
2234
|
+
const isTestAndPreviewDisabled = isAllContentMissing || hasFormErrors;
|
|
2214
2235
|
|
|
2215
|
-
// Validation in handleSave:
|
|
2216
|
-
// allow saving with just one supported platform filled in.
|
|
2236
|
+
// Validation in handleSave: every shown platform needs a title and message (no save-without dialog)
|
|
2217
2237
|
const handleSave = useCallback(() => {
|
|
2218
2238
|
if (isMobilePushContentMissing) {
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2239
|
+
const missingPlatforms = [
|
|
2240
|
+
[ANDROID, isAndroidFieldsMissing, androidContent],
|
|
2241
|
+
[IOS, isIosFieldsMissing, iosContent],
|
|
2242
|
+
].filter(([, isMissing]) => isMissing);
|
|
2243
|
+
missingPlatforms.forEach(([platform, , content]) => {
|
|
2244
|
+
const isAndroid = platform === ANDROID;
|
|
2245
|
+
(isAndroid ? setAndroidTitleError : setIosTitleError)(validateTitle(content?.title));
|
|
2246
|
+
(isAndroid ? setAndroidMessageError : setIosMessageError)(validateMessage(content?.message));
|
|
2223
2247
|
});
|
|
2248
|
+
// Open a tab that has the errors, unless the open one already does
|
|
2249
|
+
if (!missingPlatforms.some(([platform]) => platform === activeTab)) {
|
|
2250
|
+
setActiveTab(missingPlatforms[0][0]);
|
|
2251
|
+
}
|
|
2224
2252
|
if (onValidationFail) onValidationFail();
|
|
2225
2253
|
return;
|
|
2226
2254
|
}
|
|
@@ -2244,32 +2272,38 @@ export const MobilePushNew = ({
|
|
|
2244
2272
|
// Use ref to get the latest template name value to avoid closure issues
|
|
2245
2273
|
let finalTemplateName = templateNameRef.current || templateName;
|
|
2246
2274
|
if (!isFullMode && (!finalTemplateName || !finalTemplateName.trim())) {
|
|
2247
|
-
if (androidContent?.title && androidContent.title.trim()) {
|
|
2275
|
+
if (showAndroid && androidContent?.title && androidContent.title.trim()) {
|
|
2248
2276
|
finalTemplateName = androidContent.title.trim();
|
|
2249
|
-
} else if (iosContent?.title && iosContent.title.trim()) {
|
|
2277
|
+
} else if (showIos && iosContent?.title && iosContent.title.trim()) {
|
|
2250
2278
|
finalTemplateName = iosContent.title.trim();
|
|
2251
2279
|
} else {
|
|
2252
2280
|
finalTemplateName = '';
|
|
2253
2281
|
}
|
|
2254
2282
|
}
|
|
2255
2283
|
|
|
2256
|
-
// Validate
|
|
2257
|
-
const
|
|
2258
|
-
const
|
|
2284
|
+
// Validate the notification tap URL (only platforms that are saved, only when External link is chosen)
|
|
2285
|
+
const isTapExternalLink = (content) => content?.actionOnClick && content?.linkType === EXTERNAL_LINK;
|
|
2286
|
+
const androidUrlError = showAndroid && isTapExternalLink(androidContent) && getTapUrlError(androidContent.externalLinkValue);
|
|
2287
|
+
const iosUrlError = showIos && isTapExternalLink(iosContent) && getTapUrlError(iosContent.externalLinkValue);
|
|
2259
2288
|
|
|
2260
2289
|
setAndroidExternalLinkError(androidUrlError || "");
|
|
2261
2290
|
setIosExternalLinkError(iosUrlError || "");
|
|
2262
2291
|
|
|
2263
|
-
// Validate deep links
|
|
2264
|
-
const
|
|
2265
|
-
|
|
2292
|
+
// Validate deep links; Deep link chosen as the tap action needs one picked
|
|
2293
|
+
const getTapDeepLinkError = (content) => (
|
|
2294
|
+
content?.actionOnClick && content?.linkType === DEEP_LINK && !content?.deepLinkValue
|
|
2295
|
+
? formatMessage(messages.deepLinkRequired)
|
|
2296
|
+
: validateDeepLink(content?.deepLinkValue, formatMessage, messages)
|
|
2297
|
+
);
|
|
2298
|
+
const androidDeepLinkUrlError = showAndroid && getTapDeepLinkError(androidContent);
|
|
2299
|
+
const iosDeepLinkUrlError = showIos && getTapDeepLinkError(iosContent);
|
|
2266
2300
|
|
|
2267
2301
|
setAndroidDeepLinkError(androidDeepLinkUrlError || "");
|
|
2268
2302
|
setIosDeepLinkError(iosDeepLinkUrlError || "");
|
|
2269
2303
|
|
|
2270
2304
|
// Validate deep link keys - only require keys if the selected deep link has keys defined
|
|
2271
2305
|
const androidDeepLinkKeysErrorMsg = (() => {
|
|
2272
|
-
if (androidContent?.linkType === DEEP_LINK && androidContent?.deepLinkValue) {
|
|
2306
|
+
if (showAndroid && androidContent?.linkType === DEEP_LINK && androidContent?.deepLinkValue) {
|
|
2273
2307
|
// Use the same matching logic as deep link value extraction
|
|
2274
2308
|
let selectedDeepLink = null;
|
|
2275
2309
|
|
|
@@ -2284,8 +2318,8 @@ export const MobilePushNew = ({
|
|
|
2284
2318
|
|
|
2285
2319
|
const hasKeysDefined = selectedDeepLink?.keys?.length > 0;
|
|
2286
2320
|
|
|
2287
|
-
//
|
|
2288
|
-
if (hasKeysDefined &&
|
|
2321
|
+
// Every configured key of the selected deep link needs a value
|
|
2322
|
+
if (hasKeysDefined && !hasAllDeepLinkParams(androidContent?.deepLinkKeysValue, selectedDeepLink?.keys)) {
|
|
2289
2323
|
return formatMessage(messages.deepLinkKeysRequired);
|
|
2290
2324
|
}
|
|
2291
2325
|
}
|
|
@@ -2293,7 +2327,7 @@ export const MobilePushNew = ({
|
|
|
2293
2327
|
})();
|
|
2294
2328
|
|
|
2295
2329
|
const iosDeepLinkKeysErrorMsg = (() => {
|
|
2296
|
-
if (iosContent?.linkType === DEEP_LINK && iosContent?.deepLinkValue) {
|
|
2330
|
+
if (showIos && iosContent?.linkType === DEEP_LINK && iosContent?.deepLinkValue) {
|
|
2297
2331
|
// Use the same matching logic as deep link value extraction
|
|
2298
2332
|
let selectedDeepLink = null;
|
|
2299
2333
|
|
|
@@ -2308,8 +2342,8 @@ export const MobilePushNew = ({
|
|
|
2308
2342
|
|
|
2309
2343
|
const hasKeysDefined = selectedDeepLink?.keys?.length > 0;
|
|
2310
2344
|
|
|
2311
|
-
//
|
|
2312
|
-
if (hasKeysDefined &&
|
|
2345
|
+
// Every configured key of the selected deep link needs a value
|
|
2346
|
+
if (hasKeysDefined && !hasAllDeepLinkParams(iosContent?.deepLinkKeysValue, selectedDeepLink?.keys)) {
|
|
2313
2347
|
return formatMessage(messages.deepLinkKeysRequired);
|
|
2314
2348
|
}
|
|
2315
2349
|
}
|
|
@@ -2319,10 +2353,16 @@ export const MobilePushNew = ({
|
|
|
2319
2353
|
setAndroidDeepLinkKeysError(androidDeepLinkKeysErrorMsg || "");
|
|
2320
2354
|
setIosDeepLinkKeysError(iosDeepLinkKeysErrorMsg || "");
|
|
2321
2355
|
|
|
2322
|
-
//
|
|
2323
|
-
|
|
2356
|
+
// The host can trigger save without the (disabled) Save button
|
|
2357
|
+
if (hasUnsavedTapLink) {
|
|
2358
|
+
CapNotification.error({ message: formatMessage(messages.saveTapLinkFirst) });
|
|
2359
|
+
if (onValidationFail) {
|
|
2360
|
+
onValidationFail();
|
|
2361
|
+
}
|
|
2362
|
+
return;
|
|
2363
|
+
}
|
|
2324
2364
|
|
|
2325
|
-
if (androidUrlError || iosUrlError || androidDeepLinkUrlError || iosDeepLinkUrlError || androidDeepLinkKeysErrorMsg || iosDeepLinkKeysErrorMsg
|
|
2365
|
+
if (androidUrlError || iosUrlError || androidDeepLinkUrlError || iosDeepLinkUrlError || androidDeepLinkKeysErrorMsg || iosDeepLinkKeysErrorMsg) {
|
|
2326
2366
|
CapNotification.error({
|
|
2327
2367
|
message: formatMessage(messages.invalidUrl),
|
|
2328
2368
|
});
|
|
@@ -2338,74 +2378,34 @@ export const MobilePushNew = ({
|
|
|
2338
2378
|
const processedIosContent = { ...iosContent };
|
|
2339
2379
|
|
|
2340
2380
|
// Process button CTA data if it exists
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
processedAndroidContent.expandableDetails
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
let actionLink = cta?.url;
|
|
2348
|
-
|
|
2349
|
-
// Append deep link keys to URL if they exist
|
|
2350
|
-
if (cta?.urlType === DEEP_LINK && cta?.deepLinkKeys?.length > 0) {
|
|
2351
|
-
const deepLinkKeysArray = Array.isArray(cta?.deepLinkKeys) ? cta?.deepLinkKeys : [cta?.deepLinkKeys];
|
|
2352
|
-
const validKeys = deepLinkKeysArray.filter((key) => typeof key === 'string' && key?.length > 0);
|
|
2353
|
-
if (validKeys?.length > 0) {
|
|
2354
|
-
const separator = actionLink.includes('?') ? '&' : '?';
|
|
2355
|
-
const keyParams = validKeys.map((key) => `${key}=${key}`).join('&');
|
|
2356
|
-
actionLink = `${actionLink}${separator}${keyParams}`;
|
|
2357
|
-
}
|
|
2358
|
-
}
|
|
2359
|
-
|
|
2360
|
-
return {
|
|
2361
|
-
actionText: cta?.text,
|
|
2362
|
-
type: cta?.urlType || DEEP_LINK,
|
|
2363
|
-
actionLink,
|
|
2364
|
-
};
|
|
2365
|
-
}),
|
|
2366
|
-
};
|
|
2367
|
-
}
|
|
2381
|
+
const savedAndroidCtas = toSavedCtas(ctaDataAndroid);
|
|
2382
|
+
if (savedAndroidCtas.length > 0) {
|
|
2383
|
+
processedAndroidContent.expandableDetails = {
|
|
2384
|
+
...processedAndroidContent.expandableDetails,
|
|
2385
|
+
ctas: savedAndroidCtas,
|
|
2386
|
+
};
|
|
2368
2387
|
}
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
processedIosContent.expandableDetails
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
let actionLink = cta?.url;
|
|
2376
|
-
|
|
2377
|
-
// Append deep link keys to URL if they exist
|
|
2378
|
-
if (cta?.urlType === DEEP_LINK && cta?.deepLinkKeys?.length > 0) {
|
|
2379
|
-
const deepLinkKeysArray = Array.isArray(cta?.deepLinkKeys) ? cta?.deepLinkKeys : [cta?.deepLinkKeys];
|
|
2380
|
-
const validKeys = deepLinkKeysArray.filter((key) => typeof key === 'string' && key?.length > 0);
|
|
2381
|
-
if (validKeys?.length > 0) {
|
|
2382
|
-
const separator = actionLink.includes('?') ? '&' : '?';
|
|
2383
|
-
const keyParams = validKeys.map((key) => `${key}=${key}`).join('&');
|
|
2384
|
-
actionLink = `${actionLink}${separator}${keyParams}`;
|
|
2385
|
-
}
|
|
2386
|
-
}
|
|
2387
|
-
|
|
2388
|
-
return {
|
|
2389
|
-
actionText: cta?.text,
|
|
2390
|
-
type: cta?.urlType || DEEP_LINK,
|
|
2391
|
-
actionLink,
|
|
2392
|
-
};
|
|
2393
|
-
}),
|
|
2394
|
-
};
|
|
2395
|
-
}
|
|
2388
|
+
const savedIosCtas = toSavedCtas(ctaDataIos);
|
|
2389
|
+
if (savedIosCtas.length > 0) {
|
|
2390
|
+
processedIosContent.expandableDetails = {
|
|
2391
|
+
...processedIosContent.expandableDetails,
|
|
2392
|
+
ctas: savedIosCtas,
|
|
2393
|
+
};
|
|
2396
2394
|
}
|
|
2397
2395
|
|
|
2398
2396
|
// Create payload with enabled platform content and intl
|
|
2399
2397
|
const payload = createMobilePushPayloadWithIntl({
|
|
2400
2398
|
templateName: finalTemplateName,
|
|
2401
|
-
androidContent:
|
|
2402
|
-
iosContent:
|
|
2399
|
+
androidContent: showAndroid ? processedAndroidContent : undefined,
|
|
2400
|
+
iosContent: showIos ? processedIosContent : undefined,
|
|
2403
2401
|
imageSrc,
|
|
2404
2402
|
mpushVideoSrcAndPreview,
|
|
2405
2403
|
accountData,
|
|
2406
2404
|
sameContent,
|
|
2407
2405
|
options: {
|
|
2408
2406
|
mode: params?.mode,
|
|
2407
|
+
// One platform chosen: leave the other platform's key out of versions.base
|
|
2408
|
+
skipPlatform: singlePlatform ? getOtherPlatform(singlePlatform) : undefined,
|
|
2409
2409
|
},
|
|
2410
2410
|
intl,
|
|
2411
2411
|
});
|
|
@@ -2596,7 +2596,7 @@ export const MobilePushNew = ({
|
|
|
2596
2596
|
globalActionsProps,
|
|
2597
2597
|
onValidationFail,
|
|
2598
2598
|
resetFormData,
|
|
2599
|
-
|
|
2599
|
+
getTapUrlError,
|
|
2600
2600
|
ctaDataAndroid,
|
|
2601
2601
|
ctaDataIos,
|
|
2602
2602
|
intl,
|
|
@@ -2604,8 +2604,17 @@ export const MobilePushNew = ({
|
|
|
2604
2604
|
createTimeoutRef,
|
|
2605
2605
|
isAndroidSupported,
|
|
2606
2606
|
isIosSupported,
|
|
2607
|
+
showAndroid,
|
|
2608
|
+
showIos,
|
|
2609
|
+
singlePlatform,
|
|
2610
|
+
activeTab,
|
|
2611
|
+
validateTitle,
|
|
2612
|
+
validateMessage,
|
|
2607
2613
|
isMobilePushContentMissing,
|
|
2614
|
+
isAndroidFieldsMissing,
|
|
2615
|
+
isIosFieldsMissing,
|
|
2608
2616
|
isCarouselDataValid,
|
|
2617
|
+
hasUnsavedTapLink,
|
|
2609
2618
|
isFullMode,
|
|
2610
2619
|
templateId,
|
|
2611
2620
|
savedTemplateId,
|
|
@@ -2700,38 +2709,30 @@ export const MobilePushNew = ({
|
|
|
2700
2709
|
getLiquidTags: globalActionsProps.getLiquidTags,
|
|
2701
2710
|
formatMessage,
|
|
2702
2711
|
messages: formBuilderMessages,
|
|
2703
|
-
|
|
2712
|
+
// One platform chosen: validate only that platform
|
|
2713
|
+
singleTab: singlePlatform || getSingleTab(accountData),
|
|
2704
2714
|
});
|
|
2705
2715
|
}, [
|
|
2706
2716
|
androidContent,
|
|
2707
2717
|
iosContent,
|
|
2708
2718
|
activeTab,
|
|
2719
|
+
singlePlatform,
|
|
2709
2720
|
globalActionsProps,
|
|
2710
2721
|
formatMessage,
|
|
2711
2722
|
accountData,
|
|
2712
2723
|
isFullMode,
|
|
2713
2724
|
]);
|
|
2714
2725
|
|
|
2726
|
+
// Each platform's preview buttons follow its own ctaData, so iOS shows before its tab is opened
|
|
2727
|
+
const toPreviewButtons = (ctas) => (Array.isArray(ctas) ? ctas.map((data) => ({ label: data?.text || '' })) : []);
|
|
2728
|
+
|
|
2715
2729
|
useEffect(() => {
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
if (activeTab === ANDROID) {
|
|
2724
|
-
setAndroidContent((prevContent) => ({
|
|
2725
|
-
...prevContent,
|
|
2726
|
-
buttons: newButtons,
|
|
2727
|
-
}));
|
|
2728
|
-
} else if (activeTab === IOS) {
|
|
2729
|
-
setIosContent((prevContent) => ({
|
|
2730
|
-
...prevContent,
|
|
2731
|
-
buttons: newButtons,
|
|
2732
|
-
}));
|
|
2733
|
-
}
|
|
2734
|
-
}, [ctaData, activeTab]);
|
|
2730
|
+
setAndroidContent((prevContent) => ({ ...prevContent, buttons: toPreviewButtons(ctaDataAndroid) }));
|
|
2731
|
+
}, [ctaDataAndroid]);
|
|
2732
|
+
|
|
2733
|
+
useEffect(() => {
|
|
2734
|
+
setIosContent((prevContent) => ({ ...prevContent, buttons: toPreviewButtons(ctaDataIos) }));
|
|
2735
|
+
}, [ctaDataIos]);
|
|
2735
2736
|
|
|
2736
2737
|
// Sync button data and state from active tab to other platform when sameContent is enabled
|
|
2737
2738
|
useEffect(() => {
|
|
@@ -2757,12 +2758,141 @@ export const MobilePushNew = ({
|
|
|
2757
2758
|
}
|
|
2758
2759
|
}, [sameContent, activeTab]);
|
|
2759
2760
|
|
|
2761
|
+
// What ticking "Same content" would copy over: text, media, links and buttons
|
|
2762
|
+
const getPlatformSnapshot = (platform) => {
|
|
2763
|
+
const isAndroid = platform === ANDROID;
|
|
2764
|
+
const content = isAndroid ? androidContent : iosContent;
|
|
2765
|
+
return JSON.stringify({
|
|
2766
|
+
title: content?.title || '',
|
|
2767
|
+
message: content?.message || '',
|
|
2768
|
+
mediaType: content?.mediaType || NONE,
|
|
2769
|
+
carouselData: content?.carouselData || [],
|
|
2770
|
+
actionOnClick: !!content?.actionOnClick,
|
|
2771
|
+
linkType: content?.linkType || '',
|
|
2772
|
+
deepLinkValue: content?.deepLinkValue || '',
|
|
2773
|
+
externalLinkValue: content?.externalLinkValue || '',
|
|
2774
|
+
image: (isAndroid ? imageSrc?.androidImageSrc : imageSrc?.iosImageSrc) || '',
|
|
2775
|
+
video: (isAndroid ? videoState?.androidVideoSrc : videoState?.iosVideoSrc) || '',
|
|
2776
|
+
buttons: toSavedCtas(isAndroid ? ctaDataAndroid : ctaDataIos),
|
|
2777
|
+
});
|
|
2778
|
+
};
|
|
2779
|
+
|
|
2760
2780
|
const handleSameContentChange = useCallback((e) => {
|
|
2761
2781
|
const isCurrentPlatformAndroid = activeTab === ANDROID;
|
|
2782
|
+
const otherContent = isCurrentPlatformAndroid ? iosContent : androidContent;
|
|
2783
|
+
// Ticking replaces the other tab: confirm when it has different content, not when it is empty
|
|
2784
|
+
if (e.target.checked && hasPlatformContent(otherContent) && getPlatformSnapshot(ANDROID) !== getPlatformSnapshot(IOS)) {
|
|
2785
|
+
setIsReplaceConfirmOpen(true);
|
|
2786
|
+
return;
|
|
2787
|
+
}
|
|
2762
2788
|
syncPlatformContent(isCurrentPlatformAndroid ? androidContent : iosContent, isCurrentPlatformAndroid ? ANDROID : IOS);
|
|
2763
2789
|
setSameContent(e.target.checked);
|
|
2790
|
+
}, [activeTab, androidContent, iosContent, imageSrc, videoState, ctaDataAndroid, ctaDataIos]);
|
|
2791
|
+
|
|
2792
|
+
const confirmSameContent = useCallback(() => {
|
|
2793
|
+
setIsReplaceConfirmOpen(false);
|
|
2794
|
+
syncPlatformContent(activeTab === ANDROID ? androidContent : iosContent, activeTab);
|
|
2795
|
+
setSameContent(true);
|
|
2764
2796
|
}, [activeTab, androidContent, iosContent]);
|
|
2765
2797
|
|
|
2798
|
+
// One platform chosen: its form is the only one shown, and the upload/button handlers follow activeTab
|
|
2799
|
+
useEffect(() => {
|
|
2800
|
+
if (singlePlatform && activeTab !== singlePlatform) {
|
|
2801
|
+
setActiveTab(singlePlatform);
|
|
2802
|
+
}
|
|
2803
|
+
}, [singlePlatform, activeTab]);
|
|
2804
|
+
|
|
2805
|
+
// Both -> single: empty the dropped platform. Runs after the switch so sync is off
|
|
2806
|
+
// and the kept platform's media stays.
|
|
2807
|
+
useEffect(() => {
|
|
2808
|
+
if (!platformToClear) return;
|
|
2809
|
+
const isAndroid = platformToClear === ANDROID;
|
|
2810
|
+
const platformIndex = isAndroid ? 0 : 1;
|
|
2811
|
+
clearImageDataByMediaType(IMAGE, platformToClear);
|
|
2812
|
+
clearImageDataByMediaType(VIDEO, platformToClear);
|
|
2813
|
+
// Uploaded-video list read by the upload box
|
|
2814
|
+
setUpdateMpushVideoSrc(platformIndex, {}, true);
|
|
2815
|
+
(isAndroid ? setAndroidContent : setIosContent)(INITIAL_CONTENT);
|
|
2816
|
+
(isAndroid ? setCtaDataAndroid : setCtaDataIos)([]);
|
|
2817
|
+
(isAndroid ? setPrimaryButtonAndroid : setPrimaryButtonIos)(false);
|
|
2818
|
+
(isAndroid ? setSecondaryButtonAndroid : setSecondaryButtonIos)(false);
|
|
2819
|
+
(isAndroid ? setAndroidTitleError : setIosTitleError)("");
|
|
2820
|
+
(isAndroid ? setAndroidMessageError : setIosMessageError)("");
|
|
2821
|
+
(isAndroid ? setAndroidExternalLinkError : setIosExternalLinkError)("");
|
|
2822
|
+
(isAndroid ? setAndroidDeepLinkError : setIosDeepLinkError)("");
|
|
2823
|
+
(isAndroid ? setAndroidDeepLinkKeysError : setIosDeepLinkKeysError)("");
|
|
2824
|
+
setPlatformToClear(null);
|
|
2825
|
+
}, [platformToClear, clearImageDataByMediaType, setUpdateMpushVideoSrc]);
|
|
2826
|
+
|
|
2827
|
+
// Android only <-> iOS only: give the empty target the current platform's content, buttons and media
|
|
2828
|
+
const copyPlatformContent = useCallback((source, target) => {
|
|
2829
|
+
const fromAndroid = source === ANDROID;
|
|
2830
|
+
const targetIndex = target === ANDROID ? 0 : 1;
|
|
2831
|
+
syncPlatformContent(fromAndroid ? androidContent : iosContent, source);
|
|
2832
|
+
(fromAndroid ? setCtaDataIos : setCtaDataAndroid)(cloneDeep(fromAndroid ? ctaDataAndroid : ctaDataIos));
|
|
2833
|
+
(fromAndroid ? setPrimaryButtonIos : setPrimaryButtonAndroid)(fromAndroid ? primaryButtonAndroid : primaryButtonIos);
|
|
2834
|
+
(fromAndroid ? setSecondaryButtonIos : setSecondaryButtonAndroid)(fromAndroid ? secondaryButtonAndroid : secondaryButtonIos);
|
|
2835
|
+
// Uploaded image/video live in the upload hook, per platform
|
|
2836
|
+
const sourceImage = fromAndroid ? imageSrc?.androidImageSrc : imageSrc?.iosImageSrc;
|
|
2837
|
+
if (sourceImage) {
|
|
2838
|
+
setUpdateMpushImageSrc(sourceImage, targetIndex, IMAGE);
|
|
2839
|
+
}
|
|
2840
|
+
const sourceVideo = fromAndroid ? videoState?.androidVideoSrc : videoState?.iosVideoSrc;
|
|
2841
|
+
if (sourceVideo) {
|
|
2842
|
+
setUpdateMpushVideoSrc(targetIndex, {
|
|
2843
|
+
...(fromAndroid ? androidAssetList : iosAssetList),
|
|
2844
|
+
videoSrc: sourceVideo,
|
|
2845
|
+
previewUrl: (fromAndroid ? videoState?.androidVideoPreview : videoState?.iosVideoPreview) || '',
|
|
2846
|
+
videoDuration: (fromAndroid ? videoState?.androidVideoDuration : videoState?.iosVideoDuration) || 0,
|
|
2847
|
+
}, true);
|
|
2848
|
+
}
|
|
2849
|
+
}, [androidContent, iosContent, ctaDataAndroid, ctaDataIos, primaryButtonAndroid, primaryButtonIos, secondaryButtonAndroid, secondaryButtonIos, imageSrc, videoState, androidAssetList, iosAssetList, setUpdateMpushImageSrc, setUpdateMpushVideoSrc]);
|
|
2850
|
+
|
|
2851
|
+
const handlePlatformChange = useCallback((value) => {
|
|
2852
|
+
if (value === platformSelection) return;
|
|
2853
|
+
const getPlatformContent = (platform) => (platform === ANDROID ? androidContent : iosContent);
|
|
2854
|
+
|
|
2855
|
+
if (platformSelection === BOTH_PLATFORMS) {
|
|
2856
|
+
// Both -> single: confirm before dropping a platform that has content
|
|
2857
|
+
if (hasPlatformContent(getPlatformContent(getOtherPlatform(value)))) {
|
|
2858
|
+
setPendingPlatformSelection(value);
|
|
2859
|
+
return;
|
|
2860
|
+
}
|
|
2861
|
+
setPlatformSelection(value);
|
|
2862
|
+
setPlatformToClear(getOtherPlatform(value));
|
|
2863
|
+
return;
|
|
2864
|
+
}
|
|
2865
|
+
|
|
2866
|
+
if (value === BOTH_PLATFORMS) {
|
|
2867
|
+
// Single -> Both: content stays in its tab; a ticked "Same content" syncs it to the other tab
|
|
2868
|
+
// (media and buttons follow through the existing on-tick effects)
|
|
2869
|
+
if (sameContentChecked) {
|
|
2870
|
+
syncPlatformContent(getPlatformContent(platformSelection), platformSelection);
|
|
2871
|
+
}
|
|
2872
|
+
setPlatformSelection(value);
|
|
2873
|
+
return;
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2876
|
+
// Android only <-> iOS only: an empty target takes the current content
|
|
2877
|
+
if (!hasPlatformContent(getPlatformContent(value)) && hasPlatformContent(getPlatformContent(platformSelection))) {
|
|
2878
|
+
copyPlatformContent(platformSelection, value);
|
|
2879
|
+
}
|
|
2880
|
+
setPlatformSelection(value);
|
|
2881
|
+
}, [platformSelection, androidContent, iosContent, sameContentChecked, copyPlatformContent]);
|
|
2882
|
+
|
|
2883
|
+
const confirmPlatformRemoval = useCallback(() => {
|
|
2884
|
+
const value = pendingPlatformSelection;
|
|
2885
|
+
setPendingPlatformSelection(null);
|
|
2886
|
+
setPlatformSelection(value);
|
|
2887
|
+
setPlatformToClear(getOtherPlatform(value));
|
|
2888
|
+
}, [pendingPlatformSelection]);
|
|
2889
|
+
|
|
2890
|
+
const platformOptions = useMemo(() => [
|
|
2891
|
+
{ label: formatMessage(messages.androidAndIos), value: BOTH_PLATFORMS },
|
|
2892
|
+
{ label: formatMessage(messages.androidOnly), value: ANDROID },
|
|
2893
|
+
{ label: formatMessage(messages.iosOnly), value: IOS },
|
|
2894
|
+
], [formatMessage]);
|
|
2895
|
+
|
|
2766
2896
|
const getContentType = useCallback(
|
|
2767
2897
|
(content) => {
|
|
2768
2898
|
// Get image source from multiple possible locations
|
|
@@ -2885,23 +3015,34 @@ export const MobilePushNew = ({
|
|
|
2885
3015
|
const androidPreview = getContentType(androidContent);
|
|
2886
3016
|
const iosPreview = getContentType(iosContent);
|
|
2887
3017
|
|
|
3018
|
+
// Notification tap as Save sends it (same builder), in the keys Test & Preview reads; '' for Android, '2' for iOS
|
|
3019
|
+
const getTapFormFields = (content, keySuffix) => {
|
|
3020
|
+
const { cta } = buildPlatformContent(content, '', {}, ANDROID);
|
|
3021
|
+
if (!cta) return {};
|
|
3022
|
+
const isDeepLink = cta.type === DEEP_LINK;
|
|
3023
|
+
return {
|
|
3024
|
+
[`cta-deeplink${keySuffix}`]: isDeepLink ? 'Deeplink' : 'External Link',
|
|
3025
|
+
[`cta-deeplink${keySuffix}-select`]: isDeepLink ? cta.actionLink : '',
|
|
3026
|
+
[`cta-deeplink${keySuffix}-text`]: isDeepLink ? '' : cta.actionLink,
|
|
3027
|
+
};
|
|
3028
|
+
};
|
|
3029
|
+
|
|
2888
3030
|
// Convert Android content to formData format
|
|
2889
3031
|
const androidFormData = {
|
|
2890
3032
|
'message-title': androidPreview?.header || androidContent?.title || '',
|
|
2891
3033
|
'message-editor': androidPreview?.bodyText || androidContent?.message || '',
|
|
2892
3034
|
image: androidPreview?.bodyImage || androidContent?.expandableDetails?.image || '',
|
|
2893
|
-
//
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
'cta-deeplink-label': androidContent.cta.actionText || '',
|
|
2899
|
-
}),
|
|
3035
|
+
// Video only for now. This tab's own videoSrc: the preview falls back to the visible tab's video
|
|
3036
|
+
video: androidContent?.mediaType === VIDEO ? (androidContent?.videoSrc || '') : '',
|
|
3037
|
+
// Same cards Save sends
|
|
3038
|
+
carouselData: androidContent?.mediaType === CAROUSEL ? buildCarouselCards(androidContent?.carouselData) : [],
|
|
3039
|
+
...getTapFormFields(androidContent, ''),
|
|
2900
3040
|
};
|
|
2901
3041
|
|
|
2902
|
-
//
|
|
2903
|
-
|
|
2904
|
-
|
|
3042
|
+
// Buttons live in ctaData state, not in androidContent. A carousel tab hides them, so none are sent
|
|
3043
|
+
const androidCtas = androidContent?.mediaType === CAROUSEL ? [] : toSavedCtas(ctaDataAndroid);
|
|
3044
|
+
if (androidCtas.length > 0) {
|
|
3045
|
+
androidCtas.forEach((cta, index) => {
|
|
2905
3046
|
if (index === 0) {
|
|
2906
3047
|
androidFormData['secondary-cta-0-label'] = cta.actionText || '';
|
|
2907
3048
|
androidFormData['cta-deeplink-secondary-cta-0'] = cta.type === DEEP_LINK ? 'Deeplink' : 'External Link';
|
|
@@ -2922,18 +3063,14 @@ export const MobilePushNew = ({
|
|
|
2922
3063
|
'message-title2': iosPreview?.header || iosContent?.title || '',
|
|
2923
3064
|
'message-editor2': iosPreview?.bodyText || iosContent?.message || '',
|
|
2924
3065
|
image: iosPreview?.bodyImage || iosContent?.expandableDetails?.image || '',
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
'cta-deeplink2-select': iosContent.cta.type === DEEP_LINK ? (iosContent.cta.actionLink || '') : '',
|
|
2929
|
-
'cta-deeplink2-text': iosContent.cta.type !== DEEP_LINK ? (iosContent.cta.actionLink || '') : '',
|
|
2930
|
-
'cta-deeplink2-label': iosContent.cta.actionText || '',
|
|
2931
|
-
}),
|
|
3066
|
+
video: iosContent?.mediaType === VIDEO ? (iosContent?.videoSrc || '') : '',
|
|
3067
|
+
carouselData: iosContent?.mediaType === CAROUSEL ? buildCarouselCards(iosContent?.carouselData) : [],
|
|
3068
|
+
...getTapFormFields(iosContent, '2'),
|
|
2932
3069
|
};
|
|
2933
3070
|
|
|
2934
|
-
|
|
2935
|
-
if (
|
|
2936
|
-
|
|
3071
|
+
const iosCtas = iosContent?.mediaType === CAROUSEL ? [] : toSavedCtas(ctaDataIos);
|
|
3072
|
+
if (iosCtas.length > 0) {
|
|
3073
|
+
iosCtas.forEach((cta, index) => {
|
|
2937
3074
|
if (index === 0) {
|
|
2938
3075
|
iosFormData['secondary-cta-1-label'] = cta.actionText || '';
|
|
2939
3076
|
iosFormData['cta-deeplink-secondary-cta-1'] = cta.type === DEEP_LINK ? 'Deeplink' : 'External Link';
|
|
@@ -2946,7 +3083,7 @@ export const MobilePushNew = ({
|
|
|
2946
3083
|
|
|
2947
3084
|
// Return in formData array format [androidData, iosData]
|
|
2948
3085
|
return [androidFormData, iosFormData];
|
|
2949
|
-
}, [androidContent, iosContent, getContentType]);
|
|
3086
|
+
}, [androidContent, iosContent, getContentType, ctaDataAndroid, ctaDataIos]);
|
|
2950
3087
|
|
|
2951
3088
|
// Handle Test and Preview button click
|
|
2952
3089
|
const handleTestAndPreview = useCallback(() => {
|
|
@@ -2956,7 +3093,8 @@ export const MobilePushNew = ({
|
|
|
2956
3093
|
// Handle close Test and Preview slidebox
|
|
2957
3094
|
const handleCloseTestAndPreview = useCallback(() => {
|
|
2958
3095
|
setShowTestAndPreviewSlidebox(false);
|
|
2959
|
-
|
|
3096
|
+
if (propsHandleCloseTestAndPreview) propsHandleCloseTestAndPreview();
|
|
3097
|
+
}, [propsHandleCloseTestAndPreview]);
|
|
2960
3098
|
|
|
2961
3099
|
// Add useEffect to handle isGetFormData prop changes (e.g. Done clicked in footer)
|
|
2962
3100
|
// In library mode: run liquid validation (extractTags) first; on success liquidMiddleWare calls handleSave
|
|
@@ -3082,24 +3220,45 @@ export const MobilePushNew = ({
|
|
|
3082
3220
|
<CapRow className="mobile-push-container">
|
|
3083
3221
|
<CapColumn className="content-section" span={14}>
|
|
3084
3222
|
{createModeContent()}
|
|
3085
|
-
{
|
|
3086
|
-
<
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3223
|
+
{canChoosePlatforms && (
|
|
3224
|
+
<CapRow type="flex" vertical noWrap className="input-group creative-name-container">
|
|
3225
|
+
<CapSelect
|
|
3226
|
+
id="mobile-push-platform-select"
|
|
3227
|
+
className="mobile-push-platform-select"
|
|
3228
|
+
label={formatMessage(messages.platforms)}
|
|
3229
|
+
options={platformOptions}
|
|
3230
|
+
value={platformSelection}
|
|
3231
|
+
onChange={handlePlatformChange}
|
|
3232
|
+
/>
|
|
3233
|
+
</CapRow>
|
|
3234
|
+
)}
|
|
3235
|
+
{singlePlatform ? (
|
|
3236
|
+
// One platform: its form only, no tabs or "Same content" checkbox
|
|
3237
|
+
<CapRow className="platform-header">
|
|
3238
|
+
{renderContentFields(singlePlatform)}
|
|
3239
|
+
</CapRow>
|
|
3240
|
+
) : (
|
|
3241
|
+
<>
|
|
3242
|
+
{isAndroidSupported && isIosSupported && (
|
|
3243
|
+
<CapCheckbox
|
|
3244
|
+
className="same-content-checkbox"
|
|
3245
|
+
checked={sameContent}
|
|
3246
|
+
onChange={handleSameContentChange}
|
|
3247
|
+
key={`same-content-${sameContent}`}
|
|
3248
|
+
>
|
|
3249
|
+
{formatMessage(messages.sameContentForBothChannels)}
|
|
3250
|
+
</CapCheckbox>
|
|
3251
|
+
)}
|
|
3252
|
+
<CapRow className="platform-header">
|
|
3253
|
+
<StyledCapTab
|
|
3254
|
+
className="platform-tabs"
|
|
3255
|
+
activeKey={activeTab}
|
|
3256
|
+
onChange={setActiveTab}
|
|
3257
|
+
panes={PANES}
|
|
3258
|
+
/>
|
|
3259
|
+
</CapRow>
|
|
3260
|
+
</>
|
|
3094
3261
|
)}
|
|
3095
|
-
<CapRow className="platform-header">
|
|
3096
|
-
<StyledCapTab
|
|
3097
|
-
className="platform-tabs"
|
|
3098
|
-
activeKey={activeTab}
|
|
3099
|
-
onChange={setActiveTab}
|
|
3100
|
-
panes={PANES}
|
|
3101
|
-
/>
|
|
3102
|
-
</CapRow>
|
|
3103
3262
|
<CapRow>
|
|
3104
3263
|
<CapColumn span={24}>
|
|
3105
3264
|
<ErrorInfoNote
|
|
@@ -3109,39 +3268,6 @@ export const MobilePushNew = ({
|
|
|
3109
3268
|
STANDARD_ERROR_MSG: errorMessage?.STANDARD_ERROR_MSG,
|
|
3110
3269
|
}}
|
|
3111
3270
|
/>
|
|
3112
|
-
|
|
3113
|
-
{/* In library mode, only show save button in create mode (edit mode has Done button from FormBuilder). In full mode, keep old logic. */}
|
|
3114
|
-
{((!isFullMode && computedCreativesMode !== 'edit') || (isFullMode && !isEditMode && computedCreativesMode === 'create')) && (
|
|
3115
|
-
<CapRow className="save-section">
|
|
3116
|
-
<CapColumn span={24}>
|
|
3117
|
-
<CapButton
|
|
3118
|
-
type="primary"
|
|
3119
|
-
onClick={() => {
|
|
3120
|
-
// Liquid validation (extractTags) only in library mode
|
|
3121
|
-
if (!isFullMode) {
|
|
3122
|
-
liquidMiddleWare();
|
|
3123
|
-
} else {
|
|
3124
|
-
handleSave();
|
|
3125
|
-
}
|
|
3126
|
-
}}
|
|
3127
|
-
className="save-button"
|
|
3128
|
-
disabled={isSaveDisabled}
|
|
3129
|
-
>
|
|
3130
|
-
{formatMessage(messages.saveTemplate)}
|
|
3131
|
-
</CapButton>
|
|
3132
|
-
<CapButton
|
|
3133
|
-
onClick={handleTestAndPreview}
|
|
3134
|
-
className="mobilepush-test-preview-btn"
|
|
3135
|
-
type="secondary"
|
|
3136
|
-
style={{ marginLeft: '8px' }}
|
|
3137
|
-
disabled={isSaveDisabled}
|
|
3138
|
-
>
|
|
3139
|
-
<FormattedMessage {...creativesMessages.testAndPreview} />
|
|
3140
|
-
</CapButton>
|
|
3141
|
-
</CapColumn>
|
|
3142
|
-
</CapRow>
|
|
3143
|
-
)}
|
|
3144
|
-
|
|
3145
3271
|
</CapColumn>
|
|
3146
3272
|
</CapRow>
|
|
3147
3273
|
</CapColumn>
|
|
@@ -3154,8 +3280,87 @@ export const MobilePushNew = ({
|
|
|
3154
3280
|
/>
|
|
3155
3281
|
</CapColumn>
|
|
3156
3282
|
</CapRow>
|
|
3283
|
+
{/* In library mode, only show save button in create mode (edit mode has Done button from FormBuilder). In full mode, keep old logic. */}
|
|
3284
|
+
{/* Kept outside the content row so the sticky footer can stick across the whole scroll area */}
|
|
3285
|
+
{((!isFullMode && computedCreativesMode !== 'edit') || (isFullMode && !isEditMode && computedCreativesMode === 'create')) && (
|
|
3286
|
+
<CapRow className="save-section mpush-save-section">
|
|
3287
|
+
<CapColumn span={24}>
|
|
3288
|
+
<CapButton
|
|
3289
|
+
type="primary"
|
|
3290
|
+
onClick={() => {
|
|
3291
|
+
// Liquid validation (extractTags) only in library mode
|
|
3292
|
+
if (!isFullMode) {
|
|
3293
|
+
liquidMiddleWare();
|
|
3294
|
+
} else {
|
|
3295
|
+
handleSave();
|
|
3296
|
+
}
|
|
3297
|
+
}}
|
|
3298
|
+
className="save-button"
|
|
3299
|
+
disabled={isSaveDisabled}
|
|
3300
|
+
>
|
|
3301
|
+
{formatMessage(messages.saveTemplate)}
|
|
3302
|
+
</CapButton>
|
|
3303
|
+
<CapButton
|
|
3304
|
+
onClick={handleTestAndPreview}
|
|
3305
|
+
className="mobilepush-test-preview-btn"
|
|
3306
|
+
type="secondary"
|
|
3307
|
+
style={{ marginLeft: '8px' }}
|
|
3308
|
+
disabled={isTestAndPreviewDisabled}
|
|
3309
|
+
>
|
|
3310
|
+
<FormattedMessage {...creativesMessages.testAndPreview} />
|
|
3311
|
+
</CapButton>
|
|
3312
|
+
</CapColumn>
|
|
3313
|
+
</CapRow>
|
|
3314
|
+
)}
|
|
3315
|
+
<CapModal
|
|
3316
|
+
open={isReplaceConfirmOpen}
|
|
3317
|
+
centered
|
|
3318
|
+
width={520}
|
|
3319
|
+
title={formatMessage(messages.replacePlatformContent, { platform: formatMessage(activeTab === ANDROID ? messages.ios : messages.android) })}
|
|
3320
|
+
onCancel={() => setIsReplaceConfirmOpen(false)}
|
|
3321
|
+
footer={[
|
|
3322
|
+
<CapButton key="cancel" type="secondary" onClick={() => setIsReplaceConfirmOpen(false)}>
|
|
3323
|
+
{formatMessage(globalMessages.cancel)}
|
|
3324
|
+
</CapButton>,
|
|
3325
|
+
<CapButton
|
|
3326
|
+
key="replace"
|
|
3327
|
+
type="primary"
|
|
3328
|
+
className="mpush-replace-platform-content"
|
|
3329
|
+
onClick={confirmSameContent}
|
|
3330
|
+
>
|
|
3331
|
+
{formatMessage(messages.replace)}
|
|
3332
|
+
</CapButton>,
|
|
3333
|
+
]}
|
|
3334
|
+
>
|
|
3335
|
+
{formatMessage(messages.replacePlatformContentBody, {
|
|
3336
|
+
platform: formatMessage(activeTab === ANDROID ? messages.ios : messages.android),
|
|
3337
|
+
source: formatMessage(activeTab === ANDROID ? messages.android : messages.ios),
|
|
3338
|
+
})}
|
|
3339
|
+
</CapModal>
|
|
3340
|
+
<CapModal
|
|
3341
|
+
open={!!pendingPlatformSelection}
|
|
3342
|
+
centered
|
|
3343
|
+
width={520}
|
|
3344
|
+
title={formatMessage(messages.removePlatformContent, {
|
|
3345
|
+
platform: formatMessage(pendingPlatformSelection === ANDROID ? messages.ios : messages.android),
|
|
3346
|
+
})}
|
|
3347
|
+
onCancel={() => setPendingPlatformSelection(null)}
|
|
3348
|
+
footer={[
|
|
3349
|
+
<CapButton key="cancel" type="secondary" onClick={() => setPendingPlatformSelection(null)}>
|
|
3350
|
+
{formatMessage(globalMessages.cancel)}
|
|
3351
|
+
</CapButton>,
|
|
3352
|
+
<CapButton
|
|
3353
|
+
key="remove"
|
|
3354
|
+
type="primary"
|
|
3355
|
+
className="mpush-remove-platform-content"
|
|
3356
|
+
onClick={confirmPlatformRemoval}
|
|
3357
|
+
>
|
|
3358
|
+
{formatMessage(messages.removeContent)}
|
|
3359
|
+
</CapButton>,
|
|
3360
|
+
]}
|
|
3361
|
+
/>
|
|
3157
3362
|
<TestAndPreviewSlidebox
|
|
3158
|
-
show={showTestAndPreviewSlidebox}
|
|
3363
|
+
show={propsShowTestAndPreviewSlidebox || showTestAndPreviewSlidebox}
|
|
3159
3364
|
onClose={handleCloseTestAndPreview}
|
|
3160
3365
|
formData={getFormDataForPayload()} // Pass formData structure for payload building
|
|
3161
3366
|
content={getTemplateContent()} // Also pass content for preview
|
|
@@ -3191,6 +3396,8 @@ MobilePushNew.propTypes = {
|
|
|
3191
3396
|
globalActions: PropTypes.object,
|
|
3192
3397
|
fetchingLiquidValidation: PropTypes.bool,
|
|
3193
3398
|
handleClose: PropTypes.func,
|
|
3399
|
+
showTestAndPreviewSlidebox: PropTypes.bool,
|
|
3400
|
+
handleCloseTestAndPreview: PropTypes.func,
|
|
3194
3401
|
createTemplateError: PropTypes.any,
|
|
3195
3402
|
isGetFormData: PropTypes.bool,
|
|
3196
3403
|
getTemplateDetailsInProgress: PropTypes.bool,
|
|
@@ -3223,6 +3430,8 @@ MobilePushNew.defaultProps = {
|
|
|
3223
3430
|
globalActions: {},
|
|
3224
3431
|
fetchingLiquidValidation: false,
|
|
3225
3432
|
handleClose: () => {},
|
|
3433
|
+
showTestAndPreviewSlidebox: false,
|
|
3434
|
+
handleCloseTestAndPreview: undefined,
|
|
3226
3435
|
createTemplateError: null,
|
|
3227
3436
|
isGetFormData: false,
|
|
3228
3437
|
getTemplateDetailsInProgress: false,
|