@capillarytech/creatives-library 9.2.1-alpha.sprint-cap-214249.42 → 9.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AppRoot.js +4 -7
- package/constants/unified.js +1 -0
- package/package.json +1 -1
- package/utils/beePluginLoader.js +106 -0
- package/utils/common.js +6 -0
- package/utils/createMobilePushPayload.js +51 -56
- package/utils/tests/beePluginLoader.test.js +199 -0
- package/utils/tests/createMobilePushPayload.test.js +10 -162
- package/v2Components/CapMpushCTA/index.js +57 -47
- package/v2Components/CapMpushCTA/index.scss +5 -43
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +8 -11
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
- package/v2Components/CommonTestAndPreview/constants.js +0 -2
- package/v2Components/CommonTestAndPreview/index.js +10 -48
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -83
- package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
- package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
- package/v2Components/TemplatePreview/index.js +12 -14
- package/v2Components/TemplatePreview/tests/index.test.js +0 -69
- package/v2Containers/BeeEditor/index.js +49 -22
- package/v2Containers/BeeEditor/index.scss +12 -0
- package/v2Containers/BeeEditor/messages.js +8 -0
- package/v2Containers/BeeEditor/test/index.test.js +78 -0
- package/v2Containers/BeePopupEditor/index.js +22 -11
- package/v2Containers/CreativesContainer/SlideBoxContent.js +9 -5
- package/v2Containers/CreativesContainer/index.js +1 -2
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -43
- package/v2Containers/Email/index.js +2 -2
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +25 -23
- package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +222 -314
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +130 -161
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +123 -484
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +46 -152
- package/v2Containers/MobilePushNew/constants.js +0 -12
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -78
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -40
- package/v2Containers/MobilePushNew/hooks/useUpload.js +46 -42
- package/v2Containers/MobilePushNew/index.js +273 -503
- package/v2Containers/MobilePushNew/index.scss +4 -215
- package/v2Containers/MobilePushNew/messages.js +6 -106
- package/v2Containers/MobilePushNew/tests/index.test.js +1 -482
- package/v2Containers/MobilePushNew/tests/utils.test.js +0 -122
- package/v2Containers/MobilePushNew/utils.js +0 -107
- package/v2Containers/Templates/_templates.scss +2 -10
- package/v2Containers/Templates/index.js +81 -83
- package/v2Containers/Templates/tests/index.test.js +0 -68
- package/v2Components/CapMpushCTA/tests/index.test.js +0 -150
- package/v2Containers/MobilePushNew/components/TapLinkActions.js +0 -76
|
@@ -15,11 +15,11 @@ import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
|
|
|
15
15
|
import CapRadioGroup from "@capillarytech/cap-ui-library/CapRadioGroup";
|
|
16
16
|
import CapRow from "@capillarytech/cap-ui-library/CapRow";
|
|
17
17
|
import CapTab from "@capillarytech/cap-ui-library/CapTab";
|
|
18
|
+
import CapCheckbox from "@capillarytech/cap-ui-library/CapCheckbox";
|
|
18
19
|
import CapLabel from "@capillarytech/cap-ui-library/CapLabel";
|
|
19
20
|
import CapSelect from "@capillarytech/cap-ui-library/CapSelect";
|
|
20
21
|
import CapInput from "@capillarytech/cap-ui-library/CapInput";
|
|
21
22
|
import CapError from "@capillarytech/cap-ui-library/CapError";
|
|
22
|
-
import CapTooltip from "@capillarytech/cap-ui-library/CapTooltip";
|
|
23
23
|
import CapImageUpload from "../../../v2Components/CapImageUpload";
|
|
24
24
|
import CapVideoUpload from "../../../v2Components/CapVideoUpload";
|
|
25
25
|
import {
|
|
@@ -36,25 +36,14 @@ import {
|
|
|
36
36
|
GIF,
|
|
37
37
|
IMAGE,
|
|
38
38
|
VIDEO,
|
|
39
|
+
LINK_TYPE_OPTIONS,
|
|
39
40
|
DEEP_LINK,
|
|
40
41
|
EXTERNAL_LINK,
|
|
41
42
|
CAROUSEL,
|
|
42
|
-
TAP_ACTION_APP,
|
|
43
|
-
TAP_ACTION_OPTIONS,
|
|
44
43
|
} from "../constants";
|
|
45
44
|
import messages from "../messages";
|
|
46
|
-
import {
|
|
47
|
-
validateExternalLink,
|
|
48
|
-
validateDeepLink,
|
|
49
|
-
findSelectedDeepLink,
|
|
50
|
-
getCarouselCardIssue,
|
|
51
|
-
CAROUSEL_CARD_ISSUE,
|
|
52
|
-
getDeepLinkParamValue,
|
|
53
|
-
setDeepLinkParamValue,
|
|
54
|
-
hasAllDeepLinkParams,
|
|
55
|
-
} from "../utils";
|
|
45
|
+
import { validateExternalLink, validateDeepLink } from "../utils";
|
|
56
46
|
import TagList from "../../TagList";
|
|
57
|
-
import { SavedTapLink, TapLinkSaveDelete } from "./TapLinkActions";
|
|
58
47
|
|
|
59
48
|
// Initial carousel data structure
|
|
60
49
|
const CAROUSEL_INITIAL_DATA = {
|
|
@@ -73,6 +62,22 @@ const CAROUSEL_INITIAL_DATA = {
|
|
|
73
62
|
// Maximum number of carousel cards allowed
|
|
74
63
|
const MAX_CAROUSEL_ALLOWED = 10;
|
|
75
64
|
|
|
65
|
+
// Helper function to find selected deep link with fallback to base URL
|
|
66
|
+
const findSelectedDeepLink = (links, value) => {
|
|
67
|
+
if (!links || !value) return undefined;
|
|
68
|
+
|
|
69
|
+
// Try to find exact match first
|
|
70
|
+
let selectedDeepLink = links.find((link) => link?.value === value);
|
|
71
|
+
|
|
72
|
+
// If no exact match and value contains query parameters, try base URL match
|
|
73
|
+
if (!selectedDeepLink && value?.includes('?')) {
|
|
74
|
+
const baseDeepLinkValue = value.split('?')[0];
|
|
75
|
+
selectedDeepLink = links.find((link) => link?.value === baseDeepLinkValue);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return selectedDeepLink;
|
|
79
|
+
};
|
|
80
|
+
|
|
76
81
|
const MediaUploaders = ({
|
|
77
82
|
mediaType,
|
|
78
83
|
activeTab,
|
|
@@ -116,16 +121,12 @@ const MediaUploaders = ({
|
|
|
116
121
|
// Track upload ID to prevent processing stale Redux data
|
|
117
122
|
const [currentUploadId, setCurrentUploadId] = useState(null);
|
|
118
123
|
const uploadIdRef = useRef(0); // Counter for generating unique upload IDs
|
|
119
|
-
// Card whose video Re upload was clicked (its file input may belong to another card)
|
|
120
|
-
const reuploadCardRef = useRef(null);
|
|
121
124
|
|
|
122
125
|
// Track previous upload data to detect when a new upload completes
|
|
123
126
|
const previousUploadDataRef = useRef(null);
|
|
124
127
|
|
|
125
128
|
// Track previous media type to handle transitions
|
|
126
129
|
const previousMediaTypeRef = useRef(mediaType);
|
|
127
|
-
// First card's media type last seen, for the saved-carousel effect
|
|
128
|
-
const prevCardTypeRef = useRef(null);
|
|
129
130
|
|
|
130
131
|
// Extract link props
|
|
131
132
|
const { deepLink } = linkProps || {};
|
|
@@ -164,12 +165,8 @@ const MediaUploaders = ({
|
|
|
164
165
|
};
|
|
165
166
|
}, [getCurrentCarouselData, updateCarouselCard]);
|
|
166
167
|
|
|
167
|
-
// Clear previous media data when
|
|
168
|
-
// Skip re-runs from a tab switch: both panes stay mounted, and the
|
|
169
|
-
// hidden one must not wipe the visible tab's media.
|
|
168
|
+
// Clear previous media data when switching media types
|
|
170
169
|
useEffect(() => {
|
|
171
|
-
if (previousMediaTypeRef.current === mediaType) return;
|
|
172
|
-
|
|
173
170
|
// Clear carousel data when switching to non-carousel media types
|
|
174
171
|
if (mediaType !== CAROUSEL) {
|
|
175
172
|
setCurrentCarouselData([]);
|
|
@@ -181,15 +178,15 @@ const MediaUploaders = ({
|
|
|
181
178
|
previousUploadDataRef.current = null;
|
|
182
179
|
}
|
|
183
180
|
|
|
184
|
-
// Clear image data when switching away from IMAGE media type
|
|
181
|
+
// Clear image data when switching away from IMAGE media type
|
|
185
182
|
if (mediaType !== IMAGE) {
|
|
186
|
-
clearImageDataByMediaType(IMAGE
|
|
183
|
+
clearImageDataByMediaType(IMAGE);
|
|
187
184
|
}
|
|
188
185
|
|
|
189
186
|
// Clear image data when switching FROM CAROUSEL TO IMAGE
|
|
190
187
|
// This prevents carousel images from appearing in IMAGE media type
|
|
191
188
|
if (previousMediaTypeRef.current === CAROUSEL && mediaType === IMAGE) {
|
|
192
|
-
clearImageDataByMediaType(IMAGE
|
|
189
|
+
clearImageDataByMediaType(IMAGE);
|
|
193
190
|
}
|
|
194
191
|
|
|
195
192
|
// Reset re-upload mode when switching media types
|
|
@@ -197,7 +194,7 @@ const MediaUploaders = ({
|
|
|
197
194
|
|
|
198
195
|
// Update the previous media type ref
|
|
199
196
|
previousMediaTypeRef.current = mediaType;
|
|
200
|
-
}, [mediaType,
|
|
197
|
+
}, [mediaType, clearImageDataByMediaType, setCurrentCarouselData]);
|
|
201
198
|
|
|
202
199
|
// Handle platform tab changes for carousel data
|
|
203
200
|
useEffect(() => {
|
|
@@ -372,7 +369,6 @@ const MediaUploaders = ({
|
|
|
372
369
|
mediaType: value,
|
|
373
370
|
imageUrl: value === IMAGE.toLowerCase() ? card.imageUrl : '',
|
|
374
371
|
videoSrc: value === VIDEO.toLowerCase() ? card.videoSrc : '',
|
|
375
|
-
videoPreviewImg: value === VIDEO.toLowerCase() ? card.videoPreviewImg : '',
|
|
376
372
|
buttons: card.buttons || [{
|
|
377
373
|
actionOnClick: false,
|
|
378
374
|
linkType: DEEP_LINK,
|
|
@@ -386,18 +382,13 @@ const MediaUploaders = ({
|
|
|
386
382
|
setCarouselActiveTabIndex(Number(key));
|
|
387
383
|
};
|
|
388
384
|
|
|
389
|
-
// A card is done once its media is uploaded and its tap link (if any) is filled
|
|
390
|
-
const hasIncompleteCard = getCurrentCarouselData()?.some((card) => getCarouselCardIssue(card, deepLink));
|
|
391
|
-
|
|
392
385
|
const addCarouselCard = () => {
|
|
393
386
|
const currentData = getCurrentCarouselData();
|
|
394
|
-
if (currentData?.length < MAX_CAROUSEL_ALLOWED
|
|
387
|
+
if (currentData?.length < MAX_CAROUSEL_ALLOWED) {
|
|
395
388
|
setCurrentCarouselData([
|
|
396
389
|
...currentData,
|
|
397
390
|
{ ...CAROUSEL_INITIAL_DATA, mediaType: carouselMediaType },
|
|
398
391
|
]);
|
|
399
|
-
// Open the new card so its upload box is in view
|
|
400
|
-
setCarouselActiveTabIndex(currentData.length);
|
|
401
392
|
}
|
|
402
393
|
};
|
|
403
394
|
|
|
@@ -447,40 +438,33 @@ const MediaUploaders = ({
|
|
|
447
438
|
}, 100);
|
|
448
439
|
};
|
|
449
440
|
|
|
450
|
-
|
|
441
|
+
// Action link handlers for carousel cards
|
|
442
|
+
const handleCarouselActionOnClickChange = (cardIndex, checked) => {
|
|
443
|
+
const currentData = getCurrentCarouselData();
|
|
444
|
+
const card = currentData[cardIndex];
|
|
445
|
+
const updatedButtons = [...card?.buttons];
|
|
446
|
+
updatedButtons[0] = { ...updatedButtons[0], actionOnClick: checked };
|
|
447
|
+
updateCarouselCard(cardIndex, { buttons: updatedButtons });
|
|
448
|
+
};
|
|
451
449
|
|
|
452
|
-
|
|
453
|
-
const handleCarouselTapActionChange = (cardIndex, value) => {
|
|
450
|
+
const handleCarouselLinkTypeChange = (cardIndex, value) => {
|
|
454
451
|
const currentData = getCurrentCarouselData();
|
|
455
452
|
const card = currentData[cardIndex];
|
|
456
|
-
const button = card?.buttons?.[0];
|
|
457
|
-
const currentValue = button?.actionOnClick ? (button?.linkType || DEEP_LINK) : TAP_ACTION_APP;
|
|
458
|
-
if (value === currentValue) return;
|
|
459
|
-
const isApp = value === TAP_ACTION_APP;
|
|
460
453
|
const updatedButtons = [...card?.buttons];
|
|
461
|
-
updatedButtons[0] = {
|
|
462
|
-
...
|
|
463
|
-
|
|
464
|
-
linkType: isApp ? DEEP_LINK : value,
|
|
454
|
+
updatedButtons[0] = {
|
|
455
|
+
...updatedButtons[0],
|
|
456
|
+
linkType: value,
|
|
465
457
|
deepLinkValue: '',
|
|
466
458
|
externalLinkValue: '',
|
|
467
|
-
deepLinkKeys: []
|
|
468
|
-
// A new link stays open until its Save is clicked
|
|
469
|
-
isSaved: isApp ? undefined : false,
|
|
459
|
+
deepLinkKeys: []
|
|
470
460
|
};
|
|
471
461
|
updateCarouselCard(cardIndex, { buttons: updatedButtons });
|
|
462
|
+
// Clear errors when link type changes
|
|
472
463
|
updateCarouselLinkError(cardIndex, 'deepLink', null);
|
|
473
464
|
updateCarouselLinkError(cardIndex, 'externalLink', null);
|
|
474
465
|
updateCarouselLinkError(cardIndex, 'deepLinkKeys', null);
|
|
475
466
|
};
|
|
476
467
|
|
|
477
|
-
const setCarouselTapLinkSaved = (cardIndex, isSaved) => {
|
|
478
|
-
const card = getCurrentCarouselData()[cardIndex];
|
|
479
|
-
const updatedButtons = [...card?.buttons];
|
|
480
|
-
updatedButtons[0] = { ...updatedButtons[0], isSaved };
|
|
481
|
-
updateCarouselCard(cardIndex, { buttons: updatedButtons });
|
|
482
|
-
};
|
|
483
|
-
|
|
484
468
|
const handleCarouselDeepLinkChange = (cardIndex, value) => {
|
|
485
469
|
const currentData = getCurrentCarouselData();
|
|
486
470
|
const card = currentData[cardIndex];
|
|
@@ -508,15 +492,16 @@ const MediaUploaders = ({
|
|
|
508
492
|
updateCarouselLinkError(cardIndex, 'externalLink', error);
|
|
509
493
|
};
|
|
510
494
|
|
|
511
|
-
|
|
512
|
-
const handleCarouselDeepLinkKeysChange = (cardIndex, configuredKeys, key, value) => {
|
|
495
|
+
const handleCarouselDeepLinkKeysChange = (cardIndex, value) => {
|
|
513
496
|
const currentData = getCurrentCarouselData();
|
|
514
497
|
const card = currentData[cardIndex];
|
|
515
498
|
const updatedButtons = [...card?.buttons];
|
|
516
|
-
|
|
499
|
+
// Parse comma-separated values into array
|
|
500
|
+
const keysArray = value?.split(',')?.map((key) => key?.trim())?.filter((key) => key?.length > 0);
|
|
517
501
|
updatedButtons[0] = { ...updatedButtons[0], deepLinkKeys: keysArray };
|
|
518
502
|
updateCarouselCard(cardIndex, { buttons: updatedButtons });
|
|
519
|
-
|
|
503
|
+
// Validate deep link keys
|
|
504
|
+
const error = keysArray?.length === 0 ? formatMessage(messages.deepLinkKeysRequired) : null;
|
|
520
505
|
updateCarouselLinkError(cardIndex, 'deepLinkKeys', error);
|
|
521
506
|
};
|
|
522
507
|
|
|
@@ -569,50 +554,25 @@ const MediaUploaders = ({
|
|
|
569
554
|
);
|
|
570
555
|
};
|
|
571
556
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
setCurrentUploadId(uploadIdRef.current);
|
|
592
|
-
return uploadMpushAsset(file, assetType, fileParams, index);
|
|
593
|
-
};
|
|
594
|
-
|
|
595
|
-
return (
|
|
596
|
-
<CapVideoUpload
|
|
597
|
-
key={`carousel-video-${activeTab}-${cardIndex}`}
|
|
598
|
-
index={activeTab === ANDROID ? 0 : 1}
|
|
599
|
-
allowedExtensionsRegex={ALLOWED_EXTENSIONS_VIDEO_REGEX}
|
|
600
|
-
videoSize={MPUSH_VIDEO_SIZE}
|
|
601
|
-
isFullMode={isFullMode}
|
|
602
|
-
uploadAsset={handleCarouselVideoUpload}
|
|
603
|
-
uploadedAssetList={card?.videoSrc ? { videoSrc: card.videoSrc, previewUrl: card.videoPreviewImg || '' } : {}}
|
|
604
|
-
onVideoUploadUpdateAssestList={(_index, data) => handleCarouselVideoChange(cardIndex, data)}
|
|
605
|
-
videoData={{}}
|
|
606
|
-
className="cap-custom-video-upload"
|
|
607
|
-
formClassName="mpush-video-upload"
|
|
608
|
-
channel={MOBILE_PUSH_CHANNEL}
|
|
609
|
-
errorMessage={formatMessage(messages.videoErrorMessage)}
|
|
610
|
-
showVideoNameAndDuration={false}
|
|
611
|
-
showReUploadButton
|
|
612
|
-
mediaType="video"
|
|
613
|
-
/>
|
|
614
|
-
);
|
|
615
|
-
};
|
|
557
|
+
const renderCarouselVideoComponent = (cardIndex) => (
|
|
558
|
+
<CapVideoUpload
|
|
559
|
+
index={activeTab === ANDROID ? 0 : 1}
|
|
560
|
+
allowedExtensionsRegex={ALLOWED_EXTENSIONS_VIDEO_REGEX}
|
|
561
|
+
videoSize={MPUSH_VIDEO_SIZE}
|
|
562
|
+
isFullMode={isFullMode}
|
|
563
|
+
uploadAsset={uploadMpushAsset}
|
|
564
|
+
uploadedAssetList={videoAssetList}
|
|
565
|
+
onVideoUploadUpdateAssestList={(src) => updateCarouselCard(cardIndex, { videoSrc: src })}
|
|
566
|
+
videoData={videoDataForVideo}
|
|
567
|
+
className="cap-custom-video-upload"
|
|
568
|
+
formClassName="mpush-video-upload"
|
|
569
|
+
channel={MOBILE_PUSH_CHANNEL}
|
|
570
|
+
errorMessage={formatMessage(messages.videoErrorMessage)}
|
|
571
|
+
showVideoNameAndDuration={false}
|
|
572
|
+
showReUploadButton
|
|
573
|
+
mediaType="video"
|
|
574
|
+
/>
|
|
575
|
+
);
|
|
616
576
|
|
|
617
577
|
const renderCarouselActionLinks = (cardIndex) => {
|
|
618
578
|
const currentData = getCurrentCarouselData();
|
|
@@ -624,196 +584,178 @@ const MediaUploaders = ({
|
|
|
624
584
|
}
|
|
625
585
|
|
|
626
586
|
const button = card?.buttons[0]; // We're handling only one button for now
|
|
627
|
-
const tapAction = button?.actionOnClick ? (button?.linkType || DEEP_LINK) : TAP_ACTION_APP;
|
|
628
587
|
|
|
629
588
|
// Use the callback creator instead of useCallback inside render function
|
|
630
589
|
const onButtonTagSelect = createCarouselButtonTagSelectCallback(cardIndex);
|
|
631
590
|
|
|
632
|
-
const toArray = (value) => {
|
|
633
|
-
if (Array.isArray(value)) return value;
|
|
634
|
-
return value ? [value] : [];
|
|
635
|
-
};
|
|
636
|
-
const keysFromSelection = toArray(findSelectedDeepLink(deepLink, button?.deepLinkValue)?.keys);
|
|
637
|
-
const savedKeys = toArray(button?.deepLinkKeys);
|
|
638
|
-
// One input per configured key
|
|
639
|
-
const deepLinkInputKeys = keysFromSelection;
|
|
640
|
-
const showDeepLinkKeys = tapAction === DEEP_LINK && button?.deepLinkValue && keysFromSelection.length > 0;
|
|
641
|
-
|
|
642
|
-
// Only errors from typed values show inline (as in Notification tap); an empty link just keeps Save off
|
|
643
|
-
const deepLinkError = carouselLinkErrors[`${cardIndex}-deepLink`];
|
|
644
|
-
const externalLinkError = carouselLinkErrors[`${cardIndex}-externalLink`];
|
|
645
|
-
const deepLinkKeysError = carouselLinkErrors[`${cardIndex}-deepLinkKeys`];
|
|
646
|
-
const cardIssue = getCarouselCardIssue(card, deepLink);
|
|
647
|
-
const isLinkIncomplete = [
|
|
648
|
-
CAROUSEL_CARD_ISSUE.DEEP_LINK,
|
|
649
|
-
CAROUSEL_CARD_ISSUE.DEEP_LINK_KEYS,
|
|
650
|
-
CAROUSEL_CARD_ISSUE.EXTERNAL_LINK,
|
|
651
|
-
].includes(cardIssue);
|
|
652
|
-
|
|
653
|
-
// Link chosen and saved: collapsed row, as for a saved button
|
|
654
|
-
const isLinkSaved = tapAction !== TAP_ACTION_APP && button?.isSaved !== false;
|
|
655
|
-
const isLinkSaveDisabled = isLinkIncomplete || !!(deepLinkError || externalLinkError || deepLinkKeysError);
|
|
656
|
-
const savedLinkText = tapAction === DEEP_LINK
|
|
657
|
-
? (findSelectedDeepLink(deepLink, button?.deepLinkValue)?.label || button?.deepLinkValue)
|
|
658
|
-
: button?.externalLinkValue;
|
|
659
|
-
const removeCardTapLink = () => handleCarouselTapActionChange(cardIndex, TAP_ACTION_APP);
|
|
660
|
-
|
|
661
|
-
if (isLinkSaved) {
|
|
662
|
-
return (
|
|
663
|
-
<>
|
|
664
|
-
<CapDivider />
|
|
665
|
-
<CapRow useLegacy className="creatives-mpush-actions">
|
|
666
|
-
<CapRow type="flex" align="middle" noWrap className="mpush-section-heading">
|
|
667
|
-
<CapHeading type="h4" className="mpush-actions">
|
|
668
|
-
<FormattedMessage {...messages.cardTap} />
|
|
669
|
-
</CapHeading>
|
|
670
|
-
<CapLabel className="optional-text">
|
|
671
|
-
<FormattedMessage {...messages.optionalText} />
|
|
672
|
-
</CapLabel>
|
|
673
|
-
</CapRow>
|
|
674
|
-
<CapLabel className="mpush-tap-description">
|
|
675
|
-
<FormattedMessage {...messages.cardTapDescription} />
|
|
676
|
-
</CapLabel>
|
|
677
|
-
<SavedTapLink
|
|
678
|
-
linkType={tapAction}
|
|
679
|
-
linkText={savedLinkText}
|
|
680
|
-
onEdit={() => setCarouselTapLinkSaved(cardIndex, false)}
|
|
681
|
-
onDelete={removeCardTapLink}
|
|
682
|
-
formatMessage={formatMessage}
|
|
683
|
-
/>
|
|
684
|
-
</CapRow>
|
|
685
|
-
</>
|
|
686
|
-
);
|
|
687
|
-
}
|
|
688
|
-
|
|
689
591
|
return (
|
|
690
592
|
<>
|
|
691
593
|
<CapDivider />
|
|
692
594
|
<CapRow useLegacy className="creatives-mpush-actions">
|
|
693
|
-
<CapRow
|
|
595
|
+
<CapRow useLegacy className="mpush-actions-main">
|
|
694
596
|
<CapHeading type="h4" className="mpush-actions">
|
|
695
|
-
<FormattedMessage {...messages.
|
|
597
|
+
<FormattedMessage {...messages.buttonsAndLinks} />
|
|
696
598
|
</CapHeading>
|
|
697
599
|
<CapLabel className="optional-text">
|
|
698
600
|
<FormattedMessage {...messages.optionalText} />
|
|
699
601
|
</CapLabel>
|
|
700
602
|
</CapRow>
|
|
701
|
-
<
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
<CapColumn flex="1 1 0" className="mpush-tap-link">
|
|
719
|
-
<CapHeading type="h4" className="mpush-tap-label">
|
|
720
|
-
<FormattedMessage {...messages.tapActionDeepLink} />
|
|
603
|
+
<CapCheckbox
|
|
604
|
+
checked={button.actionOnClick}
|
|
605
|
+
onChange={(e) => handleCarouselActionOnClickChange(cardIndex, e.target.checked)}
|
|
606
|
+
className="action-on-click-checkbox"
|
|
607
|
+
>
|
|
608
|
+
<FormattedMessage {...messages.actionOnClickBody} />
|
|
609
|
+
</CapCheckbox>
|
|
610
|
+
<CapRow useLegacy>
|
|
611
|
+
<CapLabel className="action-description">
|
|
612
|
+
<FormattedMessage {...messages.actionDescription} />
|
|
613
|
+
</CapLabel>
|
|
614
|
+
</CapRow>
|
|
615
|
+
{button?.actionOnClick && (
|
|
616
|
+
<CapRow style={{ display: "flex", justifyContent: "space-around" }}>
|
|
617
|
+
<CapColumn span={6}>
|
|
618
|
+
<CapHeading type="h4" className="buttons-heading">
|
|
619
|
+
<FormattedMessage {...messages.linkType} />
|
|
721
620
|
</CapHeading>
|
|
722
621
|
<CapSelect.CapCustomSelect
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
if (button?.deepLinkValue && !options.find((opt) => opt.value === button?.deepLinkValue)) {
|
|
728
|
-
options.push({
|
|
729
|
-
value: button?.deepLinkValue,
|
|
730
|
-
label: button?.deepLinkValue,
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
return options;
|
|
734
|
-
})()}
|
|
735
|
-
value={button?.deepLinkValue}
|
|
736
|
-
onChange={(value) => handleCarouselDeepLinkChange(cardIndex, value)}
|
|
737
|
-
key={`mobile-push-deep-link-type-${activeTab}-${cardIndex}`}
|
|
622
|
+
options={LINK_TYPE_OPTIONS}
|
|
623
|
+
value={button.linkType}
|
|
624
|
+
onChange={(value) => handleCarouselLinkTypeChange(cardIndex, value)}
|
|
625
|
+
key={`mobile-push-link-type-${activeTab}-${cardIndex}`}
|
|
738
626
|
selectPlaceholder={formatMessage(messages.selectDeepLink)}
|
|
739
627
|
/>
|
|
740
|
-
{deepLinkError && (
|
|
741
|
-
<CapError className="mobile-push-carousel-deep-link-error">
|
|
742
|
-
{deepLinkError}
|
|
743
|
-
</CapError>
|
|
744
|
-
)}
|
|
745
|
-
{showDeepLinkKeys && (
|
|
746
|
-
<CapRow className="mpush-tap-deep-link-keys">
|
|
747
|
-
<CapHeading type="h4" className="deep-link-keys-heading">
|
|
748
|
-
{formatMessage(messages.deepLinkKeys)}
|
|
749
|
-
</CapHeading>
|
|
750
|
-
{deepLinkInputKeys.map((key, keyIndex) => (
|
|
751
|
-
<CapRow useLegacy key={key} className="mpush-deep-link-key">
|
|
752
|
-
<CapLabel type="label2" className="deep-link-keys-value">
|
|
753
|
-
{key}
|
|
754
|
-
</CapLabel>
|
|
755
|
-
<CapInput
|
|
756
|
-
id={keyIndex === 0
|
|
757
|
-
? `mobile-push-carousel-deep-link-keys-input-${activeTab}-${cardIndex}`
|
|
758
|
-
: `mobile-push-carousel-deep-link-keys-input-${activeTab}-${cardIndex}-${keyIndex}`}
|
|
759
|
-
onChange={(e) => handleCarouselDeepLinkKeysChange(cardIndex, deepLinkInputKeys, key, e.target.value)}
|
|
760
|
-
placeholder={formatMessage(messages.deepLinkKeysPlaceholder, { key })}
|
|
761
|
-
value={getDeepLinkParamValue(savedKeys, key)}
|
|
762
|
-
size="default"
|
|
763
|
-
error={keyIndex === deepLinkInputKeys.length - 1 ? deepLinkKeysError : undefined}
|
|
764
|
-
/>
|
|
765
|
-
</CapRow>
|
|
766
|
-
))}
|
|
767
|
-
</CapRow>
|
|
768
|
-
)}
|
|
769
628
|
</CapColumn>
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
<CapHeading type="h4" className="mpush-tap-label">
|
|
775
|
-
<FormattedMessage {...messages.url} />
|
|
629
|
+
{button?.linkType === DEEP_LINK && (
|
|
630
|
+
<CapColumn span={14}>
|
|
631
|
+
<CapHeading type="h4" className="buttons-heading">
|
|
632
|
+
{formatMessage(messages.deepLink)}
|
|
776
633
|
</CapHeading>
|
|
777
|
-
<
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
634
|
+
<CapSelect.CapCustomSelect
|
|
635
|
+
options={(() => {
|
|
636
|
+
const options = [...(deepLink || [])];
|
|
637
|
+
// If the current value is not in the options, add it
|
|
638
|
+
if (button?.deepLinkValue && !options.find(opt => opt.value === button?.deepLinkValue)) {
|
|
639
|
+
options.push({
|
|
640
|
+
value: button?.deepLinkValue,
|
|
641
|
+
label: button?.deepLinkValue,
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
return options;
|
|
645
|
+
})()}
|
|
646
|
+
value={button?.deepLinkValue}
|
|
647
|
+
onChange={(value) => handleCarouselDeepLinkChange(cardIndex, value)}
|
|
648
|
+
key={`mobile-push-deep-link-type-${activeTab}-${cardIndex}`}
|
|
649
|
+
placeholder={formatMessage(messages.selectDeepLink)}
|
|
650
|
+
style={{ marginTop: "10px" }}
|
|
788
651
|
/>
|
|
789
|
-
|
|
652
|
+
{carouselLinkErrors[`${cardIndex}-deepLink`] && (
|
|
653
|
+
<CapError className="mobile-push-carousel-deep-link-error">
|
|
654
|
+
{carouselLinkErrors[`${cardIndex}-deepLink`]}
|
|
655
|
+
</CapError>
|
|
656
|
+
)}
|
|
657
|
+
</CapColumn>
|
|
658
|
+
)}
|
|
659
|
+
{button?.linkType === EXTERNAL_LINK && (
|
|
660
|
+
<CapColumn span={14}>
|
|
661
|
+
<CapRow className="buttons-heading-container">
|
|
662
|
+
<CapHeading type="h4" className="buttons-heading">
|
|
663
|
+
{formatMessage(messages.externalLink)}
|
|
664
|
+
</CapHeading>
|
|
665
|
+
<TagList
|
|
666
|
+
moduleFilterEnabled={
|
|
667
|
+
location?.query?.type !== "embedded"
|
|
668
|
+
}
|
|
669
|
+
label={formatMessage(messages.addLabels)}
|
|
670
|
+
onTagSelect={onButtonTagSelect}
|
|
671
|
+
onContextChange={handleOnTagsContextChange}
|
|
672
|
+
location={location}
|
|
673
|
+
tags={tags}
|
|
674
|
+
injectedTags={injectedTags}
|
|
675
|
+
selectedOfferDetails={selectedOfferDetails}
|
|
676
|
+
/>
|
|
677
|
+
</CapRow>
|
|
678
|
+
<CapInput
|
|
679
|
+
id={`mobile-push-external-link-input-${activeTab}-${cardIndex}`}
|
|
680
|
+
onChange={(e) => handleCarouselExternalLinkChange(cardIndex, e.target.value)}
|
|
681
|
+
placeholder={formatMessage(messages.enterExternalLink)}
|
|
682
|
+
value={button?.externalLinkValue}
|
|
683
|
+
size="default"
|
|
684
|
+
isRequired
|
|
685
|
+
/>
|
|
686
|
+
{carouselLinkErrors[`${cardIndex}-externalLink`] && (
|
|
687
|
+
<CapError className="mobile-push-carousel-external-link-error">
|
|
688
|
+
{carouselLinkErrors[`${cardIndex}-externalLink`]}
|
|
689
|
+
</CapError>
|
|
690
|
+
)}
|
|
691
|
+
</CapColumn>
|
|
692
|
+
)}
|
|
693
|
+
</CapRow>
|
|
694
|
+
)}
|
|
695
|
+
{button?.linkType === DEEP_LINK && button?.deepLinkValue && button?.actionOnClick && (() => {
|
|
696
|
+
const selectedDeepLink = findSelectedDeepLink(deepLink, button?.deepLinkValue);
|
|
697
|
+
const deepLinkKeysFromSelection = selectedDeepLink?.keys;
|
|
698
|
+
let deepLinkKeysFromSelectionArray = [];
|
|
699
|
+
if (Array.isArray(deepLinkKeysFromSelection)) {
|
|
700
|
+
deepLinkKeysFromSelectionArray = deepLinkKeysFromSelection;
|
|
701
|
+
} else if (deepLinkKeysFromSelection) {
|
|
702
|
+
deepLinkKeysFromSelectionArray = [deepLinkKeysFromSelection];
|
|
703
|
+
}
|
|
704
|
+
return deepLinkKeysFromSelectionArray?.length > 0;
|
|
705
|
+
})() && (
|
|
706
|
+
<CapRow style={{ marginTop: "10px", left: "6%", width: '115%'}}>
|
|
707
|
+
<CapColumn span={14}>
|
|
708
|
+
<CapHeading type="h4" className="deep-link-keys-heading">
|
|
709
|
+
{formatMessage(messages.deepLinkKeys)}
|
|
710
|
+
</CapHeading>
|
|
711
|
+
<CapLabel type="label2" className="deep-link-keys-value">
|
|
712
|
+
{(() => {
|
|
713
|
+
const selectedDeepLink = findSelectedDeepLink(deepLink, button?.deepLinkValue);
|
|
714
|
+
const deepLinkKeysFromSelection = selectedDeepLink?.keys;
|
|
715
|
+
let deepLinkKeysArray = [];
|
|
716
|
+
if (Array.isArray(button?.deepLinkKeys)) {
|
|
717
|
+
deepLinkKeysArray = button?.deepLinkKeys;
|
|
718
|
+
} else if (button?.deepLinkKeys) {
|
|
719
|
+
deepLinkKeysArray = [button?.deepLinkKeys];
|
|
720
|
+
}
|
|
721
|
+
let deepLinkKeysFromSelectionArray = [];
|
|
722
|
+
if (Array.isArray(deepLinkKeysFromSelection)) {
|
|
723
|
+
deepLinkKeysFromSelectionArray = deepLinkKeysFromSelection;
|
|
724
|
+
} else if (deepLinkKeysFromSelection) {
|
|
725
|
+
deepLinkKeysFromSelectionArray = [deepLinkKeysFromSelection];
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
if (deepLinkKeysFromSelectionArray?.length > 0) {
|
|
729
|
+
return deepLinkKeysFromSelectionArray.join(', ');
|
|
730
|
+
}
|
|
731
|
+
if (deepLinkKeysArray?.length > 0) {
|
|
732
|
+
return deepLinkKeysArray.join(', ');
|
|
733
|
+
}
|
|
734
|
+
})()}
|
|
735
|
+
</CapLabel>
|
|
790
736
|
<CapInput
|
|
791
|
-
id={`mobile-push-
|
|
792
|
-
onChange={(e) =>
|
|
793
|
-
placeholder={formatMessage(messages.
|
|
794
|
-
|
|
737
|
+
id={`mobile-push-carousel-deep-link-keys-input-${activeTab}-${cardIndex}`}
|
|
738
|
+
onChange={(e) => handleCarouselDeepLinkKeysChange(cardIndex, e.target.value)}
|
|
739
|
+
placeholder={formatMessage(messages.deepLinkKeysPlaceholder, {
|
|
740
|
+
key: (() => {
|
|
741
|
+
const selectedDeepLink = findSelectedDeepLink(deepLink, button?.deepLinkValue);
|
|
742
|
+
const deepLinkKeysFromSelection = selectedDeepLink?.keys;
|
|
743
|
+
let deepLinkKeysFromSelectionArray = [];
|
|
744
|
+
if (Array.isArray(deepLinkKeysFromSelection)) {
|
|
745
|
+
deepLinkKeysFromSelectionArray = deepLinkKeysFromSelection;
|
|
746
|
+
} else if (deepLinkKeysFromSelection) {
|
|
747
|
+
deepLinkKeysFromSelectionArray = [deepLinkKeysFromSelection];
|
|
748
|
+
}
|
|
749
|
+
return deepLinkKeysFromSelectionArray.join(', ') || 'deep link keys';
|
|
750
|
+
})(),
|
|
751
|
+
})}
|
|
752
|
+
value={Array.isArray(button?.deepLinkKeys) ? button?.deepLinkKeys?.join(', ') : (button?.deepLinkKeys || "")}
|
|
795
753
|
size="default"
|
|
796
|
-
|
|
754
|
+
style={{ marginTop: "10px" }}
|
|
755
|
+
error={carouselLinkErrors[`${cardIndex}-deepLinkKeys`]}
|
|
797
756
|
/>
|
|
798
|
-
{externalLinkError && (
|
|
799
|
-
<CapError className="mobile-push-carousel-external-link-error">
|
|
800
|
-
{externalLinkError}
|
|
801
|
-
</CapError>
|
|
802
|
-
)}
|
|
803
757
|
</CapColumn>
|
|
804
|
-
|
|
805
|
-
</CapRow>
|
|
806
|
-
{tapAction === TAP_ACTION_APP ? (
|
|
807
|
-
<CapLabel className="mpush-tap-description mpush-tap-help">
|
|
808
|
-
<FormattedMessage {...messages.cardTapAppHelp} />
|
|
809
|
-
</CapLabel>
|
|
810
|
-
) : (
|
|
811
|
-
<TapLinkSaveDelete
|
|
812
|
-
isSaveDisabled={isLinkSaveDisabled}
|
|
813
|
-
onSave={() => setCarouselTapLinkSaved(cardIndex, true)}
|
|
814
|
-
onDelete={removeCardTapLink}
|
|
815
|
-
formatMessage={formatMessage}
|
|
816
|
-
/>
|
|
758
|
+
</CapRow>
|
|
817
759
|
)}
|
|
818
760
|
</CapRow>
|
|
819
761
|
</>
|
|
@@ -862,30 +804,17 @@ const MediaUploaders = ({
|
|
|
862
804
|
}));
|
|
863
805
|
};
|
|
864
806
|
|
|
865
|
-
const isMaxCarouselCardsReached = getCurrentCarouselData()?.length >= MAX_CAROUSEL_ALLOWED;
|
|
866
|
-
let addCardTooltipTitle = "";
|
|
867
|
-
if (isMaxCarouselCardsReached) {
|
|
868
|
-
addCardTooltipTitle = formatMessage(messages.carouselMaxCardTooltip, { max: MAX_CAROUSEL_ALLOWED });
|
|
869
|
-
} else if (hasIncompleteCard) {
|
|
870
|
-
addCardTooltipTitle = formatMessage(messages.completeCardToAdd);
|
|
871
|
-
}
|
|
872
|
-
|
|
873
807
|
const operations = (
|
|
874
808
|
<>
|
|
875
809
|
<CapDivider type="vertical" />
|
|
876
|
-
<
|
|
877
|
-
{
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
>
|
|
885
|
-
<CapIcon type="plus" />
|
|
886
|
-
</CapButton>
|
|
887
|
-
</CapRow>
|
|
888
|
-
</CapTooltip>
|
|
810
|
+
<CapButton
|
|
811
|
+
onClick={addCarouselCard}
|
|
812
|
+
type="link"
|
|
813
|
+
className="add-carousel-content-button"
|
|
814
|
+
disabled={getCurrentCarouselData()?.length >= MAX_CAROUSEL_ALLOWED}
|
|
815
|
+
>
|
|
816
|
+
<CapIcon type="plus" />
|
|
817
|
+
</CapButton>
|
|
889
818
|
</>
|
|
890
819
|
);
|
|
891
820
|
|
|
@@ -910,6 +839,7 @@ const MediaUploaders = ({
|
|
|
910
839
|
{
|
|
911
840
|
value: VIDEO.toLowerCase(),
|
|
912
841
|
label: formatMessage(messages.mediaVideo),
|
|
842
|
+
disabled: true,
|
|
913
843
|
},
|
|
914
844
|
]}
|
|
915
845
|
value={carouselMediaType}
|
|
@@ -963,16 +893,8 @@ const MediaUploaders = ({
|
|
|
963
893
|
const previousDataKey = previousUploadDataRef.current;
|
|
964
894
|
|
|
965
895
|
if (currentDataKey !== previousDataKey) {
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
video_file_path_preview: videoPreview = '',
|
|
969
|
-
preview_image_url: previewImage = '',
|
|
970
|
-
} = uploadedData.metaInfo;
|
|
971
|
-
const isVideoCard = getCurrentCarouselData()?.[uploadingCardIndex]?.mediaType === VIDEO.toLowerCase();
|
|
972
|
-
// Update the specific card that was uploading (videoPreviewImg is what the phone preview shows)
|
|
973
|
-
updateCarouselCard(uploadingCardIndex, isVideoCard
|
|
974
|
-
? { videoSrc: filePath, videoPreviewImg: videoPreview || previewImage }
|
|
975
|
-
: { imageUrl: filePath });
|
|
896
|
+
// Update the specific card that was uploading
|
|
897
|
+
updateCarouselCard(uploadingCardIndex, { imageUrl: uploadedData?.metaInfo?.secure_file_path });
|
|
976
898
|
|
|
977
899
|
// Store this upload data as "processed" to avoid reprocessing
|
|
978
900
|
previousUploadDataRef.current = currentDataKey;
|
|
@@ -983,21 +905,7 @@ const MediaUploaders = ({
|
|
|
983
905
|
}
|
|
984
906
|
}
|
|
985
907
|
}
|
|
986
|
-
}, [mediaType, imageData, uploadingCardIndex, currentUploadId, activeTab, updateCarouselCard
|
|
987
|
-
|
|
988
|
-
// Editing a saved video carousel: show video boxes, not the default image ones.
|
|
989
|
-
// Follows the cards' type only when it changes, so a radio click isn't undone.
|
|
990
|
-
useEffect(() => {
|
|
991
|
-
if (mediaType !== CAROUSEL) {
|
|
992
|
-
prevCardTypeRef.current = null;
|
|
993
|
-
return;
|
|
994
|
-
}
|
|
995
|
-
const savedCardType = carouselData?.[0]?.mediaType;
|
|
996
|
-
if (savedCardType && savedCardType !== prevCardTypeRef.current) {
|
|
997
|
-
setCarouselMediaType(savedCardType);
|
|
998
|
-
}
|
|
999
|
-
prevCardTypeRef.current = savedCardType;
|
|
1000
|
-
}, [mediaType, carouselData]);
|
|
908
|
+
}, [mediaType, imageData, uploadingCardIndex, currentUploadId, activeTab, updateCarouselCard]);
|
|
1001
909
|
|
|
1002
910
|
if (mediaType === IMAGE) return renderImageComponent();
|
|
1003
911
|
if (mediaType === VIDEO) return renderVideoComponent();
|