@capillarytech/creatives-library 6.10.0 → 6.10.2

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 (36) hide show
  1. package/components/CapTagList/index.js +1 -1
  2. package/components/Edmeditor/index.js +1 -1
  3. package/components/FormBuilder/index.js +0 -1
  4. package/containers/TagList/index.js +3 -3
  5. package/index.html +3 -0
  6. package/package.json +2 -1
  7. package/services/api.js +19 -4
  8. package/translations/en.json +117 -4
  9. package/translations/zh.json +113 -0
  10. package/v2Components/BeeEditor/index.js +263 -0
  11. package/v2Components/BeeEditor/index.scss +11 -0
  12. package/v2Components/BeeEditor/messages.js +71 -0
  13. package/v2Components/BeeEditor/tests/index.test.js +10 -0
  14. package/v2Components/CapTagList/index.js +55 -26
  15. package/v2Components/CmsTemplatesComponent/index.js +4 -4
  16. package/v2Components/Edmeditor/index.js +1 -1
  17. package/v2Components/EmailPreview/_emailPreview.scss +2 -2
  18. package/v2Components/FormBuilder/index.js +78 -43
  19. package/v2Containers/App/constants.js +1 -0
  20. package/v2Containers/CreativesContainer/SlideBoxFooter.js +2 -2
  21. package/v2Containers/CreativesContainer/index.js +7 -2
  22. package/v2Containers/Email/constants.js +1 -0
  23. package/v2Containers/Email/index.js +170 -116
  24. package/v2Containers/Email/initialSchema.js +18 -3
  25. package/v2Containers/Email/sagas.js +2 -2
  26. package/v2Containers/Email/selectors.js +5 -0
  27. package/v2Containers/EmailWrapper/index.js +19 -3
  28. package/v2Containers/Line/Container/Image/index.js +1 -1
  29. package/v2Containers/TagList/index.js +13 -6
  30. package/v2Containers/Templates/actions.js +8 -3
  31. package/v2Containers/Templates/constants.js +6 -4
  32. package/v2Containers/Templates/index.js +36 -20
  33. package/v2Containers/Templates/messages.js +8 -0
  34. package/v2Containers/Templates/reducer.js +13 -5
  35. package/v2Containers/Templates/sagas.js +7 -7
  36. package/v2Containers/Templates/selectors.js +19 -1
@@ -11,7 +11,7 @@ import PropTypes from 'prop-types';
11
11
  import React from 'react';
12
12
  import _ from 'lodash';
13
13
  import { Tabs, Table, Modal} from 'antd';
14
- import { CapDrawer, CapButton, CapInput, CapPopover, CapImage, CapCheckbox, CapRadio, CapSelect, CapTable, CapRow, CapColumn, CapNotification, CapUploader, CapHeading, CapIcon} from '@capillarytech/cap-ui-library';
14
+ import { CapSpin, CapDrawer, CapButton, CapInput, CapPopover, CapImage, CapCheckbox, CapRadio, CapSelect, CapTable, CapRow, CapColumn, CapNotification, CapUploader, CapHeading, CapIcon} from '@capillarytech/cap-ui-library';
15
15
  import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
16
16
  import LabelHOC from '@capillarytech/cap-ui-library/assets/HOCs/ComponentWithLabelHOC';
17
17
  import { CAP_SPACE_12, CAP_SPACE_08, FONT_COLOR_05, FONT_COLOR_04 } from '@capillarytech/cap-ui-library/styled/variables';
@@ -21,6 +21,7 @@ import SlideBox from '../SlideBox';
21
21
  import CardGrid from '../CardGrid';
22
22
  import CKEditor from "../Ckeditor/";
23
23
  import EDMEditor from "../Edmeditor";
24
+ import BeeEditor from '../BeeEditor';
24
25
  import CustomPopOver from '../CustomPopOver';
25
26
  import messages from './messages';
26
27
  import './_formBuilder.scss';
@@ -275,7 +276,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
275
276
  onEdit() {
276
277
 
277
278
  }
278
-
279
279
  getModal = () => {
280
280
  let modal;
281
281
  if (this.state.modal) {
@@ -925,7 +925,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
925
925
  for (var i = 0; i < data.selectedLanguages.length; i+= 1) {
926
926
  const currentLang = data.selectedLanguages[i];
927
927
  const content = data[currentLang]['template-content'];
928
- const tagValidationResponse = this.validateTags(content, tags, injectedTags);
928
+ if (!content) {
929
+ return false;
930
+ }
931
+ const tagValidationResponse = this.validateTags(content, tags, injectedTags);;
929
932
  if (errorData[index][currentLang] === undefined) {
930
933
  errorData[index][currentLang] = {};
931
934
  }
@@ -2953,24 +2956,28 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2953
2956
  if (channel === 'EMAIL') {
2954
2957
  moduleFilterEnabled = this.props.isFullMode;
2955
2958
  }
2956
- columns.push(
2957
- <CapColumn key={`input-${val.id}`} offset={val.offset} span={val.width ? val.width : ''} style={val.style ? val.style : {marginBottom: '16px'}}>
2958
- <TagList
2959
- key={`input-${val.id}`}
2960
- moduleFilterEnabled={moduleFilterEnabled}
2961
- label={val.label ? val.label : ''}
2962
- onTagSelect={(data) => this.callChildEvent(data, val, 'onTagSelect')}
2963
- onContextChange={this.props.onContextChange}
2964
- location={this.props.location}
2965
- tags={this.props.tags ? this.props.tags : []}
2966
- injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
2967
- className={val.className ? val.className : ''}
2968
- id={val.id}
2969
- userLocale={this.props.userLocale}
2970
- selectedOfferDetails={this.props.selectedOfferDetails}
2971
- />
2972
- </CapColumn>
2973
- );
2959
+ const langIndex = 0;
2960
+ const currentLang = (!_.isEmpty(this.state.formData) && !_.isEmpty(this.state.formData[`${this.state.currentTab - 1}`]) && !_.isEmpty(this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages) && this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages[langIndex]) ? this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages[langIndex] : this.props.baseLanguage;
2961
+ if (!(_.get(this.state, `formData[${this.state.currentTab - 1}][${currentLang}].is_drag_drop`, false)) || channel !== 'EMAIL') {
2962
+ columns.push(
2963
+ <CapColumn key={`input-${val.id}`} offset={val.offset} span={val.width ? val.width : ''} style={val.style ? val.style : {marginBottom: '16px'}}>
2964
+ <TagList
2965
+ key={`input-${val.id}`}
2966
+ moduleFilterEnabled={moduleFilterEnabled}
2967
+ label={val.label ? val.label : ''}
2968
+ onTagSelect={(data) => this.callChildEvent(data, val, 'onTagSelect')}
2969
+ onContextChange={this.props.onContextChange}
2970
+ location={this.props.location}
2971
+ tags={this.props.tags ? this.props.tags : []}
2972
+ injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
2973
+ className={val.className ? val.className : ''}
2974
+ id={val.id}
2975
+ userLocale={this.props.userLocale}
2976
+ selectedOfferDetails={this.props.selectedOfferDetails}
2977
+ />
2978
+ </CapColumn>
2979
+ );
2980
+ }
2974
2981
  break;
2975
2982
  case "button":
2976
2983
  if (styling === 'semantic' && val.metaType === 'submit-button') {
@@ -3191,38 +3198,53 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3191
3198
  }
3192
3199
  }
3193
3200
  break;
3194
- case "edmeditor": {
3195
- // if (!this.state.formData[`${this.state.currentTab - 1}`]) {
3196
- // return true;
3197
- // }
3201
+ case "BEEeditor": {
3198
3202
  let langTab = 1;
3199
- if (val.id.match(/edmeditor/g)) {
3203
+ if (val.id.match(/BEEeditor/g)) {
3200
3204
  if (val.id.length > 9 && val.id.charAt(9)) {
3201
3205
  langTab = val.id.charAt(9);
3202
3206
  }
3203
3207
  }
3204
- const supportedLanguages = this.state.formData[this.state.currentTab - 1].selectedLanguages;
3205
- // let langIndex = 0;
3206
- // if (val.id.indexOf('edmeditor') > -1 && val.id !== 'edmeditorsrc') {
3207
- // const test = val.id.replace('src', '');
3208
- // langIndex = parseInt(test.replace('edmeditor', ''), 10) - 1;
3209
- // }
3210
- // const currentLang = (!_.isEmpty(this.state.formData) && !_.isEmpty(this.state.formData[`${this.state.currentTab - 1}`]) && !_.isEmpty(this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages) && this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages[langIndex]) ? this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages[langIndex] : this.props.baseLanguage;
3208
+ const { currentTab, formData } = this.state;
3209
+ const supportedLanguages = formData[currentTab - 1].selectedLanguages;
3211
3210
  const currentLang = supportedLanguages[langTab - 1];
3212
- const edmSrc = this.state.formData[`${this.state.currentTab - 1}`][currentLang] && this.state.formData[`${this.state.currentTab - 1}`][currentLang][`edmeditor${this.state.currentTab > 1 ? this.state.currentTab : ''}src`];
3213
-
3214
3211
 
3215
- if (!edmSrc) {
3212
+ let beeJson = '',
3213
+ beeToken = '',
3214
+ uuid = '';
3215
+ const data = formData[`${currentTab - 1}`][currentLang];
3216
+ if (data) {
3217
+ beeJson = data[`BEEeditor${currentTab > 1 ? currentTab : ''}json`];
3218
+ beeToken = data[`BEEeditor${currentTab > 1 ? currentTab : ''}token`];
3219
+ uuid = this.props.uuid;
3220
+ }
3221
+ if (!beeJson || !beeToken) {
3216
3222
  return false;
3217
3223
  }
3218
-
3219
-
3224
+ let isModuleFilterEnabled = _.get(this.props.location, 'query.type', '') !== 'embedded';
3225
+ const schemaChannel = _.get(this.props.schema, 'channel', "");
3226
+ if (schemaChannel === 'EMAIL') {
3227
+ isModuleFilterEnabled = this.props.isFullMode;
3228
+ }
3220
3229
  columns.push(
3221
3230
  <CapColumn style={val.colStyle ? val.colStyle : {}} span={val.width}>
3222
- <EDMEditor
3231
+ <BeeEditor
3232
+ uid={uuid}
3233
+ tokenData={beeToken}
3223
3234
  id={val.id}
3224
- getEditorInstanse={this.getEditorInstanse}
3225
- edmSrc={edmSrc}
3235
+ beeJson={beeJson}
3236
+ showTagsPopover={this.showTagsPopover}
3237
+ location={this.props.location}
3238
+ label={val.label || ''}
3239
+ className={val.className || ''}
3240
+ userLocale={this.props.userLocale}
3241
+ selectedOfferDetails={this.props.selectedOfferDetails}
3242
+ tags={this.props.tags || []}
3243
+ injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
3244
+ saveBeeInstance={this.props.saveBeeInstance}
3245
+ saveBeeData={this.props.saveBeeData}
3246
+ onContextChange={this.props.onContextChange}
3247
+ moduleFilterEnabled={isModuleFilterEnabled}
3226
3248
  />
3227
3249
  </CapColumn>
3228
3250
  );
@@ -3263,7 +3285,9 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3263
3285
  }
3264
3286
  </CapRow>
3265
3287
  );
3266
- fields.push(row);
3288
+ if (columns.length) {
3289
+ fields.push(row);
3290
+ }
3267
3291
  });
3268
3292
 
3269
3293
  _.forEach(section.actionFields, (field) => {
@@ -3303,8 +3327,18 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3303
3327
  }
3304
3328
  </CapRow>
3305
3329
  );
3306
- fields.push(row);
3330
+ if (columns.length) {
3331
+ fields.push(row);
3332
+ }
3333
+
3307
3334
  });
3335
+ if(!this.props.isEmailLoading && this.props.schema.channel.toUpperCase() === 'EMAIL' && !fields.length) {
3336
+ return (
3337
+ <div style={{ textAlign: 'center' }}>
3338
+ <CapSpin spinning />
3339
+ </div>
3340
+ );
3341
+ }
3308
3342
  return fields;
3309
3343
  }
3310
3344
 
@@ -3538,6 +3572,7 @@ FormBuilder.propTypes = {
3538
3572
  setDrawerVisibility: PropTypes.bool,
3539
3573
  capDrawerContent: PropTypes.array,
3540
3574
  isFullMode: PropTypes.bool,
3575
+
3541
3576
  };
3542
3577
 
3543
3578
  export default injectIntl(FormBuilder);
@@ -46,3 +46,4 @@ export const CHANNEL_EDIT_TRACK_MAPPING = {
46
46
  line: TRACK_EDIT_LINE,
47
47
  };
48
48
  export const GTM_TRACKING_ID = 'UA-110024621-2';
49
+ export const BEE_PLUGIN = 'BEE_PLUGIN';
@@ -10,13 +10,13 @@ function getFullModeSaveBtn(slidBoxContent) {
10
10
  <FormattedMessage {...messages.creativesTemplatesSaveFullMode}/>;
11
11
  }
12
12
  function SlideBoxFooter(props) {
13
- const { slidBoxContent, onSave, onEditTemplate, onCreateNextStep, isFullMode} = props;
13
+ const { slidBoxContent, onSave, onEditTemplate, onCreateNextStep, isFullMode, fetchingCmsData} = props;
14
14
  return (
15
15
  <div>
16
16
  <div>
17
17
  {props.shouldShowDoneFooter() && (
18
18
  <div>
19
- <CapButton onClick={onSave}>
19
+ <CapButton onClick={onSave} disabled={fetchingCmsData || false}>
20
20
  {isFullMode ?
21
21
  getFullModeSaveBtn(slidBoxContent)
22
22
  :
@@ -25,6 +25,7 @@ import * as globalActions from '../Cap/actions';
25
25
  import {isLoading as isLoadingSelector} from './selectors';
26
26
  import messages from './messages';
27
27
  import { MAP_TEMPLATE } from '../WeChat/Wrapper/constants';
28
+ import { makeSelectFetchingCmsData } from '../Email/selectors';
28
29
 
29
30
  const classPrefix = 'add-creatives-section';
30
31
 
@@ -165,6 +166,8 @@ class Creatives extends React.Component {
165
166
  iso_code: templateData.iso_code,
166
167
  language: templateData.language,
167
168
  drag_drop_id: templateData.drag_drop_id,
169
+ json_content: templateData.json_content,
170
+ id: templateData.id,
168
171
  };
169
172
  creativesTemplateData = {
170
173
  base: formData,
@@ -528,7 +531,7 @@ class Creatives extends React.Component {
528
531
  }
529
532
  render() {
530
533
  const {slidBoxContent, isGetFormData, showSlideBox, templateData, currentChannel, emailCreateMode, templateStep, isLoadingContent, mobilePushCreateMode, isDiscardMessage, weChatTemplateType, weChatMaptemplateStep} = this.state;
531
- const {isFullMode, creativesMode, cap, isUploading, channelsToHide, selectedWeChatAccount, forwardedTags, channelsToDisable, selectedOfferDetails, onTestContentClicked, onPreviewContentClicked, getCreativesData} = this.props;
534
+ const {isFullMode, creativesMode, cap, isUploading, channelsToHide, selectedWeChatAccount, forwardedTags, channelsToDisable, selectedOfferDetails, onTestContentClicked, onPreviewContentClicked, getCreativesData, fetchingCmsData} = this.props;
532
535
  const mapTemplateCreate = slidBoxContent === 'createTemplate' && weChatTemplateType === MAP_TEMPLATE && templateStep !== 'modeSelection';
533
536
  /* TODO: Instead of passing down same props separately to each component down, write common function to these props and pass it accordingly */
534
537
  return (
@@ -617,11 +620,12 @@ class Creatives extends React.Component {
617
620
  emailCreateMode={emailCreateMode}
618
621
  shouldShowContinueFooter={this.shouldShowContinueFooter}
619
622
  shouldShowDoneFooter={this.shouldShowDoneFooter}
623
+ fetchingCmsData={fetchingCmsData}
620
624
  />
621
625
  }
622
626
  handleClose={this.handleCloseSlideBox}
623
627
  show={showSlideBox}
624
- size="size-l"
628
+ size="size-xl"
625
629
  />
626
630
  </SlideBoxWrapper>
627
631
  );
@@ -659,6 +663,7 @@ const mapStatesToProps = () => createStructuredSelector({
659
663
  EmailLayout: selectEmailLayout(),
660
664
  isUploading: uploadSelector(),
661
665
  Templates: makeSelectTemplates(),
666
+ fetchingCmsData: makeSelectFetchingCmsData(),
662
667
  });
663
668
  function mapDispatchToProps(dispatch) {
664
669
  return {
@@ -35,3 +35,4 @@ export const CLEAR_ALL_VALUES = "app/v2Containers/Email/CLEAR_ALL_VALUES";
35
35
  export const DUPLICATE_TEMPLATE_REQUEST = 'app/v2Containers/Email/DUPLICATE_TEMPLATE_REQUEST';
36
36
  export const DUPLICATE_TEMPLATE_SUCCESS = 'app/v2Containers/Email/DUPLICATE_TEMPLATE_SUCCESS';
37
37
  export const DUPLICATE_TEMPLATE_FAILURE = 'app/v2Containers/Email/DUPLICATE_TEMPLATE_FAILURE';
38
+