@capillarytech/creatives-library 2.0.65 → 2.0.68

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/components/Ckeditor/index.js +30 -3
  2. package/components/FormBuilder/index.js +53 -30
  3. package/components/FormBuilder/test +1845 -0
  4. package/components/Header/index.js +7 -4
  5. package/components/Header/messages.js +12 -0
  6. package/components/TemplatePreview/WechatRichmediaTemplatePreview/_wechatRichmediaTemplatePrev.scss +42 -0
  7. package/components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +104 -0
  8. package/components/TemplatePreview/WechatRichmediaTemplatePreview/messages.js +21 -0
  9. package/components/TemplatePreview/WechatRichmediaTemplatePreview/tests/index.test.js +10 -0
  10. package/containers/Cap/actions.js +6 -0
  11. package/containers/Cap/constants.js +2 -0
  12. package/containers/Cap/reducer.js +4 -2
  13. package/containers/Cap/selectors.js +13 -0
  14. package/containers/CreativesContainer/SlideBoxContent.js +9 -2
  15. package/containers/Ebill/index.js +4 -21
  16. package/containers/Email/index.js +9 -24
  17. package/containers/Line/Create/index.js +5 -17
  18. package/containers/Line/Edit/index.js +5 -25
  19. package/containers/MobilePush/Create/index.js +5 -22
  20. package/containers/MobilePush/Create/selectors.js +1 -1
  21. package/containers/MobilePush/Edit/index.js +9 -30
  22. package/containers/MobilePush/Edit/selectors.js +2 -2
  23. package/containers/MobilePush/initialSchema.js +4 -4
  24. package/containers/MobilepushWrapper/index.js +9 -7
  25. package/containers/Sms/Create/index.js +17 -31
  26. package/containers/Sms/Edit/index.js +6 -20
  27. package/containers/Templates/index.js +60 -67
  28. package/containers/Templates/reducer.js +3 -3
  29. package/containers/WeChat/MapTemplates/index.js +6 -22
  30. package/containers/WeChat/RichmediaTemplates/Create/_createRichmedia.scss +46 -2
  31. package/containers/WeChat/RichmediaTemplates/Create/actions.js +4 -3
  32. package/containers/WeChat/RichmediaTemplates/Create/constants.js +1 -0
  33. package/containers/WeChat/RichmediaTemplates/Create/index.js +525 -165
  34. package/containers/WeChat/RichmediaTemplates/Create/messages.js +125 -1
  35. package/containers/WeChat/RichmediaTemplates/Create/reducer.js +15 -4
  36. package/containers/WeChat/RichmediaTemplates/Create/richmediaschema.js +497 -0
  37. package/containers/WeChat/RichmediaTemplates/Create/sagas.js +7 -3
  38. package/containers/WeChat/RichmediaTemplates/Create/selectors.js +5 -0
  39. package/containers/WeChat/RichmediaTemplates/Edit/index.js +24 -8
  40. package/containers/WeChat/RichmediaTemplates/Edit/selectors.js +6 -1
  41. package/initialState.js +1 -0
  42. package/package.json +2 -2
  43. package/routes.js +22 -4
@@ -6,24 +6,27 @@
6
6
 
7
7
  import React, { PropTypes } from 'react';
8
8
  // import styled from 'styled-components';
9
+ import { FormattedMessage } from 'react-intl';
9
10
 
10
11
  import { CapRow, CapColumn, CapInput, CapButton } from '@capillarytech/cap-ui-library';
12
+ import messages from './messages';
13
+
11
14
 
12
15
  function Header(props) {
13
16
  return (
14
17
  <div>
15
18
  <CapRow className="template-form-header">
16
19
  <CapColumn span={10}>
17
- <CapInput id="template-name" errorMessage="Template name cannot be empty" placeholder="Enter template name*" defaultValue={props.templateName} type="input" onChange={props.templateNameHandler}/>
20
+ <CapInput id="template-name" placeholder="Enter template name*" defaultValue={props.templateName} type="input" onChange={props.templateNameHandler}/>
18
21
  </CapColumn>
19
22
  <CapColumn span={2} offset={8}>
20
- <CapButton id="preview-button" type="cancel" onClick={props.previewHandler}> Preview </CapButton>
23
+ <CapButton id="preview-button" type="cancel" onClick={props.previewHandler}> <FormattedMessage {...messages.preview} /> </CapButton>
21
24
  </CapColumn>
22
25
  <CapColumn span={2}>
23
- <CapButton id="cancel-button" type="cancel" onClick={props.cancelHandler}> Cancel </CapButton>
26
+ <CapButton id="cancel-button" type="cancel" onClick={props.cancelHandler}> <FormattedMessage {...messages.cancel} /> </CapButton>
24
27
  </CapColumn>
25
28
  <CapColumn span={2}>
26
- <CapButton id="save-button" type="primary" onClick={props.saveHandler}> Save </CapButton>
29
+ <CapButton id="save-button" type="primary" onClick={props.saveHandler}> <FormattedMessage {...messages.save} /> </CapButton>
27
30
  </CapColumn>
28
31
  </CapRow>
29
32
  </div>
@@ -10,4 +10,16 @@ export default defineMessages({
10
10
  id: 'app.components.Header.header',
11
11
  defaultMessage: 'This is the Header component !',
12
12
  },
13
+ preview: {
14
+ id: 'app.components.Header.preview',
15
+ defaultMessage: 'Preview',
16
+ },
17
+ cancel: {
18
+ id: 'app.components.Header.cancel',
19
+ defaultMessage: 'Cancel',
20
+ },
21
+ save: {
22
+ id: 'app.components.Header.save',
23
+ defaultMessage: 'Save',
24
+ },
13
25
  });
@@ -0,0 +1,42 @@
1
+ .wechatMsgContainer{
2
+ position: absolute;
3
+ left: 30%;
4
+ top: 20%;
5
+ background: white;
6
+ width: 40%;
7
+ text-align: left;
8
+ }
9
+ .wechatMsgContainerOutbound{
10
+ position: absolute;
11
+ left: 35%;
12
+ top: 20%;
13
+ background: white;
14
+ width: 30%;
15
+ text-align: left;
16
+ }
17
+ .wechatMsgContainerCardLayout {
18
+ position: absolute;
19
+ left: 20%;
20
+ top: 20%;
21
+ background: white;
22
+ width: 60%;
23
+ text-align: left;
24
+ }
25
+ .overflow-handle-preview {
26
+ height: 430px;
27
+ overflow-y: auto;
28
+ }
29
+ .overflow-handle-preview-outbound {
30
+ height: 330px;
31
+ overflow-y: auto;
32
+ }
33
+ .preview-overflow-wrap-fields {
34
+ text-overflow: ellipsis;
35
+ overflow: hidden;
36
+ overflow-wrap: break-word;
37
+ display: -webkit-box !important;
38
+ -webkit-box-orient: vertical;
39
+ -webkit-line-clamp: 2;
40
+ text-align: left;
41
+ width: 200px;
42
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ *
3
+ * WechatRichmediaTemplatePreview
4
+ *
5
+ */
6
+
7
+ import React from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { CapRow, CapColumn, CapButton } from '@capillarytech/cap-ui-library/';
10
+ import { FormattedMessage } from 'react-intl';
11
+ import _ from 'lodash';
12
+ import SlideBox from '../../SlideBox';
13
+ import './_wechatRichmediaTemplatePrev.scss';
14
+ import messages from './messages';
15
+ const wechatBody = require('./../assets/images/WECHAT_5x.png');
16
+
17
+ class WechatRichmediaTemplatePreview extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
18
+ preparePreviewData = (mediaList) => {
19
+ const returnObj = [];
20
+ _.forEach(mediaList, (contentData, contentIndex) => {
21
+ const id = parseInt(contentIndex, 10);
22
+ if (id === 0) {
23
+ returnObj.push(
24
+ <div style={{ width: "100%", height: 116, position: "relative" }}>
25
+ <CapRow>
26
+ <img alt="default" width="100%" height="110px" src={contentData.image_url} />
27
+ <div className="preview-overflow-wrap-fields" style={{ position: "absolute", bottom: "5%", left: "5%" }}>{contentData.title ? contentData.title : ""}</div>
28
+ </CapRow>
29
+ {Object.keys(mediaList).length === 1 ?
30
+ <CapRow style={{ height: 32, left: "5%" }}>
31
+ {contentData.digest ? contentData.digest : ""}
32
+ </CapRow>
33
+ :
34
+ ""
35
+ }
36
+ </div>
37
+ );
38
+ } else {
39
+ returnObj.push(
40
+ <CapRow style={{ "width": "100%", "height": 64, "border-bottom": "0.5px solid lightgrey" }}>
41
+ <CapColumn className="preview-overflow-wrap-fields" style={{ padding: "5% 0% 0% 5%", float: "left" }}>
42
+ {contentData.title}
43
+ </CapColumn>
44
+ <CapColumn style={{ float: "right" }}>
45
+ <img alt="default" width="60px" height="60px" src={contentData.image_url} style={{ "padding-right": "10%", "float": "left" }}/>
46
+ </CapColumn>
47
+ </CapRow>
48
+ );
49
+ }
50
+ });
51
+ return returnObj;
52
+ }
53
+ goToEdit(e, path) {
54
+ this.props.onEditClick(e, this.props.templateId, this.props.modeType, path);
55
+ }
56
+ render() {
57
+ return (
58
+ this.props.showSlidebox ?
59
+ <SlideBox
60
+ show={this.props.show}
61
+ handleClose={this.props.closeSlideBox}
62
+ header={this.props.templateName}
63
+ width={50}
64
+ content={
65
+ <div className={`preview-container ${this.props.type === 'embedded' ? 'embedded-preview' : ''}`}>
66
+ <div className="shell align-center" id="sms-preview">
67
+ <img className="preview-image" src={wechatBody} alt="Preview is being generated"/>
68
+ <div className={this.props.type === 'embedded' ? "wechatMsgContainerOutbound" : "wechatMsgContainer"}>
69
+ <div className={this.props.type === 'embedded' ? "overflow-handle-preview-outbound" : "overflow-handle-preview"}>{this.preparePreviewData(this.props.content)}
70
+ </div>
71
+ </div>
72
+ </div>
73
+ {this.props.showEdit ? <CapButton onClick={(e) => this.goToEdit(e, this.props.path)} className="preview-buttons" type="primary">{this.props.type === 'embedded' ? <FormattedMessage {...messages.select} /> : <FormattedMessage {...messages.edit} /> }</CapButton> : ""}
74
+ </div>
75
+ }
76
+ />
77
+ :
78
+ <div className={`preview-container ${this.props.type === 'embedded' ? 'embedded-preview' : ''}`}>
79
+ <div className="shell align-center" id="sms-preview">
80
+ <div className="wechatMsgContainerCardLayout">
81
+ <div>{this.preparePreviewData(this.props.content)}
82
+ </div>
83
+ </div>
84
+ </div>
85
+ </div>
86
+ );
87
+ }
88
+ }
89
+
90
+ WechatRichmediaTemplatePreview.propTypes = {
91
+ showSlidebox: PropTypes.bool,
92
+ show: PropTypes.bool,
93
+ closeSlideBox: PropTypes.function,
94
+ templateName: PropTypes.string,
95
+ type: PropTypes.string,
96
+ content: PropTypes.array,
97
+ onEditClick: PropTypes.func,
98
+ showEdit: PropTypes.bool,
99
+ path: PropTypes.string,
100
+ templateId: PropTypes.string,
101
+ modeType: PropTypes.string,
102
+ };
103
+
104
+ export default WechatRichmediaTemplatePreview;
@@ -0,0 +1,21 @@
1
+ /*
2
+ * WechatRichmediaTemplatePreview Messages
3
+ *
4
+ * This contains all the text for the WechatRichmediaTemplatePreview component.
5
+ */
6
+ import { defineMessages } from 'react-intl';
7
+
8
+ export default defineMessages({
9
+ header: {
10
+ id: 'app.components.WechatRichmediaTemplatePreview.header',
11
+ defaultMessage: 'This is the WechatRichmediaTemplatePreview component !',
12
+ },
13
+ select: {
14
+ id: 'app.components.WechatRichmediaTemplatePreview.select',
15
+ defaultMessage: 'Select',
16
+ },
17
+ edit: {
18
+ id: 'app.components.WechatRichmediaTemplatePreview.edit',
19
+ defaultMessage: 'Edit',
20
+ },
21
+ });
@@ -0,0 +1,10 @@
1
+ // import React from 'react';
2
+ // import { shallow } from 'enzyme';
3
+
4
+ // import WechatRichmediaTemplatePreview from '../index';
5
+
6
+ describe('<WechatRichmediaTemplatePreview />', () => {
7
+ it('Expect to have unit tests specified', () => {
8
+ expect(true).toEqual(false);
9
+ });
10
+ });
@@ -56,3 +56,9 @@ export function clearMetaEntities() {
56
56
  type: types.CLEAR_META_ENTITIES,
57
57
  };
58
58
  }
59
+ export function setInjectedTags(injectedTags) {
60
+ return {
61
+ type: types.SET_INJECTED_TAGS, injectedTags,
62
+ };
63
+ }
64
+
@@ -20,3 +20,5 @@ export const GET_SCHEMA_FOR_ENTITY_REQUEST = 'cap/GET_SCHEMA_FOR_ENTITY_REQUEST'
20
20
  export const GET_SCHEMA_FOR_ENTITY_SUCCESS = 'cap/GET_SCHEMA_FOR_ENTITY_SUCCESS';
21
21
  export const CLEAR_META_ENTITIES = 'cap/CLEAR_META_ENTITIES';
22
22
  export const HIDE_TAGS = 'cap/HIDE_TAGS';
23
+
24
+ export const SET_INJECTED_TAGS = 'cap/SET_INJECTED_TAGS';
@@ -95,12 +95,14 @@ function capReducer(state = fromJS(initialState.cap), action) {
95
95
  layouts: [],
96
96
  tags: [],
97
97
  });
98
- case types.HIDE_TAGS: {
98
+ // eslint-disable-next-line no-case-declarations
99
+ case types.HIDE_TAGS:
99
100
  const metaEntities = {tags: {}, layouts: state.get('metaEntities').layouts};
100
101
  metaEntities.tags.standard = _.filter(state.get('metaEntities').tags.standard, (tag) => action.tagList.indexOf(tag.definition.value) === -1);
101
102
  metaEntities.tags.custom = _.filter(state.get('metaEntities').tags.custom, (tag) => action.tagList.indexOf(tag.name) === -1);
102
103
  return state.setIn(['metaEntities'], metaEntities);
103
- }
104
+ case types.SET_INJECTED_TAGS:
105
+ return state.set('injectedTags', action.injectedTags);
104
106
  default:
105
107
  return state;
106
108
  }
@@ -1,5 +1,6 @@
1
1
  // makeSelectLocationState expects a plain JS object for the routing state
2
2
  import { createSelector } from 'reselect';
3
+ import _ from 'lodash';
3
4
  const selectCapDomain = (state) => state.get('cap');
4
5
 
5
6
  const makeSelectAuthenticated = () => createSelector(
@@ -21,6 +22,17 @@ const isLoadingMetaEntities = () => createSelector(
21
22
  selectCapDomain,
22
23
  (globalState) => globalState.get('fetchingSchema')
23
24
  );
25
+ const setInjectedTags = () => createSelector(
26
+ selectCapDomain,
27
+ (globalState) => {
28
+ let injectedTags = globalState.get('injectedTags') || {};
29
+ const metaEntities = globalState.get('metaEntities') || {};
30
+ const customTags = metaEntities.tags && metaEntities.tags.custom ? metaEntities.tags.custom : {};
31
+ console.log("selector cap: ", injectedTags, customTags, metaEntities);
32
+ return (injectedTags = _.merge({}, injectedTags, customTags));
33
+ }
34
+ );
35
+
24
36
  const makeSelectLocationState = () => {
25
37
  let prevRoutingState;
26
38
  let prevRoutingStateJS;
@@ -69,4 +81,5 @@ export {
69
81
  selectCurrentOrgDetails,
70
82
  isLoadingMetaEntities,
71
83
  makeSelectFetchingSchema,
84
+ setInjectedTags,
72
85
  };
@@ -9,6 +9,7 @@ import Email from '../Email';
9
9
  import EmailWrapper from '../EmailWrapper';
10
10
  import MobilepusWrapper from '../MobilepushWrapper';
11
11
  import EmailPreviewV2 from '../../components/EmailPreviewV2';
12
+ import MobilePushPreview from '../../components/MobilePushPreviewV2';
12
13
  import CallTask from '../CallTask';
13
14
  import MobliPushEdit from '../MobilePush/Edit';
14
15
  import * as constants from './constants';
@@ -60,6 +61,7 @@ function SlideBoxContent(props) {
60
61
  let isEmailEditWithContent = false;
61
62
  let isPreview = false;
62
63
  let isEmailPreview = false;
64
+ let isMpushPreview = false;
63
65
  let isEditCallTask = false;
64
66
  let isEditMPush = false;
65
67
  const isEmailCreate = slidBoxContent === 'createTemplate' && channel === constants.EMAIL;
@@ -70,8 +72,9 @@ function SlideBoxContent(props) {
70
72
  isEditMPush = slidBoxContent === 'editTemplate' && channel === constants.MOBILE_PUSH;
71
73
  isEditEmailWithId = slidBoxContent === 'editTemplate' && channel === constants.EMAIL && templateData._id;
72
74
  isEmailEditWithContent = slidBoxContent === 'editTemplate' && channel === constants.EMAIL && !templateData._id;
73
- isPreview = slidBoxContent === 'preview' && channel !== constants.EMAIL;
75
+ isPreview = slidBoxContent === 'preview' && channel === constants.SMS;
74
76
  isEmailPreview = slidBoxContent === 'preview' && channel === constants.EMAIL;
77
+ isMpushPreview = slidBoxContent === 'preview' && channel === constants.MOBILE_PUSH;
75
78
  }
76
79
 
77
80
  return (
@@ -103,6 +106,9 @@ function SlideBoxContent(props) {
103
106
  />
104
107
  )
105
108
  }
109
+ {isMpushPreview &&
110
+ <MobilePushPreview templateData={templateData} channel={channel}/>
111
+ }
106
112
  {isEditSms && (
107
113
  <SmsEdit
108
114
  setIsLoadingContent={setIsLoadingContent}
@@ -187,7 +193,8 @@ function SlideBoxContent(props) {
187
193
  pathname: `/mobilepush/edit/`,
188
194
  query,
189
195
  }}
190
- isFullMode={false}
196
+ params={{id: templateData._id}}
197
+ isFullMode={isFullMode}
191
198
  isGetFormData={isGetFormData}
192
199
  route={{ name: 'mobilepush' }}
193
200
  templateData={templateData}
@@ -16,7 +16,7 @@ import _ from 'lodash';
16
16
  import { createStructuredSelector } from 'reselect';
17
17
  import * as actions from './actions';
18
18
  import FormBuilder from '../../components/FormBuilder';
19
- import { makeSelectMetaEntities, makeSelectAuthenticated } from '../Cap/selectors';
19
+ import { makeSelectMetaEntities, makeSelectAuthenticated, setInjectedTags } from '../Cap/selectors';
20
20
  import * as globalActions from '../../containers/Cap/actions';
21
21
  import { UserIsAuthenticated } from '../../utils/authWrapper';
22
22
  import { makeSelectTemplates } from '../Templates/selectors';
@@ -629,25 +629,6 @@ export class Ebill extends React.Component { // eslint-disable-line react/prefer
629
629
  this.props.globalActions.addMessageToQueue(message);
630
630
  }
631
631
 
632
- if (nextProps.metaEntities && nextProps.metaEntities.tags && nextProps.metaEntities.tags.custom && !_.isEqual(this.props.metaEntities.tags, nextProps.metaEntities.tags)) {
633
- let injectedTags = _.cloneDeep(this.state.injectedTags);
634
- delete injectedTags["Registration custom fields"];
635
- delete injectedTags["Store custom fields"];
636
- delete injectedTags["Transaction custom fields"];
637
- injectedTags = _.merge({}, injectedTags, nextProps.metaEntities.tags.custom);
638
- console.log('new injected tags', nextProps.metaEntities.tags.custom);
639
- if (!_.has(nextProps.metaEntities.tags.custom, "Registration custom fields")) {
640
- delete injectedTags["Registration custom fields"];
641
- }
642
- if (!_.has(nextProps.metaEntities.tags.custom, "Store custom fields")) {
643
- delete injectedTags["Store custom fields"];
644
- }
645
- if (!_.has(nextProps.metaEntities.tags.custom, "Transaction custom fields")) {
646
- delete injectedTags["Transaction custom fields"];
647
- }
648
- this.setState({injectedTags});
649
- }
650
-
651
632
  console.log('Form Data After ', nextProps.Ebill.cmsData, this.props.Ebill.cmsData);
652
633
  if (nextProps.Ebill.cmsData !== '' && !_.isEqual(nextProps.Ebill.cmsData, this.props.Ebill.cmsData)) {
653
634
  const formData = _.cloneDeep(this.state.formData);
@@ -1209,7 +1190,7 @@ export class Ebill extends React.Component { // eslint-disable-line react/prefer
1209
1190
  location={this.props.location}
1210
1191
  tabKey={this.state.tabKey}
1211
1192
  tags={this.props.metaEntities && this.props.metaEntities.tags ? this.props.metaEntities.tags.standard : []}
1212
- injectedTags={this.state.injectedTags ? this.state.injectedTags : {}}
1193
+ injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
1213
1194
  onFormValidityChange={this.setFormValidity}
1214
1195
  handleCancelModal={this.handleCancelModal}
1215
1196
  usingTabContainer
@@ -1259,6 +1240,7 @@ Ebill.propTypes = {
1259
1240
  intl: intlShape.isRequired,
1260
1241
  metaEntities: PropTypes.object,
1261
1242
  // Global: PropTypes.object,
1243
+ injectedTags: PropTypes.object,
1262
1244
  };
1263
1245
 
1264
1246
  const mapStateToProps = createStructuredSelector({
@@ -1266,6 +1248,7 @@ const mapStateToProps = createStructuredSelector({
1266
1248
  Templates: makeSelectTemplates(),
1267
1249
  metaEntities: makeSelectMetaEntities(),
1268
1250
  Global: makeSelectAuthenticated(),
1251
+ injectedTags: setInjectedTags(),
1269
1252
  });
1270
1253
 
1271
1254
  function mapDispatchToProps(dispatch) {
@@ -16,7 +16,7 @@ import { createStructuredSelector } from 'reselect';
16
16
  import _ from 'lodash';
17
17
  import moment from "moment";
18
18
  import FormBuilder from '../../components/FormBuilder';
19
- import { makeSelectMetaEntities, selectCurrentOrgDetails, isLoadingMetaEntities } from '../Cap/selectors';
19
+ import { makeSelectMetaEntities, selectCurrentOrgDetails, isLoadingMetaEntities, makeSelectAuthenticated, setInjectedTags } from '../Cap/selectors';
20
20
  import * as actions from './actions';
21
21
  import * as templatesActions from '../Templates/actions';
22
22
  import * as globalActions from '../../containers/Cap/actions';
@@ -234,7 +234,9 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
234
234
  if (this.props.getDefaultTags) {
235
235
  query.context = this.props.getDefaultTags;
236
236
  }
237
- this.props.globalActions.fetchSchemaForEntity(query);
237
+ if (_.isEmpty(this.props.metaEntities.tags)) {
238
+ this.props.globalActions.fetchSchemaForEntity(query);
239
+ }
238
240
  }
239
241
  setTimeout(() => {
240
242
  this.showSubject();
@@ -436,27 +438,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
436
438
  });
437
439
  }
438
440
 
439
- if (nextProps.metaEntities && nextProps.metaEntities.tags && nextProps.metaEntities.tags.custom && this.props.metaEntities.tags && this.props.metaEntities.tags.standard && !_.isEqual(this.props.metaEntities.tags, nextProps.metaEntities.tags)) {
440
- let injectedTags = _.cloneDeep(this.state.injectedTags);
441
- if (!_.isEmpty(injectedTags)) {
442
- delete injectedTags["Registration custom fields"];
443
- delete injectedTags["Store custom fields"];
444
- delete injectedTags["Transaction custom fields"];
445
- injectedTags = _.merge({}, injectedTags, nextProps.metaEntities.tags.custom);
446
-
447
- if (!_.has(nextProps.metaEntities.tags.custom, "Registration custom fields")) {
448
- delete injectedTags["Registration custom fields"];
449
- }
450
- if (!_.has(nextProps.metaEntities.tags.custom, "Store custom fields")) {
451
- delete injectedTags["Store custom fields"];
452
- }
453
- if (!_.has(nextProps.metaEntities.tags.custom, "Transaction custom fields")) {
454
- delete injectedTags["Transaction custom fields"];
455
- }
456
- this.setState({injectedTags});
457
- }
458
- }
459
-
460
441
  if ( !_.isEqual(nextProps.Email.uploadAssetSuccess, this.props.Email.uploadAssetSuccess) && nextProps.Email.uploadAssetSuccess) {
461
442
  const isDragDrop = this.state.formData[`${this.state.currentTab - 1}`][this.state.formData[`${this.state.currentTab - 1}`].activeTab].is_drag_drop;
462
443
  const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
@@ -2113,6 +2094,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2113
2094
  } else {
2114
2095
  this.setState({injectedTags: data.tags});
2115
2096
  }
2097
+ this.props.globalActions.setInjectedTags(data.tags);
2116
2098
  }
2117
2099
 
2118
2100
  startLoading = (ifEdit) => {
@@ -2579,7 +2561,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2579
2561
  tabKey={this.state.tabKey}
2580
2562
  tags={tags}
2581
2563
  tagModule={this.props.getDefaultTags}
2582
- injectedTags={this.state.injectedTags ? this.state.injectedTags : {}}
2564
+ injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
2583
2565
  onFormValidityChange={this.setFormValidity}
2584
2566
  handleCancelModal={this.handleCancelModal}
2585
2567
  usingTabContainer
@@ -2653,6 +2635,7 @@ Email.propTypes = {
2653
2635
  // creativesContainerActions: PropTypes.object,
2654
2636
  isFullMode: PropTypes.bool,
2655
2637
  setIsLoadingContent: PropTypes.func,
2638
+ injectedTags: PropTypes.object,
2656
2639
  };
2657
2640
 
2658
2641
  const mapStateToProps = (state, props) => createStructuredSelector({
@@ -2661,6 +2644,8 @@ const mapStateToProps = (state, props) => createStructuredSelector({
2661
2644
  metaEntities: makeSelectMetaEntities(),
2662
2645
  currentOrgDetails: props.cap ? () => props.cap.currentOrgDetails : selectCurrentOrgDetails(),
2663
2646
  isLoadingMetaEntities: isLoadingMetaEntities(),
2647
+ Global: makeSelectAuthenticated(),
2648
+ injectedTags: setInjectedTags(),
2664
2649
  });
2665
2650
 
2666
2651
  function mapDispatchToProps(dispatch) {
@@ -13,7 +13,7 @@ import { UserIsAuthenticated } from '../../../utils/authWrapper';
13
13
  import * as globalActions from '../../../containers/Cap/actions';
14
14
  //import { makeSelectCreate, makeSelectCreateResponse, makeSelectEdit, makeSelectEditResponse, makeSelectTemplateDetailsResponse } from './selectors';
15
15
  import {makeSelectCreateLine} from './selectors';
16
- import { makeSelectMetaEntities } from '../../Cap/selectors';
16
+ import { makeSelectMetaEntities, setInjectedTags } from '../../Cap/selectors';
17
17
  import {getMessageObject} from '../../../utils/messageUtils';
18
18
  import { makeSelectTemplates } from '../../Templates/selectors';
19
19
  import './_lineCreate.scss';
@@ -218,21 +218,6 @@ export class Line extends Component {
218
218
  console.log("ooo", this.state.formData);
219
219
  this.props.actions.clearAsset();
220
220
  }
221
- if (nextProps.metaEntities && nextProps.metaEntities.tags && nextProps.metaEntities.tags.custom && this.props.metaEntities.tags !== nextProps.metaEntities.tags) {
222
- let injectedTags = _.cloneDeep(this.state.injectedTags);
223
- injectedTags = _.merge({}, injectedTags, nextProps.metaEntities.tags.custom);
224
- console.log('new injected tags', nextProps.metaEntities.tags.custom);
225
- if (!_.has(nextProps.metaEntities.tags.custom, "Registration custom fields")) {
226
- delete injectedTags["Registration custom fields"];
227
- }
228
- if (!_.has(nextProps.metaEntities.tags.custom, "Store custom fields")) {
229
- delete injectedTags["Store custom fields"];
230
- }
231
- if (!_.has(nextProps.metaEntities.tags.custom, "Transaction custom fields")) {
232
- delete injectedTags["Transaction custom fields"];
233
- }
234
- this.setState({injectedTags});
235
- }
236
221
  }
237
222
 
238
223
  componentWillUnmount() {
@@ -579,6 +564,7 @@ export class Line extends Component {
579
564
  obj['0'].image = content;
580
565
  }
581
566
  this.setState({formData: obj, loading: false, injectedTags: data.tags});
567
+ this.props.globalActions.setInjectedTags(data.tags);
582
568
  };
583
569
 
584
570
  startLoading = (ifEdit) => {
@@ -781,7 +767,7 @@ export class Line extends Component {
781
767
  formData={_.cloneDeep(this.state.formData)}
782
768
  location={this.props.location}
783
769
  tags={tags}
784
- injectedTags={this.state.injectedTags ? this.state.injectedTags : {}}
770
+ injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
785
771
  onFormValidityChange={this.setFormValidity}
786
772
  usingTabContainer
787
773
  checkValidation={this.state.checkValidation}
@@ -816,12 +802,14 @@ Line.propTypes = {
816
802
  Line: PropTypes.object,
817
803
  supportedTags: PropTypes.any,
818
804
  getDefaultTags: PropTypes.string,
805
+ injectedTags: PropTypes.object,
819
806
  };
820
807
 
821
808
  const mapStateToProps = createStructuredSelector({
822
809
  Line: makeSelectCreateLine(),
823
810
  Templates: makeSelectTemplates(),
824
811
  metaEntities: makeSelectMetaEntities(),
812
+ injectedTags: setInjectedTags(),
825
813
  });
826
814
 
827
815
  function mapDispatchToProps(dispatch) {
@@ -15,7 +15,7 @@ import { createStructuredSelector } from 'reselect';
15
15
  import { injectIntl, intlShape } from 'react-intl';
16
16
  import _ from 'lodash';
17
17
  import {makeSelectEdit, makeSelectEditResponse, makeSelectTemplateDetailsResponse} from "../../MobilePush/Edit/selectors";
18
- import {makeSelectMetaEntities} from "../../Cap/selectors";
18
+ import {makeSelectMetaEntities, setInjectedTags} from "../../Cap/selectors";
19
19
  import {getMessageObject} from "../../../utils/messageUtils";
20
20
  import FormBuilder from '../../../components/FormBuilder';
21
21
  import * as globalActions from "../../Cap/actions";
@@ -200,29 +200,6 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
200
200
  const message = getMessageObject('error', (nextProps.Edit.editTemplateErrorMessage && nextProps.Edit.editTemplateErrorMessage !== '') ? nextProps.Edit.editTemplateErrorMessage : this.props.intl.formatMessage(messages.somethingWentWrong), true);
201
201
  this.props.globalActions.addMessageToQueue(message);
202
202
  }
203
- // if (nextProps.metaEntities && nextProps.metaEntities.tags && nextProps.metaEntities.tags.custom && this.props.metaEntities.tags !== nextProps.metaEntities.tags) {
204
- // let injectedTags = _.cloneDeep(this.state.injectedTags);
205
- // injectedTags = _.merge({}, injectedTags, nextProps.metaEntities.tags.custom);
206
- // this.setState({injectedTags});
207
- // }
208
- if (nextProps.metaEntities && nextProps.metaEntities.tags && nextProps.metaEntities.tags.custom && !_.isEqual(this.props.metaEntities.tags, nextProps.metaEntities.tags)) {
209
- let injectedTags = _.cloneDeep(this.state.injectedTags);
210
- delete injectedTags["Registration custom fields"];
211
- delete injectedTags["Store custom fields"];
212
- delete injectedTags["Transaction custom fields"];
213
- injectedTags = _.merge({}, injectedTags, nextProps.metaEntities.tags.custom);
214
- console.log('new injected tags', nextProps.metaEntities.tags.custom);
215
- if (!_.has(nextProps.metaEntities.tags.custom, "Registration custom fields")) {
216
- delete injectedTags["Registration custom fields"];
217
- }
218
- if (!_.has(nextProps.metaEntities.tags.custom, "Store custom fields")) {
219
- delete injectedTags["Store custom fields"];
220
- }
221
- if (!_.has(nextProps.metaEntities.tags.custom, "Transaction custom fields")) {
222
- delete injectedTags["Transaction custom fields"];
223
- }
224
- this.setState({injectedTags});
225
- }
226
203
  }
227
204
 
228
205
  componentWillUnmount() {
@@ -752,6 +729,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
752
729
  console.log('startTemplateCreation', data);
753
730
  if (!data.edit) {
754
731
  this.setState({injectedTags: data.tags});
732
+ this.props.globalActions.setInjectedTags(data.tags);
755
733
  }
756
734
  };
757
735
 
@@ -1013,7 +991,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
1013
991
  tabCount={2}
1014
992
  iosCtasData={this.state.iosCtasData}
1015
993
  tags={tags}
1016
- injectedTags={this.state.injectedTags ? this.state.injectedTags : {}}
994
+ injectedTags={this.props.injectedTags ? this.props.injectedTags : {}}
1017
995
  onFormValidityChange={this.setFormValidity}
1018
996
  usingTabContainer
1019
997
  checkValidation={this.state.checkValidation}
@@ -1049,6 +1027,7 @@ Edit.propTypes = {
1049
1027
  templateData: PropTypes.object,
1050
1028
  getDefaultTags: PropTypes.string,
1051
1029
  supportedTags: PropTypes.array,
1030
+ injectedTags: PropTypes.object,
1052
1031
  };
1053
1032
 
1054
1033
  const mapStateToProps = createStructuredSelector({
@@ -1057,6 +1036,7 @@ const mapStateToProps = createStructuredSelector({
1057
1036
  templateDetails: makeSelectTemplateDetailsResponse(),
1058
1037
  metaEntities: makeSelectMetaEntities(),
1059
1038
  Templates: makeSelectTemplates(),
1039
+ injectedTags: setInjectedTags(),
1060
1040
  });
1061
1041
 
1062
1042
  function mapDispatchToProps(dispatch) {