@capillarytech/creatives-library 9.1.7 → 9.1.8-alpha.sprint-cap-214249.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants/unified.js +0 -1
- package/index.js +0 -13
- package/package.json +1 -1
- package/services/getSchema.js +1 -4
- package/services/tests/getSchema.test.js +2 -2
- package/utils/common.js +0 -6
- package/utils/createMobilePushPayload.js +47 -33
- package/utils/tests/createMobilePushPayload.test.js +102 -8
- package/v2Components/CapMpushCTA/index.js +10 -9
- package/v2Components/CapMpushCTA/index.scss +29 -3
- package/v2Components/CapMpushCTA/tests/index.test.js +89 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +26 -13
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +13 -1
- package/v2Components/CommonTestAndPreview/constants.js +2 -0
- package/v2Components/CommonTestAndPreview/index.js +49 -11
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +79 -5
- package/v2Components/CommonTestAndPreview/tests/index.test.js +86 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.crossFlowParity.test.js +1 -1
- 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/tests/mpush.characterization.test.js +2 -2
- package/v2Components/TemplatePreview/_templatePreview.scss +12 -2
- package/v2Components/TemplatePreview/index.js +30 -17
- package/v2Components/TemplatePreview/tests/index.test.js +61 -0
- package/v2Containers/Cap/index.js +0 -3
- package/v2Containers/CreativesContainer/SlideBoxContent.js +70 -151
- package/v2Containers/CreativesContainer/index.js +3 -6
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +29 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +207 -192
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +116 -121
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +30 -208
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +316 -72
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +45 -16
- package/v2Containers/MobilePushNew/constants.js +5 -0
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +52 -0
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +38 -1
- package/v2Containers/MobilePushNew/hooks/useUpload.js +29 -39
- package/v2Containers/MobilePushNew/index.js +453 -188
- package/v2Containers/MobilePushNew/index.scss +188 -4
- package/v2Containers/MobilePushNew/messages.js +86 -6
- package/v2Containers/MobilePushNew/tests/index.test.js +450 -1
- package/v2Containers/MobilePushNew/tests/utils.test.js +25 -0
- package/v2Containers/MobilePushNew/utils.js +8 -0
- package/v2Containers/Templates/_templates.scss +10 -2
- package/v2Containers/Templates/index.js +84 -90
- package/v2Containers/Templates/tests/index.test.js +68 -0
- package/v2Components/FormBuilder/Functional/tests/manual.typingPerf.test.js +0 -135
- package/v2Components/FormBuilder/Functional/tests/mpush.ctaFlows.parity.test.js +0 -320
- package/v2Components/FormBuilder/Functional/tests/mpush.editContainer.parity.test.js +0 -148
- package/v2Components/FormBuilder/Functional/tests/mpush.libraryValidity.parity.test.js +0 -152
- package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +0 -70
- package/v2Containers/MobilePush/Create/actions.js +0 -52
- package/v2Containers/MobilePush/Create/constants.js +0 -26
- package/v2Containers/MobilePush/Create/index.js +0 -2149
- package/v2Containers/MobilePush/Create/messages.js +0 -349
- package/v2Containers/MobilePush/Create/reducer.js +0 -72
- package/v2Containers/MobilePush/Create/sagas.js +0 -79
- package/v2Containers/MobilePush/Create/selectors.js +0 -29
- package/v2Containers/MobilePush/Create/test/contentValidity.test.js +0 -154
- package/v2Containers/MobilePush/Create/test/saga.test.js +0 -19
- package/v2Containers/MobilePush/Create/test/stayOpenOnSave.test.js +0 -80
- package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +0 -65
- package/v2Containers/MobilePush/Edit/actions.js +0 -94
- package/v2Containers/MobilePush/Edit/constants.js +0 -37
- package/v2Containers/MobilePush/Edit/index.js +0 -2407
- package/v2Containers/MobilePush/Edit/messages.js +0 -341
- package/v2Containers/MobilePush/Edit/reducer.js +0 -113
- package/v2Containers/MobilePush/Edit/sagas.js +0 -113
- package/v2Containers/MobilePush/Edit/selectors.js +0 -33
- package/v2Containers/MobilePush/Edit/test/contentValidity.test.js +0 -149
- package/v2Containers/MobilePush/Edit/test/saga.test.js +0 -255
- package/v2Containers/MobilePush/Edit/test/stayOpenOnSave.test.js +0 -60
- package/v2Containers/MobilePush/commonMethods.js +0 -333
- package/v2Containers/MobilePush/eventsMap.js +0 -130
- package/v2Containers/MobilePush/tests/commonMethods.test.js +0 -401
- package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +0 -22
- package/v2Containers/MobilepushWrapper/index.js +0 -178
- package/v2Containers/MobilepushWrapper/messages.js +0 -29
- /package/{v2Containers/MobilePush/initialSchema.js → v2Components/FormBuilder/Functional/tests/fixtures/mpushInitialSchema.js} +0 -0
|
@@ -15,7 +15,6 @@ 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";
|
|
19
18
|
import CapLabel from "@capillarytech/cap-ui-library/CapLabel";
|
|
20
19
|
import CapSelect from "@capillarytech/cap-ui-library/CapSelect";
|
|
21
20
|
import CapInput from "@capillarytech/cap-ui-library/CapInput";
|
|
@@ -36,10 +35,10 @@ import {
|
|
|
36
35
|
GIF,
|
|
37
36
|
IMAGE,
|
|
38
37
|
VIDEO,
|
|
39
|
-
LINK_TYPE_OPTIONS,
|
|
40
38
|
DEEP_LINK,
|
|
41
39
|
EXTERNAL_LINK,
|
|
42
40
|
CAROUSEL,
|
|
41
|
+
TAP_ACTION_APP,
|
|
43
42
|
} from "../constants";
|
|
44
43
|
import messages from "../messages";
|
|
45
44
|
import { validateExternalLink, validateDeepLink } from "../utils";
|
|
@@ -121,6 +120,8 @@ const MediaUploaders = ({
|
|
|
121
120
|
// Track upload ID to prevent processing stale Redux data
|
|
122
121
|
const [currentUploadId, setCurrentUploadId] = useState(null);
|
|
123
122
|
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);
|
|
124
125
|
|
|
125
126
|
// Track previous upload data to detect when a new upload completes
|
|
126
127
|
const previousUploadDataRef = useRef(null);
|
|
@@ -165,8 +166,12 @@ const MediaUploaders = ({
|
|
|
165
166
|
};
|
|
166
167
|
}, [getCurrentCarouselData, updateCarouselCard]);
|
|
167
168
|
|
|
168
|
-
// Clear previous media data when
|
|
169
|
+
// Clear previous media data when this pane's media type changes.
|
|
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.
|
|
169
172
|
useEffect(() => {
|
|
173
|
+
if (previousMediaTypeRef.current === mediaType) return;
|
|
174
|
+
|
|
170
175
|
// Clear carousel data when switching to non-carousel media types
|
|
171
176
|
if (mediaType !== CAROUSEL) {
|
|
172
177
|
setCurrentCarouselData([]);
|
|
@@ -178,15 +183,15 @@ const MediaUploaders = ({
|
|
|
178
183
|
previousUploadDataRef.current = null;
|
|
179
184
|
}
|
|
180
185
|
|
|
181
|
-
// Clear image data when switching away from IMAGE media type
|
|
186
|
+
// Clear image data when switching away from IMAGE media type (this pane's platform only)
|
|
182
187
|
if (mediaType !== IMAGE) {
|
|
183
|
-
clearImageDataByMediaType(IMAGE);
|
|
188
|
+
clearImageDataByMediaType(IMAGE, activeTab);
|
|
184
189
|
}
|
|
185
190
|
|
|
186
191
|
// Clear image data when switching FROM CAROUSEL TO IMAGE
|
|
187
192
|
// This prevents carousel images from appearing in IMAGE media type
|
|
188
193
|
if (previousMediaTypeRef.current === CAROUSEL && mediaType === IMAGE) {
|
|
189
|
-
clearImageDataByMediaType(IMAGE);
|
|
194
|
+
clearImageDataByMediaType(IMAGE, activeTab);
|
|
190
195
|
}
|
|
191
196
|
|
|
192
197
|
// Reset re-upload mode when switching media types
|
|
@@ -194,7 +199,7 @@ const MediaUploaders = ({
|
|
|
194
199
|
|
|
195
200
|
// Update the previous media type ref
|
|
196
201
|
previousMediaTypeRef.current = mediaType;
|
|
197
|
-
}, [mediaType, clearImageDataByMediaType, setCurrentCarouselData]);
|
|
202
|
+
}, [mediaType, activeTab, clearImageDataByMediaType, setCurrentCarouselData]);
|
|
198
203
|
|
|
199
204
|
// Handle platform tab changes for carousel data
|
|
200
205
|
useEffect(() => {
|
|
@@ -369,6 +374,7 @@ const MediaUploaders = ({
|
|
|
369
374
|
mediaType: value,
|
|
370
375
|
imageUrl: value === IMAGE.toLowerCase() ? card.imageUrl : '',
|
|
371
376
|
videoSrc: value === VIDEO.toLowerCase() ? card.videoSrc : '',
|
|
377
|
+
videoPreviewImg: value === VIDEO.toLowerCase() ? card.videoPreviewImg : '',
|
|
372
378
|
buttons: card.buttons || [{
|
|
373
379
|
actionOnClick: false,
|
|
374
380
|
linkType: DEEP_LINK,
|
|
@@ -382,13 +388,20 @@ const MediaUploaders = ({
|
|
|
382
388
|
setCarouselActiveTabIndex(Number(key));
|
|
383
389
|
};
|
|
384
390
|
|
|
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
|
+
|
|
385
396
|
const addCarouselCard = () => {
|
|
386
397
|
const currentData = getCurrentCarouselData();
|
|
387
|
-
if (currentData?.length < MAX_CAROUSEL_ALLOWED) {
|
|
398
|
+
if (currentData?.length < MAX_CAROUSEL_ALLOWED && !hasCardWithoutMedia) {
|
|
388
399
|
setCurrentCarouselData([
|
|
389
400
|
...currentData,
|
|
390
401
|
{ ...CAROUSEL_INITIAL_DATA, mediaType: carouselMediaType },
|
|
391
402
|
]);
|
|
403
|
+
// Open the new card so its upload box is in view
|
|
404
|
+
setCarouselActiveTabIndex(currentData.length);
|
|
392
405
|
}
|
|
393
406
|
};
|
|
394
407
|
|
|
@@ -438,28 +451,30 @@ const MediaUploaders = ({
|
|
|
438
451
|
}, 100);
|
|
439
452
|
};
|
|
440
453
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
updatedButtons[0] = { ...updatedButtons[0], actionOnClick: checked };
|
|
447
|
-
updateCarouselCard(cardIndex, { buttons: updatedButtons });
|
|
448
|
-
};
|
|
454
|
+
const tapActionOptions = [
|
|
455
|
+
{ label: formatMessage(messages.tapActionApp), value: TAP_ACTION_APP },
|
|
456
|
+
{ label: formatMessage(messages.tapActionDeepLink), value: DEEP_LINK },
|
|
457
|
+
{ label: formatMessage(messages.tapActionExternalLink), value: EXTERNAL_LINK },
|
|
458
|
+
];
|
|
449
459
|
|
|
450
|
-
|
|
460
|
+
// "When tapped, open" for a card: App turns the card action off, a link type turns it on
|
|
461
|
+
const handleCarouselTapActionChange = (cardIndex, value) => {
|
|
451
462
|
const currentData = getCurrentCarouselData();
|
|
452
463
|
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;
|
|
453
468
|
const updatedButtons = [...card?.buttons];
|
|
454
|
-
updatedButtons[0] = {
|
|
455
|
-
...
|
|
456
|
-
|
|
469
|
+
updatedButtons[0] = {
|
|
470
|
+
...button,
|
|
471
|
+
actionOnClick: !isApp,
|
|
472
|
+
linkType: isApp ? DEEP_LINK : value,
|
|
457
473
|
deepLinkValue: '',
|
|
458
474
|
externalLinkValue: '',
|
|
459
|
-
deepLinkKeys: []
|
|
475
|
+
deepLinkKeys: [],
|
|
460
476
|
};
|
|
461
477
|
updateCarouselCard(cardIndex, { buttons: updatedButtons });
|
|
462
|
-
// Clear errors when link type changes
|
|
463
478
|
updateCarouselLinkError(cardIndex, 'deepLink', null);
|
|
464
479
|
updateCarouselLinkError(cardIndex, 'externalLink', null);
|
|
465
480
|
updateCarouselLinkError(cardIndex, 'deepLinkKeys', null);
|
|
@@ -554,25 +569,50 @@ const MediaUploaders = ({
|
|
|
554
569
|
);
|
|
555
570
|
};
|
|
556
571
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
572
|
+
// Called by the box as (index, data): Re upload passes an empty videoSrc
|
|
573
|
+
const handleCarouselVideoChange = (cardIndex, data = {}) => {
|
|
574
|
+
const { videoSrc = '', previewUrl = '' } = data;
|
|
575
|
+
if (!videoSrc) {
|
|
576
|
+
// Re upload clicks the page's first "videoFileName" input, which may be another card's
|
|
577
|
+
reuploadCardRef.current = cardIndex;
|
|
578
|
+
}
|
|
579
|
+
updateCarouselCard(cardIndex, { videoSrc, videoPreviewImg: videoSrc ? previewUrl : '' });
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
const renderCarouselVideoComponent = (cardIndex) => {
|
|
583
|
+
const card = getCurrentCarouselData()?.[cardIndex];
|
|
584
|
+
|
|
585
|
+
// Track the uploading card; the completion effect below writes the result into it
|
|
586
|
+
const handleCarouselVideoUpload = (file, assetType, fileParams, index) => {
|
|
587
|
+
const targetCard = reuploadCardRef.current ?? cardIndex;
|
|
588
|
+
reuploadCardRef.current = null;
|
|
589
|
+
uploadIdRef.current += 1;
|
|
590
|
+
setUploadingCardIndex(targetCard);
|
|
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
|
+
};
|
|
576
616
|
|
|
577
617
|
const renderCarouselActionLinks = (cardIndex) => {
|
|
578
618
|
const currentData = getCurrentCarouselData();
|
|
@@ -584,178 +624,137 @@ const MediaUploaders = ({
|
|
|
584
624
|
}
|
|
585
625
|
|
|
586
626
|
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;
|
|
587
628
|
|
|
588
629
|
// Use the callback creator instead of useCallback inside render function
|
|
589
630
|
const onButtonTagSelect = createCarouselButtonTagSelectCallback(cardIndex);
|
|
590
631
|
|
|
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
|
+
|
|
591
640
|
return (
|
|
592
641
|
<>
|
|
593
642
|
<CapDivider />
|
|
594
643
|
<CapRow useLegacy className="creatives-mpush-actions">
|
|
595
|
-
<CapRow
|
|
644
|
+
<CapRow type="flex" align="middle" noWrap className="mpush-section-heading">
|
|
596
645
|
<CapHeading type="h4" className="mpush-actions">
|
|
597
|
-
<FormattedMessage {...messages.
|
|
646
|
+
<FormattedMessage {...messages.cardTap} />
|
|
598
647
|
</CapHeading>
|
|
599
648
|
<CapLabel className="optional-text">
|
|
600
649
|
<FormattedMessage {...messages.optionalText} />
|
|
601
650
|
</CapLabel>
|
|
602
651
|
</CapRow>
|
|
603
|
-
<
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
652
|
+
<CapLabel className="mpush-tap-description">
|
|
653
|
+
<FormattedMessage {...messages.cardTapDescription} />
|
|
654
|
+
</CapLabel>
|
|
655
|
+
<CapRow type="flex" noWrap gap={16} className="mpush-tap-row">
|
|
656
|
+
<CapColumn flex="0 0 30%" className="mpush-tap-action">
|
|
657
|
+
<CapHeading type="h4" className="mpush-tap-label">
|
|
658
|
+
<FormattedMessage {...messages.whenTappedOpen} />
|
|
659
|
+
</CapHeading>
|
|
660
|
+
<CapSelect.CapCustomSelect
|
|
661
|
+
id={`mobile-push-carousel-tap-action-${activeTab}-${cardIndex}`}
|
|
662
|
+
width="100%"
|
|
663
|
+
options={tapActionOptions}
|
|
664
|
+
value={tapAction}
|
|
665
|
+
onChange={(value) => handleCarouselTapActionChange(cardIndex, value)}
|
|
666
|
+
/>
|
|
667
|
+
</CapColumn>
|
|
668
|
+
{tapAction === DEEP_LINK && (
|
|
669
|
+
<CapColumn flex="1 1 0" className="mpush-tap-link">
|
|
670
|
+
<CapHeading type="h4" className="mpush-tap-label">
|
|
671
|
+
<FormattedMessage {...messages.tapActionDeepLink} />
|
|
620
672
|
</CapHeading>
|
|
621
673
|
<CapSelect.CapCustomSelect
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
674
|
+
width="100%"
|
|
675
|
+
options={(() => {
|
|
676
|
+
const options = [...(deepLink || [])];
|
|
677
|
+
// If the current value is not in the options, add it
|
|
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}`}
|
|
626
689
|
selectPlaceholder={formatMessage(messages.selectDeepLink)}
|
|
627
690
|
/>
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
<
|
|
635
|
-
|
|
636
|
-
|
|
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)}
|
|
691
|
+
{carouselLinkErrors[`${cardIndex}-deepLink`] && (
|
|
692
|
+
<CapError className="mobile-push-carousel-deep-link-error">
|
|
693
|
+
{carouselLinkErrors[`${cardIndex}-deepLink`]}
|
|
694
|
+
</CapError>
|
|
695
|
+
)}
|
|
696
|
+
{showDeepLinkKeys && (
|
|
697
|
+
<CapRow className="mpush-tap-deep-link-keys">
|
|
698
|
+
<CapHeading type="h4" className="deep-link-keys-heading">
|
|
699
|
+
{formatMessage(messages.deepLinkKeys)}
|
|
664
700
|
</CapHeading>
|
|
665
|
-
<
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
701
|
+
<CapLabel type="label2" className="deep-link-keys-value">
|
|
702
|
+
{(keysFromSelection.length > 0 ? keysFromSelection : savedKeys).join(', ')}
|
|
703
|
+
</CapLabel>
|
|
704
|
+
<CapInput
|
|
705
|
+
id={`mobile-push-carousel-deep-link-keys-input-${activeTab}-${cardIndex}`}
|
|
706
|
+
onChange={(e) => handleCarouselDeepLinkKeysChange(cardIndex, e.target.value)}
|
|
707
|
+
placeholder={formatMessage(messages.deepLinkKeysPlaceholder, {
|
|
708
|
+
key: keysFromSelection.join(', ') || 'deep link keys',
|
|
709
|
+
})}
|
|
710
|
+
value={savedKeys.join(', ')}
|
|
711
|
+
size="default"
|
|
712
|
+
style={{ marginTop: "10px" }}
|
|
713
|
+
error={carouselLinkErrors[`${cardIndex}-deepLinkKeys`]}
|
|
676
714
|
/>
|
|
677
715
|
</CapRow>
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
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(', ');
|
|
716
|
+
)}
|
|
717
|
+
</CapColumn>
|
|
718
|
+
)}
|
|
719
|
+
{tapAction === EXTERNAL_LINK && (
|
|
720
|
+
<CapColumn flex="1 1 0" className="mpush-tap-link">
|
|
721
|
+
<CapRow type="flex" align="middle" justify="space-between" noWrap className="mpush-tap-link-header">
|
|
722
|
+
<CapHeading type="h4" className="mpush-tap-label">
|
|
723
|
+
<FormattedMessage {...messages.url} />
|
|
724
|
+
</CapHeading>
|
|
725
|
+
<TagList
|
|
726
|
+
moduleFilterEnabled={
|
|
727
|
+
location?.query?.type !== "embedded"
|
|
733
728
|
}
|
|
734
|
-
|
|
735
|
-
|
|
729
|
+
label={formatMessage(messages.addLabels)}
|
|
730
|
+
onTagSelect={onButtonTagSelect}
|
|
731
|
+
onContextChange={handleOnTagsContextChange}
|
|
732
|
+
location={location}
|
|
733
|
+
tags={tags}
|
|
734
|
+
injectedTags={injectedTags}
|
|
735
|
+
selectedOfferDetails={selectedOfferDetails}
|
|
736
|
+
/>
|
|
737
|
+
</CapRow>
|
|
736
738
|
<CapInput
|
|
737
|
-
id={`mobile-push-
|
|
738
|
-
onChange={(e) =>
|
|
739
|
-
placeholder={formatMessage(messages.
|
|
740
|
-
|
|
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 || "")}
|
|
739
|
+
id={`mobile-push-external-link-input-${activeTab}-${cardIndex}`}
|
|
740
|
+
onChange={(e) => handleCarouselExternalLinkChange(cardIndex, e.target.value)}
|
|
741
|
+
placeholder={formatMessage(messages.enterUrl)}
|
|
742
|
+
value={button?.externalLinkValue}
|
|
753
743
|
size="default"
|
|
754
|
-
|
|
755
|
-
error={carouselLinkErrors[`${cardIndex}-deepLinkKeys`]}
|
|
744
|
+
isRequired
|
|
756
745
|
/>
|
|
746
|
+
{carouselLinkErrors[`${cardIndex}-externalLink`] && (
|
|
747
|
+
<CapError className="mobile-push-carousel-external-link-error">
|
|
748
|
+
{carouselLinkErrors[`${cardIndex}-externalLink`]}
|
|
749
|
+
</CapError>
|
|
750
|
+
)}
|
|
757
751
|
</CapColumn>
|
|
758
|
-
|
|
752
|
+
)}
|
|
753
|
+
</CapRow>
|
|
754
|
+
{tapAction === TAP_ACTION_APP && (
|
|
755
|
+
<CapLabel className="mpush-tap-description mpush-tap-help">
|
|
756
|
+
<FormattedMessage {...messages.cardTapAppHelp} />
|
|
757
|
+
</CapLabel>
|
|
759
758
|
)}
|
|
760
759
|
</CapRow>
|
|
761
760
|
</>
|
|
@@ -811,7 +810,7 @@ const MediaUploaders = ({
|
|
|
811
810
|
onClick={addCarouselCard}
|
|
812
811
|
type="link"
|
|
813
812
|
className="add-carousel-content-button"
|
|
814
|
-
disabled={getCurrentCarouselData()?.length >= MAX_CAROUSEL_ALLOWED}
|
|
813
|
+
disabled={getCurrentCarouselData()?.length >= MAX_CAROUSEL_ALLOWED || hasCardWithoutMedia}
|
|
815
814
|
>
|
|
816
815
|
<CapIcon type="plus" />
|
|
817
816
|
</CapButton>
|
|
@@ -839,7 +838,6 @@ const MediaUploaders = ({
|
|
|
839
838
|
{
|
|
840
839
|
value: VIDEO.toLowerCase(),
|
|
841
840
|
label: formatMessage(messages.mediaVideo),
|
|
842
|
-
disabled: true,
|
|
843
841
|
},
|
|
844
842
|
]}
|
|
845
843
|
value={carouselMediaType}
|
|
@@ -893,8 +891,16 @@ const MediaUploaders = ({
|
|
|
893
891
|
const previousDataKey = previousUploadDataRef.current;
|
|
894
892
|
|
|
895
893
|
if (currentDataKey !== previousDataKey) {
|
|
896
|
-
|
|
897
|
-
|
|
894
|
+
const {
|
|
895
|
+
secure_file_path: filePath,
|
|
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 });
|
|
898
904
|
|
|
899
905
|
// Store this upload data as "processed" to avoid reprocessing
|
|
900
906
|
previousUploadDataRef.current = currentDataKey;
|
|
@@ -905,7 +911,16 @@ const MediaUploaders = ({
|
|
|
905
911
|
}
|
|
906
912
|
}
|
|
907
913
|
}
|
|
908
|
-
}, [mediaType, imageData, uploadingCardIndex, currentUploadId, activeTab, updateCarouselCard]);
|
|
914
|
+
}, [mediaType, imageData, uploadingCardIndex, currentUploadId, activeTab, updateCarouselCard, getCurrentCarouselData]);
|
|
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]);
|
|
909
924
|
|
|
910
925
|
if (mediaType === IMAGE) return renderImageComponent();
|
|
911
926
|
if (mediaType === VIDEO) return renderVideoComponent();
|