@capillarytech/creatives-library 2.0.33 → 2.0.35

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.
@@ -8,18 +8,37 @@ import PropTypes from 'prop-types';
8
8
 
9
9
  import React from 'react';
10
10
  import { connect } from 'react-redux';
11
- import { injectIntl, intlShape } from 'react-intl';
11
+ import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
12
12
  import { createStructuredSelector } from 'reselect';
13
13
  import { bindActionCreators } from 'redux';
14
- import { CapTab, CapCustomCard, CapIcons, CapButton } from '@capillarytech/cap-ui-library';
14
+ import styled from 'styled-components';
15
+ import { CapTab, CapCustomCard, CapIcons, CapButton, CapHeader } from '@capillarytech/cap-ui-library';
15
16
  import { find } from 'lodash';
17
+ import Helmet from 'react-helmet';
18
+
19
+ import {CAP_SPACE_24, CAP_SPACE_16} from '@capillarytech/cap-ui-library/styled/variables';
16
20
  import { UserIsAuthenticated } from '../../utils/authWrapper';
17
21
  import { makeSelectTemplates, makeSelectTemplatesResponse } from '../Templates/selectors';
18
22
  import messages from './messages';
19
23
  import * as actions from './actions';
20
24
  import Templates from '../Templates';
25
+ import './_templatesV2.scss';
26
+
21
27
  const { View } = CapIcons;
22
28
  const {CapCustomCardList} = CapCustomCard;
29
+
30
+ const ComponentWrapper = styled.div`
31
+ max-width: 1140px;
32
+ margin: 0 auto;
33
+ width: 100%;
34
+ padding: ${CAP_SPACE_24} 0;
35
+ .ant-tabs-content{
36
+ margin-top: ${CAP_SPACE_16}
37
+ }
38
+ `;
39
+ const MarginTop = styled.div`
40
+ margin-top: ${CAP_SPACE_24}
41
+ `;
23
42
  export class TemplatesV2 extends React.Component { // eslint-disable-line react/prefer-stateless-function
24
43
  constructor(props) {
25
44
  super(props);
@@ -42,18 +61,27 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
42
61
  this.setState({selectedChannel: nextProps.channel, panes });
43
62
  }
44
63
  }
45
- getTemplateDataForGrid = ({templates, handlers, filterContent}) => {
46
- const cardDataList = templates.map((template) => (
47
- {
48
- title: template.name,
49
- content: template.versions.base['sms-editor'],
50
- extra: [<View onClick={() => { if (this.props.isFullMode) { handlers.handlePreviewClick(template); } else { this.props.handlePeviewTemplate(template); } }} />],
51
- hoverOption: <CapButton onClick={(e) => handlers.handleEditClick(e, template._id)}>{this.props.intl.formatMessage(this.props.isFullMode ? messages.edit : messages.select)}</CapButton>,
52
- }));
64
+ getTemplateDataForGrid = ({templates, handlers, filterContent, channel}) => {
65
+ const currentChannel = channel.toUpperCase();
66
+ const cardDataList = templates.map((template) => {
67
+ const templateData =
68
+ {
69
+ key: `${currentChannel}-card-${template.name}`,
70
+ title: <span title={template.name} >{template.name}</span>,
71
+ extra: [<View onClick={() => { if (this.props.isFullMode) { handlers.handlePreviewClick(template); } else { this.props.handlePeviewTemplate(template); } }} />],
72
+ hoverOption: <CapButton onClick={(e) => handlers.handleEditClick(e, template._id)}>{this.props.intl.formatMessage(this.props.isFullMode ? messages.edit : messages.select)}</CapButton>,
73
+ };
74
+ if (currentChannel === "SMS") {
75
+ templateData.content = template.versions.base['sms-editor'];
76
+ } else if (currentChannel === "EMAIL") {
77
+ templateData.url = template.versions.base.preview_http_url;
78
+ }
79
+ return templateData;
80
+ });
53
81
  return (<div>
54
82
  {filterContent}
55
83
  <div className="pagination-container">
56
- <CapCustomCardList cardList={cardDataList} type="SMS" />
84
+ <CapCustomCardList key={`${currentChannel}-card-list`} cardList={cardDataList} type={currentChannel} />
57
85
  </div>
58
86
  </div>);
59
87
  }
@@ -88,7 +116,7 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
88
116
  }
89
117
  channelChange = (selectedChannel) => {
90
118
  const panes = this.setChannelContent(selectedChannel, this.state.panes);
91
- this.setState({panes, selectedChannel}, () => { this.props.onChannelChange(selectedChannel); });
119
+ this.setState({panes, selectedChannel}, () => { if (!this.props.isFullMode) this.props.onChannelChange(selectedChannel); });
92
120
  }
93
121
  selectTemplate = (id) => find(this.props.TemplatesList, {_id: id})
94
122
 
@@ -96,15 +124,28 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
96
124
  return this.props.Templates.loadingTemplates;
97
125
  }
98
126
  render() {
127
+ const {isFullMode} = this.props;
99
128
  return (
100
129
  <div>
101
- <CapTab
102
- panes={this.state.panes}
103
- onChange={this.channelChange}
104
- activeKey={this.state.selectedChannel}
105
- defaultActiveKey={this.state.selectedChannel}/>
130
+ {isFullMode && <Helmet
131
+ title={this.props.intl.formatMessage(messages.creatives)}
132
+ meta={[
133
+ { name: 'description', content: this.props.intl.formatMessage(messages.creativesDesc) },
134
+ ]}
135
+ />}
136
+ <ComponentWrapper>
137
+
138
+ <CapHeader title={<FormattedMessage {...messages.creatives}/>} description={<FormattedMessage {...messages.creativesDesc}/>}/>
139
+ <MarginTop>
140
+ <CapTab
141
+ panes={this.state.panes}
142
+ onChange={this.channelChange}
143
+ activeKey={this.state.selectedChannel}
144
+ defaultActiveKey={this.state.selectedChannel}/>
145
+ </MarginTop>
106
146
 
107
147
 
148
+ </ComponentWrapper>
108
149
  </div>
109
150
 
110
151
  );
@@ -18,4 +18,12 @@ export default defineMessages({
18
18
  id: 'app.containers.TemplatesV2.edit',
19
19
  defaultMessage: 'Edit',
20
20
  },
21
+ creatives: {
22
+ id: 'app.containers.TemplatesV2.creatives',
23
+ defaultMessage: 'Creatives',
24
+ },
25
+ creativesDesc: {
26
+ id: 'app.containers.TemplatesV2.creativesDesc',
27
+ defaultMessage: 'These are pre-built templates which you could use to customize your message content.',
28
+ },
21
29
  });
@@ -12,7 +12,6 @@ import { bindActionCreators } from 'redux';
12
12
  import Helmet from 'react-helmet';
13
13
  import { injectIntl, intlShape } from 'react-intl';
14
14
  import { createStructuredSelector } from 'reselect';
15
- // import { CapButton, CapSelect } from '@capillarytech/cap-react-ui-library';
16
15
  import { Row, Col, Spin } from 'antd';
17
16
  import _ from 'lodash';
18
17
  import { makeSelectTemplates } from '../Templates/selectors';
@@ -23,6 +22,7 @@ import * as actions from './actions';
23
22
  import FormBuilder from '../../components/FormBuilder';
24
23
  import { UserIsAuthenticated } from '../../utils/authWrapper';
25
24
  import * as globalActions from '../../containers/Cap/actions';
25
+ import * as templateActions from '../../containers/Templates/actions';
26
26
  import {getMessageObject} from '../../utils/messageUtils';
27
27
  // import SlideBox from '../../components/SlideBox';
28
28
  // import PageHeader from '../../components/PageHeader';
@@ -404,6 +404,7 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
404
404
  sortBy: 'Most Recent',
405
405
  wecrmId: this.props.Templates.selectedWeChatAccount.configs.wecrm_app_id,
406
406
  wecrmToken: this.props.Templates.selectedWeChatAccount.configs.wecrm_token,
407
+ originalId: this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier,
407
408
  };
408
409
  this.props.actions.getDefaultWeChatTemplates('wechat', params);
409
410
  } else {
@@ -544,6 +545,7 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
544
545
  sortBy: 'Most Recent',
545
546
  wecrmId: nextProps.WeChat.selectedWeChatAccount.configs.wecrm_app_id,
546
547
  wecrmToken: nextProps.WeChat.selectedWeChatAccount.configs.wecrm_token,
548
+ originalId: nextProps.WeChat.selectedWeChatAccount.sourceAccountIdentifier,
547
549
  };
548
550
  this.props.actions.getDefaultWeChatTemplates('wechat', params);
549
551
  }
@@ -600,11 +602,11 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
600
602
  componentWillUnmount() {
601
603
  console.log('removed listener create');
602
604
  window.removeEventListener("message", this.handleFrameTasks);
605
+ this.props.templateActions.resetTemplate();
603
606
  this.resetState();
604
607
  }
605
608
 
606
609
  onFormDataChange(formData) {
607
- console.log('Form Data Change ', formData);
608
610
  let selectedWechatTemplateIndex = -1;
609
611
  let selectedTemplate = {};
610
612
  let selectedTemplateData = {};
@@ -643,6 +645,7 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
643
645
  selectedWechatTemplateIndex = _.findIndex(this.props.WeChat.weChatDefaultTemplate, {template_id: formData['wechat-template']});
644
646
  selectedTemplate = this.props.WeChat.weChatDefaultTemplate[selectedWechatTemplateIndex];
645
647
  }
648
+
646
649
  if (!_.isEqual(formData['wechat-template'], this.state.formData['wechat-template'])) {
647
650
  this.updateSchema = true;
648
651
  }
@@ -1150,10 +1153,15 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
1150
1153
 
1151
1154
  setTemplateOptions(weChatData) {
1152
1155
  console.log('Set Templates ', weChatData);
1153
- const {schema, baseSchema} = this.state;
1154
- // const schema = _.cloneDeep(this.state.schema);
1155
- // const baseSchema = _.cloneDeep(this.state.baseSchema);
1156
+ //const {schema, baseSchema} = this.state;
1157
+ const schema = _.cloneDeep(this.state.schema);
1158
+ const baseSchema = _.cloneDeep(this.state.baseSchema);
1156
1159
  const baseSchemaTemplateOptionEmpty = (!_.isEmpty(baseSchema) && _.isEmpty(baseSchema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[1].options));
1160
+ schema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[1].options = [];
1161
+ if (!_.isEmpty(baseSchema)) {
1162
+ baseSchema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[1].options = [];
1163
+
1164
+ }
1157
1165
  _.forEach(weChatData, (template) => {
1158
1166
  schema.standalone.sections[0].childSections[1].childSections[0].childSections[0].inputFields[1].options.push({
1159
1167
  key: (template.versions) ? template.versions.base.template_id : template.template_id,
@@ -1607,6 +1615,7 @@ WeChat.propTypes = {
1607
1615
  getLibraryFormData: PropTypes.func,
1608
1616
  getDefaultTags: PropTypes.string,
1609
1617
  templateData: PropTypes.object,
1618
+ templateActions: PropTypes.object,
1610
1619
  };
1611
1620
 
1612
1621
  const mapStateToProps = createStructuredSelector({
@@ -1619,6 +1628,7 @@ function mapDispatchToProps(dispatch) {
1619
1628
  return {
1620
1629
  actions: bindActionCreators(actions, dispatch),
1621
1630
  globalActions: bindActionCreators(globalActions, dispatch),
1631
+ templateActions: bindActionCreators(templateActions, dispatch),
1622
1632
  };
1623
1633
  }
1624
1634
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "2.0.33",
4
+ "version": "2.0.35",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -12,13 +12,12 @@
12
12
  },
13
13
  "license": "LicenseRef-LICENSE",
14
14
  "dependencies": {
15
- "@capillarytech/cap-react-ui-library": "latest",
16
- "@capillarytech/cap-ui-library": "^1.0.47",
17
- "antd": "^3.13.1",
15
+ "@capillarytech/cap-react-ui-library": "^1.11.10",
16
+ "@capillarytech/cap-ui-library": "^1.0.77",
17
+ "antd": "^3.15.0",
18
18
  "axios": "^0.16.2",
19
19
  "babel-polyfill": "6.20.0",
20
20
  "babel-preset-env": "^1.6.1",
21
- "c3": "^0.4.11",
22
21
  "chalk": "1.1.3",
23
22
  "chevrotain": "*",
24
23
  "compression": "1.6.2",
@@ -40,16 +39,17 @@
40
39
  "normalizr": "^3.2.3",
41
40
  "perfect-scrollbar": "^0.7.0",
42
41
  "prop-types": "^15.7.2",
43
- "react": "15.4.1",
42
+ "react": "^16.8.1",
44
43
  "react-datepicker": "^0.46.0",
45
- "react-dom": "15.4.1",
44
+ "react-dom": "^16.8.1",
46
45
  "react-grid-layout": "^0.14.6",
47
- "react-helmet": "3.2.2",
48
- "react-intl": "2.1.5",
49
- "react-redux": "4.4.6",
50
- "react-router": "3.0.0",
46
+ "react-helmet": "^5.0.3",
47
+ "react-intl": "^2.4.0",
48
+ "react-redux": "^5.0.4",
49
+ "react-router": "^3.2.0",
50
+ "react-router-dom": "^4.2.2",
51
51
  "react-router-redux": "4.0.6",
52
- "react-router-scroll": "0.4.1",
52
+ "react-router-scroll": "^0.4.3",
53
53
  "react-sizeme": "^2.3.2",
54
54
  "redux": "3.6.0",
55
55
  "redux-auth-wrapper": "^1.1.0",
@@ -61,7 +61,7 @@
61
61
  "sanitize.css": "4.1.0",
62
62
  "semantic-ui-react": "0.68.3",
63
63
  "source-map-loader": "^0.2.4",
64
- "styled-components": "2",
64
+ "styled-components": "^3.2.1",
65
65
  "warning": "3.0.0",
66
66
  "whatwg-fetch": "2.0.1"
67
67
  }
package/routes.js CHANGED
@@ -251,6 +251,7 @@ export default function createRoutes(store) {
251
251
  injectReducer('weChat', reducer.default);
252
252
  injectSagas(sagas.default);
253
253
  injectSagas(rootSaga.default);
254
+ injectSagas(templateSagas.default);
254
255
  renderRoute(component);
255
256
  });
256
257
 
@@ -558,14 +559,16 @@ export default function createRoutes(store) {
558
559
  import('containers/Templates/sagas'),
559
560
  import('containers/TemplatesV2'),
560
561
  import('containers/Email/sagas'),
562
+ import('containers/CreativesContainer/reducer'),
561
563
  ]);
562
564
 
563
565
  const renderRoute = loadModule(cb);
564
566
 
565
- importModules.then(([reducer, sagas, component, emailContainerSagas]) => {
567
+ importModules.then(([reducer, sagas, component, emailContainerSagas, creativesContainerReducer]) => {
566
568
  injectReducer('templates', reducer.default);
567
569
  injectSagas(sagas.default);
568
570
  injectSagas(emailContainerSagas.default);
571
+ injectReducer('creativesContainer', creativesContainerReducer.default);
569
572
  renderRoute(component);
570
573
  });
571
574