@capillarytech/creatives-library 2.0.37 → 2.0.39

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.
@@ -10,8 +10,8 @@ import PropTypes from 'prop-types';
10
10
  import React from 'react';
11
11
  import { Label } from 'semantic-ui-react';
12
12
  import _ from 'lodash';
13
- import { Tabs, Row, Col, Table, Modal, notification} from 'antd';
14
- import { CapButton, CapInput, CapPopover, CapCheckbox, CapRadio, CapSelect, CapTable, CapColumn} from '@capillarytech/cap-ui-library';
13
+ import { Tabs, Row, Col, Table, Modal} from 'antd';
14
+ import { CapButton, CapInput, CapPopover, CapCheckbox, CapRadio, CapSelect, CapTable, CapColumn, CapNotification} from '@capillarytech/cap-ui-library';
15
15
  import TemplatePreview from '../../components/TemplatePreview';
16
16
  import TagList from '../../containers/TagList';
17
17
  import SmsEditor from '../SmsEditor';
@@ -299,11 +299,9 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
299
299
  };
300
300
 
301
301
  openNotificationWithIcon = (type, message) => {
302
- const dur = (type === 'error' || type === 'warning') ? null : 5;
303
- notification[type]({
302
+ CapNotification.error({
304
303
  message: (`${type.toUpperCase()} ! ! ! `),
305
304
  description: message, //'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
306
- duration: dur,
307
305
  });
308
306
  }
309
307
 
@@ -7,7 +7,6 @@
7
7
  import PropTypes from 'prop-types';
8
8
 
9
9
  import React from 'react';
10
- import moment from "moment";
11
10
  import { CapButton } from '@capillarytech/cap-ui-library';
12
11
  // import styled from 'styled-components';
13
12
 
@@ -49,7 +48,6 @@ class PreviewSideBar extends React.Component { // eslint-disable-line react/pref
49
48
  }
50
49
  render() {
51
50
  console.log('preview sidebar', this.props);
52
- const modeTypeLine = this.props.templateData.modeType; // expected: (text or image)
53
51
  let content = '';
54
52
  if (this.props.channel.toLowerCase() === 'wechat') {
55
53
  console.log('Template Infog ', this.props.templateData);
@@ -104,6 +102,7 @@ class PreviewSideBar extends React.Component { // eslint-disable-line react/pref
104
102
  device={this.state.device === "android" ? "android" : "iphone"}
105
103
  channel={this.props.channel}
106
104
  content={content || ''}
105
+ templateData={this.props.templateData}
107
106
  >
108
107
  </TemplatePreview>
109
108
  :
@@ -113,11 +112,10 @@ class PreviewSideBar extends React.Component { // eslint-disable-line react/pref
113
112
  location={this.props.location}
114
113
  charCounterEnabled={this.props.channel.toLowerCase() === 'sms'}
115
114
  unicodeEnabled={this.props.channel.toLowerCase() === 'sms'}
115
+ templateData={this.props.templateData}
116
116
  >
117
117
  </TemplatePreview>
118
118
  }
119
- <p className="preview-info"><FormattedMessage {...messages.lastModified} />: {moment(this.props.templateData).format('MM-DD-YYYY')}</p>
120
- <p style={{marginBottom: '8px'}} className="preview-info"><FormattedMessage {...messages.uploadedBy} /> : {this.props.templateData.updatedByName}</p>
121
119
  <hr className="seperator-line" />
122
120
  <div className="preview-action-container" style={{margin: '16px'}}>
123
121
  {this.props.channel.toLowerCase() === 'sms' && !this.props.embedded && <CapButton onClick={() => this.goToDuplicate()}className="preview-buttons" style={{marginRight: '8px'}} type="secondary"><FormattedMessage {...messages.duplicate} /></CapButton>}
@@ -8,11 +8,11 @@ import PropTypes from 'prop-types';
8
8
 
9
9
  import React from 'react';
10
10
  import _ from 'lodash';
11
- import { injectIntl, intlShape} from 'react-intl';
11
+ import { injectIntl, intlShape, FormattedMessage} from 'react-intl';
12
12
  // import styled from 'styled-components';
13
- import {CapColumn} from '@capillarytech/cap-ui-library'
13
+ import {CapColumn} from '@capillarytech/cap-ui-library';
14
+ import moment from 'moment';
14
15
  import './_templatePreview.scss';
15
- import * as charCount from '../../utils/smsCharCount';
16
16
  import {updateCharCount} from '../../utils/smsCharCountV2';
17
17
  import messages from './messages';
18
18
  const smsIcon = require('./assets/images/user-icon.svg');
@@ -54,14 +54,14 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
54
54
  }
55
55
  return (
56
56
  <div className={`preview-container ${type === 'embedded' ? 'embedded-preview' : ''}`}>
57
- { channel && channel.toLowerCase() === 'sms'&&
57
+ { channel && channel.toLowerCase() === 'sms' &&
58
58
  <div className="shell align-center" id="sms-preview">
59
59
  <img className="preview-image sms" src={smsBody} alt="Preview is being generated"/>
60
60
  <div className="msgContainer sms">
61
61
  <img className="sms-icon" src={smsIcon} alt="Sms icon" />
62
62
  <div className={"message-pop sms"}>
63
63
  {content && content.length && content.map((msg) =>
64
- <CapColumn className="message-pop-item align-left" style={{ background: '#3F51B5', color: '#ffffff'}}>
64
+ <CapColumn className="message-pop-item align-left" style={{ background: '#3F51B5', color: '#ffffff'}}>
65
65
  {msg}
66
66
  </CapColumn>)
67
67
  }
@@ -156,6 +156,11 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
156
156
  </div>
157
157
  : ''
158
158
  }
159
+ {this.props.templateData &&
160
+ [<p className="preview-info"><FormattedMessage {...messages.lastModified} />: {moment(this.props.templateData.updatedAt).format('MM-DD-YYYY')}</p>,
161
+ <p style={{marginBottom: '8px'}} className="preview-info"><FormattedMessage {...messages.uploadedBy} /> : {this.props.templateData.updatedByName}</p>,
162
+ ]
163
+ }
159
164
  </div>
160
165
  );
161
166
  }
@@ -171,6 +176,7 @@ TemplatePreview.propTypes = {
171
176
  intl: intlShape.isRequired,
172
177
  device: PropTypes.string,
173
178
  unicodeEnabled: PropTypes.bool,
179
+ templateData: PropTypes.object,
174
180
  };
175
181
 
176
182
  export default (injectIntl(TemplatePreview));
@@ -26,4 +26,12 @@ export default defineMessages({
26
26
  id: 'app.components.TemplatePreview.smsFormatType',
27
27
  defaultMessage: 'Message has unicode characters',
28
28
  },
29
+ lastModified: {
30
+ id: 'app.components.PreviewSideBar.lastModified',
31
+ defaultMessage: 'Last Modified On',
32
+ },
33
+ uploadedBy: {
34
+ id: 'app.components.PreviewSideBar.uploadedBy',
35
+ defaultMessage: 'Last Modified By',
36
+ },
29
37
  });
@@ -80,6 +80,7 @@ function SlideBoxContent(props) {
80
80
  content={templateData.versions.base['sms-editor']}
81
81
  channel={templateData.type.toLowerCase()}
82
82
  charCounterEnabled
83
+ templateData={this.props.templateData}
83
84
  />
84
85
  )}
85
86
  {isEmailPreview && (
@@ -14,10 +14,13 @@ import SlideBoxContent from './SlideBoxContent';
14
14
  import SlideBoxHeader from './SlideBoxHeader';
15
15
  import SlideBoxFooter from './SlideBoxFooter';
16
16
  import * as constants from './constants';
17
+ import * as commonUtil from '../../utils/common';
18
+
17
19
  import './index.scss';
18
20
  import * as templateActions from '../Templates/actions';
19
21
  import * as globalActions from '../Cap/actions';
20
22
  import {isLoading as isLoadingSelector} from './selectors';
23
+ import {templateUserList} from '../Templates/selectors';
21
24
 
22
25
  const classPrefix = 'add-creatives-section';
23
26
  class Creatives extends React.Component {
@@ -47,7 +50,9 @@ class Creatives extends React.Component {
47
50
  this.setState({ slidBoxContent: 'editTemplate', templateData: template });
48
51
  };
49
52
  onPreviewTemplate = (template) => {
50
- this.setState({ slidBoxContent: 'preview', templateData: template });
53
+ const templateData = template;
54
+ templateData.updatedByName = commonUtil.getUserNameById(parseInt(template.updatedBy, 10), commonUtil.getMergedUserList(this.props.templateUserList));
55
+ this.setState({ slidBoxContent: 'preview', templateData });
51
56
  };
52
57
  onEditTemplate = () => {
53
58
  this.setState({ slidBoxContent: 'editTemplate', showSlideBox: true });
@@ -156,10 +161,16 @@ class Creatives extends React.Component {
156
161
  saveMessage = () => {
157
162
  this.setState({ isGetFormData: true });
158
163
  };
164
+ showFooter = () => {
165
+ const {slidBoxContent, currentChannel, emailCreateMode, templateStep} = this.state;
159
166
 
167
+ const isEmailCreate = slidBoxContent === 'createTemplate' && currentChannel === constants.EMAIL && templateStep !== 'createTemplate';
168
+ const isCreate = (slidBoxContent === 'editTemplate' || slidBoxContent === 'createTemplate') && !isEmailCreate;
169
+ return (isCreate || (isEmailCreate && emailCreateMode) || slidBoxContent === 'preview');
170
+ }
160
171
  render() {
161
172
  const {slidBoxContent, isGetFormData, showSlideBox, templateData, currentChannel, emailCreateMode, templateStep} = this.state;
162
- const {isFullMode, creativesMode, cap, isLoading} = this.props;
173
+ const {isFullMode, creativesMode, cap} = this.props;
163
174
  return (
164
175
  <div className={classnames(`${classPrefix} ${isFullMode ? 'creatives-full-mode' : 'creatives-library-mode'}`)}>
165
176
  <CapSlideBox
@@ -197,7 +208,7 @@ class Creatives extends React.Component {
197
208
  cap={cap}
198
209
  />
199
210
  }
200
- footer={!isFullMode && !isLoading &&
211
+ footer={!isFullMode && this.showFooter() &&
201
212
  <SlideBoxFooter
202
213
  messages={this.props.messages}
203
214
  onSave={this.saveMessage}
@@ -231,10 +242,12 @@ Creatives.propTypes = {
231
242
  templateActions: PropTypes.object,
232
243
  globalActions: PropTypes.object,
233
244
  cap: PropTypes.object,
234
- isLoading: PropTypes.bool,
245
+ // isLoading: PropTypes.bool,
246
+ templateUserList: PropTypes.array,
235
247
  };
236
248
  const mapStatesToProps = () => createStructuredSelector({
237
249
  isLoading: isLoadingSelector(),
250
+ templateUserList: templateUserList(),
238
251
  });
239
252
  function mapDispatchToProps(dispatch) {
240
253
  return {
@@ -712,7 +712,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
712
712
  }
713
713
 
714
714
  setFormValidity = (isFormValid) => {
715
- this.setState({isFormValid});
715
+ this.setState({isFormValid, startValidation: false});
716
716
  }
717
717
 
718
718
  setEditData(editData) {
@@ -20,6 +20,11 @@ const makeSelectTemplates = () => createSelector(
20
20
  (substate) => substate.toJS()
21
21
  );
22
22
 
23
+ const templateUserList = () => createSelector(
24
+ makeSelectTemplates(),
25
+ (substate) => substate.userList || [],
26
+ );
27
+
23
28
  const makeSelectTemplatesResponse = () => createSelector(
24
29
  selectTemplatesDomain(), (templatesState) => templatesState.get('templates')
25
30
  );
@@ -56,5 +61,6 @@ const selectEdmEditor = () => createSelector(makeSelectTemplates(), (templates)
56
61
  return edmTemplate || null;
57
62
  });
58
63
  export {
64
+ templateUserList,
59
65
  makeSelectTemplates, makeSelectTemplatesResponse, selectTemplateContent, selectEmailLayout, selectCmsTemplates, selectEdmEditor,
60
66
  };
@@ -36,7 +36,9 @@ padding: ${CAP_SPACE_24} 0;
36
36
  .ant-tabs-content{
37
37
  margin-top: ${CAP_SPACE_16}
38
38
  }
39
- ` : ` `}
39
+ ` : `.cap-tab-v2 {
40
+ height: calc(100vh - 118px);
41
+ } `}
40
42
 
41
43
 
42
44
  `;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "2.0.37",
4
+ "version": "2.0.39",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/routes.js CHANGED
@@ -560,15 +560,28 @@ export default function createRoutes(store) {
560
560
  import('containers/TemplatesV2'),
561
561
  import('containers/Email/sagas'),
562
562
  import('containers/CreativesContainer/reducer'),
563
+ import('containers/Sms/create/reducer'),
564
+ import('containers/Sms/create/sagas'),
565
+ import('containers/Sms/Edit/reducer'),
566
+ import('containers/Sms/Edit/sagas'),
567
+ import('containers/Email/reducer'),
568
+ import('containers/Email/sagas'),
563
569
  ]);
564
570
 
565
571
  const renderRoute = loadModule(cb);
566
572
 
567
- importModules.then(([reducer, sagas, component, emailContainerSagas, creativesContainerReducer]) => {
573
+ importModules.then(([reducer, sagas, component, emailContainerSagas, creativesContainerReducer, smsCreateReducer, smsCreateSaga, smsEditReducer, smsEditSaga, emailReducer, emailSaga]) => {
568
574
  injectReducer('templates', reducer.default);
575
+ injectReducer('create', smsCreateReducer.default);
576
+ injectReducer('creativesContainer', creativesContainerReducer.default);
577
+ injectReducer('edit', smsEditReducer.default);
578
+ injectReducer('email', emailReducer.default);
569
579
  injectSagas(sagas.default);
570
580
  injectSagas(emailContainerSagas.default);
571
- injectReducer('creativesContainer', creativesContainerReducer.default);
581
+ injectSagas(smsCreateSaga.default);
582
+ injectSagas(smsEditSaga.default);
583
+ injectSagas(emailSaga.default);
584
+
572
585
  renderRoute(component);
573
586
  });
574
587