@capillarytech/creatives-library 3.0.18 → 3.0.20
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.
- package/containers/Email/index.js +6 -4
- package/containers/Templates/index.js +10 -8
- package/package.json +1 -1
- package/v2Components/EmailMobilePreview/index.js +12 -4
- package/v2Components/EmailMobilePreview/index.scss +9 -2
- package/v2Components/EmailPreview/_emailPreview.scss +29 -30
- package/v2Components/EmailPreview/index.js +72 -32
- package/v2Components/EmailPreview/messages.js +4 -0
- package/v2Components/EmailPreviewV2/_emailPreviewV2.scss +31 -10
- package/v2Components/EmailPreviewV2/index.js +76 -24
- package/v2Components/EmailPreviewV2/messages.js +4 -0
- package/v2Components/NavigationBar/index.js +1 -4
- package/v2Containers/Assets/Gallery/index.js +6 -1
- package/v2Containers/Assets/Gallery/messages.js +4 -0
- package/v2Containers/Cap/constants.js +1 -1
- package/v2Containers/Templates/index.js +1 -0
|
@@ -2638,20 +2638,22 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2638
2638
|
const formData = _.cloneDeep(this.state.formData);
|
|
2639
2639
|
formData[0].selectedLanguages = [];
|
|
2640
2640
|
let tabKey;
|
|
2641
|
+
const isDragDrop = _.get(data, 'base.is_drag_drop');
|
|
2641
2642
|
if (this.props.location.query.type === 'embedded' && (this.props.location.query.isLanguageSupport === undefined || this.props.location.query.isLanguageSupport === 'false')) {
|
|
2642
|
-
formData['template-subject'] = data
|
|
2643
|
+
formData['template-subject'] = _.get(data, 'base.subject', '');
|
|
2643
2644
|
const baseLanguage = this.props.Global.currentOrgDetails.basic_details.base_language;
|
|
2644
2645
|
let languageIndex = _.findIndex(this.supportedLanguages, {iso_code: baseLanguage});
|
|
2645
2646
|
console.log("startTemplatecreation before index", languageIndex, this.supportedLanguages, baseLanguage, formData);
|
|
2646
2647
|
if (languageIndex === -1) {
|
|
2647
2648
|
languageIndex = 0;
|
|
2648
2649
|
}
|
|
2650
|
+
const isDragDrop = _.get(data, 'base.is_drag_drop');
|
|
2649
2651
|
const tempData = {
|
|
2650
|
-
"is_drag_drop":
|
|
2652
|
+
"is_drag_drop": isDragDrop,
|
|
2651
2653
|
"lang_id": this.supportedLanguages[languageIndex].lang_id,
|
|
2652
2654
|
"iso_code": this.supportedLanguages[languageIndex].iso_code,
|
|
2653
2655
|
"language": this.supportedLanguages[languageIndex].language,
|
|
2654
|
-
"template-content": !
|
|
2656
|
+
"template-content": !isDragDrop && isDragDrop !== 1 ? _.get(data, 'base.html_content') : "",
|
|
2655
2657
|
};
|
|
2656
2658
|
formData[0].base = true;
|
|
2657
2659
|
formData[0].selectedLanguages.push(this.supportedLanguages[languageIndex].iso_code);
|
|
@@ -2700,7 +2702,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2700
2702
|
}
|
|
2701
2703
|
formData.base = _.cloneDeep(formData[0]);
|
|
2702
2704
|
console.log('startTemplateCreation final ', formData);
|
|
2703
|
-
this.setState({formData, loading: false, injectedTags: data.tags, tabKey, isDragDrop: (
|
|
2705
|
+
this.setState({formData, loading: false, injectedTags: data.tags, tabKey, isDragDrop: (isDragDrop !== 0 )}, () => {
|
|
2704
2706
|
// this.setState({tabKey: ''});
|
|
2705
2707
|
_.forEach(formData[0].selectedLanguages, (language) => {
|
|
2706
2708
|
if (formData[0][language].is_drag_drop) {
|
|
@@ -222,13 +222,15 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
});
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
225
|
+
if (!_.isEmpty(selectedAccount)) {
|
|
226
|
+
this.setState({selectedAccount: selectedAccount.name}, () => {
|
|
227
|
+
params.wecrmId = selectedAccount.configs.wecrm_app_id;
|
|
228
|
+
params.wecrmToken = selectedAccount.configs.wecrm_token;
|
|
229
|
+
params.originalId = selectedAccount.sourceAccountIdentifier;
|
|
230
|
+
nextProps.actions.setWeChatAccount(selectedAccount);
|
|
231
|
+
this.getAllTemplates({params});
|
|
232
|
+
});
|
|
233
|
+
}
|
|
232
234
|
} else if (this.state.channel.toLowerCase() === 'mobilepush' && (nextProps.location.query.account_id || nextProps.location.query.source_account_id)) {
|
|
233
235
|
_.forEach(nextProps.Templates.weCrmAccounts, (account) => {
|
|
234
236
|
if ((nextProps.location.query.account_id && account.id === Number(nextProps.location.query.account_id)) || (nextProps.location.query.source_account_id && account.sourceAccountIdentifier && account.sourceAccountIdentifier === nextProps.location.query.source_account_id)) {
|
|
@@ -1080,7 +1082,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1080
1082
|
const updateDateTime = (moment().format('DD-MM-YYYY') === moment(template.updatedAt).format('DD-MM-YYYY')) ? moment(template.updatedAt).format('hh:mma') : moment(template.updatedAt).format('DD MMM YYYY');
|
|
1081
1083
|
let content = '';
|
|
1082
1084
|
temp.id = template._id;
|
|
1083
|
-
if (this.state.channel === 'wechat') {
|
|
1085
|
+
if (this.state.channel === 'wechat' && template.type.toLowerCase() === 'wechat') {
|
|
1084
1086
|
let path = '';
|
|
1085
1087
|
if (template && template.versions && template.versions.base && !_.isEmpty(template.versions.base)) {
|
|
1086
1088
|
if (template.definition && template.definition.msgcontent && template.definition.msgcontent === "RICH_MEDIA_WECHAT") {
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ import {isEmpty} from 'lodash';
|
|
|
12
12
|
import { connect } from 'react-redux';
|
|
13
13
|
import { bindActionCreators } from 'redux';
|
|
14
14
|
import { createStructuredSelector } from 'reselect';
|
|
15
|
-
import { CapSpin, CapButton } from '@capillarytech/cap-ui-library';
|
|
15
|
+
import { CapSpin, CapButton, CapLabel } from '@capillarytech/cap-ui-library';
|
|
16
16
|
import moment from 'moment';
|
|
17
17
|
import EmailPreviewV2 from '../EmailPreviewV2';
|
|
18
18
|
import messages from '../EmailPreviewV2/messages';
|
|
@@ -24,8 +24,8 @@ import * as templateActions from '../../containers/Templates/actions';
|
|
|
24
24
|
|
|
25
25
|
const deviceAspectRatio = {
|
|
26
26
|
mobile: {
|
|
27
|
-
height: "
|
|
28
|
-
width: "
|
|
27
|
+
height: "415",
|
|
28
|
+
width: "227",
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
31
|
|
|
@@ -65,9 +65,15 @@ class EmailMobilePreview extends React.Component {
|
|
|
65
65
|
const {
|
|
66
66
|
templateContent,
|
|
67
67
|
enableShowAllDevices,
|
|
68
|
+
templateSubject,
|
|
68
69
|
} = this.props;
|
|
69
70
|
const { showAllDevices } = this.state;
|
|
70
71
|
|
|
72
|
+
const emailSubjectLabel = templateSubject && (
|
|
73
|
+
<CapLabel className="email-subject-mobile" type="label2">
|
|
74
|
+
<FormattedMessage {...messages.subject} /> {templateSubject}</CapLabel>
|
|
75
|
+
);
|
|
76
|
+
|
|
71
77
|
return (
|
|
72
78
|
<div className="email-mobile-preview-container">
|
|
73
79
|
{showAllDevices ? (
|
|
@@ -87,8 +93,9 @@ class EmailMobilePreview extends React.Component {
|
|
|
87
93
|
</CapButton>
|
|
88
94
|
)}
|
|
89
95
|
<div className={"shell align-center"}>
|
|
96
|
+
{emailSubjectLabel}
|
|
90
97
|
<img src={mobileBody} alt="capillary" width="60%" />
|
|
91
|
-
<div className={messageContainerName}>
|
|
98
|
+
<div className={`${messageContainerName} ${emailSubjectLabel ? 'with-subject' : ''}`}>
|
|
92
99
|
<iframe srcDoc={templateContent} {...deviceAspectRatio.mobile} >
|
|
93
100
|
<p><FormattedMessage {...messages.noIframeSupport}/></p>
|
|
94
101
|
</iframe>
|
|
@@ -115,6 +122,7 @@ class EmailMobilePreview extends React.Component {
|
|
|
115
122
|
|
|
116
123
|
EmailMobilePreview.propTypes = {
|
|
117
124
|
templateContent: PropTypes.string,
|
|
125
|
+
templateSubject: PropTypes.string,
|
|
118
126
|
templateData: PropTypes.object,
|
|
119
127
|
templateActions: PropTypes.object,
|
|
120
128
|
onClickShowInAllDevices: PropTypes.func,
|
|
@@ -33,15 +33,22 @@ $classPrefix: email-mobile-preview-container;
|
|
|
33
33
|
|
|
34
34
|
}
|
|
35
35
|
.email-preview-container{
|
|
36
|
-
|
|
36
|
+
.email-subject-mobile {
|
|
37
|
+
position: absolute;
|
|
38
|
+
top: 11.5%;
|
|
39
|
+
left: 26%;
|
|
40
|
+
}
|
|
37
41
|
.mobile-message-container {
|
|
38
42
|
position: absolute;
|
|
39
43
|
top: 10.3%;
|
|
40
|
-
left: 24%;
|
|
44
|
+
left: 24.8%;
|
|
41
45
|
overflow: auto;
|
|
42
46
|
display: -webkit-box;
|
|
43
47
|
display: -ms-flexbox;
|
|
44
48
|
display: flex;
|
|
49
|
+
&.with-subject {
|
|
50
|
+
top: 15%;
|
|
51
|
+
}
|
|
45
52
|
}
|
|
46
53
|
}
|
|
47
54
|
padding: 0 0px 0 24px;
|
|
@@ -53,48 +53,47 @@
|
|
|
53
53
|
// display: table;
|
|
54
54
|
|
|
55
55
|
#emailPreivew-content {
|
|
56
|
-
.device-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
margin-top: 16px;
|
|
60
|
-
.device-name {
|
|
61
|
-
padding: 6px 24px;
|
|
62
|
-
background: #E6F0FB;
|
|
63
|
-
border: 2px solid #E6F0FB;
|
|
64
|
-
font-family: "open-sans";
|
|
65
|
-
line-height: 20px;
|
|
66
|
-
font-size: 14px;
|
|
67
|
-
color: #4E92E5;
|
|
68
|
-
cursor: pointer;
|
|
69
|
-
}
|
|
70
|
-
.active {
|
|
71
|
-
background: #FFFFFF !important;
|
|
72
|
-
border: 2px solid #E6F0FB;
|
|
73
|
-
}
|
|
74
|
-
|
|
56
|
+
.email-preview-device-tabs .ant-tabs-bar {
|
|
57
|
+
justify-content: center;
|
|
58
|
+
flex-direction: none;
|
|
75
59
|
}
|
|
76
60
|
.email-preview-container{
|
|
61
|
+
.shell {
|
|
62
|
+
position: relative;
|
|
63
|
+
-webkit-transform: unset;
|
|
64
|
+
transform: unset;
|
|
65
|
+
left: unset;
|
|
66
|
+
padding: unset;
|
|
67
|
+
width: unset;
|
|
68
|
+
display: flex;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
}
|
|
71
|
+
.email-subject-mobile {
|
|
72
|
+
width: 310px;
|
|
73
|
+
text-align: left;
|
|
74
|
+
margin: 8px 0;
|
|
75
|
+
margin-left: 4px;
|
|
76
|
+
}
|
|
77
|
+
.email-subject-tablet {
|
|
78
|
+
width: 450px;
|
|
79
|
+
text-align: left;
|
|
80
|
+
margin: 8px 0;
|
|
81
|
+
margin-left: 4px;
|
|
82
|
+
}
|
|
83
|
+
.email-subject-desktop {
|
|
84
|
+
text-align: left;
|
|
85
|
+
margin-bottom: 8px;
|
|
86
|
+
}
|
|
77
87
|
.tablet-message-container {
|
|
78
88
|
position: absolute;
|
|
79
89
|
top: 9%;
|
|
80
|
-
left: 10%;
|
|
81
|
-
width: 100%;
|
|
82
90
|
height: 100%;
|
|
83
91
|
overflow: auto;
|
|
84
|
-
display: -webkit-box;
|
|
85
|
-
display: -ms-flexbox;
|
|
86
|
-
display: flex;
|
|
87
92
|
}
|
|
88
93
|
.mobile-message-container {
|
|
89
94
|
position: absolute;
|
|
90
95
|
top: 10.3%;
|
|
91
|
-
left: 14%;
|
|
92
|
-
width: 100%;
|
|
93
96
|
height: 100%;
|
|
94
|
-
overflow: auto;
|
|
95
|
-
display: -webkit-box;
|
|
96
|
-
display: -ms-flexbox;
|
|
97
|
-
display: flex;
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
99
|
padding: 0 0px 0 24px;
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
|
|
9
9
|
import React from 'react';
|
|
10
|
+
import styled from 'styled-components';
|
|
11
|
+
import get from 'lodash/get';
|
|
12
|
+
import { CapTab, CapIcon, CapLabel } from '@capillarytech/cap-ui-library';
|
|
13
|
+
import { CAP_G01, CAP_G06, FONT_SIZE_VL } from '@capillarytech/cap-ui-library/styled/variables';
|
|
10
14
|
import { FormattedMessage } from 'react-intl';
|
|
11
15
|
import moment from "moment";
|
|
12
16
|
import messages from "./messages";
|
|
@@ -16,30 +20,49 @@ import mobileBody from '../../assets/mobile.png';
|
|
|
16
20
|
|
|
17
21
|
// this component will be deprecated after replacing with the v2 component.
|
|
18
22
|
const deviceAspectRatio = {
|
|
19
|
-
desktop: {
|
|
23
|
+
desktop: () => ({
|
|
20
24
|
height: "500",
|
|
21
25
|
width: "1024",
|
|
22
|
-
},
|
|
23
|
-
tablet: {
|
|
24
|
-
height: "600",
|
|
25
|
-
width: "
|
|
26
|
-
},
|
|
27
|
-
mobile: {
|
|
28
|
-
height: "600",
|
|
29
|
-
width: "
|
|
30
|
-
},
|
|
26
|
+
}),
|
|
27
|
+
tablet: (emailSubject) => ({
|
|
28
|
+
height: emailSubject ? "570" : "600",
|
|
29
|
+
width: "450",
|
|
30
|
+
}),
|
|
31
|
+
mobile: (emailSubject) => ({
|
|
32
|
+
height: emailSubject ? "570" : "600",
|
|
33
|
+
width: "310",
|
|
34
|
+
}),
|
|
31
35
|
};
|
|
32
36
|
|
|
37
|
+
const StyledCapIcon = styled(CapIcon)`
|
|
38
|
+
color: ${(props) => props.active ? CAP_G01 : CAP_G06};
|
|
39
|
+
font-size: ${FONT_SIZE_VL};
|
|
40
|
+
`;
|
|
41
|
+
|
|
33
42
|
class EmailPreview extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
34
43
|
render() {
|
|
35
|
-
|
|
44
|
+
const { device, content, versions = {} } = this.props;
|
|
45
|
+
const emailSubject = get(versions, 'base.subject');
|
|
36
46
|
let messageContainerName = '';
|
|
37
|
-
|
|
47
|
+
let subjectClassName = 'email-subject-desktop';
|
|
48
|
+
if (device === 'tablet') {
|
|
38
49
|
messageContainerName = 'tablet-message-container';
|
|
39
|
-
|
|
50
|
+
subjectClassName = "email-subject-tablet";
|
|
51
|
+
} else if (device === 'mobile') {
|
|
40
52
|
messageContainerName = 'mobile-message-container';
|
|
53
|
+
subjectClassName = "email-subject-mobile";
|
|
41
54
|
}
|
|
42
55
|
|
|
56
|
+
const emailSubjectLabel = emailSubject && (
|
|
57
|
+
<CapLabel className={subjectClassName} type="label2">
|
|
58
|
+
<FormattedMessage {...messages.subject} /> {emailSubject}</CapLabel>
|
|
59
|
+
);
|
|
60
|
+
const iframeDiv = (<div className={`${messageContainerName}`}>
|
|
61
|
+
{emailSubjectLabel}
|
|
62
|
+
<iframe srcDoc={content} {...deviceAspectRatio[device](emailSubject)} >
|
|
63
|
+
<p>Your browser does not support iframes.</p>
|
|
64
|
+
</iframe>
|
|
65
|
+
</div>);
|
|
43
66
|
return (
|
|
44
67
|
<div className={this.props.show ? "modal-emailPreivew-wrapper show-emailPreivew" : "modal-emailPreivew-wrapper hide-emailPreivew"}>
|
|
45
68
|
<div id="emailPreivew-container">
|
|
@@ -54,25 +77,41 @@ class EmailPreview extends React.Component { // eslint-disable-line react/prefer
|
|
|
54
77
|
|
|
55
78
|
<div id="emailPreivew-content-wrapper">
|
|
56
79
|
<div id="emailPreivew-content">
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
<CapTab
|
|
81
|
+
className="email-preview-device-tabs"
|
|
82
|
+
activeKey={this.props.device}
|
|
83
|
+
onChange={this.props.changePreviewDevice}
|
|
84
|
+
panes={[
|
|
85
|
+
{
|
|
86
|
+
key: 'desktop',
|
|
87
|
+
tab: <StyledCapIcon type="desktop" active={device === 'desktop'} />,
|
|
88
|
+
content: <div className="email-preview-container">
|
|
89
|
+
{iframeDiv}
|
|
90
|
+
</div>,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
key: 'tablet',
|
|
94
|
+
tab: <StyledCapIcon type="tablet" active={device === 'tablet'} />,
|
|
95
|
+
content: (<div className="email-preview-container">
|
|
96
|
+
<div className="shell align-center">
|
|
97
|
+
<img src={tabletBody} alt="capillary" width="520" />
|
|
98
|
+
{iframeDiv}
|
|
99
|
+
</div>
|
|
100
|
+
</div>),
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
key: 'mobile',
|
|
104
|
+
tab: <StyledCapIcon type="mobile" active={device === 'mobile'} />,
|
|
105
|
+
content: (<div className="email-preview-container">
|
|
106
|
+
<div className="shell align-center">
|
|
107
|
+
<img src={mobileBody} alt="capillary" width="350" />
|
|
108
|
+
{iframeDiv}
|
|
109
|
+
</div>
|
|
110
|
+
</div>),
|
|
111
|
+
},
|
|
112
|
+
]}
|
|
113
|
+
/>
|
|
114
|
+
<div>
|
|
76
115
|
{(this.props.lastModified && this.props.updatedByName) ? <div>
|
|
77
116
|
<p className="preview-info" style={{ marginBottom: '8px', paddingTop: '8px'}}><FormattedMessage {...messages.lastModified} />: {moment(this.props.lastModified).format('MM-DD-YYYY')}</p>
|
|
78
117
|
<p style={{marginBottom: '8px'}} className="preview-info"><FormattedMessage {...messages.uploadedBy} /> : {this.props.updatedByName}</p>
|
|
@@ -101,6 +140,7 @@ EmailPreview.propTypes = {
|
|
|
101
140
|
changePreviewDevice: PropTypes.func,
|
|
102
141
|
lastModified: PropTypes.string,
|
|
103
142
|
updatedByName: PropTypes.string,
|
|
143
|
+
versions: PropTypes.object,
|
|
104
144
|
};
|
|
105
145
|
|
|
106
146
|
export default EmailPreview;
|
|
@@ -16,6 +16,10 @@ $classPrefix: email-preview-v2;
|
|
|
16
16
|
// display: table;
|
|
17
17
|
|
|
18
18
|
#emailPreivew-content {
|
|
19
|
+
.email-preview-device-tabs .ant-tabs-bar {
|
|
20
|
+
justify-content: center;
|
|
21
|
+
flex-direction: none;
|
|
22
|
+
}
|
|
19
23
|
.device-wrapper {
|
|
20
24
|
display: inline-flex;
|
|
21
25
|
margin-bottom: 8px;
|
|
@@ -37,25 +41,42 @@ $classPrefix: email-preview-v2;
|
|
|
37
41
|
|
|
38
42
|
}
|
|
39
43
|
.email-preview-container{
|
|
44
|
+
.shell {
|
|
45
|
+
position: relative;
|
|
46
|
+
-webkit-transform: unset;
|
|
47
|
+
transform: unset;
|
|
48
|
+
left: unset;
|
|
49
|
+
padding: unset;
|
|
50
|
+
width: unset;
|
|
51
|
+
display: flex;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
}
|
|
54
|
+
.email-subject-mobile {
|
|
55
|
+
width: 310px;
|
|
56
|
+
text-align: left;
|
|
57
|
+
margin: 8px 0;
|
|
58
|
+
margin-left: 4px;
|
|
59
|
+
}
|
|
60
|
+
.email-subject-tablet {
|
|
61
|
+
width: 450px;
|
|
62
|
+
text-align: left;
|
|
63
|
+
margin: 8px 0;
|
|
64
|
+
margin-left: 4px;
|
|
65
|
+
}
|
|
66
|
+
.email-subject-desktop {
|
|
67
|
+
text-align: left;
|
|
68
|
+
margin-bottom: 8px;
|
|
69
|
+
}
|
|
40
70
|
.tablet-message-container {
|
|
41
71
|
position: absolute;
|
|
42
72
|
top: 9%;
|
|
43
|
-
left: 10%;
|
|
44
|
-
width: 100%;
|
|
45
73
|
height: 100%;
|
|
46
74
|
overflow: auto;
|
|
47
|
-
display: -webkit-box;
|
|
48
|
-
display: -ms-flexbox;
|
|
49
|
-
display: flex;
|
|
50
75
|
}
|
|
51
76
|
.mobile-message-container {
|
|
52
77
|
position: absolute;
|
|
53
78
|
top: 10.3%;
|
|
54
|
-
|
|
55
|
-
overflow: auto;
|
|
56
|
-
display: -webkit-box;
|
|
57
|
-
display: -ms-flexbox;
|
|
58
|
-
display: flex;
|
|
79
|
+
height: 100%;
|
|
59
80
|
}
|
|
60
81
|
}
|
|
61
82
|
padding: 0 0px 0 24px;
|
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import React from 'react';
|
|
8
|
-
|
|
8
|
+
import styled from 'styled-components';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
10
|
import { FormattedMessage } from 'react-intl';
|
|
11
|
-
import {isEmpty} from 'lodash';
|
|
11
|
+
import { isEmpty, get } from 'lodash';
|
|
12
12
|
import { connect } from 'react-redux';
|
|
13
13
|
import { bindActionCreators } from 'redux';
|
|
14
14
|
import { createStructuredSelector } from 'reselect';
|
|
15
|
-
import { CapSpin } from '@capillarytech/cap-ui-library';
|
|
15
|
+
import { CapSpin, CapTab, CapIcon, CapLabel } from '@capillarytech/cap-ui-library';
|
|
16
|
+
import { CAP_G01, CAP_G06, FONT_SIZE_VL } from '@capillarytech/cap-ui-library/styled/variables';
|
|
16
17
|
import moment from 'moment';
|
|
17
18
|
import messages from './messages';
|
|
18
19
|
import './_emailPreviewV2.scss';
|
|
@@ -23,24 +24,30 @@ import {selectTemplateContent} from '../../v2Containers/Templates/selectors';
|
|
|
23
24
|
import * as templateActions from '../../v2Containers/Templates/actions';
|
|
24
25
|
|
|
25
26
|
const deviceAspectRatio = {
|
|
26
|
-
desktop: {
|
|
27
|
+
desktop: () => ({
|
|
27
28
|
height: "500",
|
|
28
29
|
width: "1024",
|
|
29
|
-
},
|
|
30
|
-
tablet: {
|
|
31
|
-
height: "600",
|
|
32
|
-
width: "
|
|
33
|
-
},
|
|
34
|
-
mobile: {
|
|
35
|
-
height: "600",
|
|
36
|
-
width: "
|
|
37
|
-
},
|
|
30
|
+
}),
|
|
31
|
+
tablet: (emailSubject) => ({
|
|
32
|
+
height: emailSubject ? "570" : "600",
|
|
33
|
+
width: "450",
|
|
34
|
+
}),
|
|
35
|
+
mobile: (emailSubject) => ({
|
|
36
|
+
height: emailSubject ? "570" : "600",
|
|
37
|
+
width: "310",
|
|
38
|
+
}),
|
|
38
39
|
};
|
|
39
40
|
const devices = {
|
|
40
41
|
mobile: 'mobile',
|
|
41
42
|
desktop: 'desktop',
|
|
42
43
|
tablet: 'tablet',
|
|
43
44
|
};
|
|
45
|
+
|
|
46
|
+
const StyledCapIcon = styled(CapIcon)`
|
|
47
|
+
color: ${(props) => props.active ? CAP_G01 : CAP_G06};
|
|
48
|
+
font-size: ${FONT_SIZE_VL};
|
|
49
|
+
`;
|
|
50
|
+
|
|
44
51
|
class EmailPreviewV2 extends React.Component {
|
|
45
52
|
constructor(props) {
|
|
46
53
|
super(props);
|
|
@@ -57,31 +64,75 @@ class EmailPreviewV2 extends React.Component {
|
|
|
57
64
|
componentWillUnmount() {
|
|
58
65
|
this.props.templateActions.resetTemplateData();
|
|
59
66
|
}
|
|
60
|
-
changePreviewDevice = (
|
|
61
|
-
this.setState({currentDevice:
|
|
67
|
+
changePreviewDevice = (device) => {
|
|
68
|
+
this.setState({currentDevice: device});
|
|
62
69
|
}
|
|
63
70
|
render() {
|
|
64
71
|
let messageContainerName = '';
|
|
65
72
|
const {currentDevice} = this.state;
|
|
66
|
-
const {templateContent} = this.props;
|
|
67
|
-
|
|
73
|
+
const { templateContent, templateData = {}, templateSubject } = this.props;
|
|
74
|
+
let subjectClassName = 'email-subject-desktop';
|
|
68
75
|
if (currentDevice === devices.tablet) {
|
|
69
76
|
messageContainerName = 'tablet-message-container';
|
|
77
|
+
subjectClassName = "email-subject-tablet";
|
|
70
78
|
} else if (currentDevice === devices.mobile) {
|
|
71
79
|
messageContainerName = 'mobile-message-container';
|
|
80
|
+
subjectClassName = "email-subject-mobile";
|
|
72
81
|
}
|
|
82
|
+
const emailSubject = get(templateData, 'versions.base.subject') || templateSubject;
|
|
83
|
+
const emailSubjectLabel = emailSubject && (
|
|
84
|
+
<CapLabel className={subjectClassName} type="label2">
|
|
85
|
+
<FormattedMessage {...messages.subject} /> {emailSubject}</CapLabel>
|
|
86
|
+
);
|
|
87
|
+
const iframeDiv = (<div className={`${messageContainerName}`}>
|
|
88
|
+
{emailSubjectLabel}
|
|
89
|
+
<iframe srcDoc={templateContent} {...deviceAspectRatio[currentDevice](emailSubject)} >
|
|
90
|
+
<p>Your browser does not support iframes.</p>
|
|
91
|
+
</iframe>
|
|
92
|
+
</div>);
|
|
93
|
+
|
|
94
|
+
|
|
73
95
|
return (
|
|
74
96
|
<div className="email-preview-v2">
|
|
75
97
|
<CapSpin spinning={!templateContent}>
|
|
76
98
|
<div id="emailPreivew-container">
|
|
77
99
|
<div id="emailPreivew-content-wrapper">
|
|
78
100
|
<div id="emailPreivew-content">
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
101
|
+
<CapTab
|
|
102
|
+
className="email-preview-device-tabs"
|
|
103
|
+
activeKey={currentDevice}
|
|
104
|
+
onChange={this.changePreviewDevice}
|
|
105
|
+
panes={[
|
|
106
|
+
{
|
|
107
|
+
key: 'desktop',
|
|
108
|
+
tab: <StyledCapIcon type="desktop" active={currentDevice === 'desktop'} />,
|
|
109
|
+
content: <div className="email-preview-container">
|
|
110
|
+
{iframeDiv}
|
|
111
|
+
</div>,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
key: 'tablet',
|
|
115
|
+
tab: <StyledCapIcon type="tablet" active={currentDevice === 'tablet'} />,
|
|
116
|
+
content: (<div className="email-preview-container">
|
|
117
|
+
<div className="shell align-center">
|
|
118
|
+
<img src={tabletBody} alt="capillary" width="520" />
|
|
119
|
+
{iframeDiv}
|
|
120
|
+
</div>
|
|
121
|
+
</div>),
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
key: 'mobile',
|
|
125
|
+
tab: <StyledCapIcon type="mobile" active={currentDevice === 'mobile'} />,
|
|
126
|
+
content: (<div className="email-preview-container">
|
|
127
|
+
<div className="shell align-center">
|
|
128
|
+
<img src={mobileBody} alt="capillary" width="350" />
|
|
129
|
+
{iframeDiv}
|
|
130
|
+
</div>
|
|
131
|
+
</div>),
|
|
132
|
+
},
|
|
133
|
+
]}
|
|
134
|
+
/>
|
|
135
|
+
{/* <div className="email-preview-container">
|
|
85
136
|
<div className={currentDevice === devices.desktop ? '' : "shell align-center"}>
|
|
86
137
|
{currentDevice === devices.tablet ?
|
|
87
138
|
<img src={tabletBody} alt="capillary" width="520" /> : ''}
|
|
@@ -95,7 +146,7 @@ class EmailPreviewV2 extends React.Component {
|
|
|
95
146
|
</div>
|
|
96
147
|
|
|
97
148
|
|
|
98
|
-
</div>
|
|
149
|
+
</div> */}
|
|
99
150
|
</div>
|
|
100
151
|
</div>
|
|
101
152
|
</div>
|
|
@@ -115,6 +166,7 @@ class EmailPreviewV2 extends React.Component {
|
|
|
115
166
|
|
|
116
167
|
EmailPreviewV2.propTypes = {
|
|
117
168
|
templateContent: PropTypes.string,
|
|
169
|
+
templateSubject: PropTypes.string,
|
|
118
170
|
templateData: PropTypes.object,
|
|
119
171
|
templateActions: PropTypes.object,
|
|
120
172
|
device: PropTypes.string,
|
|
@@ -72,10 +72,7 @@ class NavigationBar extends React.Component {
|
|
|
72
72
|
onHelpIconClick = () => {
|
|
73
73
|
const { helpUrl } = this.props;
|
|
74
74
|
if (helpUrl) {
|
|
75
|
-
|
|
76
|
-
page: "help",
|
|
77
|
-
};
|
|
78
|
-
window.history.pushState(stateObj, 'Help', window.location.replace(helpUrl));
|
|
75
|
+
window.open(helpUrl, '_blank');
|
|
79
76
|
}
|
|
80
77
|
};
|
|
81
78
|
|
|
@@ -13,7 +13,7 @@ import { FormattedMessage, injectIntl, intlShape } from 'react-intl';
|
|
|
13
13
|
import { createStructuredSelector } from 'reselect';
|
|
14
14
|
import moment from "moment";
|
|
15
15
|
import _ from "lodash";
|
|
16
|
-
import { CapHeader, CapInput, CapButton, CapSpin, CapIcon, CapDropdown, CapMenu, CapCustomCard, CapSlideBox, CapLabel, CapIllustration} from '@capillarytech/cap-ui-library';
|
|
16
|
+
import { CapHeading, CapHeader, CapInput, CapButton, CapSpin, CapIcon, CapDropdown, CapMenu, CapCustomCard, CapSlideBox, CapLabel, CapIllustration} from '@capillarytech/cap-ui-library';
|
|
17
17
|
import { Popover } from 'antd';
|
|
18
18
|
import makeSelectGallery from './selectors';
|
|
19
19
|
import messages from './messages';
|
|
@@ -336,6 +336,11 @@ export class Gallery extends React.Component { // eslint-disable-line react/pref
|
|
|
336
336
|
{!isLoading && <div>
|
|
337
337
|
{!_.isEmpty(templates) || !_.isEmpty(this.state.searchText) ? <div className="pagination-container">
|
|
338
338
|
<CapCustomCardList key={`${currentChannel}-card-list`} cardList={cardDataList} type={'Email'} />
|
|
339
|
+
{!_.isEmpty(this.state.searchText) && _.isEmpty(templates) && (
|
|
340
|
+
<div style={{ height: '65vh', textAlign: 'center', lineHeight: '65vh'}}>
|
|
341
|
+
<CapHeading type="h6">{this.props.intl.formatMessage(messages.noTemplatesFound)}</CapHeading>
|
|
342
|
+
</div>
|
|
343
|
+
)}
|
|
339
344
|
</div> : <CapIllustration {...this.getIllustrationProps} />}</div>
|
|
340
345
|
}
|
|
341
346
|
</CapSpin>
|
|
@@ -98,4 +98,8 @@ export default defineMessages({
|
|
|
98
98
|
id: 'app.containers.Assets.Gallery.lastUpdated',
|
|
99
99
|
defaultMessage: 'Last update {on} by {by}',
|
|
100
100
|
},
|
|
101
|
+
noTemplatesFound: {
|
|
102
|
+
id: `app.containers.Assets.Gallery.noTemplatesFound`,
|
|
103
|
+
defaultMessage: 'No templates found',
|
|
104
|
+
},
|
|
101
105
|
});
|
|
@@ -31,4 +31,4 @@ export const CLEAR_TOPBAR_MENU_DATA = 'creatives/cap/CLEAR_TOPBAR_MENU_DATA';
|
|
|
31
31
|
export const CAMPAIGN_SETTINGS_URL = '/creatives/settings/message';
|
|
32
32
|
export const BRAND_SETTINGS_URL = '/org/index';
|
|
33
33
|
export const PROFILE_SETTINGS_URL = '/org/users/NewProfile';
|
|
34
|
-
export const HELP_URL = 'https://support.capillarytech.com';
|
|
34
|
+
export const HELP_URL = 'https://support.capillarytech.com/en/support/solutions/4000007853';
|
|
@@ -1716,6 +1716,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1716
1716
|
device={this.state.device}
|
|
1717
1717
|
handleClose={this.toggleEmailPreview}
|
|
1718
1718
|
changePreviewDevice={this.changePreviewDevice}
|
|
1719
|
+
versions={_.get(this.state, 'previewTemplate.versions', {})}
|
|
1719
1720
|
lastModified={this.state.previewTemplate ? this.state.previewTemplate.updatedAt : ''}
|
|
1720
1721
|
updatedByName={commonUtil.getUserNameById(parseInt(this.state.previewTemplate.updatedBy, 10), commonUtil.getMergedUserList(this.props.Templates.userList))}
|
|
1721
1722
|
/>}
|