@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.
Files changed (127) hide show
  1. package/constants/unified.js +4 -0
  2. package/index.js +13 -0
  3. package/package.json +1 -1
  4. package/services/getSchema.js +4 -1
  5. package/services/tests/getSchema.test.js +2 -2
  6. package/translations/en.json +1 -0
  7. package/translations/ja-JP.json +1 -0
  8. package/translations/zh.json +1 -0
  9. package/utils/common.js +6 -0
  10. package/utils/createMobilePushPayload.js +33 -47
  11. package/utils/tagValidations.js +35 -4
  12. package/utils/templateVarUtils.js +49 -0
  13. package/utils/tests/createMobilePushPayload.test.js +8 -102
  14. package/utils/tests/tagValidations.test.js +48 -0
  15. package/utils/tests/templateVarUtils.test.js +89 -0
  16. package/v2Components/CapMpushCTA/index.js +9 -10
  17. package/v2Components/CapMpushCTA/index.scss +3 -29
  18. package/v2Components/CapTagList/TagFallbackPanel.js +124 -0
  19. package/v2Components/CapTagList/constants.js +5 -0
  20. package/v2Components/CapTagList/index.js +46 -7
  21. package/v2Components/CapTagList/messages.js +44 -0
  22. package/v2Components/CapTagList/style.scss +113 -1
  23. package/v2Components/CapTagList/tests/TagFallback.test.js +222 -0
  24. package/v2Components/CapTagList/utils.js +17 -0
  25. package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +13 -26
  26. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
  27. package/v2Components/CommonTestAndPreview/constants.js +3 -2
  28. package/v2Components/CommonTestAndPreview/index.js +62 -62
  29. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -79
  30. package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
  31. package/v2Components/CommonTestAndPreview/tests/utils.test.js +102 -0
  32. package/v2Components/CommonTestAndPreview/utils.js +42 -3
  33. package/v2Components/FormBuilder/Classic.js +24 -14
  34. package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +1 -0
  35. package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
  36. package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +57 -0
  37. package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
  38. package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +3 -0
  39. package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +5 -0
  40. package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +6 -0
  41. package/v2Components/FormBuilder/Functional/channels/sms/validate.js +3 -1
  42. package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +3 -0
  43. package/v2Components/FormBuilder/Functional/tests/manual.typingPerf.test.js +135 -0
  44. package/v2Components/FormBuilder/Functional/tests/mpush.crossFlowParity.test.js +1 -1
  45. package/v2Components/FormBuilder/Functional/tests/mpush.ctaFlows.parity.test.js +320 -0
  46. package/v2Components/FormBuilder/Functional/tests/mpush.editContainer.parity.test.js +148 -0
  47. package/v2Components/FormBuilder/Functional/tests/mpush.libraryValidity.parity.test.js +152 -0
  48. package/v2Components/FormBuilder/Functional/tests/mpush.shellEvents.test.js +1 -1
  49. package/v2Components/FormBuilder/Functional/tests/mpush.singlePlatform.test.js +1 -1
  50. package/v2Components/FormBuilder/Functional/tests/mpushRenderers.test.js +22 -0
  51. package/v2Components/FormBuilder/tests/mpush.characterization.test.js +2 -2
  52. package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
  53. package/v2Components/TemplatePreview/index.js +17 -30
  54. package/v2Components/TemplatePreview/tests/index.test.js +0 -61
  55. package/v2Containers/Cap/index.js +3 -0
  56. package/v2Containers/Cap/messages.js +4 -0
  57. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
  58. package/v2Containers/CreativesContainer/SlideBoxContent.js +151 -70
  59. package/v2Containers/CreativesContainer/index.js +6 -3
  60. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -29
  61. package/v2Containers/InApp/index.js +4 -1
  62. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
  63. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
  64. package/v2Containers/Line/Container/Text/index.js +3 -1
  65. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +16 -0
  66. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +18 -0
  67. package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +70 -0
  68. package/v2Containers/MobilePush/Create/actions.js +52 -0
  69. package/v2Containers/MobilePush/Create/constants.js +26 -0
  70. package/v2Containers/MobilePush/Create/index.js +2149 -0
  71. package/v2Containers/MobilePush/Create/messages.js +349 -0
  72. package/v2Containers/MobilePush/Create/reducer.js +72 -0
  73. package/v2Containers/MobilePush/Create/sagas.js +79 -0
  74. package/v2Containers/MobilePush/Create/selectors.js +29 -0
  75. package/v2Containers/MobilePush/Create/test/contentValidity.test.js +154 -0
  76. package/v2Containers/MobilePush/Create/test/saga.test.js +19 -0
  77. package/v2Containers/MobilePush/Create/test/stayOpenOnSave.test.js +80 -0
  78. package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +65 -0
  79. package/v2Containers/MobilePush/Edit/actions.js +94 -0
  80. package/v2Containers/MobilePush/Edit/constants.js +37 -0
  81. package/v2Containers/MobilePush/Edit/index.js +2407 -0
  82. package/v2Containers/MobilePush/Edit/messages.js +341 -0
  83. package/v2Containers/MobilePush/Edit/reducer.js +113 -0
  84. package/v2Containers/MobilePush/Edit/sagas.js +113 -0
  85. package/v2Containers/MobilePush/Edit/selectors.js +33 -0
  86. package/v2Containers/MobilePush/Edit/test/contentValidity.test.js +149 -0
  87. package/v2Containers/MobilePush/Edit/test/saga.test.js +255 -0
  88. package/v2Containers/MobilePush/Edit/test/stayOpenOnSave.test.js +60 -0
  89. package/v2Containers/MobilePush/commonMethods.js +333 -0
  90. package/v2Containers/MobilePush/eventsMap.js +130 -0
  91. package/v2Containers/MobilePush/tests/commonMethods.test.js +401 -0
  92. package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
  93. package/v2Containers/MobilePushNew/components/MediaUploaders.js +192 -207
  94. package/v2Containers/MobilePushNew/components/PlatformContentFields.js +121 -116
  95. package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
  96. package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +72 -316
  97. package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +16 -45
  98. package/v2Containers/MobilePushNew/constants.js +0 -5
  99. package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
  100. package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -52
  101. package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -38
  102. package/v2Containers/MobilePushNew/hooks/useUpload.js +39 -29
  103. package/v2Containers/MobilePushNew/index.js +192 -454
  104. package/v2Containers/MobilePushNew/index.scss +4 -188
  105. package/v2Containers/MobilePushNew/messages.js +6 -86
  106. package/v2Containers/MobilePushNew/tests/index.test.js +1 -450
  107. package/v2Containers/MobilePushNew/tests/utils.test.js +0 -25
  108. package/v2Containers/MobilePushNew/utils.js +0 -8
  109. package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +22 -0
  110. package/v2Containers/MobilepushWrapper/index.js +178 -0
  111. package/v2Containers/MobilepushWrapper/messages.js +29 -0
  112. package/v2Containers/Rcs/index.js +8 -1
  113. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +59 -0
  114. package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -0
  115. package/v2Containers/SmsTrai/Edit/index.js +17 -7
  116. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +42 -0
  117. package/v2Containers/Templates/_templates.scss +2 -10
  118. package/v2Containers/Templates/index.js +90 -84
  119. package/v2Containers/Templates/tests/index.test.js +0 -68
  120. package/v2Containers/Viber/index.js +3 -1
  121. package/v2Containers/WebPush/Create/utils/validation.js +6 -0
  122. package/v2Containers/WebPush/Create/utils/validation.test.js +50 -0
  123. package/v2Containers/Whatsapp/index.js +9 -5
  124. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
  125. package/v2Containers/Zalo/index.js +4 -1
  126. package/v2Components/CapMpushCTA/tests/index.test.js +0 -89
  127. /package/{v2Components/FormBuilder/Functional/tests/fixtures/mpushInitialSchema.js → v2Containers/MobilePush/initialSchema.js} +0 -0
@@ -0,0 +1,178 @@
1
+ /*
2
+ *
3
+ * MobilepushWrapper
4
+ *
5
+ */
6
+ import PropTypes from 'prop-types';
7
+ import React from 'react';
8
+ import { connect } from 'react-redux';
9
+ import { FormattedMessage } from 'react-intl';
10
+ import {CapRadioCard, CapInput} from '@capillarytech/cap-ui-library';
11
+ import ComponentWithLabelHOC from '@capillarytech/cap-ui-library/assets/HOCs/ComponentWithLabelHOC';
12
+ import {isEmpty} from 'lodash';
13
+ import styled from 'styled-components';
14
+ import MobilepushCreate from '../MobilePush/Create';
15
+ import WithImage from '../../assets/WithImage1';
16
+ import WithNoImage from '../../assets/NoImage1';
17
+ import messages from './messages';
18
+ import './_mobilepushWrapper.scss';
19
+
20
+ const CapRadioCardWithLabel = ComponentWithLabelHOC(CapRadioCard);
21
+ const CardContainer = styled.div`
22
+ margin-top: 16px;
23
+ .component-with-label-label{
24
+ margin-bottom: unset;
25
+ }
26
+ .ant-radio-group{
27
+ .ant-radio-button-wrapper{
28
+ &:first-child{
29
+ margin-left: unset;
30
+ margin-top: unset;
31
+ }
32
+ }
33
+
34
+ }
35
+ `;
36
+ export class MobilepushWrapper extends React.Component { // eslint-disable-line react/prefer-stateless-function
37
+ constructor(props) {
38
+ super(props);
39
+ this.modes = [
40
+
41
+ {
42
+ title: <FormattedMessage {...messages.image}/>,
43
+ content: <WithImage height="216px" width={"224px"}/>,
44
+ value: 'image',
45
+ },
46
+ {
47
+ title: <FormattedMessage {...messages.text}/>,
48
+ content: <WithNoImage height="216px" width={"224px"}/>,
49
+ value: 'text',
50
+ // onClick: () => {
51
+ // this.emailUploader.current.click();
52
+ // },
53
+ },
54
+ ];
55
+ this.state = {
56
+ templateName: "",
57
+ };
58
+ }
59
+
60
+
61
+ onChange = (e) => {
62
+ this.props.onMobilepushModeChange( e.target.value );
63
+ };
64
+ onTemplateNameChange = (ev) => {
65
+ const {onEnterTemplateName, onRemoveTemplateName} = this.props;
66
+ this.setState({templateName: ev.target.value});
67
+ if (ev.target.value && onEnterTemplateName) {
68
+ onEnterTemplateName();
69
+ } else if (onRemoveTemplateName) {
70
+ onRemoveTemplateName();
71
+ }
72
+ }
73
+
74
+ render() {
75
+ const {mobilePushCreateMode, step, getFormData, getLiquidTags, setIsLoadingContent, isGetFormData, query, isFullMode, showTemplateName, type, onValidationFail, onPreviewContentClicked, onTestContentClicked, onContentValidityChange, templateData, eventContextTags = [], waitEventContextTags = {},showTestAndPreviewSlidebox, handleTestAndPreview, handleCloseTestAndPreview, restrictPersonalization, isAnonymousType, onPersonalizationTokensChange} = this.props;
76
+ const {templateName} = this.state;
77
+ const isShowMobilepushCreate = !isEmpty(mobilePushCreateMode);
78
+ return (
79
+ <div className="mobilepush-wrapper">
80
+ {step === "modeSelection" ?
81
+ <div>
82
+ {isFullMode &&
83
+ <CapInput
84
+ label={<FormattedMessage {...messages.creativeName}/>}
85
+ onChange={this.onTemplateNameChange}
86
+ value={templateName}
87
+ labelPosition="top"
88
+ size="default"
89
+ />
90
+ }
91
+ <CardContainer>
92
+ <CapRadioCardWithLabel
93
+ label={<FormattedMessage {...messages.createMode}/>}
94
+ panes={this.modes}
95
+ cardHeight={"286px"}
96
+ onChange={this.onChange}
97
+ selected={mobilePushCreateMode}
98
+ />
99
+ </CardContainer>
100
+ </div>
101
+ :
102
+ <div>
103
+ {isShowMobilepushCreate && <MobilepushCreate
104
+ getFormLibraryData={getFormData}
105
+ getLiquidTags={getLiquidTags}
106
+ setIsLoadingContent={setIsLoadingContent}
107
+ defaultData={{"template-name": templateName}}
108
+ location={{
109
+ pathname: `/mobilepush/create/${mobilePushCreateMode}`,
110
+ query,
111
+ }}
112
+ params={{mode: mobilePushCreateMode}}
113
+ isFullMode={isFullMode}
114
+ isGetFormData={isGetFormData}
115
+ showTemplateName={showTemplateName}
116
+ route={{ name: 'mobilepush' }}
117
+ getDefaultTags={type}
118
+ onValidationFail={onValidationFail}
119
+ onPreviewContentClicked={onPreviewContentClicked}
120
+ onTestContentClicked={onTestContentClicked}
121
+ onContentValidityChange={onContentValidityChange}
122
+ templateData={templateData}
123
+ hideTestAndPreviewBtn={this.props.hideTestAndPreviewBtn}
124
+ eventContextTags={eventContextTags}
125
+ waitEventContextTags={waitEventContextTags}
126
+ showLiquidErrorInFooter={this.props.showLiquidErrorInFooter}
127
+ showTestAndPreviewSlidebox={showTestAndPreviewSlidebox}
128
+ handleTestAndPreview={handleTestAndPreview}
129
+ handleCloseTestAndPreview={handleCloseTestAndPreview}
130
+ restrictPersonalization={restrictPersonalization}
131
+ isAnonymousType={isAnonymousType}
132
+ onPersonalizationTokensChange={onPersonalizationTokensChange}
133
+ />
134
+
135
+
136
+ }
137
+ </div>
138
+ }
139
+ </div>
140
+ );
141
+ }
142
+ }
143
+
144
+ MobilepushWrapper.propTypes = {
145
+ onMobilepushModeChange: PropTypes.func,
146
+ mobilePushCreateMode: PropTypes.string,
147
+ step: PropTypes.string,
148
+ getFormData: PropTypes.string,
149
+ getLiquidTags: PropTypes.func,
150
+ setIsLoadingContent: PropTypes.func,
151
+ onEnterTemplateName: PropTypes.func,
152
+ onRemoveTemplateName: PropTypes.func,
153
+ isGetFormData: PropTypes.bool,
154
+ query: PropTypes.object,
155
+ isFullMode: PropTypes.bool,
156
+ showTemplateName: PropTypes.func,
157
+ type: PropTypes.string,
158
+ onValidationFail: PropTypes.func,
159
+ onContentValidityChange: PropTypes.func,
160
+ eventContextTags: PropTypes.array,
161
+ waitEventContextTags: PropTypes.object,
162
+ showLiquidErrorInFooter: PropTypes.func,
163
+ showTestAndPreviewSlidebox: PropTypes.bool,
164
+ handleTestAndPreview: PropTypes.func,
165
+ handleCloseTestAndPreview: PropTypes.func,
166
+ restrictPersonalization: PropTypes.bool,
167
+ isAnonymousType: PropTypes.bool,
168
+ onPersonalizationTokensChange: PropTypes.func,
169
+ };
170
+
171
+
172
+ function mapDispatchToProps(dispatch) {
173
+ return {
174
+ dispatch,
175
+ };
176
+ }
177
+
178
+ export default connect(null, mapDispatchToProps)(MobilepushWrapper);
@@ -0,0 +1,29 @@
1
+ /*
2
+ * MobilepushWrapper Messages
3
+ *
4
+ * This contains all the text for the MobilepushWrapper component.
5
+ */
6
+ import { defineMessages } from 'react-intl';
7
+
8
+ export default defineMessages({
9
+ header: {
10
+ id: 'creatives.containersV2.MobilepushWrapper.header',
11
+ defaultMessage: 'This is MobilepushWrapper container !',
12
+ },
13
+ image: {
14
+ id: 'creatives.containersV2.MobilepushWrapper.image',
15
+ defaultMessage: 'Image content',
16
+ },
17
+ text: {
18
+ id: 'creatives.containersV2.MobilepushWrapper.text',
19
+ defaultMessage: 'Text content',
20
+ },
21
+ createMode: {
22
+ id: 'creatives.containersV2.MobilepushWrapper.createMode',
23
+ defaultMessage: 'Which type of content you want to create?',
24
+ },
25
+ creativeName: {
26
+ id: 'creatives.containersV2.MobilepushWrapper.creativeName',
27
+ defaultMessage: 'Creative name',
28
+ },
29
+ });
@@ -800,6 +800,8 @@ export const Rcs = (props) => {
800
800
  })) ||
801
801
  (validationResponse.isBraceError &&
802
802
  formatMessage(globalMessages.unbalanacedCurlyBraces)) ||
803
+ (validationResponse.isDefaultQuoteError &&
804
+ formatMessage(globalMessages.unquotedTagDefaultValue)) ||
803
805
  false;
804
806
  if (type === TITLE_TEXT) setTemplateTitleError(errorMsg);
805
807
  if (type === MESSAGE_TEXT) setTemplateDescError(errorMsg);
@@ -851,6 +853,8 @@ export const Rcs = (props) => {
851
853
  })) ||
852
854
  (validationResponse.isBraceError &&
853
855
  formatMessage(globalMessages.unbalanacedCurlyBraces)) ||
856
+ (validationResponse.isDefaultQuoteError &&
857
+ formatMessage(globalMessages.unquotedTagDefaultValue)) ||
854
858
  false;
855
859
  updateCarouselErrors(idx, { [field]: errorMsg });
856
860
  });
@@ -1808,7 +1812,7 @@ export const Rcs = (props) => {
1808
1812
 
1809
1813
  const templateDescErrorHandler = (value) => {
1810
1814
  let errorMessage = false;
1811
- const { unsupportedTags, isBraceError } = validateTags({
1815
+ const { unsupportedTags, isBraceError, isDefaultQuoteError } = validateTags({
1812
1816
  content: value,
1813
1817
  tagsParam: tags,
1814
1818
  injectedTagsParams: injectedTags,
@@ -1829,6 +1833,9 @@ export const Rcs = (props) => {
1829
1833
  if (isBraceError) {
1830
1834
  errorMessage = formatMessage(globalMessages.unbalanacedCurlyBraces);
1831
1835
  }
1836
+ if (isDefaultQuoteError) {
1837
+ errorMessage = formatMessage(globalMessages.unquotedTagDefaultValue);
1838
+ }
1832
1839
  return errorMessage;
1833
1840
  };
1834
1841