@capillarytech/creatives-library 3.0.5 → 3.0.7

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 (73) hide show
  1. package/components/FormBuilder/index.js +15 -15
  2. package/containers/Dashboard/index.js +5 -0
  3. package/containers/Email/index.js +5 -4
  4. package/containers/Line/Create/index.js +3 -3
  5. package/containers/MobilePush/Edit/index.js +2 -2
  6. package/containers/WeChat/MapTemplates/index.js +64 -58
  7. package/containers/WeChat/RichmediaTemplates/Create/index.js +3 -3
  8. package/index.html +3 -0
  9. package/package.json +1 -1
  10. package/routes.js +1 -3
  11. package/v2Components/FormBuilder/index.js +12 -18
  12. package/v2Components/NavigationBar/index.js +7 -4
  13. package/v2Components/NavigationBar/messages.js +6 -2
  14. package/v2Containers/Cap/index.js +2 -1
  15. package/v2Containers/CreativesContainer/SlideBoxContent.js +9 -2
  16. package/v2Containers/CreativesContainer/index.js +4 -1
  17. package/v2Containers/Email/index.js +27 -42
  18. package/v2Containers/Email/initialSchema.js +2 -58
  19. package/v2Containers/Email/messages.js +4 -0
  20. package/v2Containers/Email/sagas.js +0 -2
  21. package/v2Containers/MobilePush/Create/actions.js +2 -2
  22. package/v2Containers/MobilePush/Create/index.js +17 -16
  23. package/v2Containers/MobilePush/Create/messages.js +1 -1
  24. package/v2Containers/MobilePush/Create/sagas.js +3 -0
  25. package/v2Containers/MobilePush/Edit/index.js +13 -7
  26. package/v2Containers/MobilePush/initialSchema.js +3 -0
  27. package/v2Containers/MobilepushWrapper/index.js +3 -1
  28. package/v2Containers/Templates/index.js +14 -11
  29. package/v2Containers/TemplatesV2/index.js +21 -12
  30. package/assets/android-message-gui-2.svg +0 -55
  31. package/components/CallTaskPreview/_callTaskPreview.scss +0 -17
  32. package/components/CallTaskPreview/images/Footer.png +0 -0
  33. package/components/CallTaskPreview/images/Header.png +0 -0
  34. package/components/CallTaskPreview/index.js +0 -37
  35. package/components/CallTaskPreview/messages.js +0 -13
  36. package/components/CallTaskPreview/tests/index.test.js +0 -15
  37. package/components/CmsTemplatesComponent/index.js +0 -33
  38. package/components/CmsTemplatesComponent/messages.js +0 -17
  39. package/components/CmsTemplatesComponent/tests/index.test.js +0 -10
  40. package/components/EmailMobilePreview/index.js +0 -129
  41. package/components/EmailMobilePreview/index.scss +0 -55
  42. package/components/EmailPreviewV2/_emailPreviewV2.scss +0 -69
  43. package/components/EmailPreviewV2/index.js +0 -132
  44. package/components/EmailPreviewV2/messages.js +0 -41
  45. package/components/EmailPreviewV2/tests/index.test.js +0 -10
  46. package/components/MobilePushPreviewV2/index.js +0 -120
  47. package/components/MobilePushPreviewV2/messages.js +0 -13
  48. package/components/MobilePushPreviewV2/tests/index.test.js +0 -10
  49. package/components/NewCallTask/_newCallTask.scss +0 -9
  50. package/components/NewCallTask/index.js +0 -152
  51. package/components/NewCallTask/messages.js +0 -29
  52. package/components/NewCallTask/tests/index.test.js +0 -10
  53. package/components/SmsPreviewV2/_smsPreviewV2.scss +0 -353
  54. package/components/SmsPreviewV2/index.js +0 -69
  55. package/components/SmsPreviewV2/messages.js +0 -13
  56. package/components/SmsPreviewV2/tests/index.test.js +0 -10
  57. package/v2Components/DateFilter/index.js +0 -349
  58. package/v2Components/DateFilter/messages.js +0 -17
  59. package/v2Components/DateFilter/tests/index.test.js +0 -15
  60. package/v2Components/DateRange/index.js +0 -113
  61. package/v2Components/DateRange/messages.js +0 -13
  62. package/v2Components/DateRange/tests/index.test.js +0 -10
  63. package/v2Components/PageHeader/_pageHeader.scss +0 -22
  64. package/v2Components/PageHeader/index.js +0 -37
  65. package/v2Components/PageHeader/messages.js +0 -13
  66. package/v2Components/PageHeader/tests/index.test.js +0 -10
  67. package/v2Components/Sidebar/_sidebar.scss +0 -115
  68. package/v2Components/Sidebar/index.js +0 -208
  69. package/v2Components/Sidebar/messages.js +0 -21
  70. package/v2Components/Sidebar/tests/index.test.js +0 -10
  71. package/v2Components/SmsEditor/index.js +0 -55
  72. package/v2Components/SmsEditor/tests/index.test.js +0 -10
  73. package/v2Components/TopBar/_topbar.scss +0 -46
@@ -51,19 +51,27 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
51
51
  constructor(props) {
52
52
  super(props);
53
53
  const defaultChannel = get(this, 'props.channel') || get(this, 'props.params.channel') || 'sms';
54
- const defaultPanes = [
55
- {content: <div></div>, tab: 'SMS', key: 'sms'},
56
- {content: <div></div>, tab: 'Email', key: 'email'},
57
- // {content: this.getTemplatesComponent('wechat'), tab: 'Wechat', key: 'wechat'},
58
- {content: <div></div>, tab: 'Push notification', key: 'mobilepush'},
59
- ];
60
- if (props.isFullMode) {
61
- defaultPanes.push({content: <div></div>, tab: 'Gallery', key: 'assets'});
62
- }
63
- if (!props.isFullMode) {
64
- defaultPanes.push({content: <div></div>, tab: 'Call Task', key: 'call_task'});
54
+ const defaultPanes = {
55
+ sms: {content: <div></div>, tab: 'SMS', key: 'sms'},
56
+ email: {content: <div></div>, tab: 'Email', key: 'email'},
57
+ //'wechat': {content: this.getTemplatesComponent('wechat'), tab: 'Wechat', key: 'wechat'},
58
+ mPush: {content: <div></div>, tab: 'Push notification', key: 'mobilepush'},
59
+ };
60
+ const channelsToHide = this.props.channelsToHide || [];
61
+
62
+ const filteredPanes = Object.keys(defaultPanes)
63
+ .filter((key) => !channelsToHide.includes(key)).reduce((obj = [], key) => {
64
+ obj.push(defaultPanes[key]);
65
+ return obj;
66
+ }, []);
67
+
68
+ if (props.isFullMode ) {
69
+ filteredPanes.push({content: <div></div>, tab: 'Gallery', key: 'assets'});
70
+ } else if (!channelsToHide.includes('callTask')) {
71
+ filteredPanes.push({content: <div></div>, tab: 'Call Task', key: 'call_task'});
65
72
  }
66
- const panes = this.setChannelContent(defaultChannel, defaultPanes);
73
+
74
+ const panes = this.setChannelContent(defaultChannel, filteredPanes);
67
75
  this.state = {
68
76
  selectedChannel: defaultChannel,
69
77
  panes,
@@ -197,6 +205,7 @@ TemplatesV2.propTypes = {
197
205
  onCallTaskSubmit: PropTypes.func,
198
206
  intl: intlShape,
199
207
  onChannelChange: PropTypes.func,
208
+ channelsToHide: PropTypes.array,
200
209
  };
201
210
 
202
211
  TemplatesV2.defaultProps = {
@@ -1,55 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <svg width="360px" height="725px" viewBox="0 0 360 725" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
- <!-- Generator: Sketch 55.2 (78181) - https://sketchapp.com -->
4
- <title>Artboard Copy 3</title>
5
- <desc>Created with Sketch.</desc>
6
- <g id="Artboard-Copy-3" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
7
- <rect id="Rectangle" fill="#FFFFFF" x="0" y="660" width="360" height="65"></rect>
8
- <g id="Organisms/ui/android/screenshots/wallpaper" transform="translate(120.000000, 0.000000)"></g>
9
- <g id="Group-5" transform="translate(16.000000, 680.000000)">
10
- <polygon id="Stroke-1" stroke-opacity="0.0117647061" stroke="#000000" stroke-width="1.33333336e-11" points="0 0 23.999999 0 23.999999 23.999999 0 23.999999"></polygon>
11
- <polygon id="Fill-3" fill="#7F7F7F" points="18.9999989 12.9999992 12.9999992 12.9999992 12.9999992 18.9999989 10.9999993 18.9999989 10.9999993 12.9999992 4.9999997 12.9999992 4.9999997 10.9999993 10.9999993 10.9999993 10.9999993 4.9999997 12.9999992 4.9999997 12.9999992 10.9999993 18.9999989 10.9999993"></polygon>
12
- </g>
13
- <text id="Add-text-to-this-mes" font-family="Roboto-Regular, Roboto" font-size="15" font-weight="normal" letter-spacing="0.3" fill="#959595">
14
- <tspan x="53" y="697">Add text to this message</tspan>
15
- </text>
16
- <g id="Group-5" transform="translate(320.000000, 679.000000)">
17
- <polygon id="Stroke-1" stroke-opacity="0.0117647061" stroke="#000000" stroke-width="1.33333336e-11" points="0 0 23.999999 0 23.999999 23.999999 0 23.999999"></polygon>
18
- <polygon id="Fill-3" fill="#757575" points="2.00999988 20.9999987 22.9999986 11.9999993 2.00999988 2.99999982 1.99999988 9.9999994 16.999999 11.9999993 1.99999988 13.9999992"></polygon>
19
- </g>
20
- <rect id="Rectangle" stroke="#E6E6E6" fill="#F4F5F7" x="0.5" y="86.5" width="359" height="573"></rect>
21
- <g id="Group">
22
- <g id="Toolbar">
23
- <polygon id="Toolbar-bg" fill="#E51FA3" points="360 0 0 0 0 86 360 86"></polygon>
24
- <g id="Toolbar-contents" transform="translate(16.000000, 40.000000)">
25
- <g id="Back">
26
- <rect id="Bounds" x="0" y="0" width="24" height="24"></rect>
27
- <polygon id="Shape" fill="#FFFFFF" points="20 11 7.8 11 13.4 5.4 12 4 4 12 12 20 13.4 18.6 7.8 13 20 13"></polygon>
28
- </g>
29
- </g>
30
- </g>
31
- <g id="Status-bar">
32
- <rect id="Status-bar-bg" fill="#CF0E8F" x="0" y="0" width="360" height="24"></rect>
33
- <rect id="bounds" x="242" y="0" width="118" height="24"></rect>
34
- <g id="battery" transform="translate(337.000000, 4.000000)">
35
- <polygon id="bounds" points="0 0 16 0 16 16 0 16"></polygon>
36
- <polygon id="Shape" fill="#FFFFFF" points="9 1.875 9 1 6 1 6 1.875 3 1.875 3 15 12 15 12 1.875"></polygon>
37
- </g>
38
- <g id="cellular" transform="translate(317.000000, 4.000000)">
39
- <polygon id="bounds" points="0 0 16 0 16 16 0 16"></polygon>
40
- <polygon id="Shape" fill="#FFFFFF" points="0 15 14 15 14 1"></polygon>
41
- </g>
42
- <g id="wifi" transform="translate(296.000000, 4.000000)">
43
- <polygon id="bounds" points="2 0 18 0 18 16 2 16"></polygon>
44
- <path d="M0.977372085,4.01593123 C3.48821908,2.12256382 6.61301513,1 10,1 C13.3869849,1 16.5117809,2.12256382 19.0226279,4.01593123 L10,15 L0.977372085,4.01593123 Z" id="Shape" fill="#FFFFFF"></path>
45
- </g>
46
- </g>
47
- <g id="Icons-/-Navigation-24px-/-White-/-More" transform="translate(332.000000, 42.000000)">
48
- <g id="More">
49
- <rect id="Bounds" x="0" y="0" width="12" height="24"></rect>
50
- <path d="M6,8 C7.1,8 8,7.1 8,6 C8,4.9 7.1,4 6,4 C4.9,4 4,4.9 4,6 C4,7.1 4.9,8 6,8 L6,8 Z M6,10 C4.9,10 4,10.9 4,12 C4,13.1 4.9,14 6,14 C7.1,14 8,13.1 8,12 C8,10.9 7.1,10 6,10 L6,10 Z M6,16 C4.9,16 4,16.9 4,18 C4,19.1 4.9,20 6,20 C7.1,20 8,19.1 8,18 C8,16.9 7.1,16 6,16 L6,16 Z" id="Shape" fill="#FFFFFF"></path>
51
- </g>
52
- </g>
53
- </g>
54
- </g>
55
- </svg>
@@ -1,17 +0,0 @@
1
- .call-task-preview {
2
- .call-task-subject-container {
3
- padding: 8px;
4
- background: #444;
5
- color: white;
6
- font-size: 12px;
7
- font-weight: 500;
8
- }
9
- .call-task-message-container {
10
- overflow-y: auto;
11
- height: 150px;
12
- width: 100%;
13
- font-size: 12px;
14
- background: #eee;
15
- padding: 8px;
16
- }
17
- }
@@ -1,37 +0,0 @@
1
- /**
2
- *
3
- * CallTaskPreview
4
- *
5
- */
6
-
7
- import React from 'react';
8
- import PropTypes from 'prop-types';
9
- import HeaderPng from './images/Header.png';
10
- import FooterPng from './images/Footer.png';
11
-
12
- import './_callTaskPreview.scss';
13
-
14
- class CallTaskPreview extends React.Component { // eslint-disable-line react/prefer-stateless-function
15
- render() {
16
- const { subject, messageBody } = this.props;
17
- return (
18
- <div className="call-task-preview">
19
- <img style={{ width: '100%' }} src={HeaderPng} alt="header" />
20
- <div className="call-task-subject-container">
21
- {subject}
22
- </div>
23
- <div className="call-task-message-container">
24
- {messageBody}
25
- </div>
26
- <img style={{ width: '100%' }} src={FooterPng} alt="footer" />
27
- </div>
28
- );
29
- }
30
- }
31
-
32
- CallTaskPreview.propTypes = {
33
- subject: PropTypes.string,
34
- messageBody: PropTypes.string,
35
- };
36
-
37
- export default CallTaskPreview;
@@ -1,13 +0,0 @@
1
- /*
2
- * CallTaskPreview Messages
3
- *
4
- * This contains all the text for the CallTaskPreview component.
5
- */
6
- import { defineMessages } from 'react-intl';
7
-
8
- export default defineMessages({
9
- header: {
10
- id: 'app.components.CallTaskPreview.header',
11
- defaultMessage: 'This is the CallTaskPreview component !',
12
- },
13
- });
@@ -1,15 +0,0 @@
1
- import React from "react";
2
- import { shallow } from "enzyme";
3
- import CallTaskPreview from "../index";
4
-
5
- describe("<CallTaskPreview />", () => {
6
- it("Test if Call task component renders", () => {
7
- const component = shallow(
8
- <CallTaskPreview
9
- subject="this is test"
10
- body="this is test message body"
11
- />
12
- );
13
- expect(component).toMatchSnapshot();
14
- });
15
- });
@@ -1,33 +0,0 @@
1
- /**
2
- *
3
- * CmsTemplatesComponent
4
- *
5
- */
6
-
7
- import React from 'react';
8
- import PropTypes from 'prop-types';
9
- // import styled from 'styled-components';
10
- import {CapButton, CapCustomCard} from '@capillarytech/cap-ui-library';
11
- import { FormattedMessage } from 'react-intl';
12
- import messages from './messages';
13
- const {CapCustomCardList} = CapCustomCard;
14
- function CmsTemplatesComponent(props) {
15
- const cardDataList = props.cmsTemplates.map((template) => (
16
- {
17
- key: template.name,
18
- title: template.name,
19
- url: template.versions.base.preview_http_url,
20
- hoverOption: <CapButton onClick={() => props.handleEdmDefaultTemplateSelection(template._id)}><FormattedMessage {...messages.select}/></CapButton>,
21
- }));
22
- return (<div>
23
- <div className="pagination-container">
24
- <CapCustomCardList cardList={cardDataList} type="Email" />
25
- </div>
26
- </div>);
27
- }
28
-
29
- CmsTemplatesComponent.propTypes = {
30
- cmsTemplates: PropTypes.array,
31
- };
32
-
33
- export default CmsTemplatesComponent;
@@ -1,17 +0,0 @@
1
- /*
2
- * CmsTemplatesComponent Messages
3
- *
4
- * This contains all the text for the CmsTemplatesComponent component.
5
- */
6
- import { defineMessages } from 'react-intl';
7
-
8
- export default defineMessages({
9
- header: {
10
- id: 'app.components.CmsTemplatesComponent.header',
11
- defaultMessage: 'This is the CmsTemplatesComponent component !',
12
- },
13
- select: {
14
- id: 'app.components.CmsTemplatesComponent.select',
15
- defaultMessage: 'Select',
16
- },
17
- });
@@ -1,10 +0,0 @@
1
- // import React from 'react';
2
- // import { shallow } from 'enzyme';
3
-
4
- // import CmsTemplatesComponent from '../index';
5
-
6
- describe('<CmsTemplatesComponent />', () => {
7
- it('Expect to have unit tests specified', () => {
8
- expect(true).toEqual(false);
9
- });
10
- });
@@ -1,129 +0,0 @@
1
- /**
2
- *
3
- * EmailPreviewV2
4
- *
5
- */
6
-
7
- import React from 'react';
8
- // import styled from 'styled-components';
9
- import PropTypes from 'prop-types';
10
- import { FormattedMessage } from 'react-intl';
11
- import {isEmpty} from 'lodash';
12
- import { connect } from 'react-redux';
13
- import { bindActionCreators } from 'redux';
14
- import { createStructuredSelector } from 'reselect';
15
- import { CapSpin, CapButton } from '@capillarytech/cap-ui-library';
16
- import moment from 'moment';
17
- import EmailPreviewV2 from '../EmailPreviewV2';
18
- import messages from '../EmailPreviewV2/messages';
19
- import './index.scss';
20
- import mobileBody from '../../assets/mobile.png';
21
-
22
- import {selectTemplateContent} from '../../containers/Templates/selectors';
23
- import * as templateActions from '../../containers/Templates/actions';
24
-
25
- const deviceAspectRatio = {
26
- mobile: {
27
- height: "440",
28
- width: "230",
29
- },
30
- };
31
-
32
- class EmailMobilePreview extends React.Component {
33
- constructor() {
34
- super();
35
- this.state = {
36
- showAllDevices: false,
37
- };
38
- }
39
- componentWillMount() {
40
- const {templateData, templateContent} = this.props;
41
- if (isEmpty(templateContent) && !isEmpty(templateData) && templateData._id) { // templateData: comes from templates list email preview
42
- this.props.templateActions.getTemplateDetails(templateData._id); // templateContent: html data to be shown in iframe
43
- }
44
- }
45
- onClickShowInAllDevices = () => {
46
- const { onClickShowInAllDevices } = this.props;
47
- if (onClickShowInAllDevices) {
48
- onClickShowInAllDevices();
49
- } else {
50
- this.setState({
51
- showAllDevices: true,
52
- });
53
- }
54
- }
55
- render() {
56
- const messageContainerName = 'mobile-message-container';
57
- const {
58
- templateContent,
59
- enableShowAllDevices,
60
- } = this.props;
61
- const { showAllDevices } = this.state;
62
-
63
- return (
64
- <div className="email-mobile-preview-container">
65
- {showAllDevices ? (
66
- <EmailPreviewV2 {...this.props} />
67
- ) : (
68
- <CapSpin spinning={!templateContent}>
69
- <div id="emailPreivew-container">
70
- <div id="emailPreivew-content-wrapper">
71
- <div id="emailPreivew-content">
72
- <div className="email-preview-container">
73
- {enableShowAllDevices && (
74
- <CapButton
75
- type="flat"
76
- onClick={this.onClickShowInAllDevices}
77
- >
78
- View in all devices
79
- </CapButton>
80
- )}
81
- <div className={"shell align-center"}>
82
- <img src={mobileBody} alt="capillary" width="60%" />
83
- <div className={messageContainerName}>
84
- <iframe srcDoc={templateContent} {...deviceAspectRatio.mobile} >
85
- <p><FormattedMessage {...messages.noIframeSupport}/></p>
86
- </iframe>
87
- </div>
88
- </div>
89
- </div>
90
- </div>
91
- </div>
92
- </div>
93
- {this.props.templateData &&
94
- [
95
- <p className="preview-info"><FormattedMessage {...messages.lastModified} />: {moment(this.props.templateData.updatedAt).format('MM-DD-YYYY')}</p>,
96
- <p style={{marginBottom: '8px'}} className="preview-info"><FormattedMessage {...messages.uploadedBy} /> : {this.props.templateData.updatedByName}</p>,
97
- ]
98
- }
99
- </CapSpin>
100
- )}
101
- </div>
102
-
103
- );
104
- }
105
-
106
- }
107
-
108
- EmailMobilePreview.propTypes = {
109
- templateContent: PropTypes.string,
110
- templateData: PropTypes.object,
111
- templateActions: PropTypes.object,
112
- onClickShowInAllDevices: PropTypes.func,
113
- enableShowAllDevices: PropTypes.bool,
114
- };
115
-
116
- EmailMobilePreview.defaultProps = {
117
- showDeviceSelection: true,
118
- };
119
-
120
- const mapStateToProps = (state, props) => createStructuredSelector({
121
- templateContent: props.templateData ? selectTemplateContent() : () => props.templateContent, // when props has templateContent that means preview with content
122
- });
123
- function mapDispatchToProps(dispatch) {
124
- return {
125
- templateActions: bindActionCreators(templateActions, dispatch),
126
- };
127
- }
128
-
129
- export default connect(mapStateToProps, mapDispatchToProps)(EmailMobilePreview);
@@ -1,55 +0,0 @@
1
- $classPrefix: email-mobile-preview-container;
2
- .#{$classPrefix}{
3
- #emailPreivew-container {
4
- position: relative;
5
- // padding: 0 24px 0 24px;
6
- overflow-y: auto;
7
- // font-family: 'proxima-nova';
8
- overflow: hidden;
9
- #emailPreivew-content-wrapper{
10
- width: 100%;
11
- height: 90%;
12
- // display: table;
13
-
14
- #emailPreivew-content {
15
- .device-wrapper {
16
- display: inline-flex;
17
- margin-bottom: 8px;
18
- margin-top: 16px;
19
- .device-name {
20
- padding: 6px 24px;
21
- background: #E6F0FB;
22
- border: 2px solid #E6F0FB;
23
- font-family: "open-sans";
24
- line-height: 20px;
25
- font-size: 14px;
26
- color: #4E92E5;
27
- cursor: pointer;
28
- }
29
- .active {
30
- background: #FFFFFF !important;
31
- border: 2px solid #E6F0FB;
32
- }
33
-
34
- }
35
- .email-preview-container{
36
-
37
- .mobile-message-container {
38
- position: absolute;
39
- top: 10.3%;
40
- left: 24%;
41
- overflow: auto;
42
- display: -webkit-box;
43
- display: -ms-flexbox;
44
- display: flex;
45
- }
46
- }
47
- padding: 0 0px 0 24px;
48
- // display: table-cell;
49
- // vertical-align: middle;
50
- text-align: center;
51
- margin-bottom: 36px;
52
- }
53
- }
54
- }
55
- }
@@ -1,69 +0,0 @@
1
- $classPrefix: email-preview-v2;
2
- .#{$classPrefix}{
3
- #emailPreivew-container {
4
- position: relative;
5
- // padding: 0 24px 0 24px;
6
- overflow-y: auto;
7
- // font-family: 'proxima-nova';
8
- overflow: hidden;
9
-
10
- #email-iframe {
11
- width: -webkit-fill-available;
12
- }
13
- #emailPreivew-content-wrapper{
14
- width: 100%;
15
- height: 90%;
16
- // display: table;
17
-
18
- #emailPreivew-content {
19
- .device-wrapper {
20
- display: inline-flex;
21
- margin-bottom: 8px;
22
- margin-top: 16px;
23
- .device-name {
24
- padding: 6px 24px;
25
- background: #E6F0FB;
26
- border: 2px solid #E6F0FB;
27
- font-family: "open-sans";
28
- line-height: 20px;
29
- font-size: 14px;
30
- color: #4E92E5;
31
- cursor: pointer;
32
- }
33
- .active {
34
- background: #FFFFFF !important;
35
- border: 2px solid #E6F0FB;
36
- }
37
-
38
- }
39
- .email-preview-container{
40
- .tablet-message-container {
41
- position: absolute;
42
- top: 9%;
43
- left: 10%;
44
- width: 100%;
45
- height: 100%;
46
- overflow: auto;
47
- display: -webkit-box;
48
- display: -ms-flexbox;
49
- display: flex;
50
- }
51
- .mobile-message-container {
52
- position: absolute;
53
- top: 10.3%;
54
- left: 14%;
55
- overflow: auto;
56
- display: -webkit-box;
57
- display: -ms-flexbox;
58
- display: flex;
59
- }
60
- }
61
- padding: 0 0px 0 24px;
62
- // display: table-cell;
63
- // vertical-align: middle;
64
- text-align: center;
65
- margin-bottom: 36px;
66
- }
67
- }
68
- }
69
- }
@@ -1,132 +0,0 @@
1
- /**
2
- *
3
- * EmailPreviewV2
4
- *
5
- */
6
-
7
- import React from 'react';
8
- // import styled from 'styled-components';
9
- import PropTypes from 'prop-types';
10
- import { FormattedMessage } from 'react-intl';
11
- import {isEmpty} from 'lodash';
12
- import { connect } from 'react-redux';
13
- import { bindActionCreators } from 'redux';
14
- import { createStructuredSelector } from 'reselect';
15
- import { CapSpin } from '@capillarytech/cap-ui-library';
16
- import moment from 'moment';
17
- import messages from './messages';
18
- import './_emailPreviewV2.scss';
19
- import tabletBody from '../../assets/iPad.svg';
20
- import mobileBody from '../../assets/mobile.png';
21
-
22
- import {selectTemplateContent} from '../../containers/Templates/selectors';
23
- import * as templateActions from '../../containers/Templates/actions';
24
-
25
- const deviceAspectRatio = {
26
- desktop: {
27
- height: "500",
28
- width: "1024",
29
- },
30
- tablet: {
31
- height: "600",
32
- width: "520",
33
- },
34
- mobile: {
35
- height: "600",
36
- width: "320",
37
- },
38
- };
39
- const devices = {
40
- mobile: 'mobile',
41
- desktop: 'desktop',
42
- tablet: 'tablet',
43
- };
44
- class EmailPreviewV2 extends React.Component {
45
- constructor(props) {
46
- super(props);
47
- this.state = {
48
- currentDevice: props.device || devices.desktop,
49
- };
50
- }
51
- componentWillMount() {
52
- const {templateData, templateContent} = this.props;
53
- if (isEmpty(templateContent) && !isEmpty(templateData) && templateData._id) { // templateData: comes from templates list email preview
54
- this.props.templateActions.getTemplateDetails(templateData._id); // templateContent: html data to be shown in iframe
55
- }
56
- }
57
- componentWillUnmount() {
58
- this.props.templateActions.resetTemplateData();
59
- }
60
- changePreviewDevice = (ev) => {
61
- this.setState({currentDevice: ev.currentTarget.id});
62
- }
63
- render() {
64
- let messageContainerName = '';
65
- const {currentDevice} = this.state;
66
- const {templateContent} = this.props;
67
-
68
- if (currentDevice === devices.tablet) {
69
- messageContainerName = 'tablet-message-container';
70
- } else if (currentDevice === devices.mobile) {
71
- messageContainerName = 'mobile-message-container';
72
- }
73
- return (
74
- <div className="email-preview-v2">
75
- <CapSpin spinning={!templateContent}>
76
- <div id="emailPreivew-container">
77
- <div id="emailPreivew-content-wrapper">
78
- <div id="emailPreivew-content">
79
- <div className="device-wrapper">
80
- <div id={devices.desktop} onClick={this.changePreviewDevice} className={`device-name ${currentDevice === devices.desktop ? 'active' : ''}`}><FormattedMessage {...messages.desktop}/></div>
81
- <div id={devices.tablet} onClick={this.changePreviewDevice} className={`device-name ${currentDevice === devices.tablet ? 'active' : ''}`}><FormattedMessage {...messages.tablet}/></div>
82
- <div id={devices.mobile} onClick={this.changePreviewDevice} className={`device-name ${currentDevice === devices.mobile ? 'active' : ''}`}><FormattedMessage {...messages.mobile}/></div>
83
- </div>
84
- <div className="email-preview-container">
85
- <div className={currentDevice === devices.desktop ? '' : "shell align-center"}>
86
- {currentDevice === devices.tablet ?
87
- <img src={tabletBody} alt="capillary" width="520" /> : ''}
88
- {currentDevice === devices.mobile ?
89
- <img src={mobileBody} alt="capillary" width="85%" /> : ''}
90
- <div className={messageContainerName}>
91
- <iframe id="email-iframe" srcDoc={templateContent} {...deviceAspectRatio[currentDevice]} >
92
- <p><FormattedMessage {...messages.noIframeSupport}/></p>
93
- </iframe>
94
- </div>
95
- </div>
96
-
97
-
98
- </div>
99
- </div>
100
- </div>
101
- </div>
102
- {this.props.templateData &&
103
- [
104
- <p className="preview-info" key="lastModified"><FormattedMessage {...messages.lastModified} />: {moment(this.props.templateData.updatedAt).format('MM-DD-YYYY')}</p>,
105
- <p style={{marginBottom: '8px'}} key="uploadedBy" className="preview-info"><FormattedMessage {...messages.uploadedBy} /> : {this.props.templateData.updatedByName}</p>,
106
- ]
107
- }
108
- </CapSpin>
109
- </div>
110
-
111
- );
112
- }
113
-
114
- }
115
-
116
- EmailPreviewV2.propTypes = {
117
- templateContent: PropTypes.string,
118
- templateData: PropTypes.object,
119
- templateActions: PropTypes.object,
120
- device: PropTypes.string,
121
- };
122
-
123
- const mapStateToProps = (state, props) => createStructuredSelector({
124
- templateContent: props.templateData ? selectTemplateContent() : () => props.templateContent, // when props has templateContent that means preview with content
125
- });
126
- function mapDispatchToProps(dispatch) {
127
- return {
128
- templateActions: bindActionCreators(templateActions, dispatch),
129
- };
130
- }
131
-
132
- export default connect(mapStateToProps, mapDispatchToProps)(EmailPreviewV2);