@capillarytech/creatives-library 8.0.168 → 8.0.170-beta.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.
Files changed (38) hide show
  1. package/app.js +4 -0
  2. package/containers/App/constants.js +2 -0
  3. package/package.json +2 -1
  4. package/utils/commonUtils.js +50 -0
  5. package/utils/test-utils.js +6 -2
  6. package/utils/tests/newrelic.test.js +546 -0
  7. package/v2Components/CapActionButton/index.js +52 -12
  8. package/v2Components/CapActionButton/messages.js +4 -0
  9. package/v2Components/CapActionButton/tests/index.test.js +135 -0
  10. package/v2Components/CapDeviceContent/index.js +5 -0
  11. package/v2Components/CapInAppCTA/index.js +29 -14
  12. package/v2Components/CapInAppCTA/index.scss +0 -2
  13. package/v2Components/CapInAppCTA/messages.js +4 -0
  14. package/v2Components/CapMpushCTA/index.js +54 -38
  15. package/v2Components/CapMpushCTA/index.scss +2 -2
  16. package/v2Components/CapMpushCTA/messages.js +4 -0
  17. package/v2Components/CapTagListWithInput/index.js +169 -0
  18. package/v2Components/CapTagListWithInput/messages.js +10 -0
  19. package/v2Components/FormBuilder/index.js +93 -1
  20. package/v2Components/TestAndPreviewSlidebox/PreviewSection.js +1 -1
  21. package/v2Components/TestAndPreviewSlidebox/index.js +24 -4
  22. package/v2Containers/Email/index.js +64 -3
  23. package/v2Containers/Email/initialSchema.js +7 -21
  24. package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +2 -2
  25. package/v2Containers/Line/Container/Wrapper/tests/index.test.js +56 -1
  26. package/v2Containers/Line/Container/Wrapper/utils.js +6 -4
  27. package/v2Containers/MobilePush/Create/index.js +24 -3
  28. package/v2Containers/MobilePush/commonMethods.js +25 -3
  29. package/v2Containers/MobilePushNew/components/CtaButtons.js +20 -0
  30. package/v2Containers/MobilePushNew/components/MediaUploaders.js +31 -3
  31. package/v2Containers/MobilePushNew/components/PlatformContentFields.js +34 -3
  32. package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +200 -5
  33. package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +59 -1
  34. package/v2Containers/MobilePushNew/index.js +9 -0
  35. package/v2Containers/MobilePushNew/index.scss +2 -1
  36. package/v2Containers/Rcs/index.js +77 -71
  37. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +15270 -492
  38. package/v2Containers/Viber/index.js +102 -76
@@ -4,7 +4,6 @@ import { createStructuredSelector } from 'reselect';
4
4
  import { injectIntl, FormattedMessage } from 'react-intl';
5
5
  import isEmpty from 'lodash/isEmpty';
6
6
  import get from 'lodash/get';
7
- import * as globalActions from '../Cap/actions';
8
7
  import CapHeader from '@capillarytech/cap-ui-library/CapHeader';
9
8
  import CapRow from '@capillarytech/cap-ui-library/CapRow';
10
9
  import CapColumn from '@capillarytech/cap-ui-library/CapColumn';
@@ -19,6 +18,7 @@ import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
19
18
  import CapRadioGroup from '@capillarytech/cap-ui-library/CapRadioGroup';
20
19
  import CapAskAira from '@capillarytech/cap-ui-library/CapAskAira';
21
20
  import { GA } from '@capillarytech/cap-ui-utils';
21
+ import * as globalActions from '../Cap/actions';
22
22
  import { makeSelectViber, makeSelectCreateViber } from './selectors';
23
23
  import * as viberActions from './actions';
24
24
  import { validateTags } from '../../utils/tagValidations';
@@ -26,6 +26,7 @@ import TemplatePreview from '../../v2Components/TemplatePreview';
26
26
  import { isUrl } from '../Line/Container/Wrapper/utils';
27
27
  import messages from './messages';
28
28
  import TagList from '../TagList';
29
+ import CapTagListWithInput from '../../v2Components/CapTagListWithInput';
29
30
  import { makeSelectMetaEntities, setInjectedTags, selectCurrentOrgDetails } from '../Cap/selectors';
30
31
  import {
31
32
  ALLOWED_IMAGE_EXTENSIONS_REGEX_VIBER,
@@ -43,7 +44,9 @@ import {
43
44
  AI_CONTENT_BOT_DISABLED,
44
45
  } from './constants';
45
46
  import withCreatives from '../../hoc/withCreatives';
46
- import { CREATE, EDIT, TRACK_CREATE_VIBER, TRACK_EDIT_VIBER } from '../App/constants';
47
+ import {
48
+ CREATE, EDIT, TRACK_CREATE_VIBER, TRACK_EDIT_VIBER,
49
+ } from '../App/constants';
47
50
  import { gtmPush } from '../../utils/gtmTrackers';
48
51
  import { VIBER } from '../CreativesContainer/constants';
49
52
  import { getCdnUrl } from '../../utils/cdnTransformation';
@@ -55,6 +58,7 @@ import { ViberFooter } from './style';
55
58
  import injectReducer from '../../utils/injectReducer';
56
59
  import v2ViberReducer from './reducer';
57
60
 
61
+
58
62
  const { TextArea } = CapInput;
59
63
 
60
64
  export const Viber = (props) => {
@@ -64,7 +68,7 @@ export const Viber = (props) => {
64
68
  injectedTags,
65
69
  location,
66
70
  metaEntities,
67
- globalActions,
71
+ globalActions: globalActionsProps,
68
72
  handleClose,
69
73
  onCreateComplete,
70
74
  params,
@@ -130,12 +134,10 @@ export const Viber = (props) => {
130
134
 
131
135
  useEffect(() => {
132
136
  if ((params && params.id) || (templateData || {}).edit) {
133
- const { content: editViberContent = {} } =
134
- get(templateData, `versions.base.content`) ||
135
- get(viber, `templateDetails.versions.base.content`) ||
136
- {};
137
- const editMessageTitle =
138
- (templateData || {}).name || get(viber, "templateDetails.name");
137
+ const { content: editViberContent = {} } = get(templateData, `versions.base.content`)
138
+ || get(viber, `templateDetails.versions.base.content`)
139
+ || {};
140
+ const editMessageTitle = (templateData || {}).name || get(viber, "templateDetails.name");
139
141
  const {
140
142
  text = "",
141
143
  button = {},
@@ -172,7 +174,7 @@ export const Viber = (props) => {
172
174
  setTemplateMediaType(VIBER_MEDIA_TYPES.TEXT);
173
175
  }
174
176
  }
175
- }, [viber[`templateDetails`] || templateData]);
177
+ }, [viber.templateDetails || templateData]);
176
178
 
177
179
  // Text area Code start here
178
180
 
@@ -185,15 +187,22 @@ export const Viber = (props) => {
185
187
  context: type ? 'outbound' : 'default',
186
188
  embedded: type || 'full',
187
189
  };
188
- globalActions.fetchSchemaForEntity(getTagsQuery);
190
+ globalActionsProps.fetchSchemaForEntity(getTagsQuery);
189
191
  }, []);
190
192
 
191
193
  const onTagSelect = (data) => {
194
+ // update message content
192
195
  const messageData = `${messageContent}{{${data}}}`;
193
196
  updateTextMessageContent(messageData);
194
197
  updateTextContentError(messageData);
195
198
  };
196
199
 
200
+ const onButtonTagSelect = (data) => {
201
+ const newUrl = `${buttonURL}{{${data}}}`;
202
+ updateButtonUrl(newUrl);
203
+ onChangeButtonUrl({ target: { value: newUrl } });
204
+ };
205
+
197
206
  const handleOnTagsContextChange = (data) => {
198
207
  const query = {
199
208
  layout: 'LINE',
@@ -202,16 +211,14 @@ export const Viber = (props) => {
202
211
  (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
203
212
  embedded:
204
213
  location.query.type === 'embedded'
205
- ? location.query.type
206
- : 'full',
214
+ ? location.query.type
215
+ : 'full',
207
216
  };
208
- globalActions.fetchSchemaForEntity(query);
217
+ globalActionsProps.fetchSchemaForEntity(query);
209
218
  };
210
219
 
211
- const tags = metaEntities && metaEntities.tags
212
- ? metaEntities.tags.standard
213
- : [];
214
- // tags Code end here
220
+ const tags = metaEntities?.tags?.standard || [];
221
+ // tags Code end here
215
222
 
216
223
  // validation on Text area and tags validation
217
224
  const updateTextContentError = (value) => {
@@ -261,10 +268,10 @@ export const Viber = (props) => {
261
268
  {formatMessage(messages.message)}
262
269
  </CapHeading>
263
270
  <TagList
264
- key={"viber_tags"}
271
+ key="viber_tags"
265
272
  className="tag-list-viber"
266
273
  moduleFilterEnabled={
267
- location && location.query && location.query.type !== "embedded"
274
+ location?.query?.type !== "embedded"
268
275
  }
269
276
  label={formatMessage(messages.addLabels)}
270
277
  onTagSelect={onTagSelect}
@@ -272,7 +279,7 @@ export const Viber = (props) => {
272
279
  location={location}
273
280
  tags={tags}
274
281
  injectedTags={injectedTags || {}}
275
- id={"viber_tags"}
282
+ id="viber_tags"
276
283
  userLocale={localStorage.getItem("jlocale") || "en"}
277
284
  selectedOfferDetails={selectedOfferDetails}
278
285
  eventContextTags={eventContextTags}
@@ -280,7 +287,7 @@ export const Viber = (props) => {
280
287
  </CapColumn>
281
288
  <div className="viber-textarea-wrapper">
282
289
  <TextArea
283
- id={"viber_textarea"}
290
+ id="viber_textarea"
284
291
  autosize={false}
285
292
  onChange={onTextContentChange}
286
293
  className={`${errorMessageTextarea ? "error" : ""}`}
@@ -292,25 +299,28 @@ export const Viber = (props) => {
292
299
  placeholder={formatMessage(messages.enterMessage)}
293
300
  />
294
301
  {!isAiContentBotDisabled && (
295
- <CapAskAira.ContentGenerationBot
296
- text={messageContent || ""}
297
- setText={(text) => {
298
- onTextContentChange({ target: { value: text } });
299
- }}
300
- iconPlacement="float-br"
301
- iconSize="1.6rem"
302
- rootStyle={{
303
- bottom: "0.2rem",
304
- right: "0.2rem",
305
- left: "auto",
306
- position: "absolute",
307
- }}
308
- />
309
- )}
302
+ <CapAskAira.ContentGenerationBot
303
+ text={messageContent || ""}
304
+ setText={(text) => {
305
+ onTextContentChange({ target: { value: text } });
306
+ }}
307
+ iconPlacement="float-br"
308
+ iconSize="1.6rem"
309
+ rootStyle={{
310
+ bottom: "0.2rem",
311
+ right: "0.2rem",
312
+ left: "auto",
313
+ position: "absolute",
314
+ }}
315
+ />
316
+ )}
310
317
  </div>
311
318
  <CapLabel type="label1" className="char-count-viber">
312
319
  <FormattedMessage {...messages.charCount} />
313
- {(messageContent || "").length}/{charLimit}{" "}
320
+ {(messageContent || "").length}
321
+ /
322
+ {charLimit}
323
+ {" "}
314
324
  </CapLabel>
315
325
  </>
316
326
  );
@@ -399,7 +409,7 @@ export const Viber = (props) => {
399
409
  onVideoUploadUpdateAssestList={setUpdateViberVideoSrc}
400
410
  videoData={viber}
401
411
  className="cap-custom-video-upload"
402
- formClassName={"viber-video-upload"}
412
+ formClassName="viber-video-upload"
403
413
  channel={VIBER}
404
414
  errorMessage={formatMessage(messages.videoErrorMessage)}
405
415
  showVideoNameAndDuration
@@ -465,15 +475,14 @@ export const Viber = (props) => {
465
475
  }
466
476
  };
467
477
 
468
- const isCtaSaveDisabled =
469
- isEmpty(buttonText.trim()) ||
470
- isEmpty(buttonURL.trim()) ||
471
- buttonURLErrorMessage;
478
+ const isCtaSaveDisabled = isEmpty(buttonText.trim())
479
+ || isEmpty(buttonURL.trim())
480
+ || buttonURLErrorMessage;
472
481
 
473
482
  const ButtonViber = !isCtaSaved ? (
474
483
  <div className="cta-section">
475
484
  <CapHeading type="h4" className="button-text">
476
- {formatMessage(messages.buttonText)}{" "}
485
+ {formatMessage(messages.buttonText)}
477
486
  <CapTooltip title={formatMessage(messages.buttonTextTooltip)}>
478
487
  <CapIcon type="info" size="s" />
479
488
  </CapTooltip>
@@ -488,15 +497,24 @@ export const Viber = (props) => {
488
497
  maxLength={20}
489
498
  placeholder={formatMessage(messages.enterButtonText)}
490
499
  />
491
- <CapInput
492
- id="viber-button-url"
493
- type="input"
494
- onChange={onChangeButtonUrl}
495
- defaultValue={buttonURL}
496
- value={buttonURL}
497
- label={formatMessage(messages.buttonUrl)}
498
- errorMessage={buttonURLErrorMessage}
499
- placeholder={formatMessage(messages.enterButtonUrl)}
500
+ <CapTagListWithInput
501
+ inputId="viber-button-url"
502
+ inputValue={buttonURL}
503
+ inputOnChange={onChangeButtonUrl}
504
+ inputPlaceholder={formatMessage(messages.enterButtonUrl)}
505
+ inputErrorMessage={buttonURLErrorMessage}
506
+ headingText={formatMessage(messages.buttonUrl)}
507
+ headingStyle={{ marginTop: '3%', marginRight: '68%'}}
508
+ className="tag-list-viber"
509
+ moduleFilterEnabled={location?.query?.type !== "embedded"}
510
+ onTagSelect={onButtonTagSelect}
511
+ onContextChange={handleOnTagsContextChange}
512
+ location={location}
513
+ tags={tags}
514
+ injectedTags={injectedTags || {}}
515
+ userLocale={localStorage.getItem("jlocale") || "en"}
516
+ selectedOfferDetails={selectedOfferDetails}
517
+ eventContextTags={eventContextTags}
500
518
  />
501
519
  <CapColumn className="cta-actions">
502
520
  <CapButton
@@ -537,7 +555,7 @@ export const Viber = (props) => {
537
555
  <div className="button-section">
538
556
  <CapHeader
539
557
  className="viber-render-heading"
540
- title={
558
+ title={(
541
559
  <CapRow type="flex">
542
560
  <CapHeading type="h4">
543
561
  {formatMessage(messages.btnLabel)}
@@ -546,7 +564,7 @@ export const Viber = (props) => {
546
564
  {formatMessage(messages.optional)}
547
565
  </CapHeading>
548
566
  </CapRow>
549
- }
567
+ )}
550
568
  description={
551
569
  <CapLabel type="label3">{formatMessage(messages.btnDesc)}</CapLabel>
552
570
  }
@@ -578,8 +596,7 @@ export const Viber = (props) => {
578
596
  messageData.image.url = imageSrc;
579
597
  }
580
598
  if (isMediaTypeVideo) {
581
- const { viberVideoSrc, duration, viberVideoPreviewImg } =
582
- viberVideoSrcAndPreview;
599
+ const { viberVideoSrc, duration, viberVideoPreviewImg } = viberVideoSrcAndPreview;
583
600
  messageData.video = {};
584
601
  messageData.video.url = viberVideoSrc;
585
602
  messageData.video.thumbnailUrl = viberVideoPreviewImg;
@@ -642,13 +659,13 @@ export const Viber = (props) => {
642
659
 
643
660
  const onCreateViber = () => {
644
661
  actions.createTemplate(
645
- formatSubmitPayload(),
646
- (resp, errorMessage) => {
647
- createCallback({resp, errorMessage});
648
- if (!errorMessage) {
649
- onCreateComplete();
650
- }
662
+ formatSubmitPayload(),
663
+ (resp, errorMessage) => {
664
+ createCallback({resp, errorMessage});
665
+ if (!errorMessage) {
666
+ onCreateComplete();
651
667
  }
668
+ }
652
669
  );
653
670
  };
654
671
 
@@ -658,12 +675,13 @@ export const Viber = (props) => {
658
675
  ...formatSubmitPayload(),
659
676
  _id: params.id,
660
677
  },
661
- (resp, errorMessage) => {
662
- createCallback({resp, errorMessage}, true);
663
- if (!errorMessage) {
664
- onCreateComplete();
665
- }
666
- });
678
+ (resp, errorMessage) => {
679
+ createCallback({resp, errorMessage}, true);
680
+ if (!errorMessage) {
681
+ onCreateComplete();
682
+ }
683
+ }
684
+ );
667
685
  };
668
686
 
669
687
  const onDoneCallback = () => {
@@ -692,8 +710,8 @@ export const Viber = (props) => {
692
710
  }
693
711
  // if media type is image/video than image/video should be uploaded
694
712
  if (
695
- (isMediaTypeImage && !imageSrc) ||
696
- (isMediaTypeVideo && !viberVideoSrcAndPreview.viberVideoSrc)
713
+ (isMediaTypeImage && !imageSrc)
714
+ || (isMediaTypeVideo && !viberVideoSrcAndPreview.viberVideoSrc)
697
715
  ) {
698
716
  return true;
699
717
  }
@@ -710,7 +728,7 @@ export const Viber = (props) => {
710
728
  <CapColumn span={14}>
711
729
  {isFullMode ? (
712
730
  <CapInput
713
- id={`viber_input`}
731
+ id="viber_input"
714
732
  onChange={onTextTitleChange}
715
733
  errorMessage={errorMessageTitle}
716
734
  placeholder={formatMessage(
@@ -727,7 +745,7 @@ export const Viber = (props) => {
727
745
  {renderMediaComponent()}
728
746
  {renderTextAreaViber()}
729
747
  {renderButtonsSection()}
730
- <div style={{marginBottom: '100px'}}/>
748
+ <div style={{marginBottom: '100px'}} />
731
749
  </CapColumn>
732
750
  <CapColumn span={6}>
733
751
  <CapRow>
@@ -737,9 +755,17 @@ export const Viber = (props) => {
737
755
  type="h3"
738
756
  style={{margin: '24px 0px 0px 28px'}}
739
757
  >
740
- <FormattedMessage {...messages.message} />: {" "}
741
- ({(messageContent || '').length}/{charLimit} {" "}
742
- <FormattedMessage {...messages.characters} />)
758
+ <FormattedMessage {...messages.message} />
759
+ :
760
+ {" "}
761
+ (
762
+ {(messageContent || '').length}
763
+ /
764
+ {charLimit}
765
+ {' '}
766
+ {" "}
767
+ <FormattedMessage {...messages.characters} />
768
+ )
743
769
  </CapHeading>
744
770
  </CapColumn>
745
771
  </CapRow>