@capillarytech/creatives-library 7.12.81 → 7.12.82
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/config/app.js +1 -0
- package/package.json +2 -1
- package/utils/cdnTransformation.js +155 -0
- package/v2Containers/CreativesContainer/index.js +18 -40
- package/v2Containers/Email/index.js +4 -2
- package/v2Containers/Facebook/Advertisement/index.js +3 -3
- package/v2Containers/Line/Container/Image/index.js +5 -4
- package/v2Containers/Line/Container/ImageCarousel/index.js +6 -5
- package/v2Containers/Line/Container/ImageMap/index.js +2 -1
- package/v2Containers/Line/Container/Video/index.js +7 -1
- package/v2Containers/MobilePush/Create/index.js +3 -2
- package/v2Containers/MobilePush/Edit/index.js +3 -2
- package/v2Containers/Rcs/index.js +4 -1
- package/v2Containers/Viber/index.js +10 -1
- package/v2Containers/Whatsapp/index.js +3 -1
package/config/app.js
CHANGED
|
@@ -16,6 +16,7 @@ const config = {
|
|
|
16
16
|
accountConfig: (strs, accountId) => `${window.location.origin}/org/config/AccountAdd?q=a&channelId=2&accountId=${accountId}&edit=1`,
|
|
17
17
|
},
|
|
18
18
|
development: {
|
|
19
|
+
// api_endpoint: 'http://localhost:2022/arya/api/v1/creatives',
|
|
19
20
|
api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
|
|
20
21
|
campaigns_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/campaigns',
|
|
21
22
|
campaigns_api_org_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/org/campaign',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capillarytech/creatives-library",
|
|
3
3
|
"author": "meharaj",
|
|
4
|
-
"version": "7.12.
|
|
4
|
+
"version": "7.12.82",
|
|
5
5
|
"description": "Capillary creatives ui",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"module": "./index.es.js",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"jest-date-mock": "^1.0.8",
|
|
25
25
|
"jquery": "^3.3.1",
|
|
26
26
|
"load-script": "^1.0.0",
|
|
27
|
+
"node-html-parser": "^5.3.3",
|
|
27
28
|
"normalizr": "^3.2.3",
|
|
28
29
|
"papaparse": "^5.3.1",
|
|
29
30
|
"pre-push": "^0.1.2",
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
2
|
+
/* eslint-disable no-unused-expressions */
|
|
3
|
+
import { parse } from 'node-html-parser';
|
|
4
|
+
|
|
5
|
+
// https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=100,height=100,quality=75,fit=cover,g=top,format=auto/intouch_creative_assets/005710a7-6412-44fe-a19f-e72456b1.jpg
|
|
6
|
+
|
|
7
|
+
const CDN_BASE_URL = `https://storage.crm.n.content-cdn.io`;
|
|
8
|
+
const CDN_TRANSFORMATION_URL_SUFFIX = `/cdn-cgi/image/`;
|
|
9
|
+
const QUALITY = 75;
|
|
10
|
+
// const regex = /https:\/\/.*intouch_creative_assets.*(?:jpg|png|jpeg|gif)$/;
|
|
11
|
+
const regex = /https:\/\/.*intouch_creative_assets.*$/;
|
|
12
|
+
const INTOUCH_CREATIVE_ASSETS = 'intouch_creative_assets';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* getCdnUrl : utility function to replace and return s3/cdn url with cdn url.
|
|
16
|
+
*/
|
|
17
|
+
export const getCdnUrl = ({url, height, width, transformationEnabled = false, reduceQuality = true}) => {
|
|
18
|
+
if (!url.includes(INTOUCH_CREATIVE_ASSETS)) return url;
|
|
19
|
+
|
|
20
|
+
const [, assetKey] = url.split(INTOUCH_CREATIVE_ASSETS);
|
|
21
|
+
let newUrl = `${CDN_BASE_URL}`;
|
|
22
|
+
if (transformationEnabled || reduceQuality) {
|
|
23
|
+
newUrl += CDN_TRANSFORMATION_URL_SUFFIX;
|
|
24
|
+
if (height) {
|
|
25
|
+
newUrl += `height=${height},`;
|
|
26
|
+
}
|
|
27
|
+
if (width) {
|
|
28
|
+
newUrl += `width=${width},`;
|
|
29
|
+
}
|
|
30
|
+
newUrl += `quality=${QUALITY}`;
|
|
31
|
+
}
|
|
32
|
+
newUrl += `/intouch_creative_assets${assetKey}`;
|
|
33
|
+
return newUrl;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @param {*} htmlContents
|
|
39
|
+
* @returns htmlContents with updated urls in image tag
|
|
40
|
+
*/
|
|
41
|
+
export const updateImagesInHtml = (htmlContents) => {
|
|
42
|
+
const copiedHtmlContents = htmlContents;
|
|
43
|
+
try {
|
|
44
|
+
const root = parse(htmlContents);
|
|
45
|
+
root.querySelectorAll('img').forEach((element) => {
|
|
46
|
+
const imageSrc = element.getAttribute('src');
|
|
47
|
+
const isAsset = regex.test(imageSrc);
|
|
48
|
+
if (isAsset) {
|
|
49
|
+
const height = element.getAttribute('height');
|
|
50
|
+
const width = element.getAttribute('width');
|
|
51
|
+
const newUrl = getCdnUrl({url: imageSrc, height, width, transformationEnabled: true, reduceQuality: true});
|
|
52
|
+
element.setAttribute('src', newUrl);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return root.toString();
|
|
56
|
+
} catch (e) {
|
|
57
|
+
console.log('An error occured while updating images in html', e);
|
|
58
|
+
return copiedHtmlContents; //return received input directly in case an exception is thrown
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param {*} contents
|
|
65
|
+
* @returns
|
|
66
|
+
*/
|
|
67
|
+
export const transformEmailTemplates = (contents) => {
|
|
68
|
+
const contentsCopy = cloneDeep(contents);
|
|
69
|
+
try {
|
|
70
|
+
const base = contentsCopy?.versions?.base;
|
|
71
|
+
const languages = base?.selectedLanguages;
|
|
72
|
+
languages?.forEach((lang) => {
|
|
73
|
+
const htmlContents = base?.[lang]?.['template-content'];
|
|
74
|
+
const newHtmlContents = updateImagesInHtml(htmlContents);
|
|
75
|
+
base[lang]['template-content'] = newHtmlContents;
|
|
76
|
+
});
|
|
77
|
+
return contentsCopy;
|
|
78
|
+
} catch (e) {
|
|
79
|
+
console.log('Some error has occured while transforming email templates', e);
|
|
80
|
+
return contents; //return received input directly in case an exception is thrown
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// export const transformRcsTemplates = (contents) => {
|
|
85
|
+
// const contentsCopy = cloneDeep(contents);
|
|
86
|
+
// }
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
// {
|
|
90
|
+
// "name": "test 1",
|
|
91
|
+
// "versions": {
|
|
92
|
+
// "base": {
|
|
93
|
+
// "content": {
|
|
94
|
+
// "RCS": {
|
|
95
|
+
// "cardContent": [
|
|
96
|
+
// {
|
|
97
|
+
// "title": "asdf",
|
|
98
|
+
// "description": "asdf",
|
|
99
|
+
// "mediaType": "NONE"
|
|
100
|
+
// }
|
|
101
|
+
// ],
|
|
102
|
+
// "cardSettings": {
|
|
103
|
+
// "cardOrientation": "VERTICAL"
|
|
104
|
+
// },
|
|
105
|
+
// "cardType": "STANDALONE",
|
|
106
|
+
// "contentType": "RICHCARD",
|
|
107
|
+
// "smsFallBackContent": {
|
|
108
|
+
// "message": ""
|
|
109
|
+
// }
|
|
110
|
+
// }
|
|
111
|
+
// }
|
|
112
|
+
// }
|
|
113
|
+
// },
|
|
114
|
+
// "type": "RCS"
|
|
115
|
+
// }
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
// {
|
|
119
|
+
// "name": "test 2",
|
|
120
|
+
// "versions": {
|
|
121
|
+
// "base": {
|
|
122
|
+
// "content": {
|
|
123
|
+
// "RCS": {
|
|
124
|
+
// "cardContent": [
|
|
125
|
+
// {
|
|
126
|
+
// "title": "asdfasdf",
|
|
127
|
+
// "description": "asdfadsf",
|
|
128
|
+
// "mediaType": "IMAGE",
|
|
129
|
+
// "suggestions": [
|
|
130
|
+
// {
|
|
131
|
+
// "type": "CTA",
|
|
132
|
+
// "text": "fasdf",
|
|
133
|
+
// "url": "https://www.google.com"
|
|
134
|
+
// }
|
|
135
|
+
// ],
|
|
136
|
+
// "media": {
|
|
137
|
+
// "mediaUrl": "https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/820a9ff9-ad5b-410e-b471-75c2e1a9.jpg",
|
|
138
|
+
// "height": "MEDIUM"
|
|
139
|
+
// }
|
|
140
|
+
// }
|
|
141
|
+
// ],
|
|
142
|
+
// "cardSettings": {
|
|
143
|
+
// "cardOrientation": "VERTICAL"
|
|
144
|
+
// },
|
|
145
|
+
// "cardType": "STANDALONE",
|
|
146
|
+
// "contentType": "RICHCARD",
|
|
147
|
+
// "smsFallBackContent": {
|
|
148
|
+
// "message": "asdf"
|
|
149
|
+
// }
|
|
150
|
+
// }
|
|
151
|
+
// }
|
|
152
|
+
// }
|
|
153
|
+
// },
|
|
154
|
+
// "type": "RCS"
|
|
155
|
+
// }
|
|
@@ -33,6 +33,7 @@ import { CREATIVE } from '../Facebook/constants';
|
|
|
33
33
|
import { LOYALTY } from '../App/constants';
|
|
34
34
|
import { WHATSAPP_STATUSES } from '../Whatsapp/constants';
|
|
35
35
|
|
|
36
|
+
import {updateImagesInHtml} from '../../utils/cdnTransformation';
|
|
36
37
|
|
|
37
38
|
const classPrefix = 'add-creatives-section';
|
|
38
39
|
const CREATIVES_CONTAINER = 'creativesContainer';
|
|
@@ -369,15 +370,15 @@ export class Creatives extends React.Component {
|
|
|
369
370
|
const {
|
|
370
371
|
messageBody = '',
|
|
371
372
|
templateConfigs: {
|
|
373
|
+
id,
|
|
372
374
|
name,
|
|
373
375
|
template,
|
|
374
376
|
varMapped,
|
|
375
|
-
category,
|
|
376
377
|
language,
|
|
378
|
+
category,
|
|
379
|
+
mediaType,
|
|
377
380
|
buttonType = 'NONE',
|
|
378
381
|
buttons = [],
|
|
379
|
-
mediaType = 'TEXT',
|
|
380
|
-
whatsappMedia: { url: imageUrl = '' } = {},
|
|
381
382
|
} = {},
|
|
382
383
|
} = templateData;
|
|
383
384
|
const modifiedButtons = cloneDeep(buttons).map((btn) => {
|
|
@@ -388,13 +389,9 @@ export class Creatives extends React.Component {
|
|
|
388
389
|
}
|
|
389
390
|
return btn;
|
|
390
391
|
});
|
|
391
|
-
for (const key in varMapped) {
|
|
392
|
-
if (key.includes('_unsubscribe')) {
|
|
393
|
-
delete varMapped[key];
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
392
|
const unsubscribeRegex = /Click {{unsubscribe}} to unsubscribe/g;
|
|
397
393
|
creativesTemplateData = {
|
|
394
|
+
_id: id,
|
|
398
395
|
type: constants.WHATSAPP,
|
|
399
396
|
edit: true,
|
|
400
397
|
name,
|
|
@@ -406,7 +403,6 @@ export class Creatives extends React.Component {
|
|
|
406
403
|
category,
|
|
407
404
|
varMapped,
|
|
408
405
|
mediaType,
|
|
409
|
-
imageUrl,
|
|
410
406
|
buttonType,
|
|
411
407
|
buttons: modifiedButtons,
|
|
412
408
|
languages: [
|
|
@@ -456,7 +452,8 @@ export class Creatives extends React.Component {
|
|
|
456
452
|
return templateData || null;
|
|
457
453
|
}
|
|
458
454
|
|
|
459
|
-
getCreativesData = (channel, template, templateRecords) => {
|
|
455
|
+
getCreativesData = (channel, template, templateRecords) => {
|
|
456
|
+
//from creatives to consumers
|
|
460
457
|
let templateData = { channel };
|
|
461
458
|
switch (channel) {
|
|
462
459
|
case constants.SMS:
|
|
@@ -495,7 +492,8 @@ export class Creatives extends React.Component {
|
|
|
495
492
|
if (!html_content) {
|
|
496
493
|
emailBase = templateRecords.base;
|
|
497
494
|
}
|
|
498
|
-
|
|
495
|
+
const newHtmlContent = updateImagesInHtml(html_content);
|
|
496
|
+
templateData = {...templateData, ...emailBase, emailBody: newHtmlContent, emailSubject: (emailBase && emailBase.subject) ? emailBase.subject : ''};
|
|
499
497
|
delete templateData.html_content;
|
|
500
498
|
delete templateData.subject;
|
|
501
499
|
}
|
|
@@ -587,63 +585,43 @@ export class Creatives extends React.Component {
|
|
|
587
585
|
case constants.WHATSAPP:
|
|
588
586
|
if (template.value) {
|
|
589
587
|
const { Templates, templateData: templateDataProps } = this.props;
|
|
590
|
-
const selectedWhatsappAccount = Templates?.selectedWhatsappAccount;
|
|
591
588
|
const { accountDetails: selectedAccountDetails, accountId: selectedAccountId } = templateDataProps || {};
|
|
589
|
+
const selectedWhatsappAccount = Templates?.selectedWhatsappAccount;
|
|
592
590
|
const accountDetails = (selectedWhatsappAccount ? selectedWhatsappAccount : selectedAccountDetails);
|
|
593
591
|
const accountId = selectedAccountId || (selectedWhatsappAccount?.id || '');
|
|
594
592
|
const { versions } = template.value;
|
|
595
593
|
const {
|
|
596
594
|
languages = [{}],
|
|
597
|
-
mediaType
|
|
598
|
-
category
|
|
599
|
-
templateEditor
|
|
600
|
-
varMapped
|
|
595
|
+
mediaType,
|
|
596
|
+
category,
|
|
597
|
+
templateEditor,
|
|
598
|
+
varMapped,
|
|
601
599
|
buttonType = 'NONE',
|
|
602
600
|
buttons = [],
|
|
603
|
-
imageUrl = '',
|
|
604
601
|
} = cloneDeep(versions.base.content.whatsapp);
|
|
605
|
-
|
|
606
602
|
const modifiedButtons = cloneDeep(buttons).map((btn) => {
|
|
607
603
|
if (btn.type === 'PHONE_NUMBER') {
|
|
608
604
|
btn.phoneNumber = btn.phone_number;
|
|
609
605
|
delete btn.phone_number;
|
|
610
|
-
|
|
611
|
-
const dynamicUrlPayload = btn.url.match(/{{(.*?)}}/g);
|
|
612
|
-
btn.dynamicUrlPayload = dynamicUrlPayload.length === 1 ? dynamicUrlPayload[0] : '';
|
|
606
|
+
return btn;
|
|
613
607
|
}
|
|
614
608
|
return btn;
|
|
615
609
|
});
|
|
616
|
-
|
|
617
|
-
//to send {{unsubscribe}} to backend inside varMapped
|
|
618
|
-
const unsubscribeRegex = /Click {{unsubscribe}} to unsubscribe/g;
|
|
619
|
-
if (
|
|
620
|
-
languages[0].content?.match(unsubscribeRegex)?.length > 0 &&
|
|
621
|
-
Object.keys(varMapped)?.every(
|
|
622
|
-
(key) => !key?.includes("_unsubscribe")
|
|
623
|
-
)
|
|
624
|
-
) {
|
|
625
|
-
varMapped[`{{${Object.keys(varMapped).length + 1}}}_unsubscribe`] =
|
|
626
|
-
"{{unsubscribe}}";
|
|
627
|
-
}
|
|
628
|
-
|
|
629
610
|
templateData = {
|
|
630
611
|
channel,
|
|
631
612
|
accountId,
|
|
632
613
|
accountName: accountDetails?.name || '',
|
|
633
614
|
messageBody: languages[0].content,
|
|
634
615
|
templateConfigs: {
|
|
635
|
-
id: template
|
|
616
|
+
id: template._id,
|
|
636
617
|
name: template?.value?.name,
|
|
637
618
|
template: templateEditor,
|
|
638
619
|
varMapped,
|
|
639
620
|
category,
|
|
640
621
|
language: languages[0].language,
|
|
641
|
-
buttonType,
|
|
642
|
-
buttons: modifiedButtons,
|
|
643
622
|
mediaType,
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
},
|
|
623
|
+
buttonType,
|
|
624
|
+
buttons : modifiedButtons,
|
|
647
625
|
},
|
|
648
626
|
};
|
|
649
627
|
}
|
|
@@ -35,6 +35,8 @@ import { TRACK_CREATE_EMAIL, TRACK_EDIT_EMAIL, BEE_PLUGIN, CREATE, EDIT } from '
|
|
|
35
35
|
import { FONT_COLOR_05 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
36
36
|
import { gtmPush } from '../../utils/gtmTrackers';
|
|
37
37
|
const {CapCustomCardList} = CapCustomCard;
|
|
38
|
+
import {transformEmailTemplates} from '../../utils/cdnTransformation';
|
|
39
|
+
|
|
38
40
|
export class Email extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
39
41
|
constructor(props) {
|
|
40
42
|
super(props);
|
|
@@ -2437,8 +2439,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2437
2439
|
});
|
|
2438
2440
|
|
|
2439
2441
|
// if (saveCount === 0) {
|
|
2440
|
-
|
|
2441
|
-
this.props.actions.createTemplate(
|
|
2442
|
+
const newEmail = transformEmailTemplates(obj);
|
|
2443
|
+
this.props.actions.createTemplate(newEmail, this.onUpdateTemplateComplete);
|
|
2442
2444
|
// } else {
|
|
2443
2445
|
// this.setState({saveObj: obj, targetSaveCount: saveCount, mode: "save", saveEdmDataMode: 'save'}, () => {
|
|
2444
2446
|
// _.forEach(data.selectedLanguages, (language, langIndex) => {
|
|
@@ -7,7 +7,7 @@ import isEmpty from 'lodash/isEmpty';
|
|
|
7
7
|
import { connect } from "react-redux";
|
|
8
8
|
import { createStructuredSelector } from "reselect";
|
|
9
9
|
import { selectCurrentOrgDetails } from "../../Cap/selectors";
|
|
10
|
-
|
|
10
|
+
import { getCdnUrl } from '../../../utils/cdnTransformation';
|
|
11
11
|
import {
|
|
12
12
|
CapInput,
|
|
13
13
|
CapRadioCard,
|
|
@@ -197,7 +197,7 @@ export const Advertisement = (props) => {
|
|
|
197
197
|
};
|
|
198
198
|
if (obj.subType === IMAGE) {
|
|
199
199
|
data.imageData = {
|
|
200
|
-
imageSrc: obj.imgSrc,
|
|
200
|
+
imageSrc: getCdnUrl({url: obj.imgSrc}),
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
203
|
if (obj.subType === VIDEO) {
|
|
@@ -336,7 +336,7 @@ export const Advertisement = (props) => {
|
|
|
336
336
|
};
|
|
337
337
|
}
|
|
338
338
|
if (obj.subType === IMAGE) {
|
|
339
|
-
data.imgSrc = obj.imageData.imageSrc;
|
|
339
|
+
data.imgSrc = getCdnUrl({url: obj.imageData.imageSrc});
|
|
340
340
|
} else {
|
|
341
341
|
const {
|
|
342
342
|
videoSrc,
|
|
@@ -15,6 +15,7 @@ import Gallery from '../../../Assets/Gallery';
|
|
|
15
15
|
import style from './style';
|
|
16
16
|
import { CAP_G06, CAP_G09 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
17
17
|
import withStyles from '../../../../hoc/withStyles';
|
|
18
|
+
import { getCdnUrl } from '../../../../utils/cdnTransformation';
|
|
18
19
|
|
|
19
20
|
import messages from './messages';
|
|
20
21
|
import {
|
|
@@ -73,7 +74,7 @@ export const LineImage = ({
|
|
|
73
74
|
if (imageSrc && (isFullMode ? messageTitle: true) && imagePreview) {
|
|
74
75
|
updateMessageState({
|
|
75
76
|
isError: !imageSrc || !(isFullMode ? messageTitle : true) || isImageError || errorMessageTitle,
|
|
76
|
-
originalContentUrl: imageSrc,
|
|
77
|
+
originalContentUrl: getCdnUrl({url: imageSrc}),
|
|
77
78
|
previewImageUrl: imagePreview,
|
|
78
79
|
messageTitle,
|
|
79
80
|
index,
|
|
@@ -112,7 +113,7 @@ export const LineImage = ({
|
|
|
112
113
|
|
|
113
114
|
updateMessageState({
|
|
114
115
|
isError: !imgSrc || !(isFullMode ? messageTitle : true) || errorMessageTitle,
|
|
115
|
-
originalContentUrl: imgSrc,
|
|
116
|
+
originalContentUrl: getCdnUrl({url: imgSrc}),
|
|
116
117
|
previewImageUrl: imgPreview,
|
|
117
118
|
messageTitle,
|
|
118
119
|
index,
|
|
@@ -155,7 +156,7 @@ export const LineImage = ({
|
|
|
155
156
|
}
|
|
156
157
|
updateMessageState({
|
|
157
158
|
isError: !imageSrc || !(isFullMode ? value : true) || isImageError || !value,
|
|
158
|
-
originalContentUrl: imageSrc,
|
|
159
|
+
originalContentUrl: getCdnUrl({url: imageSrc}),
|
|
159
160
|
previewImageUrl: imagePreview,
|
|
160
161
|
messageTitle: value,
|
|
161
162
|
index,
|
|
@@ -412,7 +413,7 @@ export const LineImage = ({
|
|
|
412
413
|
updateImagePreview(imagePreview);
|
|
413
414
|
updateMessageState({
|
|
414
415
|
isError: !image || !(isFullMode ? messageTitle : true) || isImageError || errorMessageTitle,
|
|
415
|
-
originalContentUrl: image,
|
|
416
|
+
originalContentUrl: getCdnUrl({url: image}),
|
|
416
417
|
previewImageUrl: imagePreview,
|
|
417
418
|
messageTitle,
|
|
418
419
|
index,
|
|
@@ -15,6 +15,7 @@ import LineDrawer from '../Drawer';
|
|
|
15
15
|
import style from './style';
|
|
16
16
|
import { CAP_G06, FONT_COLOR_01, FONT_COLOR_02, CAP_SPACE_08, CAP_WHITE, CAP_SPACE_24, CAP_SPACE_04 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
17
17
|
import withStyles from '../../../../hoc/withStyles';
|
|
18
|
+
import { getCdnUrl } from '../../../../utils/cdnTransformation';
|
|
18
19
|
|
|
19
20
|
import LineImageCarouselContent from './Content';
|
|
20
21
|
|
|
@@ -103,7 +104,7 @@ export const LineImageCarousel = (props) => {
|
|
|
103
104
|
} = content || {};
|
|
104
105
|
validCarouselImages.push({
|
|
105
106
|
activeIndex: index,
|
|
106
|
-
originalContentUrl: url,
|
|
107
|
+
originalContentUrl: getCdnUrl({url: url}),
|
|
107
108
|
aspectRatio,
|
|
108
109
|
selectedActionType: buttonType ? (buttonType === MESSAGE_ACTION_TYPE ? TEXT_ACTION_TYPE : URL_ACTION_TYPE) : '',
|
|
109
110
|
actionContent: text || uri,
|
|
@@ -127,7 +128,7 @@ export const LineImageCarousel = (props) => {
|
|
|
127
128
|
|
|
128
129
|
validCarouselImages.push({
|
|
129
130
|
activeIndex: index,
|
|
130
|
-
originalContentUrl: imageUrl,
|
|
131
|
+
originalContentUrl: getCdnUrl({url: imageUrl}),
|
|
131
132
|
selectedActionType: type ? (type === MESSAGE_ACTION_TYPE ? TEXT_ACTION_TYPE : URL_ACTION_TYPE) : '',
|
|
132
133
|
actionContent: text || uri,
|
|
133
134
|
actionLabel: label,
|
|
@@ -160,7 +161,7 @@ export const LineImageCarousel = (props) => {
|
|
|
160
161
|
? isErrorIndex
|
|
161
162
|
: ((!originalContentUrl || !selectedActionType || actionContentErrorMessage || actionLabelErrorMessage || !actionContent) && activeIndex);
|
|
162
163
|
columns.push({
|
|
163
|
-
imageUrl: originalContentUrl,
|
|
164
|
+
imageUrl: getCdnUrl({url: originalContentUrl}),
|
|
164
165
|
aspectRatio,
|
|
165
166
|
action: {
|
|
166
167
|
type: selectedActionType ? (selectedActionType === TEXT_ACTION_TYPE ? MESSAGE_ACTION_TYPE : URL_ACTION_TYPE) : '',
|
|
@@ -455,7 +456,7 @@ export const LineImageCarousel = (props) => {
|
|
|
455
456
|
} = content || {};
|
|
456
457
|
validCarouselImages.push({
|
|
457
458
|
activeIndex: index,
|
|
458
|
-
originalContentUrl: url,
|
|
459
|
+
originalContentUrl: getCdnUrl({url: url}),
|
|
459
460
|
aspectRatio,
|
|
460
461
|
selectedActionType: buttonType ? (buttonType === MESSAGE_ACTION_TYPE ? TEXT_ACTION_TYPE : URL_ACTION_TYPE) : '',
|
|
461
462
|
actionContent: text || uri,
|
|
@@ -480,7 +481,7 @@ export const LineImageCarousel = (props) => {
|
|
|
480
481
|
|
|
481
482
|
validCarouselImages.push({
|
|
482
483
|
activeIndex: index,
|
|
483
|
-
originalContentUrl: imageUrl,
|
|
484
|
+
originalContentUrl: getCdnUrl({url: imageUrl}),
|
|
484
485
|
selectedActionType: type ? (type === MESSAGE_ACTION_TYPE ? TEXT_ACTION_TYPE : URL_ACTION_TYPE) : '',
|
|
485
486
|
actionContent: text || uri,
|
|
486
487
|
actionLabel: label,
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
} from '../constants';
|
|
40
40
|
|
|
41
41
|
const { CapIconAvatar } = CapIcon;
|
|
42
|
+
import { getCdnUrl } from '../../../../utils/cdnTransformation';
|
|
42
43
|
|
|
43
44
|
export const LineImageMap = ({
|
|
44
45
|
className,
|
|
@@ -114,7 +115,7 @@ export const LineImageMap = ({
|
|
|
114
115
|
if (imageSrc && (isFullMode ? messageTitle: true) && imageMapTemplate && actionLinks) {
|
|
115
116
|
updateMessageState({
|
|
116
117
|
isError: !imageSrc || !(isFullMode ? messageTitle : true) || !imageMapTemplate || (isImageError && errorMessageTitle) || errorTitle || !altText,
|
|
117
|
-
baseUrl: imageSrc,
|
|
118
|
+
baseUrl: getCdnUrl({url: imageSrc}),
|
|
118
119
|
messageTitle,
|
|
119
120
|
index,
|
|
120
121
|
type: IMAGE_MAP,
|
|
@@ -27,6 +27,8 @@ import {
|
|
|
27
27
|
MAX_ACTION_LABEL_LENGTH,
|
|
28
28
|
} from './constants';
|
|
29
29
|
|
|
30
|
+
import { getCdnUrl } from '../../../../utils/cdnTransformation';
|
|
31
|
+
|
|
30
32
|
export const LineVideo = ({
|
|
31
33
|
className,
|
|
32
34
|
id,
|
|
@@ -58,7 +60,7 @@ export const LineVideo = ({
|
|
|
58
60
|
const [isTemplateDrawerRequired, updateTemplateDrawerRequirement] = useState(false);
|
|
59
61
|
const [selectedTemplate, updateSelectedTemplate] = useState();
|
|
60
62
|
|
|
61
|
-
const [videoSrc,
|
|
63
|
+
const [videoSrc, setVideoSrc] = useState('');
|
|
62
64
|
const [videoName, updateVideoName] = useState('');
|
|
63
65
|
const [isVideo, updateVideoStatus] = useState(false);
|
|
64
66
|
const [isVideoError, updateVideoErrorMessage] = useState(false);
|
|
@@ -75,6 +77,10 @@ export const LineVideo = ({
|
|
|
75
77
|
const [videoWidth, updateVideoWidth] = useState();
|
|
76
78
|
const [isPlaying, updateIsPlaying] = useState(false);
|
|
77
79
|
|
|
80
|
+
const updateVideoSrc = React.useCallback((url)=>{
|
|
81
|
+
const newUrl = getCdnUrl({url, transformationEnabled: false, reduceQuality: false});
|
|
82
|
+
setVideoSrc(newUrl)
|
|
83
|
+
},[]);
|
|
78
84
|
|
|
79
85
|
useEffect(() => {
|
|
80
86
|
const {
|
|
@@ -31,6 +31,7 @@ import { GA } from '@capillarytech/cap-ui-utils';
|
|
|
31
31
|
import { CREATE, TRACK_CREATE_MPUSH } from '../../App/constants';
|
|
32
32
|
import { MOBILE_PUSH } from '../../CreativesContainer/constants';
|
|
33
33
|
import { getContent } from '../commonMethods';
|
|
34
|
+
import { getCdnUrl } from '../../../utils/cdnTransformation'
|
|
34
35
|
|
|
35
36
|
const PrefixWrapper = styled.div`
|
|
36
37
|
margin-right: 16px;
|
|
@@ -464,7 +465,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
464
465
|
const secondaryCta2 = !!android['cta-deeplink-secondary-cta-1-select'] || !!android['secondary-cta-1-label'];
|
|
465
466
|
const imageLink = android.image;
|
|
466
467
|
if (imageLink) {
|
|
467
|
-
obj.versions.base.ANDROID.expandableDetails.image = imageLink;
|
|
468
|
+
obj.versions.base.ANDROID.expandableDetails.image = getCdnUrl({url: imageLink});
|
|
468
469
|
obj.versions.base.ANDROID.expandableDetails.style = "BIG_PICTURE";
|
|
469
470
|
}
|
|
470
471
|
if (secondaryCta1 || secondaryCta2 ) {
|
|
@@ -538,7 +539,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
538
539
|
const imageLinkIos = ios.image;
|
|
539
540
|
const secondaryCtaIos = !!ios['cta-deeplink-secondary-cta-1-select'] || !!ios['secondary-cta-1-label'];
|
|
540
541
|
if (imageLinkIos) {
|
|
541
|
-
obj.versions.base.IOS.expandableDetails.image = imageLinkIos;
|
|
542
|
+
obj.versions.base.IOS.expandableDetails.image = getCdnUrl({url: imageLinkIos});
|
|
542
543
|
obj.versions.base.IOS.expandableDetails.style = "BIG_PICTURE";
|
|
543
544
|
}
|
|
544
545
|
if (secondaryCtaIos) {
|
|
@@ -33,6 +33,7 @@ import {getPrimaryCtaFields, getSecondaryCtaFields, getLinkTypeFields, getConten
|
|
|
33
33
|
import { GA } from '@capillarytech/cap-ui-utils';
|
|
34
34
|
import { EDIT, TRACK_EDIT_MPUSH } from '../../App/constants';
|
|
35
35
|
import { MOBILE_PUSH } from '../../CreativesContainer/constants';
|
|
36
|
+
import { getCdnUrl } from '../../../utils/cdnTransformation';
|
|
36
37
|
|
|
37
38
|
const PrefixWrapper = styled.div`
|
|
38
39
|
margin-right: 16px;
|
|
@@ -421,7 +422,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
421
422
|
}
|
|
422
423
|
const imageLink = android.image;
|
|
423
424
|
if (imageLink) {
|
|
424
|
-
obj.versions.base.ANDROID.expandableDetails.image = imageLink;
|
|
425
|
+
obj.versions.base.ANDROID.expandableDetails.image = getCdnUrl({url: imageLink});
|
|
425
426
|
obj.versions.base.ANDROID.expandableDetails.style = "BIG_PICTURE";
|
|
426
427
|
}
|
|
427
428
|
if (obj.versions.base.ANDROID && obj.versions.base.ANDROID.cta) {
|
|
@@ -492,7 +493,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
492
493
|
}
|
|
493
494
|
const imageLinkIos = ios.image;
|
|
494
495
|
if (imageLinkIos) {
|
|
495
|
-
obj.versions.base.IOS.expandableDetails.image = imageLinkIos;
|
|
496
|
+
obj.versions.base.IOS.expandableDetails.image = getCdnUrl({url: imageLinkIos});
|
|
496
497
|
obj.versions.base.IOS.expandableDetails.style = "BIG_PICTURE";
|
|
497
498
|
}
|
|
498
499
|
if (obj.versions.base.IOS && obj.versions.base.IOS.cta) {
|
|
@@ -81,6 +81,9 @@ import Templates from '../Templates';
|
|
|
81
81
|
import SmsTraiEdit from '../SmsTrai/Edit';
|
|
82
82
|
import TagList from '../TagList';
|
|
83
83
|
import { validateTags } from '../../utils/tagValidations';
|
|
84
|
+
|
|
85
|
+
import { getCdnUrl } from '../../utils/cdnTransformation';
|
|
86
|
+
|
|
84
87
|
const { Group: CapCheckboxGroup } = CapCheckbox;
|
|
85
88
|
export const Rcs = (props) => {
|
|
86
89
|
const {
|
|
@@ -900,7 +903,7 @@ export const Rcs = (props) => {
|
|
|
900
903
|
...(suggestions.length > 0 && { suggestions }),
|
|
901
904
|
...(!isMediaTypeNone && {
|
|
902
905
|
media: {
|
|
903
|
-
mediaUrl: rcsImageSrc,
|
|
906
|
+
mediaUrl: getCdnUrl({url: rcsImageSrc}),
|
|
904
907
|
height: MEDIUM,
|
|
905
908
|
},
|
|
906
909
|
}),
|
|
@@ -53,9 +53,12 @@ import { GA } from '@capillarytech/cap-ui-utils';
|
|
|
53
53
|
import { CREATE, EDIT, TRACK_CREATE_VIBER, TRACK_EDIT_VIBER } from '../App/constants';
|
|
54
54
|
import { gtmPush } from '../../utils/gtmTrackers';
|
|
55
55
|
import { VIBER } from '../CreativesContainer/constants';
|
|
56
|
+
import { getCdnUrl } from '../../utils/cdnTransformation';
|
|
57
|
+
|
|
56
58
|
const { CapHeadingSpan } = CapHeading;
|
|
57
59
|
const { TextArea } = CapInput;
|
|
58
60
|
|
|
61
|
+
|
|
59
62
|
const Viber = (props) => {
|
|
60
63
|
const {
|
|
61
64
|
intl,
|
|
@@ -78,7 +81,7 @@ const Viber = (props) => {
|
|
|
78
81
|
const { formatMessage } = intl;
|
|
79
82
|
const [isImageError, updateImageErrorMessage] = useState(false);
|
|
80
83
|
const [isImage, updateImageStatus] = useState(false);
|
|
81
|
-
const [imageSrc,
|
|
84
|
+
const [imageSrc, setImageSrc] = useState();
|
|
82
85
|
const [isDrawerRequired, updateDrawerRequirement] = useState(false);
|
|
83
86
|
const [messageContent, updateTextMessageContent] = useState('');
|
|
84
87
|
const [buttonText, updateButtonText] = useState('');
|
|
@@ -92,6 +95,12 @@ const Viber = (props) => {
|
|
|
92
95
|
const [buttonURLErrorMessage, updateButtonURLErrorMessage] = useState(false);
|
|
93
96
|
const [accountName, updateAccountName] = useState("");
|
|
94
97
|
|
|
98
|
+
|
|
99
|
+
const updateImageSrc = React.useCallback((url)=>{
|
|
100
|
+
const newUrl = getCdnUrl({url});
|
|
101
|
+
setImageSrc(newUrl);
|
|
102
|
+
},[]);
|
|
103
|
+
|
|
95
104
|
const StyledHeader = styled(CapHeader)`
|
|
96
105
|
margin-bottom: 14px;
|
|
97
106
|
`;
|
|
@@ -74,6 +74,8 @@ import {
|
|
|
74
74
|
PHONE_NUMBER,
|
|
75
75
|
WEBSITE,
|
|
76
76
|
} from '../../v2Components/CapWhatsappCTA/constants';
|
|
77
|
+
import { getCdnUrl } from '../../utils/cdnTransformation';
|
|
78
|
+
|
|
77
79
|
let varMap = {};
|
|
78
80
|
let editContent = {};
|
|
79
81
|
let tagValidationResponse = {};
|
|
@@ -855,7 +857,7 @@ export const Whatsapp = (props) => {
|
|
|
855
857
|
}),
|
|
856
858
|
mediaType: templateMediaType,
|
|
857
859
|
...(isMediaTypeImage && {
|
|
858
|
-
imageUrl: whatsappImageSrc,
|
|
860
|
+
imageUrl: getCdnUrl({url: whatsappImageSrc}),
|
|
859
861
|
karixFileHandle,
|
|
860
862
|
}),
|
|
861
863
|
varMapped: !isFullMode ? varMap : {},
|