@capillarytech/creatives-library 9.0.70-alpha.sprint-cap-modalintact.12 → 9.0.70
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/package.json +1 -1
- package/v2Containers/CreativesContainer/SlideBoxContent.js +3 -2
- package/v2Containers/CreativesContainer/constants.js +1 -0
- package/v2Containers/CreativesContainer/index.js +8 -8
- package/v2Containers/CreativesContainer/tests/index.test.js +20 -0
- package/v2Containers/Email/index.js +2 -2
- package/v2Containers/Sms/Create/index.js +1 -1
- package/v2Containers/Sms/Edit/index.js +3 -3
package/package.json
CHANGED
|
@@ -20,6 +20,7 @@ import { RICH_MEDIA, MAP_TEMPLATE, CREATE } from '../WeChat/Wrapper/constants';
|
|
|
20
20
|
import CallTask from '../CallTask';
|
|
21
21
|
import MobliPushEdit from '../MobilePush/Edit';
|
|
22
22
|
import * as constants from './constants';
|
|
23
|
+
import { SMS as SMS_LOWERCASE } from '../../constants/unified';
|
|
23
24
|
import LineContainer from '../Line/Container';
|
|
24
25
|
import FTP from '../FTP';
|
|
25
26
|
import Viber from '../Viber';
|
|
@@ -272,7 +273,7 @@ export function SlideBoxContent(props) {
|
|
|
272
273
|
isEditSms: true,
|
|
273
274
|
location: creativesLocationProps,
|
|
274
275
|
isFullMode,
|
|
275
|
-
route: { name:
|
|
276
|
+
route: { name: SMS_LOWERCASE },
|
|
276
277
|
isGetFormData,
|
|
277
278
|
getFormSubscriptionData: getFormData,
|
|
278
279
|
getDefaultTags: type,
|
|
@@ -670,7 +671,7 @@ export function SlideBoxContent(props) {
|
|
|
670
671
|
showLiquidErrorInFooter={showLiquidErrorInFooter}
|
|
671
672
|
setIsLoadingContent={setIsLoadingContent}
|
|
672
673
|
location={creativesLocationProps}
|
|
673
|
-
route={{ name:
|
|
674
|
+
route={{ name: SMS_LOWERCASE }}
|
|
674
675
|
isCreateSms={isCreateSms}
|
|
675
676
|
isComponent
|
|
676
677
|
templateData={templateData}
|
|
@@ -25,6 +25,7 @@ export const INAPP = "INAPP";
|
|
|
25
25
|
export const WEBPUSH = "WEBPUSH";
|
|
26
26
|
export const WEBPUSH_BRAND_ICON = "WEBPUSH_BRAND_ICON";
|
|
27
27
|
export const PREVIEW = "preview";
|
|
28
|
+
export const CREATE_TEMPLATE = "createTemplate";
|
|
28
29
|
export const EDIT_TEMPLATE = "editTemplate";
|
|
29
30
|
export const JOURNEY = "journey";
|
|
30
31
|
export const HTML = "HTML";
|
|
@@ -1205,8 +1205,8 @@ export class Creatives extends React.Component {
|
|
|
1205
1205
|
const { Templates, templateData: templateDataProps } = this.props;
|
|
1206
1206
|
const { accountDetails: selectedAccountDetails, accountId: selectedAccountId } = templateDataProps || {};
|
|
1207
1207
|
const selectedLineAccount = Templates && Templates.selectedLineAccount;
|
|
1208
|
-
const accountDetails =
|
|
1209
|
-
const accountId =
|
|
1208
|
+
const accountDetails = (selectedLineAccount ? JSON.stringify(selectedLineAccount) : selectedAccountDetails);
|
|
1209
|
+
const accountId = (selectedLineAccount ? selectedLineAccount.id : '') || selectedAccountId || '';
|
|
1210
1210
|
templateData = {
|
|
1211
1211
|
channel,
|
|
1212
1212
|
accountId,
|
|
@@ -1221,7 +1221,7 @@ export class Creatives extends React.Component {
|
|
|
1221
1221
|
const { accountDetails: selectedAccountDetails, accountId: selectedAccountId } = templateDataProps || {};
|
|
1222
1222
|
const selectedViberAccount = Templates && Templates.selectedViberAccount;
|
|
1223
1223
|
const accountDetails = (selectedViberAccount ? JSON.stringify(selectedViberAccount) : selectedAccountDetails);
|
|
1224
|
-
const accountId =
|
|
1224
|
+
const accountId = (selectedViberAccount ? selectedViberAccount.id : '') || selectedAccountId || '';
|
|
1225
1225
|
const { versions } = template.value;
|
|
1226
1226
|
const content = cloneDeep(versions.base.content);
|
|
1227
1227
|
content.scenarioKey = accountDetails ? get(JSON.parse(accountDetails), 'configs.scenario_key') : "";
|
|
@@ -1239,7 +1239,7 @@ export class Creatives extends React.Component {
|
|
|
1239
1239
|
const selectedWhatsappAccount = Templates?.selectedWhatsappAccount;
|
|
1240
1240
|
const { accountDetails: selectedAccountDetails, accountId: selectedAccountId } = templateDataProps || {};
|
|
1241
1241
|
const accountDetails = (selectedWhatsappAccount || selectedAccountDetails);
|
|
1242
|
-
const accountId =
|
|
1242
|
+
const accountId = selectedWhatsappAccount?.id || selectedAccountId || '';
|
|
1243
1243
|
const { versions } = template.value;
|
|
1244
1244
|
const {
|
|
1245
1245
|
languages = [{}],
|
|
@@ -1714,13 +1714,13 @@ export class Creatives extends React.Component {
|
|
|
1714
1714
|
|
|
1715
1715
|
getFormData = (template) => {
|
|
1716
1716
|
// Full-mode save that stays open: host only refreshes its list (creates need edit permission).
|
|
1717
|
-
const canStayOpen = this.state.slidBoxContent !==
|
|
1717
|
+
const canStayOpen = this.state.slidBoxContent !== constants.CREATE_TEMPLATE || this.props.switchToEditAfterCreate;
|
|
1718
1718
|
if (this.props.isFullMode && template?.keepSlideBoxOpen && canStayOpen) {
|
|
1719
1719
|
this.setState({ isGetFormData: false });
|
|
1720
1720
|
if (template.continuedAsEdit) {
|
|
1721
1721
|
this.handleCreateContinuedAsEdit(); // header switches to the edit title
|
|
1722
1722
|
}
|
|
1723
|
-
this.props.getCreativesData({ channel: this.state.currentChannel
|
|
1723
|
+
this.props.getCreativesData({ channel: this.state.currentChannel?.toUpperCase(), keepSlideBoxOpen: true });
|
|
1724
1724
|
return;
|
|
1725
1725
|
}
|
|
1726
1726
|
// Always reset isGetFormData so the child does not re-send form data on every re-render
|
|
@@ -2356,8 +2356,8 @@ export class Creatives extends React.Component {
|
|
|
2356
2356
|
channel={currentChannel}
|
|
2357
2357
|
messages={this.props.messages}
|
|
2358
2358
|
// Edit title after an in-place create
|
|
2359
|
-
slidBoxContent={this.state.isCreateContinuedAsEdit && this.state.slidBoxContent ===
|
|
2360
|
-
?
|
|
2359
|
+
slidBoxContent={this.state.isCreateContinuedAsEdit && this.state.slidBoxContent === constants.CREATE_TEMPLATE
|
|
2360
|
+
? constants.EDIT_TEMPLATE
|
|
2361
2361
|
: this.state.slidBoxContent}
|
|
2362
2362
|
templateData={templateData}
|
|
2363
2363
|
onShowTemplates={this.onShowTemplates}
|
|
@@ -139,6 +139,26 @@ describe('Test SlideBoxContent container', () => {
|
|
|
139
139
|
expect(getCreativesData).toHaveBeenCalledTimes(2);
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
+
it('WhatsApp getCreativesData prefers the live-selected account id over a stale carried-over accountId', async () => {
|
|
143
|
+
renderFunction('WHATSAPP', 'editTemplate', whatsappTemplates, {
|
|
144
|
+
accountId: 853,
|
|
145
|
+
accountName: 'Mochishoes_rcs',
|
|
146
|
+
});
|
|
147
|
+
const data = await renderedComponent
|
|
148
|
+
.instance()
|
|
149
|
+
.getCreativesData('WHATSAPP', whatsappGetCreativeData1, whatsappGetCreativeData1);
|
|
150
|
+
expect(data.accountId).toBe(12721);
|
|
151
|
+
expect(data.accountName).toBe('WhatsappAccount');
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('WhatsApp getCreativesData resolves the live account id when there is no carryover (fresh content)', async () => {
|
|
155
|
+
renderFunction('WHATSAPP', 'editTemplate', whatsappTemplates, {});
|
|
156
|
+
const data = await renderedComponent
|
|
157
|
+
.instance()
|
|
158
|
+
.getCreativesData('WHATSAPP', whatsappGetCreativeData1, whatsappGetCreativeData1);
|
|
159
|
+
expect(data.accountId).toBe(12721);
|
|
160
|
+
});
|
|
161
|
+
|
|
142
162
|
it('It should clear templateData, on channel change.', async () => {
|
|
143
163
|
renderFunction(
|
|
144
164
|
'WHATSAPP',
|
|
@@ -1038,7 +1038,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
1038
1038
|
const savedResponse = createResponse.templateId;
|
|
1039
1039
|
const {versions, ...rest} = _.isPlainObject(savedResponse) ? savedResponse : {};
|
|
1040
1040
|
const savedTemplateId = rest._id || (_.isString(savedResponse) ? savedResponse : '')
|
|
1041
|
-
|| previouslySavedTemplate?._id || this.props.Email
|
|
1041
|
+
|| previouslySavedTemplate?._id || this.props.Email?.templateDetails?._id;
|
|
1042
1042
|
const savedTemplate = { ...this.lastSavePayload, _id: savedTemplateId, name: rest.name || this.lastSavePayload?.name };
|
|
1043
1043
|
this.originalBaseTemplateContent = _.get(savedTemplate, ['versions', 'base', this.getBaseLanguage(), 'template-content']);
|
|
1044
1044
|
this.setState({ savedTemplate, exportHtmlContentLocked: false });
|
|
@@ -2089,7 +2089,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2089
2089
|
|
|
2090
2090
|
exportHtml = () => {
|
|
2091
2091
|
// After a full-mode save the stored details are stale (or absent for a create): export what was just saved
|
|
2092
|
-
const templateDetails = this.state.savedTemplate || this.props.Email
|
|
2092
|
+
const templateDetails = this.state.savedTemplate || this.props.Email?.templateDetails;
|
|
2093
2093
|
if (_.isEmpty(templateDetails) || this.state.exportHtmlContentLocked) {
|
|
2094
2094
|
CapNotification.error({ message: this.props.intl.formatMessage(messages.exportHtmlError) });
|
|
2095
2095
|
return;
|
|
@@ -269,7 +269,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
269
269
|
savedTemplateId,
|
|
270
270
|
} = this.state;
|
|
271
271
|
const isUpdate = !!savedTemplateId; // a later save of the template created in this session
|
|
272
|
-
if (editResponse
|
|
272
|
+
if (editResponse?.templateId) {
|
|
273
273
|
const savedResponse = editResponse.templateId; // the template or just its id
|
|
274
274
|
const templateId = (_.isPlainObject(savedResponse) ? savedResponse._id : savedResponse) || savedTemplateId;
|
|
275
275
|
gtmPush('creativeDetails', {
|
|
@@ -272,7 +272,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
272
272
|
const {
|
|
273
273
|
formData
|
|
274
274
|
} = this.state;
|
|
275
|
-
if (editResponse
|
|
275
|
+
if (editResponse?.templateId) {
|
|
276
276
|
gtmPush('creativeDetails', {
|
|
277
277
|
id: editResponse.templateId,
|
|
278
278
|
name: formData?.['template-name'],
|
|
@@ -288,7 +288,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
288
288
|
const type = this.props.location.query.type;
|
|
289
289
|
if (this.props.isFullMode) {
|
|
290
290
|
// Stay in edit mode with the saved content; the slidebox is closed only via its close icon
|
|
291
|
-
const {versions, ...rest} = editResponse.templateId;
|
|
291
|
+
const {versions, ...rest} = _.isPlainObject(editResponse.templateId) ? editResponse.templateId : {};
|
|
292
292
|
this.props.getFormSubscriptionData({ value: versions, ...rest, validity: true, keepSlideBoxOpen: true });
|
|
293
293
|
} else {
|
|
294
294
|
this.resetSchema();
|
|
@@ -544,7 +544,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
544
544
|
|
|
545
545
|
resetSchema() {
|
|
546
546
|
// Back to Edit's own injected layout (a fresh copy, since versions mutate the active schema)
|
|
547
|
-
this.setState({ schema: _.cloneDeep(this.injectedSchema || this.props.metaEntities
|
|
547
|
+
this.setState({ schema: _.cloneDeep(this.injectedSchema || this.props.metaEntities?.layouts?.[0]?.definition) });
|
|
548
548
|
}
|
|
549
549
|
|
|
550
550
|
validateFormData(formData) {
|