@capillarytech/creatives-library 6.3.7 → 6.4.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 (42) hide show
  1. package/components/CapTagList/index.js +5 -5
  2. package/components/EmailPreview/index.js +3 -3
  3. package/components/FormBuilder/index.js +2 -2
  4. package/components/PreviewSideBar/index.js +8 -8
  5. package/components/Sidebar/index.js +7 -7
  6. package/components/TemplatePreview/index.js +7 -7
  7. package/containers/Ebill/index.js +2 -2
  8. package/containers/Email/index.js +25 -18
  9. package/containers/Line/Create/index.js +2 -2
  10. package/containers/Line/Edit/index.js +7 -7
  11. package/containers/MobilePush/Create/index.js +5 -5
  12. package/containers/MobilePush/Edit/index.js +5 -5
  13. package/containers/Sms/Create/index.js +1 -1
  14. package/containers/Sms/Edit/index.js +1 -1
  15. package/containers/Templates/index.js +8 -8
  16. package/containers/WeChat/MapTemplates/index.js +1 -1
  17. package/containers/WeChat/RichmediaTemplates/Create/index.js +5 -3
  18. package/package.json +1 -1
  19. package/utils/Formatter.js +1 -1
  20. package/v2Components/CapTagList/index.js +7 -7
  21. package/v2Components/EmailPreview/index.js +1 -1
  22. package/v2Components/FormBuilder/index.js +4 -4
  23. package/v2Components/NavigationBar/index.js +3 -3
  24. package/v2Components/PreviewSideBar/index.js +8 -8
  25. package/v2Components/TemplatePreview/index.js +3 -3
  26. package/v2Containers/CreativesContainer/SlideBoxContent.js +5 -5
  27. package/v2Containers/CreativesContainer/SlideBoxHeader.js +1 -1
  28. package/v2Containers/CreativesContainer/index.js +5 -5
  29. package/v2Containers/Ebill/index.js +2 -2
  30. package/v2Containers/Email/index.js +19 -14
  31. package/v2Containers/Email/sagas.js +1 -1
  32. package/v2Containers/EmailWrapper/index.js +1 -1
  33. package/v2Containers/Line/Create/index.js +1 -1
  34. package/v2Containers/Line/Edit/index.js +5 -5
  35. package/v2Containers/MobilePush/Create/index.js +5 -5
  36. package/v2Containers/MobilePush/Edit/index.js +5 -5
  37. package/v2Containers/Sms/Create/index.js +1 -1
  38. package/v2Containers/Sms/Edit/index.js +1 -1
  39. package/v2Containers/Templates/index.js +27 -25
  40. package/v2Containers/WeChat/MapTemplates/index.js +1 -1
  41. package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +4 -2
  42. package/v2Containers/WeChat/Wrapper/index.js +2 -2
@@ -50,16 +50,16 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
50
50
  this.handleOnExpand(info.node.props.eventKey);
51
51
  };
52
52
 
53
- getSearchedExpandedKeys(tags, value) {
53
+ getSearchedExpandedKeys(tags, value = '') {
54
54
  let list = [];
55
55
  _.forEach(tags, (val, key) => {
56
56
  if (_.has(val, 'subtags')) {
57
- if (val.name.toLowerCase().indexOf(value.toLowerCase()) !== -1) {
57
+ if ((val.name || '').toLowerCase().indexOf(value.toLowerCase()) !== -1) {
58
58
  list.push(key);
59
59
  }
60
60
  const temp = this.getSearchedExpandedKeys(val.subtags, value);
61
61
  list = list.concat(temp);
62
- } else if (val.name.toLowerCase().indexOf(value.toLowerCase()) !== -1) {
62
+ } else if ((val.name || '').toLowerCase().indexOf(value.toLowerCase()) !== -1) {
63
63
  list.push(key);
64
64
  }
65
65
  });
@@ -135,7 +135,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
135
135
  this.setState({showModal: true, visible: false});
136
136
  };
137
137
 
138
- renderTags(tags, searchString) {
138
+ renderTags(tags, searchString = '') {
139
139
  console.log('final tags list', tags);
140
140
  const list = [];
141
141
  _.forEach(tags, (val, key) => {
@@ -152,7 +152,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
152
152
  {temp}
153
153
  </TreeNode>
154
154
  ));
155
- } else if (searchString === '' || !searchString || val.name.toLowerCase().indexOf(searchString.toLowerCase()) !== -1) {
155
+ } else if (searchString === '' || !searchString || ((val.name || '').toLowerCase().indexOf(searchString.toLowerCase()) !== -1)) {
156
156
  const tempNode = (<TreeNode title={val.name} isLeaf key={key}></TreeNode>);
157
157
  list.push(tempNode);
158
158
  }
@@ -57,9 +57,9 @@ class EmailPreview extends React.Component { // eslint-disable-line react/prefer
57
57
  <div id="emailPreivew-content">
58
58
  {/* {this.props.content} */}
59
59
  <div className="device-wrapper">
60
- <div onClick={() => this.props.changePreviewDevice("desktop")} className={(this.props.device.toLowerCase() === "desktop") ? "device-name active" : "device-name"}><FormattedMessage {...messages.desktop} /></div>
61
- <div onClick={() => this.props.changePreviewDevice("tablet")} className={(this.props.device.toLowerCase() === "tablet") ? "device-name active" : "device-name"}><FormattedMessage {...messages.tablet} /></div>
62
- <div onClick={() => this.props.changePreviewDevice("mobile")} className={(this.props.device.toLowerCase() === "mobile") ? "device-name active" : "device-name"}><FormattedMessage {...messages.mobile} /></div>
60
+ <div onClick={() => this.props.changePreviewDevice("desktop")} className={((this.props.device || '').toLowerCase() === "desktop") ? "device-name active" : "device-name"}><FormattedMessage {...messages.desktop} /></div>
61
+ <div onClick={() => this.props.changePreviewDevice("tablet")} className={((this.props.device || '').toLowerCase() === "tablet") ? "device-name active" : "device-name"}><FormattedMessage {...messages.tablet} /></div>
62
+ <div onClick={() => this.props.changePreviewDevice("mobile")} className={((this.props.device || '').toLowerCase() === "mobile") ? "device-name active" : "device-name"}><FormattedMessage {...messages.mobile} /></div>
63
63
  </div>
64
64
  <div className="email-preview-container">
65
65
  <div className={this.props.device === 'desktop' ? '' : "shell align-center"}>
@@ -1996,7 +1996,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1996
1996
  const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
1997
1997
  const module = this.props.location.query.module ? this.props.location.query.module : 'default';
1998
1998
  this.props.router.push({
1999
- pathname: `/${this.props.schema.channel.toLowerCase()}/`,
1999
+ pathname: `/${(this.props.schema.channel || '').toLowerCase()}/`,
2000
2000
  query: type === 'embedded' ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module, isLanguageSupport, isEdmSupport},
2001
2001
  });
2002
2002
  } else if (id === "email-language-delete-modal") {
@@ -2093,7 +2093,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2093
2093
  //
2094
2094
  const temp = {};
2095
2095
  temp.id = template._id;
2096
- if (this.props.schema.channel.toLowerCase() === 'email') {
2096
+ if ((this.props.schema.channel || '').toLowerCase() === 'email') {
2097
2097
  //
2098
2098
  const imgSrc = template && template.versions && template.versions.base ? template.versions.base.preview_http_url : '';
2099
2099
  const content = <img src={imgSrc || ''} alt="" />;
@@ -51,10 +51,10 @@ class PreviewSideBar extends React.Component { // eslint-disable-line react/pref
51
51
  console.log('preview sidebar', this.props);
52
52
  // const modeTypeLine = this.props.templateData.modeType; // expected: (text or image)
53
53
  let content = '';
54
- if (this.props.channel.toLowerCase() === 'wechat') {
54
+ if ((this.props.channel || '').toLowerCase() === 'wechat') {
55
55
  console.log('Template Infog ', this.props.templateData);
56
56
  content = this.props.templateData.content;
57
- } else if (this.props.channel.toLowerCase() === "mobilepush" && !_.isEmpty(this.props.templateData)) {
57
+ } else if ((this.props.channel || '').toLowerCase() === "mobilepush" && !_.isEmpty(this.props.templateData)) {
58
58
  const data = this.state.device === "android" ? this.props.templateData.versions.base.ANDROID : this.props.templateData.versions.base.IOS;
59
59
  content = {
60
60
  header: data.title,
@@ -70,7 +70,7 @@ class PreviewSideBar extends React.Component { // eslint-disable-line react/pref
70
70
  content.actions = [{label: data.expandableDetails.ctas[0].actionLabel}, {label: data.expandableDetails.ctas[0].actionLabel2}];
71
71
  }
72
72
  }
73
- } else if (this.props.channel.toLowerCase() === "line") {
73
+ } else if ((this.props.channel || '').toLowerCase() === "line") {
74
74
  const isMsgReady = (this.props.templateData && this.props.templateData.versions && this.props.templateData.versions.base);
75
75
  if (isMsgReady) {
76
76
  content = {
@@ -87,7 +87,7 @@ class PreviewSideBar extends React.Component { // eslint-disable-line react/pref
87
87
  }
88
88
  }
89
89
  let path = '';
90
- if (this.props.channel.toLowerCase() === 'wechat') {
90
+ if ((this.props.channel || '').toLowerCase() === 'wechat') {
91
91
  path = this.props.templateData && this.props.templateData.definition && this.props.templateData.definition.msgcontent === "RICH_MEDIA_WECHAT" ? `/wechat/richmedia/edit/${this.props.templateData._id}` : `/wechat/edit/${this.props.templateData._id}`;
92
92
  }
93
93
  console.log('final content is', content);
@@ -103,7 +103,7 @@ class PreviewSideBar extends React.Component { // eslint-disable-line react/pref
103
103
  <CapButton type={this.state.device === "iphone" ? "primary" : "secondary"} value={"iphone"}><FormattedMessage {...messages.ios} /></CapButton>
104
104
  </ButtonGroup>}
105
105
  </div>
106
- {this.props.channel.toLowerCase() === "mobilepush" ?
106
+ {(this.props.channel || '').toLowerCase() === "mobilepush" ?
107
107
  <TemplatePreview
108
108
  device={this.state.device === "android" ? "android" : "iphone"}
109
109
  channel={this.props.channel}
@@ -115,8 +115,8 @@ class PreviewSideBar extends React.Component { // eslint-disable-line react/pref
115
115
  content={content || ''}
116
116
  channel={this.props.channel}
117
117
  location={this.props.location}
118
- charCounterEnabled={this.props.channel.toLowerCase() === 'sms'}
119
- unicodeEnabled={this.props.channel.toLowerCase() === 'sms'}
118
+ charCounterEnabled={(this.props.channel || '').toLowerCase() === 'sms'}
119
+ unicodeEnabled={(this.props.channel || '').toLowerCase() === 'sms'}
120
120
  >
121
121
  </TemplatePreview>
122
122
  }
@@ -124,7 +124,7 @@ class PreviewSideBar extends React.Component { // eslint-disable-line react/pref
124
124
  <p style={{marginBottom: '8px'}} className="preview-info"><FormattedMessage {...messages.uploadedBy} /> : {this.props.templateData.updatedByName}</p>
125
125
  <hr className="seperator-line" />
126
126
  <div className="preview-action-container" style={{margin: '16px'}}>
127
- {this.props.channel.toLowerCase() === 'sms' && !this.props.embedded && <CapButton onClick={() => this.goToDuplicate()}className="preview-buttons" style={{marginRight: '8px'}} type="secondary"><FormattedMessage {...messages.duplicate} /></CapButton>}
127
+ {(this.props.channel || '').toLowerCase() === 'sms' && !this.props.embedded && <CapButton onClick={() => this.goToDuplicate()}className="preview-buttons" style={{marginRight: '8px'}} type="secondary"><FormattedMessage {...messages.duplicate} /></CapButton>}
128
128
  <CapButton onClick={(e) => this.goToEdit(e, path)} className="preview-buttons" type="primary">{this.props.location.query.type === 'embedded' ? <FormattedMessage {...messages.select} /> : <FormattedMessage {...messages.edit} />}</CapButton>
129
129
  </div>
130
130
  </div>
@@ -52,14 +52,14 @@ class Sidebar extends React.Component { // eslint-disable-line react/prefer-stat
52
52
  return (<Accordion.Content key={keyValue}>{links}</Accordion.Content>);
53
53
  }
54
54
 
55
- getLinkElement(to, text, value, isExternal) {
55
+ getLinkElement(to, text = '', value, isExternal) {
56
56
  const selectedItem = (value && value.trim().toLowerCase() === this.state.activeItem) ? 'selected' : '';
57
- if (text.toLowerCase().includes(this.state.searchText.toLowerCase())) {
57
+ if (text.toLowerCase().includes((this.state.searchText || '').toLowerCase())) {
58
58
  if (isExternal) {
59
- return ((text.toLowerCase().includes(this.state.searchText.toLowerCase())) ? <a key={to} className={`item menu-item ${selectedItem}`} href={to}>{text}</a> : '');
59
+ return (text.toLowerCase().includes((this.state.searchText || '').toLowerCase()) ? <a key={to} className={`item menu-item ${selectedItem}`} href={to}>{text}</a> : '');
60
60
  }
61
61
  return (
62
- (text.toLowerCase().includes(this.state.searchText.toLowerCase())) ?
62
+ text.toLowerCase().includes((this.state.searchText || '').toLowerCase()) ?
63
63
  <Link to={to} className={`item menu-item ${selectedItem}`} onClick={this.handleItemClick} key={to} title={text}>{text}</Link>
64
64
  : ''
65
65
  );
@@ -68,13 +68,13 @@ class Sidebar extends React.Component { // eslint-disable-line react/prefer-stat
68
68
  }
69
69
 
70
70
  selectActiveLinkFromUrl(props) {
71
- const activeRoute = props.router.routes[props.router.routes.length - 1];
71
+ const activeRoute = props.router.routes[props.router.routes.length - 1] || {};
72
72
  const activeRouteName = (activeRoute.name && activeRoute.name.trim().toLowerCase()) || '';
73
73
  let selectedItem = '';
74
74
  let selectedIndex = -1;
75
75
  _.forEach(props.menuData, (menuItem, menuIndex) => {
76
76
  if (menuItem.items && typeof menuItem.items === 'object') {
77
- _.forEach(menuItem.items, (menuData) => {
77
+ _.forEach(menuItem.items, (menuData = {}) => {
78
78
  // console.log('Menua Data ', menuData, activeRouteName, menuItem);
79
79
  if ((menuItem.id && menuData.id.toLowerCase() === activeRouteName.toLowerCase()) || (menuData.value.toLowerCase() === activeRouteName.toLowerCase())) {
80
80
  selectedIndex = menuIndex;
@@ -84,7 +84,7 @@ class Sidebar extends React.Component { // eslint-disable-line react/prefer-stat
84
84
  selectedItem = 'gallery';
85
85
  }
86
86
  });
87
- } else if (menuItem.value.toLowerCase() === activeRouteName.toLowerCase()) {
87
+ } else if ((menuItem.value || '').toLowerCase() === activeRouteName.toLowerCase()) {
88
88
  selectedIndex = menuIndex;
89
89
  selectedItem = activeRouteName.toLowerCase();
90
90
  }
@@ -169,7 +169,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
169
169
  const type = this.props.location && this.props.location.query.type ? this.props.location.query.type : '';
170
170
  const { containsUnicodeContent = false } = this.props;
171
171
  let iosActions = [];
172
- if (channel.toLowerCase() === "mobilepush") {
172
+ if ((channel || '').toLowerCase() === "mobilepush") {
173
173
  iosActions = _.map(content.actions, (action) => {
174
174
  if (action.label) {
175
175
  return (<div className="actions">
@@ -181,7 +181,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
181
181
  }
182
182
  return (
183
183
  <div className={`preview-container ${type === 'embedded' ? 'embedded-preview' : ''}`}>
184
- { channel && channel.toLowerCase() === 'sms' &&
184
+ { (channel || '').toLowerCase() === 'sms' &&
185
185
  (showLockScreenPreview ? (
186
186
  <CapTab
187
187
  panes={[
@@ -212,7 +212,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
212
212
  </div>
213
213
  </div>)
214
214
  )}
215
- {channel && channel.toLowerCase() === 'wechat' &&
215
+ {(channel || '').toLowerCase() === 'wechat' &&
216
216
  (showLockScreenPreview ? (
217
217
  <CapTab
218
218
  panes={[
@@ -231,15 +231,15 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
231
231
  />
232
232
  ) : (
233
233
  <div className="shell align-center" id="sms-preview">
234
- <CapImage className="preview-image" src={channel.toLowerCase() === 'wechat' ? wechatMobileAndroid : smsBody} alt={this.props.intl.formatMessage(messages.previewGenerated)}/>
234
+ <CapImage className="preview-image" src={(channel || '').toLowerCase() === 'wechat' ? wechatMobileAndroid : smsBody} alt={this.props.intl.formatMessage(messages.previewGenerated)}/>
235
235
  <div className="msgContainer">
236
- <div className="message-pop align-left" style={{ background: `${this.props.channel.toLowerCase() === 'wechat' ? '#ffffff' : '#3F51B5'}`, color: `${this.props.channel.toLowerCase() === 'wechat' ? '#333333' : '#ffffff'}`}}>{content}
236
+ <div className="message-pop align-left" style={{ background: `${(this.props.channel || '').toLowerCase() === 'wechat' ? '#ffffff' : '#3F51B5'}`, color: `${(this.props.channel || '').toLowerCase() === 'wechat' ? '#333333' : '#ffffff'}`}}>{content}
237
237
  </div>
238
238
  </div>
239
239
  </div>
240
240
  )
241
241
  )}
242
- { channel && (channel.toLowerCase() === 'mobilepush') &&
242
+ { (channel || '').toLowerCase() === 'mobilepush' &&
243
243
  (<div className="shell align-center" id="mobilepush-preview">
244
244
  <CapImage className="preview-image" src={this.props.device === "android" ? androidPushMessagePhone : iPhonePushMessagePhone} alt={this.props.intl.formatMessage(messages.previewGenerated)}/>
245
245
  {(!!content.header || !!content.bodyText || !!content.bodyImage) &&
@@ -289,7 +289,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
289
289
  )
290
290
  }
291
291
  {
292
- channel && channel.toLowerCase() === 'line' ? (
292
+ (channel || '').toLowerCase() === 'line' ? (
293
293
  <div className="shell align-center" id="sms-preview">
294
294
  <CapImage className="preview-image" src={wechatBody} alt={this.props.intl.formatMessage(messages.previewGenerated)}/>
295
295
  <div className="msgContainer line-preview">
@@ -664,7 +664,7 @@ export class Ebill extends React.Component { // eslint-disable-line react/prefer
664
664
  const msgString = JSON.stringify(msg);
665
665
  const win = document.getElementById(`edmeditor${this.state.currentTab > 1 ? this.state.currentTab : ''}`).contentWindow;
666
666
  win.postMessage(msgString, '*');
667
- } else {
667
+ } else if (this.state.editorInstanse) {
668
668
  this.state.editorInstanse.insertHtml(`{{${data}}}`);
669
669
  }
670
670
  };
@@ -826,7 +826,7 @@ export class Ebill extends React.Component { // eslint-disable-line react/prefer
826
826
  const query = {
827
827
  layout: 'EBILL',
828
828
  type: 'TAG',
829
- context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
829
+ context: (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
830
830
  embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
831
831
  };
832
832
  this.props.globalActions.fetchSchemaForEntity(query);
@@ -1036,7 +1036,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1036
1036
  }), "*");
1037
1037
  }
1038
1038
  this.edmEvent = undefined;
1039
- } else {
1039
+ } else if (this.state.editorInstanse) {
1040
1040
  this.state.editorInstanse.insertHtml(`<img src='${nextProps.Email.uploadedAssetData.metaInfo.secure_file_path}' alt='Capillary Image'>`);
1041
1041
  //this.resetCkEditorInstance(this.state.currentTab, this.state.formData, true, nextProps.Email.uploadedAssetData, true);
1042
1042
  }
@@ -1159,11 +1159,13 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1159
1159
  win.postMessage(msgString, '*');
1160
1160
  } else {
1161
1161
  console.log('tag', this.state, this.state.editorInstanse);
1162
- if (data === "unsubscribe") {
1163
- const anchor = `<a href='{{${data}}}'>${data}</a>`;
1164
- this.state.editorInstanse.insertHtml(`${anchor}`);
1165
- } else {
1166
- this.state.editorInstanse.insertHtml(`{{${data}}}`);
1162
+ if (this.state.editorInstanse) {
1163
+ if (data === "unsubscribe") {
1164
+ const anchor = `<a href='{{${data}}}'>${data}</a>`;
1165
+ this.state.editorInstanse.insertHtml(`${anchor}`);
1166
+ } else {
1167
+ this.state.editorInstanse.insertHtml(`{{${data}}}`);
1168
+ }
1167
1169
  }
1168
1170
  //this.resetCkEditorInstance(currentTab, formData, true, data);
1169
1171
  }
@@ -1597,10 +1599,12 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1597
1599
  console.log('setting instance as ', instance, instance.name);
1598
1600
  instance1 = instance;
1599
1601
  this.setState({editorInstanse: instance1}, () => {
1600
- if (onInsert && !isImage) {
1601
- this.state.editorInstanse.insertHtml(`{{${value}}}`);
1602
- } else if (onInsert) {
1603
- this.state.editorInstanse.insertHtml(`<img src='${value.metaInfo.secure_file_path}' alt='Capillary Image'>`);
1602
+ if (this.state.editorInstanse) {
1603
+ if (onInsert && !isImage) {
1604
+ this.state.editorInstanse.insertHtml(`{{${value}}}`);
1605
+ } else if (onInsert) {
1606
+ this.state.editorInstanse.insertHtml(`<img src='${value.metaInfo.secure_file_path}' alt='Capillary Image'>`);
1607
+ }
1604
1608
  }
1605
1609
  });
1606
1610
  }
@@ -1671,7 +1675,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1671
1675
  e.preventDefault();
1672
1676
  const _URL = window.URL || window.webkitURL;
1673
1677
  const file = files[0];
1674
- const fileSize = (file.size / ( 1024 * 1024 ));
1678
+ const fileSize = file && (file.size / ( 1024 * 1024 ));
1675
1679
  if (fileSize > 5) {
1676
1680
  const message = getMessageObject('error', this.props.intl.formatMessage(messages.uploadSizeError), true);
1677
1681
  this.props.globalActions.addMessageToQueue(message);
@@ -2048,7 +2052,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2048
2052
  }), "*");
2049
2053
  }
2050
2054
  this.edmEvent = undefined;
2051
- } else {
2055
+ } else if (this.state.editorInstanse) {
2052
2056
  this.state.editorInstanse.insertHtml(`<img src='${data.metaInfo.secure_file_path}' alt='Capillary Image'>`);
2053
2057
  //this.resetCkEditorInstance(this.state.currentTab, this.state.formData, true, data, true);
2054
2058
  }
@@ -2424,7 +2428,9 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2424
2428
  }
2425
2429
 
2426
2430
  selectAsset = (asset) => {
2427
- this.state.editorInstanse.insertHtml(`<img src='${asset}' alt='Capillary Image'>`);
2431
+ if (this.state.editorInstanse) {
2432
+ this.state.editorInstanse.insertHtml(`<img src='${asset}' alt='Capillary Image'>`);
2433
+ }
2428
2434
  }
2429
2435
 
2430
2436
  prepareImageData() {
@@ -2461,9 +2467,10 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2461
2467
  <div className="more-icon-wrapper">
2462
2468
  <Popover
2463
2469
  placement="leftTop"
2464
- content={<div style={{ cursor: 'pointer'}}><p onClick={() => this.deleteAsset(asset)}>
2465
- <FormattedMessage {...messages.delete} />
2466
- </p></div>} trigger="click">
2470
+ content={<div style={{ cursor: 'pointer'}}>
2471
+ <p>
2472
+ <FormattedMessage {...messages.delete} />
2473
+ </p></div>} trigger="click">
2467
2474
  <i className="material-icons creative-icons">more_vert</i>
2468
2475
  </Popover>
2469
2476
  </div>
@@ -2569,7 +2576,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2569
2576
  const query = {
2570
2577
  layout: 'EMAIL',
2571
2578
  type: 'TAG',
2572
- context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
2579
+ context: (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
2573
2580
  embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
2574
2581
  };
2575
2582
  this.props.globalActions.fetchSchemaForEntity(query);
@@ -2641,7 +2648,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2641
2648
  formData[0].selectedLanguages = [];
2642
2649
  let tabKey;
2643
2650
  if (this.props.location.query.type === 'embedded' && (this.props.location.query.isLanguageSupport === undefined || this.props.location.query.isLanguageSupport === 'false')) {
2644
- formData['template-subject'] = data.base.subject ? data.base.subject : '';
2651
+ formData['template-subject'] = (data.base && data.base.subject) ? data.base.subject : '';
2645
2652
  const baseLanguage = this.props.Global.currentOrgDetails.basic_details.base_language;
2646
2653
  let languageIndex = _.findIndex(this.supportedLanguages, {iso_code: baseLanguage});
2647
2654
  console.log("startTemplatecreation before index", languageIndex, this.supportedLanguages, baseLanguage, formData);
@@ -702,7 +702,7 @@ export class Line extends Component {
702
702
  const query = {
703
703
  layout: 'LINE',
704
704
  type: 'TAG',
705
- context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
705
+ context: (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
706
706
  embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
707
707
  };
708
708
  this.props.globalActions.fetchSchemaForEntity(query);
@@ -711,7 +711,7 @@ export class Line extends Component {
711
711
  uploadImage = (pearmData) => {
712
712
  console.log("image data line@@@", pearmData);
713
713
  const data = pearmData;
714
- if (data.file.size > 1000000) {
714
+ if (data.file && data.file.size > 1000000) {
715
715
  const message = getMessageObject('error', this.props.intl.formatMessage(messages['File size cannot be more than 1mb']), true);
716
716
  this.props.globalActions.addMessageToQueue(message);
717
717
  } else {
@@ -431,8 +431,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
431
431
  if (secondaryCta1) {
432
432
  const cta = {
433
433
  actionText: android['secondary-cta-0-label'],
434
- type: android['cta-deeplink-secondary-cta-0'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
435
- actionLink: android['cta-deeplink-secondary-cta-0'].toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-0-select'] : android['cta-deeplink-secondary-cta-0-text'],
434
+ type: (android['cta-deeplink-secondary-cta-0'] || '').toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
435
+ actionLink: (android['cta-deeplink-secondary-cta-0'] || '').toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-0-select'] : android['cta-deeplink-secondary-cta-0-text'],
436
436
  seccdeepLinkName: this.getLinkName(android['cta-deeplink-secondary-cta-0-select']),
437
437
  };
438
438
  if (this.props.location.query.type === 'embedded') {
@@ -456,8 +456,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
456
456
  if (secondaryCta2) {
457
457
  obj.versions.base.ANDROID.expandableDetails.ctas.push({
458
458
  actionText: android['secondary-cta-1-label'],
459
- type: android['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
460
- actionLink: android['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-1-select'] : android['cta-deeplink-secondary-cta-1-text'],
459
+ type: (android['cta-deeplink-secondary-cta-1'] || '').toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
460
+ actionLink: (android['cta-deeplink-secondary-cta-1'] || '').toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-1-select'] : android['cta-deeplink-secondary-cta-1-text'],
461
461
  seccdeepLinkName: this.getLinkName(android['cta-deeplink-secondary-cta-1-select']),
462
462
  });
463
463
  if (obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
@@ -503,8 +503,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
503
503
  actionText: ios['secondary-cta-1-label'],
504
504
  actionLabel: ios['secondary-cta-1-action'],
505
505
  actionLabel2: ios['secondary-cta-1-action2'],
506
- type: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL"),
507
- actionLink: ios['cta-deeplink-secondary-cta-1'] && (ios['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? ios['cta-deeplink-secondary-cta-1-select2'] : ios['cta-deeplink-secondary-cta-1-text2']),
506
+ type: (ios['cta-deeplink-secondary-cta-1'] || '').toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
507
+ actionLink: (ios['cta-deeplink-secondary-cta-1'] || '').toLowerCase() === "deeplink" ? ios['cta-deeplink-secondary-cta-1-select2'] : ios['cta-deeplink-secondary-cta-1-text2'],
508
508
  ioscdeepLinkName: this.getLinkName(ios['cta-deeplink-secondary-cta-1-select']),
509
509
  templateCtaId: ios['secondary-cta-1-table'] ? ios['secondary-cta-1-table'].ctaTemplateDetails[0].id : undefined,
510
510
  };
@@ -947,7 +947,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
947
947
  const query = {
948
948
  layout: 'line',
949
949
  type: 'TAG',
950
- context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
950
+ context: (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
951
951
  embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
952
952
  };
953
953
  this.props.globalActions.fetchSchemaForEntity(query);
@@ -617,8 +617,8 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
617
617
  if (secondaryCta1) {
618
618
  const cta = {
619
619
  actionText: android['secondary-cta-0-label'],
620
- type: android['cta-deeplink-secondary-cta-0'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
621
- actionLink: android['cta-deeplink-secondary-cta-0'].toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-0-select'] : android['cta-deeplink-secondary-cta-0-text'],
620
+ type: (android['cta-deeplink-secondary-cta-0'] || '').toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
621
+ actionLink: (android['cta-deeplink-secondary-cta-0'] || '').toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-0-select'] : android['cta-deeplink-secondary-cta-0-text'],
622
622
  seccdeepLinkName: this.getLinkName(android['cta-deeplink-secondary-cta-0-select']),
623
623
  };
624
624
  if (this.props.location.query.type === 'embedded') {
@@ -642,8 +642,8 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
642
642
  if (secondaryCta2) {
643
643
  const cta = {
644
644
  actionText: android['secondary-cta-1-label'],
645
- type: android['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
646
- actionLink: android['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-1-select'] : android['cta-deeplink-secondary-cta-1-text'],
645
+ type: (android['cta-deeplink-secondary-cta-1'] || '').toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
646
+ actionLink: (android['cta-deeplink-secondary-cta-1'] || '').toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-1-select'] : android['cta-deeplink-secondary-cta-1-text'],
647
647
  seccdeepLinkName: this.getLinkName(android['cta-deeplink-secondary-cta-1-select']),
648
648
  };
649
649
  if (this.props.location.query.type === 'embedded') {
@@ -2162,7 +2162,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
2162
2162
  const query = {
2163
2163
  layout: 'mobilepush',
2164
2164
  type: 'TAG',
2165
- context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
2165
+ context: (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
2166
2166
  embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
2167
2167
  };
2168
2168
  this.props.globalActions.fetchSchemaForEntity(query);
@@ -682,8 +682,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
682
682
  if (secondaryCta1) {
683
683
  const cta = {
684
684
  actionText: android['secondary-cta-0-label'],
685
- type: android['cta-deeplink-secondary-cta-0'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
686
- actionLink: android['cta-deeplink-secondary-cta-0'].toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-0-select'] : android['cta-deeplink-secondary-cta-0-text'],
685
+ type: (android['cta-deeplink-secondary-cta-0'] || '').toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
686
+ actionLink: (android['cta-deeplink-secondary-cta-0'] || '').toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-0-select'] : android['cta-deeplink-secondary-cta-0-text'],
687
687
  seccdeepLinkName: this.getLinkName(android['cta-deeplink-secondary-cta-0-select']),
688
688
  };
689
689
  if (this.props.location.query.type === 'embedded') {
@@ -707,8 +707,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
707
707
  if (secondaryCta2) {
708
708
  obj.versions.base.ANDROID.expandableDetails.ctas.push({
709
709
  actionText: android['secondary-cta-1-label'],
710
- type: android['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
711
- actionLink: android['cta-deeplink-secondary-cta-1'].toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-1-select'] : android['cta-deeplink-secondary-cta-1-text'],
710
+ type: (android['cta-deeplink-secondary-cta-1'] || '').toLowerCase() === "deeplink" ? "DEEP_LINK" : "EXTERNAL_URL",
711
+ actionLink: (android['cta-deeplink-secondary-cta-1'] || '').toLowerCase() === "deeplink" ? android['cta-deeplink-secondary-cta-1-select'] : android['cta-deeplink-secondary-cta-1-text'],
712
712
  seccdeepLinkName: this.getLinkName(android['cta-deeplink-secondary-cta-1-select']),
713
713
  });
714
714
  if (obj.versions.base.ANDROID.expandableDetails.ctas[obj.versions.base.ANDROID.expandableDetails.ctas.length - 1].type === "DEEP_LINK") {
@@ -2454,7 +2454,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
2454
2454
  const query = {
2455
2455
  layout: 'mobilepush',
2456
2456
  type: 'TAG',
2457
- context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
2457
+ context: (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
2458
2458
  embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
2459
2459
  };
2460
2460
  this.props.globalActions.fetchSchemaForEntity(query);
@@ -824,7 +824,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
824
824
  const query = {
825
825
  layout: 'SMS',
826
826
  type: 'TAG',
827
- context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
827
+ context: (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
828
828
  embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
829
829
  };
830
830
  this.props.globalActions.fetchSchemaForEntity(query);
@@ -353,7 +353,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
353
353
  const query = {
354
354
  layout: 'SMS',
355
355
  type: 'TAG',
356
- context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
356
+ context: (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
357
357
  embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
358
358
  };
359
359
  this.props.globalActions.fetchSchemaForEntity(query);
@@ -316,7 +316,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
316
316
  return;
317
317
  }
318
318
  this.props.router.push({
319
- pathname: `/${nextProps.route.name.toLowerCase()}/create`,
319
+ pathname: `/${(nextProps.route.name || '').toLowerCase()}/create`,
320
320
  query: type === 'embedded' ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module},
321
321
  });
322
322
  }
@@ -498,12 +498,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
498
498
  this.setState({loading: true});
499
499
  }
500
500
 
501
- handleMenuAction = (item, key) => {
501
+ handleMenuAction = (item = {}, key) => {
502
502
  console.log('Menu Clicked ', item.key, key);
503
- if (item.key.toLowerCase() === 'uploadfile') {
503
+ if ((item.key || '').toLowerCase() === 'uploadfile') {
504
504
  document.getElementById('filename').click();
505
505
  console.log('Upload File');
506
- } else if (item.key.toLowerCase() === 'useeditor') {
506
+ } else if ((item.key || '').toLowerCase() === 'useeditor') {
507
507
  console.log('Use Editor');
508
508
  this.toggleEdmEmailTemplateSelection();
509
509
  }
@@ -827,7 +827,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
827
827
  this.getAllTemplates({params, resetPage: true});
828
828
  });
829
829
  }
830
- handleType = (data) => {
830
+ handleType = (data = {}) => {
831
831
  this.setState({mode: data}, () => {
832
832
  const params = {
833
833
  name: this.state.searchText,
@@ -1076,14 +1076,14 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1076
1076
  </div>,
1077
1077
  });
1078
1078
  }*/
1079
- data.map( (template) => {
1079
+ data.map( (template = {}) => {
1080
1080
  // console.log("Templates ", template._id, " Data ", template);
1081
1081
  const temp = {};
1082
1082
  // console.log('template ', template);
1083
1083
  const updateDateTime = (moment().format('DD-MM-YYYY') === moment(template.updatedAt).format('DD-MM-YYYY')) ? moment(template.updatedAt).format('hh:mma') : moment(template.updatedAt).format('DD MMM YYYY');
1084
1084
  let content = '';
1085
1085
  temp.id = template._id;
1086
- if (this.state.channel === 'wechat' && template.type.toLowerCase() === 'wechat') {
1086
+ if (this.state.channel === 'wechat' && (template.type || '').toLowerCase() === 'wechat') {
1087
1087
  let path = '';
1088
1088
  if (template && template.versions && template.versions.base && !_.isEmpty(template.versions.base)) {
1089
1089
  if (template.definition && template.definition.msgcontent && template.definition.msgcontent === "RICH_MEDIA_WECHAT") {
@@ -1131,7 +1131,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1131
1131
  {template._id === this.state.hoveredItem ? <CapButton onClick={(e) => this.handleEditClick(e, template._id)} className="edit-button" type="secondary">{type === 'embedded' ? this.props.intl.formatMessage(messages.selectButton) : this.props.intl.formatMessage(messages.editButton)}</CapButton> : ''}
1132
1132
  {template._id === this.state.hoveredItem ? <CapButton onClick={() => this.handlePreviewClick(template)} className="preview-button" type="cancel">{this.props.intl.formatMessage(messages.previewButton)}</CapButton> : ''}
1133
1133
  </div>);
1134
- } else if (this.state.channel.toLowerCase() === 'line' && template.type.toLowerCase() === 'line') {
1134
+ } else if (this.state.channel.toLowerCase() === 'line' && template.type && template.type.toLowerCase() === 'line') {
1135
1135
  //content = template.versions.base.messages[0].Text;
1136
1136
  content = {
1137
1137
  bodyText: template.versions.base.content.messages[0].text ? template.versions.base.content.messages[0].text : '',
@@ -985,7 +985,7 @@ export class MapTemplates extends React.Component { // eslint-disable-line react
985
985
  const query = {
986
986
  layout: 'WECHAT',
987
987
  type: 'TAG',
988
- context: data.toLowerCase() === 'all' ? 'default' : data.toLowerCase(),
988
+ context: (data || '').toLowerCase() === 'all' ? 'default' : (data || '').toLowerCase(),
989
989
  embedded: this.props.location.query.type === 'embedded' ? this.props.location.query.type : 'full',
990
990
  };
991
991
  this.props.globalActions.fetchSchemaForEntity(query);
@@ -796,9 +796,9 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
796
796
  const templateData = _.cloneDeep(this.state.templateData);
797
797
  const titleSet = new Set();
798
798
  let isRepeated = false;
799
- _.forEach(templateData, (content) => {
799
+ _.forEach(templateData, (content = '') => {
800
800
  const setSizeBefore = titleSet.size;
801
- titleSet.add(content.formData['title-value'].toLowerCase());
801
+ titleSet.add((content.formData['title-value'] || '').toLowerCase());
802
802
  const setSizeAfter = titleSet.size;
803
803
  if (setSizeAfter === setSizeBefore) {
804
804
  isRepeated = true;
@@ -896,7 +896,9 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
896
896
  return true;
897
897
  }
898
898
  updateContentData = () => {
899
- this.state.editorInstanse.insertHtml(`<img src='${this.props.ContentImageData.metaInfo.wechatUrl}' alt='Capillary Image'>`);
899
+ if (this.state.editorInstanse) {
900
+ this.state.editorInstanse.insertHtml(`<img src='${this.props.ContentImageData.metaInfo.wechatUrl}' alt='Capillary Image'>`);
901
+ }
900
902
  this.props.actions.clearContentImageStore();
901
903
  this.setState({loading: false});
902
904
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "6.3.7",
4
+ "version": "6.4.0",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -8,7 +8,7 @@ export function formatUnderscoreToSpaces(str) {
8
8
  return str.split('_').join(' ');
9
9
  }
10
10
 
11
- export function capitalizeString(str) {
11
+ export function capitalizeString(str = '') {
12
12
  const newStr = [];
13
13
  const words = str.toLowerCase().split(' ');
14
14
  _.forEach(words, (value) => {