@capillarytech/creatives-library 9.2.1 → 9.2.2-alpha.sprint-cap-214249.44

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