@capillarytech/creatives-library 9.1.8-alpha.sprint-cap-214249.38 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants/unified.js +4 -0
- package/index.js +13 -0
- package/package.json +1 -1
- package/services/getSchema.js +4 -1
- package/services/tests/getSchema.test.js +2 -2
- package/translations/en.json +1 -0
- package/translations/ja-JP.json +1 -0
- package/translations/zh.json +1 -0
- package/utils/common.js +6 -0
- package/utils/createMobilePushPayload.js +33 -47
- package/utils/tagValidations.js +35 -4
- package/utils/templateVarUtils.js +49 -0
- package/utils/tests/createMobilePushPayload.test.js +8 -102
- package/utils/tests/tagValidations.test.js +48 -0
- package/utils/tests/templateVarUtils.test.js +89 -0
- package/v2Components/CapMpushCTA/index.js +9 -10
- package/v2Components/CapMpushCTA/index.scss +3 -29
- package/v2Components/CapTagList/TagFallbackPanel.js +124 -0
- package/v2Components/CapTagList/constants.js +5 -0
- package/v2Components/CapTagList/index.js +46 -7
- package/v2Components/CapTagList/messages.js +44 -0
- package/v2Components/CapTagList/style.scss +113 -1
- package/v2Components/CapTagList/tests/TagFallback.test.js +222 -0
- package/v2Components/CapTagList/utils.js +17 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +13 -26
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
- package/v2Components/CommonTestAndPreview/constants.js +3 -2
- package/v2Components/CommonTestAndPreview/index.js +62 -62
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -79
- package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
- package/v2Components/CommonTestAndPreview/tests/utils.test.js +102 -0
- package/v2Components/CommonTestAndPreview/utils.js +42 -3
- package/v2Components/FormBuilder/Classic.js +24 -14
- package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +1 -0
- package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
- package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +57 -0
- package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
- package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +3 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +5 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +6 -0
- package/v2Components/FormBuilder/Functional/channels/sms/validate.js +3 -1
- package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +3 -0
- package/v2Components/FormBuilder/Functional/tests/manual.typingPerf.test.js +135 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.crossFlowParity.test.js +1 -1
- package/v2Components/FormBuilder/Functional/tests/mpush.ctaFlows.parity.test.js +320 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.editContainer.parity.test.js +148 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.libraryValidity.parity.test.js +152 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.shellEvents.test.js +1 -1
- package/v2Components/FormBuilder/Functional/tests/mpush.singlePlatform.test.js +1 -1
- package/v2Components/FormBuilder/Functional/tests/mpushRenderers.test.js +22 -0
- package/v2Components/FormBuilder/tests/mpush.characterization.test.js +2 -2
- package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
- package/v2Components/TemplatePreview/index.js +17 -30
- package/v2Components/TemplatePreview/tests/index.test.js +0 -61
- package/v2Containers/Cap/index.js +3 -0
- package/v2Containers/Cap/messages.js +4 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +151 -70
- package/v2Containers/CreativesContainer/index.js +6 -3
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -29
- package/v2Containers/InApp/index.js +4 -1
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
- package/v2Containers/Line/Container/Text/index.js +3 -1
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +16 -0
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +18 -0
- package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +70 -0
- package/v2Containers/MobilePush/Create/actions.js +52 -0
- package/v2Containers/MobilePush/Create/constants.js +26 -0
- package/v2Containers/MobilePush/Create/index.js +2149 -0
- package/v2Containers/MobilePush/Create/messages.js +349 -0
- package/v2Containers/MobilePush/Create/reducer.js +72 -0
- package/v2Containers/MobilePush/Create/sagas.js +79 -0
- package/v2Containers/MobilePush/Create/selectors.js +29 -0
- package/v2Containers/MobilePush/Create/test/contentValidity.test.js +154 -0
- package/v2Containers/MobilePush/Create/test/saga.test.js +19 -0
- package/v2Containers/MobilePush/Create/test/stayOpenOnSave.test.js +80 -0
- package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +65 -0
- package/v2Containers/MobilePush/Edit/actions.js +94 -0
- package/v2Containers/MobilePush/Edit/constants.js +37 -0
- package/v2Containers/MobilePush/Edit/index.js +2407 -0
- package/v2Containers/MobilePush/Edit/messages.js +341 -0
- package/v2Containers/MobilePush/Edit/reducer.js +113 -0
- package/v2Containers/MobilePush/Edit/sagas.js +113 -0
- package/v2Containers/MobilePush/Edit/selectors.js +33 -0
- package/v2Containers/MobilePush/Edit/test/contentValidity.test.js +149 -0
- package/v2Containers/MobilePush/Edit/test/saga.test.js +255 -0
- package/v2Containers/MobilePush/Edit/test/stayOpenOnSave.test.js +60 -0
- package/v2Containers/MobilePush/commonMethods.js +333 -0
- package/v2Containers/MobilePush/eventsMap.js +130 -0
- package/v2Containers/MobilePush/tests/commonMethods.test.js +401 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +192 -207
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +121 -116
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +72 -316
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +16 -45
- package/v2Containers/MobilePushNew/constants.js +0 -5
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -52
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -38
- package/v2Containers/MobilePushNew/hooks/useUpload.js +39 -29
- package/v2Containers/MobilePushNew/index.js +192 -454
- package/v2Containers/MobilePushNew/index.scss +4 -188
- package/v2Containers/MobilePushNew/messages.js +6 -86
- package/v2Containers/MobilePushNew/tests/index.test.js +1 -450
- package/v2Containers/MobilePushNew/tests/utils.test.js +0 -25
- package/v2Containers/MobilePushNew/utils.js +0 -8
- package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +22 -0
- package/v2Containers/MobilepushWrapper/index.js +178 -0
- package/v2Containers/MobilepushWrapper/messages.js +29 -0
- package/v2Containers/Rcs/index.js +8 -1
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +59 -0
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -0
- package/v2Containers/SmsTrai/Edit/index.js +17 -7
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +42 -0
- package/v2Containers/Templates/_templates.scss +2 -10
- package/v2Containers/Templates/index.js +90 -84
- package/v2Containers/Templates/tests/index.test.js +0 -68
- package/v2Containers/Viber/index.js +3 -1
- package/v2Containers/WebPush/Create/utils/validation.js +6 -0
- package/v2Containers/WebPush/Create/utils/validation.test.js +50 -0
- package/v2Containers/Whatsapp/index.js +9 -5
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
- package/v2Containers/Zalo/index.js +4 -1
- package/v2Components/CapMpushCTA/tests/index.test.js +0 -89
- /package/{v2Components/FormBuilder/Functional/tests/fixtures/mpushInitialSchema.js → v2Containers/MobilePush/initialSchema.js} +0 -0
|
@@ -15,6 +15,7 @@ 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";
|
|
@@ -35,10 +36,10 @@ import {
|
|
|
35
36
|
GIF,
|
|
36
37
|
IMAGE,
|
|
37
38
|
VIDEO,
|
|
39
|
+
LINK_TYPE_OPTIONS,
|
|
38
40
|
DEEP_LINK,
|
|
39
41
|
EXTERNAL_LINK,
|
|
40
42
|
CAROUSEL,
|
|
41
|
-
TAP_ACTION_APP,
|
|
42
43
|
} from "../constants";
|
|
43
44
|
import messages from "../messages";
|
|
44
45
|
import { validateExternalLink, validateDeepLink } from "../utils";
|
|
@@ -120,8 +121,6 @@ const MediaUploaders = ({
|
|
|
120
121
|
// Track upload ID to prevent processing stale Redux data
|
|
121
122
|
const [currentUploadId, setCurrentUploadId] = useState(null);
|
|
122
123
|
const uploadIdRef = useRef(0); // Counter for generating unique upload IDs
|
|
123
|
-
// Card whose video Re upload was clicked (its file input may belong to another card)
|
|
124
|
-
const reuploadCardRef = useRef(null);
|
|
125
124
|
|
|
126
125
|
// Track previous upload data to detect when a new upload completes
|
|
127
126
|
const previousUploadDataRef = useRef(null);
|
|
@@ -166,12 +165,8 @@ const MediaUploaders = ({
|
|
|
166
165
|
};
|
|
167
166
|
}, [getCurrentCarouselData, updateCarouselCard]);
|
|
168
167
|
|
|
169
|
-
// Clear previous media data when
|
|
170
|
-
// Skip re-runs from a tab switch: both panes stay mounted, and the
|
|
171
|
-
// hidden one must not wipe the visible tab's media.
|
|
168
|
+
// Clear previous media data when switching media types
|
|
172
169
|
useEffect(() => {
|
|
173
|
-
if (previousMediaTypeRef.current === mediaType) return;
|
|
174
|
-
|
|
175
170
|
// Clear carousel data when switching to non-carousel media types
|
|
176
171
|
if (mediaType !== CAROUSEL) {
|
|
177
172
|
setCurrentCarouselData([]);
|
|
@@ -183,15 +178,15 @@ const MediaUploaders = ({
|
|
|
183
178
|
previousUploadDataRef.current = null;
|
|
184
179
|
}
|
|
185
180
|
|
|
186
|
-
// Clear image data when switching away from IMAGE media type
|
|
181
|
+
// Clear image data when switching away from IMAGE media type
|
|
187
182
|
if (mediaType !== IMAGE) {
|
|
188
|
-
clearImageDataByMediaType(IMAGE
|
|
183
|
+
clearImageDataByMediaType(IMAGE);
|
|
189
184
|
}
|
|
190
185
|
|
|
191
186
|
// Clear image data when switching FROM CAROUSEL TO IMAGE
|
|
192
187
|
// This prevents carousel images from appearing in IMAGE media type
|
|
193
188
|
if (previousMediaTypeRef.current === CAROUSEL && mediaType === IMAGE) {
|
|
194
|
-
clearImageDataByMediaType(IMAGE
|
|
189
|
+
clearImageDataByMediaType(IMAGE);
|
|
195
190
|
}
|
|
196
191
|
|
|
197
192
|
// Reset re-upload mode when switching media types
|
|
@@ -199,7 +194,7 @@ const MediaUploaders = ({
|
|
|
199
194
|
|
|
200
195
|
// Update the previous media type ref
|
|
201
196
|
previousMediaTypeRef.current = mediaType;
|
|
202
|
-
}, [mediaType,
|
|
197
|
+
}, [mediaType, clearImageDataByMediaType, setCurrentCarouselData]);
|
|
203
198
|
|
|
204
199
|
// Handle platform tab changes for carousel data
|
|
205
200
|
useEffect(() => {
|
|
@@ -374,7 +369,6 @@ const MediaUploaders = ({
|
|
|
374
369
|
mediaType: value,
|
|
375
370
|
imageUrl: value === IMAGE.toLowerCase() ? card.imageUrl : '',
|
|
376
371
|
videoSrc: value === VIDEO.toLowerCase() ? card.videoSrc : '',
|
|
377
|
-
videoPreviewImg: value === VIDEO.toLowerCase() ? card.videoPreviewImg : '',
|
|
378
372
|
buttons: card.buttons || [{
|
|
379
373
|
actionOnClick: false,
|
|
380
374
|
linkType: DEEP_LINK,
|
|
@@ -388,20 +382,13 @@ const MediaUploaders = ({
|
|
|
388
382
|
setCarouselActiveTabIndex(Number(key));
|
|
389
383
|
};
|
|
390
384
|
|
|
391
|
-
// A card is done once its image or video is uploaded
|
|
392
|
-
const hasCardWithoutMedia = getCurrentCarouselData()?.some((card) => (
|
|
393
|
-
card?.mediaType === VIDEO.toLowerCase() ? !card?.videoSrc : !card?.imageUrl
|
|
394
|
-
));
|
|
395
|
-
|
|
396
385
|
const addCarouselCard = () => {
|
|
397
386
|
const currentData = getCurrentCarouselData();
|
|
398
|
-
if (currentData?.length < MAX_CAROUSEL_ALLOWED
|
|
387
|
+
if (currentData?.length < MAX_CAROUSEL_ALLOWED) {
|
|
399
388
|
setCurrentCarouselData([
|
|
400
389
|
...currentData,
|
|
401
390
|
{ ...CAROUSEL_INITIAL_DATA, mediaType: carouselMediaType },
|
|
402
391
|
]);
|
|
403
|
-
// Open the new card so its upload box is in view
|
|
404
|
-
setCarouselActiveTabIndex(currentData.length);
|
|
405
392
|
}
|
|
406
393
|
};
|
|
407
394
|
|
|
@@ -451,30 +438,28 @@ const MediaUploaders = ({
|
|
|
451
438
|
}, 100);
|
|
452
439
|
};
|
|
453
440
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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
|
+
};
|
|
459
449
|
|
|
460
|
-
|
|
461
|
-
const handleCarouselTapActionChange = (cardIndex, value) => {
|
|
450
|
+
const handleCarouselLinkTypeChange = (cardIndex, value) => {
|
|
462
451
|
const currentData = getCurrentCarouselData();
|
|
463
452
|
const card = currentData[cardIndex];
|
|
464
|
-
const button = card?.buttons?.[0];
|
|
465
|
-
const currentValue = button?.actionOnClick ? (button?.linkType || DEEP_LINK) : TAP_ACTION_APP;
|
|
466
|
-
if (value === currentValue) return;
|
|
467
|
-
const isApp = value === TAP_ACTION_APP;
|
|
468
453
|
const updatedButtons = [...card?.buttons];
|
|
469
|
-
updatedButtons[0] = {
|
|
470
|
-
...
|
|
471
|
-
|
|
472
|
-
linkType: isApp ? DEEP_LINK : value,
|
|
454
|
+
updatedButtons[0] = {
|
|
455
|
+
...updatedButtons[0],
|
|
456
|
+
linkType: value,
|
|
473
457
|
deepLinkValue: '',
|
|
474
458
|
externalLinkValue: '',
|
|
475
|
-
deepLinkKeys: []
|
|
459
|
+
deepLinkKeys: []
|
|
476
460
|
};
|
|
477
461
|
updateCarouselCard(cardIndex, { buttons: updatedButtons });
|
|
462
|
+
// Clear errors when link type changes
|
|
478
463
|
updateCarouselLinkError(cardIndex, 'deepLink', null);
|
|
479
464
|
updateCarouselLinkError(cardIndex, 'externalLink', null);
|
|
480
465
|
updateCarouselLinkError(cardIndex, 'deepLinkKeys', null);
|
|
@@ -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,137 +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
|
-
const showDeepLinkKeys = tapAction === DEEP_LINK && button?.deepLinkValue && keysFromSelection.length > 0;
|
|
639
|
-
|
|
640
591
|
return (
|
|
641
592
|
<>
|
|
642
593
|
<CapDivider />
|
|
643
594
|
<CapRow useLegacy className="creatives-mpush-actions">
|
|
644
|
-
<CapRow
|
|
595
|
+
<CapRow useLegacy className="mpush-actions-main">
|
|
645
596
|
<CapHeading type="h4" className="mpush-actions">
|
|
646
|
-
<FormattedMessage {...messages.
|
|
597
|
+
<FormattedMessage {...messages.buttonsAndLinks} />
|
|
647
598
|
</CapHeading>
|
|
648
599
|
<CapLabel className="optional-text">
|
|
649
600
|
<FormattedMessage {...messages.optionalText} />
|
|
650
601
|
</CapLabel>
|
|
651
602
|
</CapRow>
|
|
652
|
-
<
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
<CapColumn flex="1 1 0" className="mpush-tap-link">
|
|
670
|
-
<CapHeading type="h4" className="mpush-tap-label">
|
|
671
|
-
<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} />
|
|
672
620
|
</CapHeading>
|
|
673
621
|
<CapSelect.CapCustomSelect
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
if (button?.deepLinkValue && !options.find((opt) => opt.value === button?.deepLinkValue)) {
|
|
679
|
-
options.push({
|
|
680
|
-
value: button?.deepLinkValue,
|
|
681
|
-
label: button?.deepLinkValue,
|
|
682
|
-
});
|
|
683
|
-
}
|
|
684
|
-
return options;
|
|
685
|
-
})()}
|
|
686
|
-
value={button?.deepLinkValue}
|
|
687
|
-
onChange={(value) => handleCarouselDeepLinkChange(cardIndex, value)}
|
|
688
|
-
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}`}
|
|
689
626
|
selectPlaceholder={formatMessage(messages.selectDeepLink)}
|
|
690
627
|
/>
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
<
|
|
698
|
-
|
|
699
|
-
|
|
628
|
+
</CapColumn>
|
|
629
|
+
{button?.linkType === DEEP_LINK && (
|
|
630
|
+
<CapColumn span={14}>
|
|
631
|
+
<CapHeading type="h4" className="buttons-heading">
|
|
632
|
+
{formatMessage(messages.deepLink)}
|
|
633
|
+
</CapHeading>
|
|
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" }}
|
|
651
|
+
/>
|
|
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)}
|
|
700
664
|
</CapHeading>
|
|
701
|
-
<
|
|
702
|
-
{
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
style={{ marginTop: "10px" }}
|
|
713
|
-
error={carouselLinkErrors[`${cardIndex}-deepLinkKeys`]}
|
|
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}
|
|
714
676
|
/>
|
|
715
677
|
</CapRow>
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
<FormattedMessage {...messages.url} />
|
|
724
|
-
</CapHeading>
|
|
725
|
-
<TagList
|
|
726
|
-
moduleFilterEnabled={
|
|
727
|
-
location?.query?.type !== "embedded"
|
|
728
|
-
}
|
|
729
|
-
label={formatMessage(messages.addLabels)}
|
|
730
|
-
onTagSelect={onButtonTagSelect}
|
|
731
|
-
onContextChange={handleOnTagsContextChange}
|
|
732
|
-
location={location}
|
|
733
|
-
tags={tags}
|
|
734
|
-
injectedTags={injectedTags}
|
|
735
|
-
selectedOfferDetails={selectedOfferDetails}
|
|
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
|
|
736
685
|
/>
|
|
737
|
-
|
|
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>
|
|
738
736
|
<CapInput
|
|
739
|
-
id={`mobile-push-
|
|
740
|
-
onChange={(e) =>
|
|
741
|
-
placeholder={formatMessage(messages.
|
|
742
|
-
|
|
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 || "")}
|
|
743
753
|
size="default"
|
|
744
|
-
|
|
754
|
+
style={{ marginTop: "10px" }}
|
|
755
|
+
error={carouselLinkErrors[`${cardIndex}-deepLinkKeys`]}
|
|
745
756
|
/>
|
|
746
|
-
{carouselLinkErrors[`${cardIndex}-externalLink`] && (
|
|
747
|
-
<CapError className="mobile-push-carousel-external-link-error">
|
|
748
|
-
{carouselLinkErrors[`${cardIndex}-externalLink`]}
|
|
749
|
-
</CapError>
|
|
750
|
-
)}
|
|
751
757
|
</CapColumn>
|
|
752
|
-
|
|
753
|
-
</CapRow>
|
|
754
|
-
{tapAction === TAP_ACTION_APP && (
|
|
755
|
-
<CapLabel className="mpush-tap-description mpush-tap-help">
|
|
756
|
-
<FormattedMessage {...messages.cardTapAppHelp} />
|
|
757
|
-
</CapLabel>
|
|
758
|
+
</CapRow>
|
|
758
759
|
)}
|
|
759
760
|
</CapRow>
|
|
760
761
|
</>
|
|
@@ -810,7 +811,7 @@ const MediaUploaders = ({
|
|
|
810
811
|
onClick={addCarouselCard}
|
|
811
812
|
type="link"
|
|
812
813
|
className="add-carousel-content-button"
|
|
813
|
-
disabled={getCurrentCarouselData()?.length >= MAX_CAROUSEL_ALLOWED
|
|
814
|
+
disabled={getCurrentCarouselData()?.length >= MAX_CAROUSEL_ALLOWED}
|
|
814
815
|
>
|
|
815
816
|
<CapIcon type="plus" />
|
|
816
817
|
</CapButton>
|
|
@@ -838,6 +839,7 @@ const MediaUploaders = ({
|
|
|
838
839
|
{
|
|
839
840
|
value: VIDEO.toLowerCase(),
|
|
840
841
|
label: formatMessage(messages.mediaVideo),
|
|
842
|
+
disabled: true,
|
|
841
843
|
},
|
|
842
844
|
]}
|
|
843
845
|
value={carouselMediaType}
|
|
@@ -891,16 +893,8 @@ const MediaUploaders = ({
|
|
|
891
893
|
const previousDataKey = previousUploadDataRef.current;
|
|
892
894
|
|
|
893
895
|
if (currentDataKey !== previousDataKey) {
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
video_file_path_preview: videoPreview = '',
|
|
897
|
-
preview_image_url: previewImage = '',
|
|
898
|
-
} = uploadedData.metaInfo;
|
|
899
|
-
const isVideoCard = getCurrentCarouselData()?.[uploadingCardIndex]?.mediaType === VIDEO.toLowerCase();
|
|
900
|
-
// Update the specific card that was uploading (videoPreviewImg is what the phone preview shows)
|
|
901
|
-
updateCarouselCard(uploadingCardIndex, isVideoCard
|
|
902
|
-
? { videoSrc: filePath, videoPreviewImg: videoPreview || previewImage }
|
|
903
|
-
: { imageUrl: filePath });
|
|
896
|
+
// Update the specific card that was uploading
|
|
897
|
+
updateCarouselCard(uploadingCardIndex, { imageUrl: uploadedData?.metaInfo?.secure_file_path });
|
|
904
898
|
|
|
905
899
|
// Store this upload data as "processed" to avoid reprocessing
|
|
906
900
|
previousUploadDataRef.current = currentDataKey;
|
|
@@ -911,16 +905,7 @@ const MediaUploaders = ({
|
|
|
911
905
|
}
|
|
912
906
|
}
|
|
913
907
|
}
|
|
914
|
-
}, [mediaType, imageData, uploadingCardIndex, currentUploadId, activeTab, updateCarouselCard
|
|
915
|
-
|
|
916
|
-
// Editing a saved video carousel: show video boxes, not the default image ones
|
|
917
|
-
useEffect(() => {
|
|
918
|
-
const savedCardType = carouselData?.[0]?.mediaType;
|
|
919
|
-
if (mediaType === CAROUSEL && savedCardType && savedCardType !== carouselMediaType) {
|
|
920
|
-
setCarouselMediaType(savedCardType);
|
|
921
|
-
}
|
|
922
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
923
|
-
}, [mediaType, carouselData]);
|
|
908
|
+
}, [mediaType, imageData, uploadingCardIndex, currentUploadId, activeTab, updateCarouselCard]);
|
|
924
909
|
|
|
925
910
|
if (mediaType === IMAGE) return renderImageComponent();
|
|
926
911
|
if (mediaType === VIDEO) return renderVideoComponent();
|