@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.
Files changed (81) hide show
  1. package/constants/unified.js +0 -1
  2. package/index.js +0 -13
  3. package/package.json +1 -1
  4. package/services/getSchema.js +1 -4
  5. package/services/tests/getSchema.test.js +2 -2
  6. package/utils/common.js +0 -6
  7. package/utils/createMobilePushPayload.js +47 -33
  8. package/utils/tests/createMobilePushPayload.test.js +102 -8
  9. package/v2Components/CapMpushCTA/index.js +10 -9
  10. package/v2Components/CapMpushCTA/index.scss +29 -3
  11. package/v2Components/CapMpushCTA/tests/index.test.js +89 -0
  12. package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +26 -13
  13. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +13 -1
  14. package/v2Components/CommonTestAndPreview/constants.js +2 -0
  15. package/v2Components/CommonTestAndPreview/index.js +49 -11
  16. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +79 -5
  17. package/v2Components/CommonTestAndPreview/tests/index.test.js +86 -0
  18. package/v2Components/FormBuilder/Functional/tests/mpush.crossFlowParity.test.js +1 -1
  19. package/v2Components/FormBuilder/Functional/tests/mpush.shellEvents.test.js +1 -1
  20. package/v2Components/FormBuilder/Functional/tests/mpush.singlePlatform.test.js +1 -1
  21. package/v2Components/FormBuilder/tests/mpush.characterization.test.js +2 -2
  22. package/v2Components/TemplatePreview/_templatePreview.scss +12 -2
  23. package/v2Components/TemplatePreview/index.js +30 -17
  24. package/v2Components/TemplatePreview/tests/index.test.js +61 -0
  25. package/v2Containers/Cap/index.js +0 -3
  26. package/v2Containers/CreativesContainer/SlideBoxContent.js +70 -151
  27. package/v2Containers/CreativesContainer/index.js +3 -6
  28. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +29 -0
  29. package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
  30. package/v2Containers/MobilePushNew/components/MediaUploaders.js +207 -192
  31. package/v2Containers/MobilePushNew/components/PlatformContentFields.js +116 -121
  32. package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +30 -208
  33. package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +316 -72
  34. package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +45 -16
  35. package/v2Containers/MobilePushNew/constants.js +5 -0
  36. package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
  37. package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +52 -0
  38. package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +38 -1
  39. package/v2Containers/MobilePushNew/hooks/useUpload.js +29 -39
  40. package/v2Containers/MobilePushNew/index.js +453 -188
  41. package/v2Containers/MobilePushNew/index.scss +188 -4
  42. package/v2Containers/MobilePushNew/messages.js +86 -6
  43. package/v2Containers/MobilePushNew/tests/index.test.js +450 -1
  44. package/v2Containers/MobilePushNew/tests/utils.test.js +25 -0
  45. package/v2Containers/MobilePushNew/utils.js +8 -0
  46. package/v2Containers/Templates/_templates.scss +10 -2
  47. package/v2Containers/Templates/index.js +84 -90
  48. package/v2Containers/Templates/tests/index.test.js +68 -0
  49. package/v2Components/FormBuilder/Functional/tests/manual.typingPerf.test.js +0 -135
  50. package/v2Components/FormBuilder/Functional/tests/mpush.ctaFlows.parity.test.js +0 -320
  51. package/v2Components/FormBuilder/Functional/tests/mpush.editContainer.parity.test.js +0 -148
  52. package/v2Components/FormBuilder/Functional/tests/mpush.libraryValidity.parity.test.js +0 -152
  53. package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +0 -70
  54. package/v2Containers/MobilePush/Create/actions.js +0 -52
  55. package/v2Containers/MobilePush/Create/constants.js +0 -26
  56. package/v2Containers/MobilePush/Create/index.js +0 -2149
  57. package/v2Containers/MobilePush/Create/messages.js +0 -349
  58. package/v2Containers/MobilePush/Create/reducer.js +0 -72
  59. package/v2Containers/MobilePush/Create/sagas.js +0 -79
  60. package/v2Containers/MobilePush/Create/selectors.js +0 -29
  61. package/v2Containers/MobilePush/Create/test/contentValidity.test.js +0 -154
  62. package/v2Containers/MobilePush/Create/test/saga.test.js +0 -19
  63. package/v2Containers/MobilePush/Create/test/stayOpenOnSave.test.js +0 -80
  64. package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +0 -65
  65. package/v2Containers/MobilePush/Edit/actions.js +0 -94
  66. package/v2Containers/MobilePush/Edit/constants.js +0 -37
  67. package/v2Containers/MobilePush/Edit/index.js +0 -2407
  68. package/v2Containers/MobilePush/Edit/messages.js +0 -341
  69. package/v2Containers/MobilePush/Edit/reducer.js +0 -113
  70. package/v2Containers/MobilePush/Edit/sagas.js +0 -113
  71. package/v2Containers/MobilePush/Edit/selectors.js +0 -33
  72. package/v2Containers/MobilePush/Edit/test/contentValidity.test.js +0 -149
  73. package/v2Containers/MobilePush/Edit/test/saga.test.js +0 -255
  74. package/v2Containers/MobilePush/Edit/test/stayOpenOnSave.test.js +0 -60
  75. package/v2Containers/MobilePush/commonMethods.js +0 -333
  76. package/v2Containers/MobilePush/eventsMap.js +0 -130
  77. package/v2Containers/MobilePush/tests/commonMethods.test.js +0 -401
  78. package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +0 -22
  79. package/v2Containers/MobilepushWrapper/index.js +0 -178
  80. package/v2Containers/MobilepushWrapper/messages.js +0 -29
  81. /package/{v2Containers/MobilePush/initialSchema.js → v2Components/FormBuilder/Functional/tests/fixtures/mpushInitialSchema.js} +0 -0
@@ -1,333 +0,0 @@
1
- import {get, filter, cloneDeep} from 'lodash';
2
- import React from 'react';
3
- import {FormattedMessage} from 'react-intl';
4
- import messages from './Create/messages';
5
- import { MOBILE_PUSH_PLATFORM_COUNT } from './Create/constants';
6
- import { extractContent } from '../../utils/commonUtils';
7
- function getPrimaryCtaFields({inputFields, fieldIndex, deepLinkOptions, tab}) {
8
- const currentTab = tab || this.state.currentTab;
9
- const newInputFields = cloneDeep(inputFields);
10
- newInputFields.splice(fieldIndex + 1, 0, {
11
- rowClassName: 'mobile-push-row',
12
- identifier: `cta-deeplink${currentTab > 1 ? currentTab : ''}`,
13
-
14
- cols: [
15
- {
16
- id: `cta-deeplink${currentTab > 1 ? currentTab : ''}`,
17
- type: "radioGroup", //Resembles component to be used
18
- metaType: "text",
19
- datatype: "string",
20
- options: ["Deeplink", "External Link"],
21
- inductiveText: [<FormattedMessage {...messages.aPageWithMobileApp}/>, <FormattedMessage {...messages.anExternalWebPage}/>],
22
- value: "Deeplink",
23
- required: true,
24
- width: 18,
25
- offset: 1,
26
- errorMessage: "Please select link type",
27
- fluid: true,
28
- styling: "semantic",
29
- order: 1,
30
- customComponent: false,
31
- supportedEvents: ["onChange"],
32
- },
33
-
34
- ],
35
- });
36
- newInputFields.splice(fieldIndex + 2, 0, {
37
- rowClassName: 'mobile-push-row',
38
- id: 'cta-deeplink-select-section',
39
- identifier: `cta-deeplink${currentTab > 1 ? currentTab : ''}-select`,
40
-
41
- cols: [
42
-
43
- {
44
- id: `cta-deeplink${currentTab > 1 ? currentTab : ''}-select`,
45
- placeholder: "Select DeepLink",
46
- type: "select", //Resembles component to be used
47
- options: deepLinkOptions,
48
- metaType: "text",
49
- datatype: "string",
50
- required: true,
51
- errorMessage: "Select a deeplink",
52
- fluid: true,
53
- width: 18,
54
- offset: 1,
55
- style: {
56
- width: '100%',
57
-
58
-
59
- marginBottom: '16px',
60
- },
61
- styling: "semantic",
62
- order: 1,
63
- customComponent: false,
64
- supportedEvents: [
65
- 'onSelect',
66
- ],
67
- },
68
- ],
69
- });
70
- return newInputFields;
71
- }
72
-
73
- function getSecondaryCtaFields({inputFields, fieldIndex, deepLinkOptions}) {
74
- const inputId = `secondary-cta-${get(inputFields[fieldIndex], 'cols[0]').fieldsCount}`;
75
- const newInputFields = cloneDeep(inputFields);
76
- newInputFields.splice(fieldIndex + 1, 0, {
77
- rowClassName: 'mobile-push-row',
78
- cols: [
79
-
80
- {
81
- id: `${inputId}-label`,
82
- label: "Button label",
83
- type: "input", //Resembles component to be used
84
- metaType: "text",
85
- datatype: "string",
86
- required: true,
87
- width: 18,
88
- offset: 1,
89
- placeholder: "Enter CTA Label here",
90
- fluid: true,
91
- styling: "semantic",
92
- order: 1,
93
- customComponent: false,
94
- errorMessage: "CTA label cannot be empty.",
95
- },
96
-
97
- ],
98
- });
99
- newInputFields.splice(fieldIndex + 2, 0, {
100
- rowClassName: 'mobile-push-row',
101
- identifier: `cta-deeplink-${inputId}`,
102
- cols: [
103
-
104
- {
105
- id: `cta-deeplink-${inputId}`,
106
- type: "radioGroup", //Resembles component to be used
107
- metaType: "text",
108
- datatype: "string",
109
- options: ["Deeplink", "External Link"],
110
- inductiveText: [<FormattedMessage {...messages.aPageWithMobileApp}/>, <FormattedMessage {...messages.anExternalWebPage}/>],
111
- value: "Deeplink",
112
- required: true,
113
- width: 18,
114
- offset: 1,
115
- errorMessage: "Please select link type",
116
- fluid: true,
117
- styling: "semantic",
118
- order: 1,
119
-
120
- customComponent: false,
121
- supportedEvents: ["onChange"],
122
- },
123
- ],
124
- });
125
- newInputFields.splice(fieldIndex + 3, 0, {
126
- rowClassName: 'mobile-push-row',
127
- id: 'cta-deeplink-select-section',
128
- identifier: `cta-deeplink-${inputId}-select`,
129
- cols: [
130
-
131
-
132
- {
133
- id: `cta-deeplink-${inputId}-select`,
134
- placeholder: "Select DeepLink",
135
- type: "select", //Resembles component to be used
136
- options: deepLinkOptions,
137
- errorMessage: "Select a deeplink",
138
- metaType: "text",
139
- datatype: "string",
140
- required: true,
141
- fluid: true,
142
- width: 18,
143
- offset: 1,
144
- style: {
145
- width: '100%',
146
- marginBottom: '16px',
147
- },
148
- styling: "semantic",
149
- order: 1,
150
- customComponent: false,
151
- supportedEvents: [
152
- 'onSelect',
153
- ],
154
- },
155
- ],
156
- });
157
- return newInputFields;
158
- }
159
- function getLinkTypeFields({inputFieldsArgs, fieldIndex, deepLinkOptions, formData, field, tab}) {
160
- const currentTab = tab || this.state.currentTab;
161
- const inputFields = cloneDeep(inputFieldsArgs);
162
- const deeplinks = this.props.Templates.selectedWeChatAccount && this.props.Templates.selectedWeChatAccount.configs && !!this.props.Templates.selectedWeChatAccount.configs.deeplink ? this.props.Templates.selectedWeChatAccount.configs.deeplink : '[]';
163
- const deeplinkValue = formData[currentTab - 1][field.id];
164
- const componentIndex = fieldIndex + 1;
165
- const inputId = deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" ? `${field.id}-select` : `${field.id}-text`;
166
- if ( deeplinkValue && deeplinkValue.toLowerCase() === "deeplink" && (fieldIndex === inputFields.length - 1 || inputFields[componentIndex].id !== "cta-deeplink-select-section")) {
167
- const deleteCount = get(inputFields, `[${componentIndex}].id`) === "cta-external-link" ? 1 : 0;
168
- inputFields.splice(componentIndex, deleteCount, {
169
- rowClassName: 'mobile-push-row',
170
- id: 'cta-deeplink-select-section',
171
- identifier: inputId,
172
- cols: [
173
-
174
- {
175
- id: inputId,
176
- placeholder: "Select DeepLink",
177
- type: "select", //Resembles component to be used
178
- options: deepLinkOptions,
179
- metaType: "text",
180
- datatype: "string",
181
- errorMessage: "Select a deeplink",
182
- required: true,
183
- fluid: true,
184
- width: 18,
185
- offset: 1,
186
- style: {
187
- width: '100%',
188
-
189
- marginBottom: '16px',
190
- },
191
- styling: "semantic",
192
- order: 1,
193
- customComponent: false,
194
- supportedEvents: [
195
- 'onSelect',
196
- ],
197
- },
198
- ],
199
- });
200
- } else if ( deeplinkValue && deeplinkValue.toLowerCase() === "external link") {
201
- const row = {
202
- rowClassName: 'mobile-push-row',
203
- id: 'cta-external-link',
204
- identifier: inputId,
205
-
206
- cols: [
207
- {
208
- // Add label control for external link input
209
- id: "title-tagList",
210
- label: "Add label",
211
- type: "tag-list",
212
- metaType: "List",
213
- datatype: "select",
214
- required: true,
215
- fluid: true,
216
- onlyDisplay: true,
217
- style: {
218
- marginRight: "10%",
219
- marginTop: "-3%",
220
- display: 'flex',
221
- justifyContent: 'end',
222
- width: '100%',
223
- },
224
- styling: "semantic",
225
- order: 2,
226
- customComponent: true,
227
- // Helps handler identify the destination input
228
- target: inputId,
229
- supportedEvents: [
230
- "onTagSelect",
231
- ],
232
- },
233
- {
234
- id: inputId,
235
- placeholder: "External Link",
236
- type: "input", //Resembles component to be used
237
- metaType: "text",
238
- datatype: "string",
239
- errorMessage: <FormattedMessage {...messages.invalidExternalLink}/>,
240
- required: true,
241
- fluid: true,
242
- width: 18,
243
- offset: 1,
244
- style: {
245
- width: '95%',
246
- },
247
- styling: "semantic",
248
- order: 1,
249
- customComponent: false,
250
- standalone: false,
251
- },
252
- ],
253
- };
254
- if (!inputFields[fieldIndex + 1] || inputFields[componentIndex].id === "cta-deeplink-select-section") {
255
- inputFields[componentIndex] = row;
256
- if (inputFields[componentIndex + 1] && inputFields[componentIndex + 1].id === "show-cta-deeplink-keys-label") {
257
- inputFields.splice(componentIndex + 1, 1);
258
- }
259
- if (inputFields[componentIndex + 1] && inputFields[componentIndex + 1].id === "cta-deeplink-keys") {
260
- let configkeys = filter(JSON.parse(deeplinks), (dl) => dl.link === formData[this.state.currentTab - 1][`${field.id}-select`]);
261
- if (configkeys[0]) {
262
- configkeys = configkeys[0].keys;
263
- }
264
- if (configkeys.length) {
265
- //inputFields = inputFields.slice(0, componentIndex + 1).concat(inputFields.slice( componentIndex + 1 + configkeys.length, inputFields.length));
266
-
267
- inputFields.splice(componentIndex + 1, configkeys.length);
268
- }
269
- }
270
- } else {
271
- inputFields.splice(componentIndex, 0, row);
272
- }
273
- }
274
- return inputFields;
275
- }
276
-
277
- function getContent(obj) {
278
- const base = obj?.versions?.base || {};
279
- const android = base.ANDROID || {};
280
- const ios = base.IOS || {};
281
- const androidTitle = android.title || '';
282
- const androidMessage = android.message || '';
283
- const iosTitle = ios.title || '';
284
- const iosMessage = ios.message || '';
285
- return `${androidTitle} ${androidMessage} ${iosTitle} ${iosMessage}`;
286
- }
287
-
288
- /**
289
- * Extracts the plain-text content of a single Mobile Push tab (Android or iOS),
290
- * mirroring the shape-detection logic in `validateMobilePushContent`
291
- * (app/utils/commonUtils.js) so "empty" is defined consistently in both places.
292
- * @param {number} tabIndex 0 = Android, 1 = iOS
293
- * @param {object} tabData formData[tabIndex]
294
- * @returns {string}
295
- */
296
- function getMobilePushTabContent(tabIndex, tabData) {
297
- if (!tabData || typeof tabData !== 'object') {
298
- return '';
299
- }
300
- const titleKey = tabIndex === 1 ? 'message-title2' : 'message-title';
301
- const messageKey = tabIndex === 1 ? 'message-editor2' : 'message-editor';
302
- const isOldUiShape = titleKey in tabData || messageKey in tabData;
303
- if (isOldUiShape) {
304
- return [tabData[titleKey], tabData[messageKey]].filter(Boolean).join(' ');
305
- }
306
- return extractContent(tabData);
307
- }
308
-
309
- /**
310
- * Live "is content empty" check for the legacy Mobile Push Edit/Create forms — the
311
- * Mobile Push analogue of Sms's `getSmsEmbeddedFooterValidity` (see
312
- * app/v2Containers/Sms/smsFormDataHelpers.js). Checks both platform tabs (Android =
313
- * formData[0], iOS = formData[1]); Mobile Push allows saving with just one platform
314
- * filled in, so the overall content is empty only when BOTH tabs' title+message
315
- * are empty.
316
- * @param {object} formData FormBuilder state (same shape as this.state.formData)
317
- * @returns {{ isContentEmpty: boolean }}
318
- */
319
- function getMobilePushEmbeddedContentValidity(formData) {
320
- for (let i = 0; i < MOBILE_PUSH_PLATFORM_COUNT; i++) {
321
- const content = getMobilePushTabContent(i, formData?.[i]);
322
- const trimmed = content != null && content !== '' ? String(content).trim() : '';
323
- if (trimmed) {
324
- return { isContentEmpty: false };
325
- }
326
- }
327
- return { isContentEmpty: true };
328
- }
329
-
330
- export {
331
- getPrimaryCtaFields, getSecondaryCtaFields, getLinkTypeFields, getContent,
332
- getMobilePushEmbeddedContentValidity
333
- };
@@ -1,130 +0,0 @@
1
- const getEventsMap = (context) => ({
2
- "template-name": {
3
- onChange: context.onTemplateNameChange,
4
- },
5
- "cta-deeplink-secondary-cta-0": {
6
- onChange: context.onLinkTypeChange,
7
- },
8
- "cta-deeplink-secondary-cta-1": {
9
- onChange: context.onLinkTypeChange,
10
- },
11
- "cta-deeplink-secondary-cta-12": {
12
- onChange: context.onLinkTypeChange,
13
- },
14
- "cta-deeplink-delete": {
15
- onDelete: context.deletePrimaryCTA,
16
- },
17
- "cta-deeplink2-delete": {
18
- onDelete: context.deletePrimaryCTA,
19
- },
20
- "secondary-cta-0-delete": {
21
- onDelete: context.deleteSecondaryCTA,
22
- },
23
- "secondary-cta-1-delete": {
24
- onDelete: context.deleteSecondaryCTA,
25
- },
26
- "secondary-cta-1-delete-ios": {
27
- onDelete: context.deleteSecondaryCtaIos,
28
- },
29
- "discard-button": {
30
- discardValues: context.discardValues,
31
- },
32
- "cancel-button": {
33
- cancelTemplate: context.cancelTemplate,
34
- },
35
- "copy-android-content": {
36
- onClick: context.copyAndroidContent,
37
- },
38
- "copy-iphone-content": {
39
- onClick: context.copyIphoneContent,
40
- },
41
- "save-button": {
42
- saveFormData: context.saveFormData,
43
- },
44
- "message-editor": {
45
- onChange: context.onTemplateContentChange,
46
- },
47
- "message-editor2": {
48
- onChange: context.onTemplateContentChange,
49
- },
50
- "message-tagList": {
51
- onTagSelect: context.onTagSelect,
52
- },
53
- "message-tagList2": {
54
- onTagSelect: context.onTagSelect,
55
- },
56
- "title-tagList": {
57
- onTagSelect: context.onTagSelect,
58
- },
59
- "title-tagList2": {
60
- onTagSelect: context.onTagSelect,
61
- },
62
- "pane": {
63
- onTabChange: context.onTabChange,
64
- },
65
- "cta-deeplink": {
66
- onChange: context.onLinkTypeChange,
67
- },
68
- "cta-deeplink2": {
69
- onChange: context.onLinkTypeChange,
70
- },
71
- "cta-deeplink-secondary-cta-1-select": {
72
- onSelect: context.showCtaKeys,
73
- },
74
- "cta-deeplink-secondary-cta-0-select": {
75
- onSelect: context.showCtaKeys,
76
- },
77
- "cta-deeplink-secondary-cta-1-select2": {
78
- onSelect: context.showCtaKeys,
79
- },
80
- "cta-deeplink-select": {
81
- onSelect: context.showCtaKeys,
82
- },
83
- "cta-deeplink2-select": {
84
- onSelect: context.showCtaKeys,
85
- },
86
- "add-pri-cta": {
87
- addPrimaryCta: context.addPrimaryCta,
88
- },
89
- "add-pri-cta-ios": {
90
- addPrimaryCta: context.addPrimaryCta,
91
- },
92
- "add-sec-cta": {
93
- addSecondaryCta: context.addSecondoryCta,
94
- },
95
- "add-sec-cta-2": {
96
- addSecondaryCta: context.addSecondoryCta,
97
- },
98
- "add-sec-cta-ios": {
99
- addSecondaryCtaIos: context.addSecondoryCtaIos,
100
- },
101
-
102
- "image": {
103
- onUpload: context.uploadImage,
104
- },
105
- "image-upload-ios": {
106
- onUpload: context.uploadImage,
107
- },
108
- "secondary-cta-1-table": {
109
- onRowClick: context.selectCtaIos,
110
- },
111
- "cta-deeplink-select-show-keys": {
112
- onShowCtaKeys: context.showCtaKeys,
113
- },
114
- "cta-deeplink-secondary-cta-0-select-show-keys": {
115
- onShowCtaKeys: context.showCtaKeys,
116
- },
117
- "cta-deeplink-secondary-cta-1-select-show-keys": {
118
- onShowCtaKeys: context.showCtaKeys,
119
- },
120
- "wechat-template": {
121
- onSelect: context.onTemplateChange,
122
- },
123
- "mobilepush-template": {
124
- onSelect: context.onTemplateChange,
125
- },
126
- "test-and-preview-button": {
127
- onClick: context.handleTestAndPreview,
128
- },
129
- });
130
- export default getEventsMap;