@capillarytech/creatives-library 7.3.4 → 7.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.3.4",
4
+ "version": "7.3.6",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -1,5 +1,6 @@
1
1
  // makeSelectLocationState expects a plain JS object for the routing state
2
2
  import { createSelector } from 'reselect';
3
+ import { fromJS } from 'immutable';
3
4
  import _ from 'lodash';
4
5
  const selectCapDomain = (state) => state.get('cap');
5
6
 
@@ -24,7 +25,7 @@ const isLoadingMetaEntities = () => createSelector(
24
25
  );
25
26
  const setInjectedTags = () => createSelector(
26
27
  selectCapDomain,
27
- (globalState) => {
28
+ (globalState = fromJS({})) => {
28
29
  let injectedTags = globalState.get('injectedTags') || {};
29
30
  const metaEntities = globalState.get('metaEntities') || {};
30
31
  const { tags } = metaEntities;
@@ -321,7 +321,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
321
321
  if (this.state.isEdit && nextProps.location.query.module === "library" && !_.isEmpty(nextProps.templateData) && !this.props.params.id && !nextProps.isGetFormData && _.isEmpty(_.get(this, `state.formData['template-subject']`))) {
322
322
  this.startTemplateCreation(nextProps.templateData);
323
323
  }
324
- if (nextProps.location.query.module === 'library' && nextProps.isGetFormData) {
324
+ if (nextProps.location.query.module === 'library' && nextProps.isGetFormData && (this.props.isGetFormData!==nextProps.isGetFormData)) {
325
325
  const formData = this.state.formData;
326
326
  let isBeeEditor = false;
327
327
  const isBEEEnable = this.checkBeeEditorAllowedForLibrary();
@@ -15,7 +15,6 @@
15
15
  display: inline-block;
16
16
  }
17
17
  .configure-csv-container{
18
- margin-top: $CAP_SPACE_32;
19
18
  .configure-csv, .add-column{
20
19
  display: inline-block;
21
20
  }
@@ -56,6 +55,7 @@
56
55
  }
57
56
  .select-csv-col-dropdown {
58
57
  padding: $CAP_SPACE_08 $CAP_SPACE_16;
58
+ max-width: 324px;
59
59
  .ant-select-tree-switcher-noop, .ant-select-tree-node-content-wrapper{
60
60
  display: inline-block !important;
61
61
  margin: 0 !important;
@@ -105,11 +105,15 @@
105
105
 
106
106
  .ftp-preview-container{
107
107
  .ftp-preview-message-title{
108
- margin-top: $CAP_SPACE_16;
108
+ margin-top: $CAP_SPACE_40;
109
+ }
110
+ .ftp-content {
111
+ margin-top: 8px;
112
+ max-width: 70%;
109
113
  }
110
114
  .ftp-preview-message-content{
111
115
  max-width: 450px;
112
- margin-top: 4px;
116
+ margin-top: $CAP_SPACE_04;
113
117
  color: $FONT_COLOR_02;
114
118
  .ant-input[disabled]{
115
119
  background-color: $CAP_WHITE;
@@ -121,10 +125,14 @@
121
125
  margin-top: $CAP_SPACE_40;
122
126
  }
123
127
  .ftp-preview-data-col-container{
124
- margin-top: $CAP_SPACE_16;
128
+ margin-top: $CAP_SPACE_08;
125
129
  .ant-tag.cap-tag-v2{
126
130
  background-color: $CAP_WHITE;
127
131
  font-weight: 500;
132
+
133
+ &:first-child {
134
+ padding-left: 0;
135
+ }
128
136
  }
129
137
  }
130
138
  }
@@ -19,6 +19,7 @@ import {
19
19
  CapTag,
20
20
  CapTreeSelect,
21
21
  CapDivider,
22
+ CapTooltip,
22
23
  } from '@capillarytech/cap-ui-library';
23
24
  import { FONT_SIZE_L } from '@capillarytech/cap-ui-library/styled/variables';
24
25
  import { find, cloneDeep, findIndex, isEmpty, isEqual, filter, flattenDeep } from 'lodash';
@@ -68,7 +69,7 @@ export class FTP extends React.Component {
68
69
  };
69
70
  } else {
70
71
  const { messageContent = {} } = this.props.messageDetails || {};
71
- const { headerTagList = [], messageBody = '' } = messageContent['message_content_id_1'] || {};
72
+ const { headerTagList = [], messageBody = '' } = messageContent.message_content_id_1 || {};
72
73
  stateObj = {
73
74
  mode,
74
75
  selectedServer: null,
@@ -100,15 +101,40 @@ export class FTP extends React.Component {
100
101
  this.props.globalActions.fetchSchemaForEntity(query);
101
102
  }
102
103
 
104
+ getTreeStructuredInjectedTags = (tags) => {
105
+ const finalTags = [];
106
+ let temp = {};
107
+ _.forEach(tags, (val, key) => {
108
+ temp = {
109
+ title: !val['tag-header'] ? val.desc : val.name,
110
+ value: `{{${key}}}`,
111
+ };
112
+ if (!val.subtags) {
113
+ finalTags.push(temp);
114
+ } else {
115
+ temp.title = temp.title || val.name;
116
+ temp.selectable = false;
117
+ temp.children = this.getTreeStructuredInjectedTags(val.subtags);
118
+ finalTags.push(temp);
119
+ }
120
+ });
121
+ return finalTags;
122
+ }
123
+
103
124
  componentWillReceiveProps(nextProps) {
104
- const { metaEntities = {}, selectedOfferDetails = [], mode, FTP: nextFTP = {} } = nextProps;
105
- const { metaEntities: thisMetaEntities = {}, FTP: thisFTP = {}} = this.props;
106
- const { tags: thisTags = {}} = thisMetaEntities;
125
+ const { metaEntities = {}, selectedOfferDetails = [], mode, FTP: nextFTP = {}, injectedTags } = nextProps;
126
+ const { metaEntities: thisMetaEntities = {}, FTP: thisFTP = {}, injectedTags: thisInjectedTags } = this.props;
127
+ const { tags: thisTags = {} } = thisMetaEntities;
107
128
  if (
108
- !isEmpty((metaEntities.tags || {}).standard) &&
109
- !isEqual((metaEntities.tags || {}).standard, thisTags.standard)
129
+ (
130
+ !isEmpty((metaEntities.tags || {}).standard) &&
131
+ !isEqual((metaEntities.tags || {}).standard, thisTags.standard)
132
+ ) || !isEqual(injectedTags, thisInjectedTags)
110
133
  ) {
111
- const tags = getTreeStructuredTags({tagsList: metaEntities.tags.standard, offerDetails: selectedOfferDetails});
134
+ const tags = _.concat(
135
+ getTreeStructuredTags({ tagsList: ((metaEntities.tags || {}).standard || []), offerDetails: selectedOfferDetails }),
136
+ this.getTreeStructuredInjectedTags(injectedTags)
137
+ );
112
138
  this.setState({ tagsTree: tags}, () => this.disableUsedColumns());
113
139
  }
114
140
 
@@ -149,7 +175,7 @@ export class FTP extends React.Component {
149
175
  >
150
176
  {formatMessage(messages.ftpServer)}
151
177
  </CapHeading>
152
- {serverOptions.length && <CapHeading type="h6" className="manage-ftp-setting-div">
178
+ {!!serverOptions.length && <CapHeading type="h6" className="manage-ftp-setting-div">
153
179
  {formatMessage(messages.ftpServerDesc)}
154
180
  <CapLink
155
181
  title={formatMessage(messages.manageFTPSettings)}
@@ -169,14 +195,18 @@ export class FTP extends React.Component {
169
195
  selected={selectedServer}
170
196
  />
171
197
  ) : (
172
- <CapHeading type="h6" className="configure-ftp-setting-div">
173
- {formatMessage(messages.selectFtpServerDesc)}
174
- <CapLink
175
- title={formatMessage(messages.manageFTPSettings)}
176
- className="select-server"
177
- onClick={this.handleManageFTPSettings}
178
- />
179
- </CapHeading>
198
+ <>
199
+ {!getFTPServersInProgress && (
200
+ <CapHeading type="h6" className="configure-ftp-setting-div">
201
+ {formatMessage(messages.selectFtpServerDesc)}
202
+ <CapLink
203
+ title={formatMessage(messages.manageFTPSettings)}
204
+ className="select-server"
205
+ onClick={this.handleManageFTPSettings}
206
+ />
207
+ </CapHeading>
208
+ )}
209
+ </>
180
210
  )}
181
211
  </CapSpin>
182
212
  );
@@ -198,7 +228,7 @@ export class FTP extends React.Component {
198
228
 
199
229
  getFlatTags = (tags) => {
200
230
  const flatTags = [];
201
- tags.forEach(tag => {
231
+ tags.forEach((tag) => {
202
232
  if ((tag.children || []).length) {
203
233
  const innerTags = this.getFlatTags(tag.children);
204
234
  flatTags.push(innerTags);
@@ -251,7 +281,7 @@ export class FTP extends React.Component {
251
281
  let errorMessageText = '';
252
282
  if (!validateTagResponse.valid) {
253
283
  unsupportedTags = validateTagResponse.unsupportedTags.join(', ').toString();
254
- errorMessageText = formatMessage(messages.unsupportedTagsValidationError, {unsupportedTags})
284
+ errorMessageText = formatMessage(messages.unsupportedTagsValidationError, {unsupportedTags});
255
285
  }
256
286
  return (
257
287
  <CapRow>
@@ -284,28 +314,31 @@ export class FTP extends React.Component {
284
314
  const tagsWithoutOptout = tagsTree.length && tagsTree.filter((tag) => tag.value !== '{{optout}}');
285
315
  const headerTagElements = headerTagList.map((item, index) => (
286
316
  index !== 0 && <div className="column-selection-container">
287
- <CapSpin spinning={!tagsWithoutOptout.length}>
288
- <CapTreeSelect
289
- dropdownClassName="select-csv-col-dropdown"
290
- treeData={tagsWithoutOptout}
291
- className="select-csv-column"
292
- value={!isEmpty(item.header) ? item.header : formatMessage(messages.selectTag)}
293
- onChange={(option, label) => this.selectCsvColumn(option, label, index)}
294
- showSearch
295
- searchPlaceholder={
296
- <span className="search-placeholder-container">
297
- <StyledCapIcon type="search" className="csv-column-search-icon"/>
298
- {formatMessage(messages.search)}
299
- </span>
300
- }
301
- />
302
- <CapIcon
303
- type="close"
304
- size="m"
305
- onClick={() => this.removeCsvColumn(item)}
306
- className="remove-csv-column"
307
- />
308
- </CapSpin>
317
+ <CapTooltip title={item.header}>
318
+ <CapSpin spinning={!tagsWithoutOptout.length}>
319
+ <CapTreeSelect
320
+ dropdownClassName="select-csv-col-dropdown"
321
+ treeData={tagsWithoutOptout}
322
+ className="select-csv-column"
323
+ value={!isEmpty(item.header) ? item.header : formatMessage(messages.selectTag)}
324
+ onChange={(option, label) => this.selectCsvColumn(option, label, index)}
325
+ showSearch
326
+ searchPlaceholder={
327
+ <span className="search-placeholder-container">
328
+ <StyledCapIcon type="search" className="csv-column-search-icon"/>
329
+ {formatMessage(messages.search)}
330
+ </span>
331
+ }
332
+ placeholder={formatMessage(messages.selectTag)}
333
+ />
334
+ <CapIcon
335
+ type="close"
336
+ size="m"
337
+ onClick={() => this.removeCsvColumn(item)}
338
+ className="remove-csv-column"
339
+ />
340
+ </CapSpin>
341
+ </CapTooltip>
309
342
  </div>
310
343
  ));
311
344
  headerTagElements.unshift(
@@ -323,7 +356,7 @@ export class FTP extends React.Component {
323
356
  getConfigureCsvContent = () => {
324
357
  const { formatMessage } = this.props.intl;
325
358
  return (
326
- <>
359
+ <CapSpin spinning={!(this.state.tagsTree || []).length}>
327
360
  <CapRow className="configure-csv-container">
328
361
  <CapColumn span={8} className="configure-csv">
329
362
  <CapHeader
@@ -343,7 +376,7 @@ export class FTP extends React.Component {
343
376
  </CapColumn>
344
377
  </CapRow>
345
378
  {this.getCsvColumns()}
346
- </>
379
+ </CapSpin>
347
380
  );
348
381
  }
349
382
 
@@ -416,20 +449,26 @@ export class FTP extends React.Component {
416
449
  getPreviewModeContents = () => {
417
450
  const { contents = [] } = this.props;
418
451
  const { messageBody = '', headerTagList = [] } = contents[0] || {};
452
+ const columns = cloneDeep(headerTagList);
453
+ if (messageBody) {
454
+ columns.push({
455
+ header: <FormattedMessage {...messages.message}/>,
456
+ });
457
+ }
419
458
  return (
420
459
  <div className="ftp-preview-container">
421
- <CapHeading className="ftp-preview-message-title" type="h3">
422
- <FormattedMessage {...messages.messageContent}/>
423
- </CapHeading>
424
- <CapInput.TextArea
425
- value={messageBody}
426
- disabled
427
- className="ftp-preview-message-content"
428
- />
429
460
  <CapHeading className="ftp-preview-data-title" type="h3">
430
461
  <FormattedMessage {...messages.dataPreview}/>
431
462
  </CapHeading>
432
- {this.getColumnsHeaderPreview(headerTagList)}
463
+ {this.getColumnsHeaderPreview(columns)}
464
+ {messageBody && (
465
+ <>
466
+ <CapHeading className="ftp-preview-message-title" type="h3">
467
+ <FormattedMessage {...messages.messageContent}/>
468
+ </CapHeading>
469
+ <CapLabel className="ftp-content" type="label1">{messageBody}</CapLabel>
470
+ </>
471
+ )}
433
472
  </div>
434
473
  );
435
474
  };
@@ -442,7 +481,7 @@ export class FTP extends React.Component {
442
481
  const { headerTagList } = this.state;
443
482
  const clonedHeaderTagList = cloneDeep(headerTagList);
444
483
  const optionValue = option.substring(this.indexOfEnd(option, '{{'), option.indexOf('}}'));
445
- let readableOptionValue = optionValue.replaceAll('_', ' ');
484
+ let readableOptionValue = optionValue.replaceAll('_', ' ');
446
485
  readableOptionValue = readableOptionValue[0].toUpperCase() + readableOptionValue.slice(1);
447
486
  const obj = {
448
487
  header: readableOptionValue,
@@ -454,8 +493,11 @@ export class FTP extends React.Component {
454
493
 
455
494
  disableUsedColumns = () => {
456
495
  const { headerTagList = [] } = this.state;
457
- const { selectedOfferDetails = [], metaEntities = {} } = this.props;
458
- const tags = getTreeStructuredTags({tagsList: (metaEntities.tags || {}).standard, offerDetails: selectedOfferDetails});
496
+ const { selectedOfferDetails = [], metaEntities = {}, injectedTags } = this.props;
497
+ const tags = _.concat(
498
+ getTreeStructuredTags({ tagsList: ((metaEntities.tags || {}).standard || []), offerDetails: selectedOfferDetails }),
499
+ this.getTreeStructuredInjectedTags(injectedTags)
500
+ );
459
501
  const clonnedTagsTree = cloneDeep(tags);
460
502
  headerTagList.map((headerTag) => {
461
503
  clonnedTagsTree.map((tag, index) => {
@@ -69,4 +69,8 @@ export default defineMessages({
69
69
  id: 'creatives.componentsV2.FTP.search',
70
70
  defaultMessage: 'Search',
71
71
  },
72
+ message: {
73
+ id: `creatives.componentsV2.FTP.search`,
74
+ defaultMessage: 'Message',
75
+ },
72
76
  });
@@ -140,6 +140,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
140
140
  if (nextProps.Create.createTemplateError && !_.isEqual(nextProps.Create.createTemplateError, this.props.Create.createTemplateError)) {
141
141
  const message = (nextProps.Create.createTemplateErrorMessage && nextProps.Create.createTemplateErrorMessage !== '') ? nextProps.Create.createTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong);
142
142
  CapNotification.error({key: 'createTemplateError', message });
143
+ this.stopValidation();
143
144
  }
144
145
  if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.schema)) {
145
146
  this.injectEvents(nextProps.metaEntities.layouts[0].definition);