@capillarytech/creatives-library 6.3.7 → 6.4.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 (43) hide show
  1. package/app.js +63 -10
  2. package/components/CapTagList/index.js +5 -5
  3. package/components/EmailPreview/index.js +3 -3
  4. package/components/FormBuilder/index.js +2 -2
  5. package/components/PreviewSideBar/index.js +8 -8
  6. package/components/Sidebar/index.js +7 -7
  7. package/components/TemplatePreview/index.js +7 -7
  8. package/containers/Ebill/index.js +2 -2
  9. package/containers/Email/index.js +25 -18
  10. package/containers/Line/Create/index.js +2 -2
  11. package/containers/Line/Edit/index.js +7 -7
  12. package/containers/MobilePush/Create/index.js +5 -5
  13. package/containers/MobilePush/Edit/index.js +5 -5
  14. package/containers/Sms/Create/index.js +1 -1
  15. package/containers/Sms/Edit/index.js +1 -1
  16. package/containers/Templates/index.js +8 -8
  17. package/containers/WeChat/MapTemplates/index.js +1 -1
  18. package/containers/WeChat/RichmediaTemplates/Create/index.js +5 -3
  19. package/package.json +6 -3
  20. package/utils/Formatter.js +1 -1
  21. package/v2Components/CapTagList/index.js +7 -7
  22. package/v2Components/EmailPreview/index.js +1 -1
  23. package/v2Components/FormBuilder/index.js +4 -4
  24. package/v2Components/NavigationBar/index.js +3 -3
  25. package/v2Components/PreviewSideBar/index.js +8 -8
  26. package/v2Components/TemplatePreview/index.js +3 -3
  27. package/v2Containers/CreativesContainer/SlideBoxContent.js +5 -5
  28. package/v2Containers/CreativesContainer/SlideBoxHeader.js +1 -1
  29. package/v2Containers/CreativesContainer/index.js +5 -5
  30. package/v2Containers/Ebill/index.js +2 -2
  31. package/v2Containers/Email/index.js +19 -14
  32. package/v2Containers/Email/sagas.js +1 -1
  33. package/v2Containers/EmailWrapper/index.js +1 -1
  34. package/v2Containers/Line/Create/index.js +1 -1
  35. package/v2Containers/Line/Edit/index.js +5 -5
  36. package/v2Containers/MobilePush/Create/index.js +5 -5
  37. package/v2Containers/MobilePush/Edit/index.js +8 -8
  38. package/v2Containers/Sms/Create/index.js +1 -1
  39. package/v2Containers/Sms/Edit/index.js +1 -1
  40. package/v2Containers/Templates/index.js +27 -25
  41. package/v2Containers/WeChat/MapTemplates/index.js +1 -1
  42. package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +4 -2
  43. package/v2Containers/WeChat/Wrapper/index.js +2 -2
@@ -343,16 +343,16 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
343
343
  licenseCode: selectedWeChatAccount.sourceAccountIdentifier,
344
344
  };
345
345
  if (this.props.location.query && this.props.location.query.module !== 'dvs') {
346
- obj.definition.mode = this.props.Edit.templateDetails.mode || get(this, 'props.Edit.templateDetails.definition.mode');
346
+ obj.definition.mode = get(this, 'props.Edit.templateDetails.mode', '') || get(this, 'props.Edit.templateDetails.definition.mode', '');
347
347
  }
348
348
  const android = {};
349
- Object.keys(formData[0]).forEach((data) => {
349
+ Object.keys(formData[0] || {}).forEach((data) => {
350
350
  if (!!formData[0][data] && data !== "tabKey") {
351
351
  android[data] = formData[0][data];
352
352
  }
353
353
  });
354
354
  const ios = {};
355
- Object.keys(formData[1]).forEach((data) => {
355
+ Object.keys(formData[1] || {}).forEach((data) => {
356
356
  if (!!formData[1][data] && data !== "tabKey") {
357
357
  ios[data] = formData[1][data];
358
358
  }
@@ -447,8 +447,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
447
447
  if (secondaryCta1) {
448
448
  const cta = {
449
449
  actionText: android['secondary-cta-0-label'],
450
- type: android['cta-deeplink-secondary-cta-0'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
451
- actionLink: android['cta-deeplink-secondary-cta-0'].toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-0-select'] : android['cta-deeplink-secondary-cta-0-text'],
450
+ type: (android['cta-deeplink-secondary-cta-0'] || '').toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
451
+ actionLink: (android['cta-deeplink-secondary-cta-0'] || '').toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-0-select'] : android['cta-deeplink-secondary-cta-0-text'],
452
452
  seccdeepLinkName: this.getLinkName(android['cta-deeplink-secondary-cta-0-select']),
453
453
  };
454
454
  if (this.props.location.query.type === 'embedded') {
@@ -472,8 +472,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
472
472
  if (secondaryCta2) {
473
473
  obj.versions.base.ANDROID.expandableDetails.ctas.push({
474
474
  actionText: android['secondary-cta-1-label'],
475
- type: android['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
476
- actionLink: android['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-1-select'] : android['cta-deeplink-secondary-cta-1-text'],
475
+ type: (android['cta-deeplink-secondary-cta-1'] || '').toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
476
+ actionLink: (android['cta-deeplink-secondary-cta-1'] || '').toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-1-select'] : android['cta-deeplink-secondary-cta-1-text'],
477
477
  seccdeepLinkName: this.getLinkName(android['cta-deeplink-secondary-cta-1-select']),
478
478
  });
479
479
  if (obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
@@ -1746,7 +1746,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1746
1746
  const query = {
1747
1747
  layout: 'mobilepush',
1748
1748
  type: 'TAG',
1749
- context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
1749
+ context: (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
1750
1750
  embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
1751
1751
  };
1752
1752
  this.props.globalActions.fetchSchemaForEntity(query);
@@ -831,7 +831,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
831
831
  const query = {
832
832
  layout: 'SMS',
833
833
  type: 'TAG',
834
- context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
834
+ context: (data && data.toLowerCase() === 'all') ? 'default' : (data && data.toLowerCase()),
835
835
  embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
836
836
  };
837
837
  this.props.globalActions.fetchSchemaForEntity(query);
@@ -398,7 +398,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
398
398
  const query = {
399
399
  layout: 'SMS',
400
400
  type: 'TAG',
401
- context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
401
+ context: (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
402
402
  embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
403
403
  };
404
404
  this.props.globalActions.fetchSchemaForEntity(query);
@@ -182,7 +182,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
182
182
  if (this.props.location.query.type === 'embedded') {
183
183
  this.props.actions.resetAccount();
184
184
  }
185
- if (this.state.channel.toLowerCase() === 'line' || this.state.channel.toLowerCase() === 'sms' || this.state.channel.toLowerCase() === 'email' || this.state.channel.toLowerCase() === 'ebill' || ((this.state.channel.toLowerCase() === 'wechat' || this.state.channel.toLowerCase() === 'mobilepush') && !isEmpty(this.props.Templates.selectedWeChatAccount))) {
185
+ if ((this.state.channel && (this.state.channel.toLowerCase() === 'line' || this.state.channel.toLowerCase() === 'sms' || this.state.channel.toLowerCase() === 'email' || this.state.channel.toLowerCase() === 'ebill')) || ((this.state.channel.toLowerCase() === 'wechat' || this.state.channel.toLowerCase() === 'mobilepush') && !isEmpty(this.props.Templates.selectedWeChatAccount))) {
186
186
  const queryParams = {
187
187
  // name: this.state.searchText,
188
188
  // sortBy: this.state.sortBy,
@@ -214,7 +214,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
214
214
 
215
215
  window.addEventListener("message", this.handleFrameTasks);
216
216
  }
217
- componentWillReceiveProps(nextProps) {
217
+ componentWillReceiveProps(nextProps = {}) {
218
218
  const params = {
219
219
  name: this.state.searchText,
220
220
  sortBy: this.state.sortBy,
@@ -249,7 +249,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
249
249
  }
250
250
  }
251
251
  this.setState({ channel }, () => {
252
- if (this.state.channel.toLowerCase() === 'line' || this.state.channel.toLowerCase() === 'sms' || this.state.channel.toLowerCase() === 'email' || this.state.channel.toLowerCase() === 'ebill' || (this.state.channel.toLowerCase() === 'wechat' && !isEmpty(nextProps.Templates.selectedWeChatAccount))) {
252
+ if ((this.state.channel.toLowerCase() === 'line' || this.state.channel.toLowerCase() === 'sms' || this.state.channel.toLowerCase() === 'email' || this.state.channel.toLowerCase() === 'ebill') || (this.state.channel.toLowerCase() === 'wechat' && !isEmpty(nextProps.Templates.selectedWeChatAccount))) {
253
253
  if (this.state.channel.toLowerCase() === 'wechat' && !isEmpty(nextProps.Templates.selectedWeChatAccount)) {
254
254
  params.wecrmId = nextProps.Templates.selectedWeChatAccount.configs.wecrm_app_id;
255
255
  params.wecrmToken = nextProps.Templates.selectedWeChatAccount.configs.wecrm_token;
@@ -262,12 +262,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
262
262
  }
263
263
  });
264
264
  }
265
- if (this.state.channel.toLowerCase() === 'wechat' && nextProps.Templates.selectedWeChatAccount) {
265
+ if ((this.state.channel || '').toLowerCase() === 'wechat' && nextProps.Templates.selectedWeChatAccount) {
266
266
  params.wecrmId = nextProps.Templates.selectedWeChatAccount.configs.wecrm_app_id;
267
267
  params.wecrmToken = nextProps.Templates.selectedWeChatAccount.configs.wecrm_token;
268
268
  params.originalId = nextProps.Templates.selectedWeChatAccount.sourceAccountIdentifier;
269
269
  }
270
- if (this.state.channel.toLowerCase() === "mobilepush" && nextProps.Templates.selectedWeChatAccount) {
270
+ if ((this.state.channel || '').toLowerCase() === "mobilepush" && nextProps.Templates.selectedWeChatAccount) {
271
271
  params.accountId = nextProps.Templates.selectedWeChatAccount.id;
272
272
  }
273
273
  if ((this.state.channel.toLowerCase() === 'wechat' || this.state.channel.toLowerCase() === 'mobilepush') && isEmpty(nextProps.Templates.selectedWeChatAccount) && (this.props.location.query.type === 'embedded') && !this.isEnabledInLibraryModule("showAccountSelection")) {
@@ -301,25 +301,25 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
301
301
  this.getAllTemplates({params});
302
302
  }
303
303
  }
304
- if (this.state.channel.toLowerCase() === "mobilepush" && nextProps.CreateMobilePush && nextProps.CreateMobilePush.response && nextProps.CreateMobilePush.response.templateId && nextProps.CreateMobilePush.response.templateId !== '') {
304
+ if ((this.state.channel || '').toLowerCase() === "mobilepush" && nextProps.CreateMobilePush && nextProps.CreateMobilePush.response && nextProps.CreateMobilePush.response.templateId && nextProps.CreateMobilePush.response.templateId !== '') {
305
305
 
306
306
  }
307
307
 
308
- if (this.state.channel.toLowerCase() === "ebill" && nextProps.CreateEbill && nextProps.CreateEbill.createResponse && nextProps.CreateEbill.createResponse.templateId && nextProps.CreateEbill.createResponse.templateId !== '') {
308
+ if ((this.state.channel || '').toLowerCase() === "ebill" && nextProps.CreateEbill && nextProps.CreateEbill.createResponse && nextProps.CreateEbill.createResponse.templateId && nextProps.CreateEbill.createResponse.templateId !== '') {
309
309
  const message = `${this.state.channel} ${this.props.intl.formatMessage(messages.templateDuplicateSuccess)}`;
310
310
  CapNotification.success({key: 'duplicateSucess', message});
311
311
  this.getAllTemplates({params, resetPage: true});
312
312
  this.props.ebillActions.clearStoreValues();
313
313
  }
314
314
 
315
- if (this.state.channel.toLowerCase() === "email" && nextProps.EmailCreate && nextProps.EmailCreate.duplicateResponse && nextProps.EmailCreate.duplicateResponse.templateId && nextProps.EmailCreate.duplicateResponse.templateId !== '') {
315
+ if ((this.state.channel || '').toLowerCase() === "email" && nextProps.EmailCreate && nextProps.EmailCreate.duplicateResponse && nextProps.EmailCreate.duplicateResponse.templateId && nextProps.EmailCreate.duplicateResponse.templateId !== '') {
316
316
  const message = `${this.state.channel} ${this.props.intl.formatMessage(messages.templateDuplicateSuccess)}`;
317
317
  CapNotification.success({key: 'duplicateSucess', message});
318
318
  this.getAllTemplates({params, resetPage: true});
319
319
  this.props.emailActions.clearStoreValues();
320
320
  }
321
321
 
322
- if (this.state.channel.toLowerCase() === "line" && nextProps.Line && nextProps.Line.response && nextProps.Line.response.templateId && nextProps.Line.response.templateId !== '') {
322
+ if ((this.state.channel || '').toLowerCase() === "line" && nextProps.Line && nextProps.Line.response && nextProps.Line.response.templateId && nextProps.Line.response.templateId !== '') {
323
323
  const message = `${this.state.channel} ${this.props.intl.formatMessage(messages.templateDuplicateSuccess)}`;
324
324
  CapNotification.success({key: 'duplicateSuccess', message});
325
325
  this.getAllTemplates({params, resetPage: true});
@@ -329,14 +329,16 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
329
329
  if (nextProps.Create && this.props.Create && nextProps.Create.createTemplateError && !isEqual(nextProps.Create.createTemplateError, this.props.Create.createTemplateError)) {
330
330
  const message = this.props.intl.formatMessage(messages.somethingWentWrong);
331
331
  CapNotification.error({key: 'somethingWrong', message});
332
- if (this.state.channel.toLowerCase() === "sms") {
333
- this.props.smsActions.clearCreateResponse();
334
- } else if (this.state.channel.toLowerCase() === "mobilepush") {
335
- this.props.mobilepushActions.clearCreateResponse();
336
- } else if (this.state.channel.toLowerCase() === "ebill") {
337
- this.props.ebillActions.clearCreateResponse();
338
- } else if (this.state.channel.toLowerCase() === "line") {
339
- this.props.lineActions.clearCreateResponse();
332
+ if ( this.state.channel) {
333
+ if (this.state.channel.toLowerCase() === "sms") {
334
+ this.props.smsActions.clearCreateResponse();
335
+ } else if (this.state.channel.toLowerCase() === "mobilepush") {
336
+ this.props.mobilepushActions.clearCreateResponse();
337
+ } else if (this.state.channel.toLowerCase() === "ebill") {
338
+ this.props.ebillActions.clearCreateResponse();
339
+ } else if (this.state.channel.toLowerCase() === "line") {
340
+ this.props.lineActions.clearCreateResponse();
341
+ }
340
342
  }
341
343
  }
342
344
 
@@ -360,7 +362,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
360
362
  return;
361
363
  }
362
364
  this.setState({routeParams: {
363
- pathname: `/${nextProps.route.name.toLowerCase()}/create`,
365
+ pathname: `/${(nextProps.route.name || '').toLowerCase()}/create`,
364
366
  query: type === 'embedded' ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module},
365
367
  }});
366
368
  }
@@ -618,7 +620,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
618
620
  if (url) {
619
621
  templateData.url = url;
620
622
  } else {
621
- templateData.content = template.versions.base.subject;
623
+ templateData.content = template.versions.base && template.versions.base.subject;
622
624
  }
623
625
  break;
624
626
  }
@@ -738,10 +740,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
738
740
  this.setState({loading: true, routeParams});
739
741
  }
740
742
 
741
- handleMenuAction = (item) => {
742
- if (item.key.toLowerCase() === 'uploadfile') {
743
+ handleMenuAction = (item = {}) => {
744
+ if ((item.key || '').toLowerCase() === 'uploadfile') {
743
745
  document.getElementById('filename').click();
744
- } else if (item.key.toLowerCase() === 'useeditor') {
746
+ } else if ((item.key || '').toLowerCase() === 'useeditor') {
745
747
  this.toggleEdmEmailTemplateSelection();
746
748
  }
747
749
  };
@@ -795,7 +797,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
795
797
  return;
796
798
  }
797
799
  this.setState({routeParams: {
798
- pathname: `/${this.props.route.name.toLowerCase()}/create`,
800
+ pathname: `/${(this.props.route.name || '').toLowerCase()}/create`,
799
801
  query: type === 'embedded' ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module},
800
802
  }});
801
803
  };
@@ -1063,7 +1065,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1063
1065
  this.getAllTemplates({params, resetPage: true});
1064
1066
  });
1065
1067
  }
1066
- handleType = (data) => {
1068
+ handleType = (data = '') => {
1067
1069
  this.setState({mode: data}, () => {
1068
1070
  const params = {
1069
1071
  name: this.state.searchText,
@@ -1746,7 +1748,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1746
1748
  // const isfilterContentVisisble = !isEmpty(this.props.TemplatesList) || !isEmpty(this.state.searchText) || !isEmpty(this.props.Templates.templateError);
1747
1749
  const isfilterContentVisisble = true;
1748
1750
  const isWechatEmbedded = !this.props.isFullMode && channel.toUpperCase() === WECHAT;
1749
- const channelLowerCase = channel.toLowerCase();
1751
+ const channelLowerCase = (channel || '').toLowerCase();
1750
1752
  const filterContent = (( isfilterContentVisisble || [WECHAT, MOBILE_PUSH].includes(this.state.channel.toUpperCase())) && <div className="action-container">
1751
1753
  {isfilterContentVisisble && <CapInput.Search
1752
1754
  className="search-text"
@@ -884,7 +884,7 @@ export class MapTemplates extends React.Component { // eslint-disable-line react
884
884
  const query = {
885
885
  layout: 'WECHAT',
886
886
  type: 'TAG',
887
- context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
887
+ context: (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
888
888
  embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
889
889
  };
890
890
  this.props.globalActions.fetchSchemaForEntity(query);
@@ -776,7 +776,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
776
776
  let isRepeated = false;
777
777
  forEach(templateData, (content) => {
778
778
  const setSizeBefore = titleSet.size;
779
- titleSet.add(content.formData['title-value'].toLowerCase());
779
+ titleSet.add((content.formData['title-value'] || '').toLowerCase());
780
780
  const setSizeAfter = titleSet.size;
781
781
  if (setSizeAfter === setSizeBefore) {
782
782
  isRepeated = true;
@@ -973,7 +973,9 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
973
973
  }
974
974
 
975
975
  updateContentData = () => {
976
- this.state.editorInstanse.insertHtml(`<img src='${this.props.ContentImageData.metaInfo.wechatUrl}' alt='Capillary Image'>`);
976
+ if (this.state.editorInstanse) {
977
+ this.state.editorInstanse.insertHtml(`<img src='${this.props.ContentImageData.metaInfo.wechatUrl}' alt='Capillary Image'>`);
978
+ }
977
979
  this.props.actions.clearContentImageStore();
978
980
  this.setState({loading: false});
979
981
  }
@@ -123,7 +123,7 @@ export class Wrapper extends React.Component { // eslint-disable-line react/pref
123
123
  }
124
124
  }
125
125
  getPreviewContent() {
126
- const { templateType, templateData } = this.props;
126
+ const { templateType, templateData = {} } = this.props;
127
127
  switch (templateType) {
128
128
  case RICH_MEDIA:
129
129
  return (<WechatRichmediaTemplatePreview
@@ -135,7 +135,7 @@ export class Wrapper extends React.Component { // eslint-disable-line react/pref
135
135
  case MAP_TEMPLATE:
136
136
  default:
137
137
  return (<TemplatePreview
138
- channel={templateData.type.toLowerCase()}
138
+ channel={(templateData.type || '').toLowerCase()}
139
139
  content={templateData.content}
140
140
  />);
141
141
  }