@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.
- package/constants/unified.js +4 -0
- package/index.js +13 -0
- package/package.json +1 -1
- package/services/getSchema.js +4 -1
- package/services/tests/getSchema.test.js +2 -2
- package/translations/en.json +1 -0
- package/translations/ja-JP.json +1 -0
- package/translations/zh.json +1 -0
- package/utils/common.js +6 -0
- package/utils/createMobilePushPayload.js +33 -47
- package/utils/tagValidations.js +35 -4
- package/utils/templateVarUtils.js +49 -0
- package/utils/tests/createMobilePushPayload.test.js +8 -102
- package/utils/tests/tagValidations.test.js +48 -0
- package/utils/tests/templateVarUtils.test.js +89 -0
- package/v2Components/CapMpushCTA/index.js +9 -10
- package/v2Components/CapMpushCTA/index.scss +3 -29
- package/v2Components/CapTagList/TagFallbackPanel.js +124 -0
- package/v2Components/CapTagList/constants.js +5 -0
- package/v2Components/CapTagList/index.js +46 -7
- package/v2Components/CapTagList/messages.js +44 -0
- package/v2Components/CapTagList/style.scss +113 -1
- package/v2Components/CapTagList/tests/TagFallback.test.js +222 -0
- package/v2Components/CapTagList/utils.js +17 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +13 -26
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
- package/v2Components/CommonTestAndPreview/constants.js +3 -2
- package/v2Components/CommonTestAndPreview/index.js +62 -62
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -79
- package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
- package/v2Components/CommonTestAndPreview/tests/utils.test.js +102 -0
- package/v2Components/CommonTestAndPreview/utils.js +42 -3
- package/v2Components/FormBuilder/Classic.js +24 -14
- package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +1 -0
- package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
- package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +57 -0
- package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
- package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +3 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +5 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +6 -0
- package/v2Components/FormBuilder/Functional/channels/sms/validate.js +3 -1
- package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +3 -0
- package/v2Components/FormBuilder/Functional/tests/manual.typingPerf.test.js +135 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.crossFlowParity.test.js +1 -1
- package/v2Components/FormBuilder/Functional/tests/mpush.ctaFlows.parity.test.js +320 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.editContainer.parity.test.js +148 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.libraryValidity.parity.test.js +152 -0
- 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/Functional/tests/mpushRenderers.test.js +22 -0
- package/v2Components/FormBuilder/tests/mpush.characterization.test.js +2 -2
- package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
- package/v2Components/TemplatePreview/index.js +17 -30
- package/v2Components/TemplatePreview/tests/index.test.js +0 -61
- package/v2Containers/Cap/index.js +3 -0
- package/v2Containers/Cap/messages.js +4 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +151 -70
- package/v2Containers/CreativesContainer/index.js +6 -3
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -29
- package/v2Containers/InApp/index.js +4 -1
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
- package/v2Containers/Line/Container/Text/index.js +3 -1
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +16 -0
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +18 -0
- package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +70 -0
- package/v2Containers/MobilePush/Create/actions.js +52 -0
- package/v2Containers/MobilePush/Create/constants.js +26 -0
- package/v2Containers/MobilePush/Create/index.js +2149 -0
- package/v2Containers/MobilePush/Create/messages.js +349 -0
- package/v2Containers/MobilePush/Create/reducer.js +72 -0
- package/v2Containers/MobilePush/Create/sagas.js +79 -0
- package/v2Containers/MobilePush/Create/selectors.js +29 -0
- package/v2Containers/MobilePush/Create/test/contentValidity.test.js +154 -0
- package/v2Containers/MobilePush/Create/test/saga.test.js +19 -0
- package/v2Containers/MobilePush/Create/test/stayOpenOnSave.test.js +80 -0
- package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +65 -0
- package/v2Containers/MobilePush/Edit/actions.js +94 -0
- package/v2Containers/MobilePush/Edit/constants.js +37 -0
- package/v2Containers/MobilePush/Edit/index.js +2407 -0
- package/v2Containers/MobilePush/Edit/messages.js +341 -0
- package/v2Containers/MobilePush/Edit/reducer.js +113 -0
- package/v2Containers/MobilePush/Edit/sagas.js +113 -0
- package/v2Containers/MobilePush/Edit/selectors.js +33 -0
- package/v2Containers/MobilePush/Edit/test/contentValidity.test.js +149 -0
- package/v2Containers/MobilePush/Edit/test/saga.test.js +255 -0
- package/v2Containers/MobilePush/Edit/test/stayOpenOnSave.test.js +60 -0
- package/v2Containers/MobilePush/commonMethods.js +333 -0
- package/v2Containers/MobilePush/eventsMap.js +130 -0
- package/v2Containers/MobilePush/tests/commonMethods.test.js +401 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +192 -207
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +121 -116
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +72 -316
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +16 -45
- package/v2Containers/MobilePushNew/constants.js +0 -5
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -52
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -38
- package/v2Containers/MobilePushNew/hooks/useUpload.js +39 -29
- package/v2Containers/MobilePushNew/index.js +192 -454
- package/v2Containers/MobilePushNew/index.scss +4 -188
- package/v2Containers/MobilePushNew/messages.js +6 -86
- package/v2Containers/MobilePushNew/tests/index.test.js +1 -450
- package/v2Containers/MobilePushNew/tests/utils.test.js +0 -25
- package/v2Containers/MobilePushNew/utils.js +0 -8
- package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +22 -0
- package/v2Containers/MobilepushWrapper/index.js +178 -0
- package/v2Containers/MobilepushWrapper/messages.js +29 -0
- package/v2Containers/Rcs/index.js +8 -1
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +59 -0
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -0
- package/v2Containers/SmsTrai/Edit/index.js +17 -7
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +42 -0
- package/v2Containers/Templates/_templates.scss +2 -10
- package/v2Containers/Templates/index.js +90 -84
- package/v2Containers/Templates/tests/index.test.js +0 -68
- package/v2Containers/Viber/index.js +3 -1
- package/v2Containers/WebPush/Create/utils/validation.js +6 -0
- package/v2Containers/WebPush/Create/utils/validation.test.js +50 -0
- package/v2Containers/Whatsapp/index.js +9 -5
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
- package/v2Containers/Zalo/index.js +4 -1
- package/v2Components/CapMpushCTA/tests/index.test.js +0 -89
- /package/{v2Components/FormBuilder/Functional/tests/fixtures/mpushInitialSchema.js → v2Containers/MobilePush/initialSchema.js} +0 -0
|
@@ -0,0 +1,333 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
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;
|