@capillarytech/creatives-library 2.0.2 → 2.0.5

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.
@@ -15,7 +15,8 @@ import moment from "moment";
15
15
  import _ from 'lodash';
16
16
  import { bindActionCreators } from 'redux';
17
17
  import { Row, Select, Spin, Dropdown, Col, Breadcrumb, Menu, Modal} from 'antd';
18
- import { CapInput, CapButton, CapPopover, CapSelect } from '@capillarytech/cap-react-ui-library';
18
+ import { CapPopover, CapSelect } from '@capillarytech/cap-react-ui-library';
19
+ import {CapButton, CapInput} from '@capillarytech/cap-ui-library';
19
20
  import { makeSelectTemplates, makeSelectTemplatesResponse } from './selectors';
20
21
  import { makeSelectCreate as makeSelectCreateSms} from '../Sms/Create/selectors';
21
22
  import { makeSelectCreate as makeSelectCreateMobilePush } from '../MobilePush/Create/selectors';
@@ -1260,6 +1261,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1260
1261
  value={this.state.searchText}
1261
1262
  onChange={(e) => this.searchTemplate(e.target.value)}
1262
1263
  />
1264
+ {this.props.isComponent ? <div style={{display: "flex", justifyContent: "space-between", alignItems: 'center'}}>
1265
+ <CapButton type="secondary" onClick={() => this.props.isComponent ? this.handleBlankTemplateAction() : this.createTemplate()}>{this.state.channel.toUpperCase() === 'SMS' ? this.props.intl.formatMessage(messages.createSmsActionButton) : 'Create SMS'}</CapButton>
1266
+ </div>
1267
+ :
1263
1268
  <div className="action-container">
1264
1269
  <div style={{display: "flex", justifyContent: "space-between", alignItems: 'center'}}>
1265
1270
  <div className="select-font">{this.props.intl.formatMessage(messages.sortBy)}</div>
@@ -1273,7 +1278,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1273
1278
  </CapSelect>
1274
1279
  </div>
1275
1280
  }
1276
- </div>
1281
+ </div>}
1277
1282
  </div>
1278
1283
  );
1279
1284
  const accountOptions = [];
@@ -1316,7 +1321,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1316
1321
  }
1317
1322
  const pageHeader = (
1318
1323
  <div>
1319
- {(this.props.location.query.type !== 'embedded') ? `${pageHeaderText}` : templateText}
1324
+ {(this.props.location.query.type !== 'embedded') && `${pageHeaderText}`}
1325
+ {!this.props.isComponent && templateText}
1320
1326
  {(this.isEnabledInLibraryModule("showAccountSelection") || (((this.state.channel.toUpperCase() === 'WECHAT' || this.state.channel.toUpperCase() === "MOBILEPUSH") && (this.props.location.query.type !== 'embedded') && !_.isEmpty(this.props.Templates.weCrmAccounts)))) &&
1321
1327
  <CapSelect className="selectAccount" onSelect={this.onAccountSelect} value={this.props.Templates.selectedWeChatAccount ? this.props.Templates.selectedWeChatAccount.name : undefined} placeholder={this.props.intl.formatMessage(messages.selectAccount)}>
1322
1328
  {accountOptions}
@@ -1464,7 +1470,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1464
1470
  <input type="file" id="filename" style={{ display: 'none'}} accept=".zip, .html, .htm" onChange={(event) => this.handleFileUpload(event, {files: event.target.files})} />
1465
1471
  <Row>
1466
1472
  <Col>
1467
- {this.props.location.query.type !== "embedded" &&
1473
+ {(!this.props.isComponent || this.props.location.query.type !== "embedded") &&
1468
1474
  <Breadcrumb>
1469
1475
  <BreadcrumbItem>{this.props.intl.formatMessage(messages.campaigns)}</BreadcrumbItem>
1470
1476
  <BreadcrumbItem>{this.props.intl.formatMessage(messages.creatives)}</BreadcrumbItem>
@@ -1475,7 +1481,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1475
1481
  </Row>
1476
1482
  <Row className="template-header-container">
1477
1483
  <div className="template-header">{(this.props.location.query.type === 'embedded' && moduleName === 'dvs') ? pageHeaderDvs : pageHeader}</div>
1478
- {actionButton}
1484
+ {!this.props.isComponent && actionButton}
1479
1485
  </Row>
1480
1486
  <Row>
1481
1487
  <Helmet
@@ -1485,7 +1491,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1485
1491
  ]}
1486
1492
  />
1487
1493
  {this.props.renderNewCardGrid && templateList && templateList.length > 0 &&
1488
- this.props.renderNewCardGrid({templates: this.props.TemplatesList, handlers: {handlePreviewClick: this.handlePreviewClick, handleEditClick: this.handleEditClick}})
1494
+ this.props.renderNewCardGrid({templates: this.props.TemplatesList, filterContent, handlers: {handlePreviewClick: this.handlePreviewClick, handleEditClick: this.handleEditClick}})
1489
1495
  }
1490
1496
  {!this.props.renderNewCardGrid && ((templateList && templateList.length > 0) || isSearch) && <Pagination onPageChange={() => { console.log('getting all templates pagination'); this.getAllTemplates({getNextPage: true}); }} paginationSelector="pagination-container">
1491
1497
  <CardGrid
@@ -1563,6 +1569,7 @@ Templates.propTypes = {
1563
1569
  createNew: PropTypes.func,
1564
1570
  onSelectTemplate: PropTypes.func,
1565
1571
  lineActions: PropTypes.object,
1572
+ isComponent: PropTypes.bool,
1566
1573
  };
1567
1574
 
1568
1575
  const mapStateToProps = createStructuredSelector({
@@ -8,21 +8,17 @@ import PropTypes from 'prop-types';
8
8
 
9
9
  import React from 'react';
10
10
  import { connect } from 'react-redux';
11
- import { FormattedMessage, injectIntl } from 'react-intl';
11
+ import { injectIntl } from 'react-intl';
12
12
  import { createStructuredSelector } from 'reselect';
13
13
  import { bindActionCreators } from 'redux';
14
- import { CapTab, CapCustomCard, CapIcons, CapSpin, CapButton } from '@capillarytech/cap-ui-library';
14
+ import { CapTab, CapCard, CapIcons, CapButton } from '@capillarytech/cap-ui-library';
15
15
  import { find } from 'lodash';
16
16
  import { UserIsAuthenticated } from '../../utils/authWrapper';
17
17
  import { makeSelectTemplates, makeSelectTemplatesResponse } from '../Templates/selectors';
18
18
  import messages from './messages';
19
- import ChannelTemplates from '../ChannelTemplates';
20
19
  import * as actions from './actions';
21
- import * as commonUtil from '../../utils/common';
22
- import PreviewSideBar from '../../components/PreviewSideBar';
23
20
  import Templates from '../Templates';
24
- const { CapCustomCardGrid } = CapCustomCard;
25
- const { Message, View } = CapIcons;
21
+ const { View } = CapIcons;
26
22
 
27
23
  export class TemplatesV2 extends React.Component { // eslint-disable-line react/prefer-stateless-function
28
24
  constructor(props) {
@@ -38,20 +34,20 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
38
34
  };
39
35
  }
40
36
 
41
-
42
- getTemplateDataForGrid = ({templates, handlers}) => {
37
+ getTemplateDataForGrid = ({templates, handlers, filterContent}) => {
43
38
  const cardDataList = templates.map((template) => (
44
39
  {
45
- icon: <Message />,
46
40
  title: template.name,
47
41
  content: template.versions.base['sms-editor'],
48
- options: <View onClick={() => { this.props.isFullMode ? handlers.handlePreviewClick(template) : this.props.handlePeviewTemplate(template); }} />,
42
+ extra: [<View onClick={() => { this.props.isFullMode ? handlers.handlePreviewClick(template) : this.props.handlePeviewTemplate(template); }} />],
49
43
  hoverOption: <CapButton onClick={(e) => handlers.handleEditClick(e, template._id)}>{this.props.intl.formatMessage(this.props.isFullMode ? messages.edit : messages.select)}</CapButton>,
50
44
  }));
51
- return <CapCustomCardGrid cardDataList={cardDataList} />;
45
+ return (<div>
46
+ {filterContent}
47
+ <CapCard cardList={cardDataList} type="SMS" />
48
+ </div>);
52
49
  }
53
50
  getTemplatesComponent(channel) {
54
- const notFoundMessage = `No ${channel} templates found`;
55
51
  // const templates = this.props.Templates[`${channel}Templates`];
56
52
  let query = {};
57
53
  if (!this.props.isFullMode) {
@@ -61,8 +57,8 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
61
57
  location={{pathname: channel, search: '', query}}
62
58
  route={{name: channel}}
63
59
  router={this.props.router}
64
- isComponent
65
- createNew={this.createNew}
60
+ isComponent={!this.props.isFullMode}
61
+ createNew={this.props.createNew}
66
62
  onSelectTemplate={(id) => this.props.onSelectTemplate(this.selectTemplate(id))}
67
63
  renderNewCardGrid={this.getTemplateDataForGrid}
68
64
  />);
@@ -102,14 +98,14 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
102
98
  }
103
99
 
104
100
  TemplatesV2.propTypes = {
105
- actions: PropTypes.object.isRequired,
106
- location: PropTypes.object,
101
+ router: PropTypes.object,
107
102
  isFullMode: PropTypes.bool,
108
- handlePreview: PropTypes.func,
109
103
  onSelectTemplate: PropTypes.func,
104
+ createNew: PropTypes.func,
110
105
  channel: PropTypes.string,
111
106
  Templates: PropTypes.object,
112
107
  TemplatesList: PropTypes.arrayOf(PropTypes.object),
108
+ handlePeviewTemplate: PropTypes.func,
113
109
  };
114
110
 
115
111
  TemplatesV2.defaultProps = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "2.0.2",
4
+ "version": "2.0.5",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -13,7 +13,7 @@
13
13
  "license": "LicenseRef-LICENSE",
14
14
  "dependencies": {
15
15
  "@capillarytech/cap-react-ui-library": "latest",
16
- "@capillarytech/cap-ui-library": "^1.0.29",
16
+ "@capillarytech/cap-ui-library": "^1.0.33",
17
17
  "antd": "^3.13.1",
18
18
  "axios": "^0.16.2",
19
19
  "babel-polyfill": "6.20.0",
@@ -65,4 +65,4 @@
65
65
  "warning": "3.0.0",
66
66
  "whatwg-fetch": "2.0.1"
67
67
  }
68
- }
68
+ }