@capillarytech/creatives-library 7.1.5 → 7.1.7

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.
@@ -1115,7 +1115,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1115
1115
  {content}
1116
1116
  </div>
1117
1117
  {!layoutSelection && 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> : ''}
1118
- {layoutSelection && template._id === this.state.hoveredItem ? <CapButton onClick={() => this.handleEdmDefaultTemplateSelection(true, template._id)} className="select-button" type="secondary">{type === 'embedded' ? this.props.intl.formatMessage(messages.selectDefaultButton) : this.props.intl.formatMessage(messages.selectDefaultButton)}</CapButton> : ''}
1118
+ {layoutSelection && template._id === this.state.hoveredItem ? <CapButton onClick={(event) =>{this.handleEdmDefaultTemplateSelection(true, template._id); event.stopPropagation();}} className="select-button" type="secondary">{type === 'embedded' ? this.props.intl.formatMessage(messages.selectDefaultButton) : this.props.intl.formatMessage(messages.selectDefaultButton)}</CapButton> : ''}
1119
1119
  {!layoutSelection && template._id === this.state.hoveredItem ? <CapButton onClick={() => this.handlePreviewClick(template)} className="preview-button" type="cancel">{this.props.intl.formatMessage(messages.previewButton)}</CapButton> : ''}
1120
1120
  </div>);
1121
1121
  } else if (this.state.channel.toLowerCase() === 'mobilepush') {
package/favicon.ico CHANGED
Binary file
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.1.5",
4
+ "version": "7.1.7",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -122,13 +122,14 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
122
122
  }
123
123
  if (nextProps.startValidation && nextProps.startValidation !== false && this.props.startValidation !== nextProps.startValidation) {
124
124
  this.setState({checkValidation: true});
125
- this.validateForm(null, null, true, true);
125
+ this.validateForm(null, null, true, true, () => {
126
126
  //triggering the saveFormData or onSubmit when validation sets isFormValid to TRUE
127
- if (this.state.isFormValid) {
127
+ if (this.state.isFormValid) {
128
128
  this.saveForm(true);
129
- this.setState({isFormValid:false});
130
- }
129
+ } else {
131
130
  this.props.stopValidation();
131
+ }
132
+ });
132
133
  }
133
134
  // if (nextProps.saveForm && this.props.saveForm !== nextProps.saveForm) {
134
135
  // this.saveForm(saveForm);
@@ -616,7 +616,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
616
616
  'text-align': 'center',
617
617
  "width": '140px',
618
618
  "height": '20px',
619
- "margin-left": "2px",
619
+ "margin-left": "8px",
620
620
  }}>
621
621
  <p
622
622
  style={{ 'font-size': '12px',
@@ -6,6 +6,8 @@ import moment from 'moment';
6
6
  import PropTypes from 'prop-types';
7
7
  import messages from './messages';
8
8
  import { MAP_TEMPLATE } from '../WeChat/Wrapper/constants';
9
+ import { NO_COMMUNICATION } from '../App/constants';
10
+ import { FTP } from '../FTP';
9
11
  const PrefixWrapper = styled.div`
10
12
  margin-right: 16px;
11
13
  `;
@@ -29,7 +31,7 @@ function SlideBoxHeader(props) {
29
31
  {slidBoxContent === 'templates' && !showTemplateNameHeader && (
30
32
  <CapHeader
31
33
  title={<FormattedMessage {...messages.creativeTemplates} />}
32
- description={
34
+ description={![NO_COMMUNICATION, FTP].includes(channel) &&
33
35
  <FormattedMessage {...messages.creativeTemplatesDesc} />
34
36
  }
35
37
  />
@@ -2358,6 +2358,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2358
2358
  const response = {
2359
2359
  action: "getFormData",
2360
2360
  postAction: this.state.getFormDataValue || 'next',
2361
+ id : _.get(this.props, 'Email.templateDetails._id', ''),
2361
2362
  value: this.transformFormData(passedData),
2362
2363
  validity: this.state.isFormValid,
2363
2364
  type: 'EMAIL',
@@ -61,7 +61,8 @@
61
61
  }
62
62
  .scrollable-section{
63
63
  height: calc(100vh - 220px);
64
- overflow-y: auto;
64
+ overflow-y: auto;
65
+ margin-bottom: $CAP_SPACE_08;
65
66
  }
66
67
  .FTP-tagList {
67
68
  position: absolute;
@@ -82,8 +83,13 @@
82
83
  }
83
84
  .ftp-preview-message-content{
84
85
  max-width: 450px;
85
- margin-top: 4px;
86
- color: $FONT_COLOR_02;
86
+ margin-top: 4px;
87
+ color: $FONT_COLOR_02;
88
+ .ant-input[disabled]{
89
+ background-color: $CAP_WHITE;
90
+ color: $FONT_COLOR_01;
91
+ cursor: default;
92
+ }
87
93
  }
88
94
  .ftp-preview-data-title{
89
95
  margin-top: $CAP_SPACE_40;
@@ -100,4 +106,9 @@
100
106
  .manage-ftp-setting-div{
101
107
  display: flex;
102
108
  align-items: baseline;
109
+ }
110
+
111
+ .configure-ftp-setting-div{
112
+ text-align: center;
113
+ align-items: baseline;
103
114
  }
@@ -19,7 +19,7 @@ import {
19
19
  CapTreeSelect,
20
20
  CapDivider,
21
21
  } from '@capillarytech/cap-ui-library';
22
- import { find, cloneDeep, findIndex, isEmpty, isEqual, filter } from 'lodash';
22
+ import { find, cloneDeep, findIndex, isEmpty, isEqual, filter, forEach } from 'lodash';
23
23
  import * as actions from './actions';
24
24
  import { makeSelectFTP, makeSelectMetaEntities } from './selectors';
25
25
  import withCreatives from '../../hoc/withCreatives';
@@ -140,24 +140,35 @@ export class FTP extends React.Component {
140
140
  >
141
141
  {formatMessage(messages.ftpServer)}
142
142
  </CapHeading>
143
- <CapHeading type="h6" className="manage-ftp-setting-div">
143
+ {serverOptions.length && <CapHeading type="h6" className="manage-ftp-setting-div">
144
144
  {formatMessage(messages.ftpServerDesc)}
145
145
  <CapLink
146
146
  title={formatMessage(messages.manageFTPSettings)}
147
147
  className="select-server"
148
148
  onClick={this.handleManageFTPSettings}
149
149
  />
150
- </CapHeading>
151
- <CapRadioCard
152
- className="select-account"
153
- onChange={this.onChangeFTPServer}
154
- panes={serverOptions}
155
- cardHeight="48px"
156
- cardWidth="276px"
157
- size="small"
158
- defaultValue={selectedServer}
159
- selected={selectedServer}
160
- />
150
+ </CapHeading>}
151
+ {serverOptions.length ? (
152
+ <CapRadioCard
153
+ className="select-account"
154
+ onChange={this.onChangeFTPServer}
155
+ panes={serverOptions}
156
+ cardHeight="48px"
157
+ cardWidth="276px"
158
+ size="small"
159
+ defaultValue={selectedServer}
160
+ selected={selectedServer}
161
+ />
162
+ ) : (
163
+ <CapHeading type="h6" className="configure-ftp-setting-div">
164
+ {formatMessage(messages.selectFtpServerDesc)}
165
+ <CapLink
166
+ title={formatMessage(messages.manageFTPSettings)}
167
+ className="select-server"
168
+ onClick={this.handleManageFTPSettings}
169
+ />
170
+ </CapHeading>
171
+ )}
161
172
  </CapSpin>
162
173
  );
163
174
  };
@@ -176,11 +187,62 @@ export class FTP extends React.Component {
176
187
  }));
177
188
  };
178
189
 
190
+ validateTags(content, tagsParam) {
191
+ const tags = tagsParam;
192
+ const response = {};
193
+ response.valid = true;
194
+ response.unsupportedTags = [];
195
+ if (tags && tags.length) {
196
+ const regex = /{{[(A-Z\w+(\s\w+)*$\(\)@!#$%^&*~.,/\\]+}}/g;
197
+ const matchedTags = [...content.matchAll(regex)];
198
+ matchedTags.forEach((tag) => {
199
+ const tagValue = tag[0].substring(this.indexOfEnd(tag[0], '{{'), tag[0].indexOf('}}'));
200
+ let ifSupported = !!tags.find((t) => t.definition.value === tagValue);
201
+ ifSupported = ifSupported || this.checkIfSupportedTag(tagValue, tags);
202
+ if (!ifSupported) {
203
+ response.unsupportedTags.push(tagValue);
204
+ response.valid = false;
205
+ }
206
+ if (response.unsupportedTags.length === 0) {
207
+ response.valid = true;
208
+ }
209
+ });
210
+ }
211
+ return response;
212
+ }
213
+
214
+ checkIfSupportedTag(checkingTag, injectedTags) {
215
+ let result = false;
216
+ forEach(injectedTags, (tag, key) => {
217
+ if (tag.subtags) {
218
+ if (this.checkIfSupportedTag(checkingTag, tag.subtags)) {
219
+ result = true;
220
+ }
221
+ } else if (checkingTag === key) {
222
+ result = true;
223
+ }
224
+ });
225
+
226
+ return result;
227
+ }
228
+
229
+ indexOfEnd(targetString, string) {
230
+ const io = targetString.indexOf(string);
231
+ return io == -1 ? -1 : io + string.length;
232
+ }
233
+
179
234
  getMessageContent = () => {
180
235
  const { messageContent } = this.state;
181
236
  const { formatMessage } = this.props.intl;
182
237
  const { metaEntities, selectedOfferDetails } = this.props;
183
238
  const tagsRaw = metaEntities && metaEntities.tags ? metaEntities.tags.standard : [];
239
+ const validateTagResponse = this.validateTags(messageContent, tagsRaw);
240
+ let unsupportedTags = null;
241
+ let errorMessageText = '';
242
+ if (!validateTagResponse.valid) {
243
+ unsupportedTags = validateTagResponse.unsupportedTags.join(', ').toString();
244
+ errorMessageText = formatMessage(messages.unsupportedTagsValidationError, {unsupportedTags})
245
+ }
184
246
  return (
185
247
  <CapRow>
186
248
  <CapColumn span={11}>
@@ -197,6 +259,7 @@ export class FTP extends React.Component {
197
259
  label={formatMessage(messages.messageHeader)}
198
260
  onChange={this.updateMessageBody}
199
261
  value={messageContent}
262
+ errorMessage={errorMessageText}
200
263
  />
201
264
  </div>
202
265
  </CapColumn>
@@ -341,9 +404,11 @@ export class FTP extends React.Component {
341
404
  <CapHeading className="ftp-preview-message-title" type="h3">
342
405
  <FormattedMessage {...messages.messageContent}/>
343
406
  </CapHeading>
344
- <CapLabel type="label2" className="ftp-preview-message-content">
345
- {messageBody}
346
- </CapLabel>
407
+ <CapInput.TextArea
408
+ value={messageBody}
409
+ disabled
410
+ className="ftp-preview-message-content"
411
+ />
347
412
  <CapHeading className="ftp-preview-data-title" type="h3">
348
413
  <FormattedMessage {...messages.dataPreview}/>
349
414
  </CapHeading>
@@ -353,7 +418,7 @@ export class FTP extends React.Component {
353
418
  };
354
419
 
355
420
  showAccountSelection = () => {
356
- this.setState({ viewMode: UIView.serverSelection, selectedServer: null, headerTagList: [], messageContent: ''});
421
+ this.setState({ viewMode: UIView.serverSelection, selectedServer: null});
357
422
  };
358
423
 
359
424
  selectCsvColumn = (option, label, index) => {
@@ -5,6 +5,10 @@ export default defineMessages({
5
5
  id: 'creatives.containersV2.FTP.ftpServerDesc',
6
6
  defaultMessage: 'Select the FTP server to send the message data. To add another FTP location, ',
7
7
  },
8
+ selectFtpServerDesc: {
9
+ id: 'creatives.containersV2.FTP.selectFtpServerDesc',
10
+ defaultMessage: 'FTP not configured for this org. Please add FTP server ',
11
+ },
8
12
  ftpServer: {
9
13
  id: 'creatives.containersV2.FTP.ftpServer',
10
14
  defaultMessage: 'FTP Server',
@@ -17,6 +21,10 @@ export default defineMessages({
17
21
  id: 'creatives.containersV2.FTP.addColumn',
18
22
  defaultMessage: 'Add column',
19
23
  },
24
+ unsupportedTagsValidationError: {
25
+ id: 'creatives.containersV2.FTP.unsupportedTagsValidationError',
26
+ defaultMessage: 'Unsupported tags: {unsupportedTags}. Please remove them from this message.',
27
+ },
20
28
  selectTag: {
21
29
  id: 'creatives.containersV2.FTP.selectTag',
22
30
  defaultMessage: 'Select tag',
@@ -11,11 +11,8 @@ export function* createTemplate(template) {
11
11
  try {
12
12
  console.log('saga createTemplate mobilepush', template);
13
13
  const result = yield call(Api.createMobilePushTemplate, template);
14
- if (result.message) {
14
+ if (result.message || result.status.code === 500) {
15
15
  errorMsg = result.message;
16
- if(result.status.code>=400){
17
- throw errorMsg;
18
- }
19
16
  }
20
17
  if (template.callback) {
21
18
  yield call(template.callback, result.response);
@@ -122,7 +122,7 @@ const Viber = (props) => {
122
122
  }, [viberData.selectedViberAccount]);
123
123
 
124
124
  useEffect(() => {
125
- if ((params && params.id) || templateData.edit) {
125
+ if ((params && params.id) || (templateData || {}).edit) {
126
126
  const { viber: editViberContent = {} } = get(templateData, `versions.base.content`) || get(viber, `templateDetails.versions.base.content`) || {};
127
127
  const editMessageTitle = (templateData || {}).name || get(viber, 'templateDetails.name');
128
128
  updateTextMessageTitle(editMessageTitle);