@capillarytech/creatives-library 3.1.26 → 3.1.28
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/components/TemplatePreview/index.js +1 -1
- package/components/TemplatePreview/messages.js +1 -1
- package/package.json +1 -1
- package/utils/smsCharCountV2.js +2 -1
- package/v2Components/TemplatePreview/index.js +2 -2
- package/v2Components/TemplatePreview/messages.js +1 -1
- package/v2Containers/CreativesContainer/SlideBoxContent.js +3 -0
- package/v2Containers/CreativesContainer/index.js +3 -1
- package/v2Containers/TemplatesV2/_templatesV2.scss +5 -0
- package/v2Containers/TemplatesV2/index.js +23 -3
|
@@ -149,7 +149,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
|
|
|
149
149
|
{smsDetails.unicode &&
|
|
150
150
|
<div style={{fontSize: '16px'}}>{`${this.props.intl.formatMessage(messages.smsFormatType)}`}</div>
|
|
151
151
|
}
|
|
152
|
-
<div style={{marginTop: '8px', fontSize: '16px'}} >{`${smsDetails.parts} ${this.props.intl.formatMessage(messages.sms)} (${smsDetails.
|
|
152
|
+
<div style={{marginTop: '8px', fontSize: '16px'}} >{`${smsDetails.parts} ${this.props.intl.formatMessage(messages.sms)} (${smsDetails.actual_chars_used} ${this.props.intl.formatMessage(messages.characters)})`}</div>
|
|
153
153
|
{smsDetails.optoutUrlPresent && <div style={{fontWeight: '100', fontSize: '12px'}}>
|
|
154
154
|
{`${this.props.intl.formatMessage(messages.includesOptoutTag)} (${smsDetails.optouturlLength} ${this.props.intl.formatMessage(messages.characters)})`}
|
|
155
155
|
</div>}
|
|
@@ -28,7 +28,7 @@ export default defineMessages({
|
|
|
28
28
|
},
|
|
29
29
|
includesOptoutTag: {
|
|
30
30
|
id: 'app.components.TemplatePreview.includesOptoutTag',
|
|
31
|
-
defaultMessage: 'Includes
|
|
31
|
+
defaultMessage: 'Includes optout tag',
|
|
32
32
|
},
|
|
33
33
|
previewGenerated: {
|
|
34
34
|
id: 'creatives.components.TemplatePreview.previewGenerated',
|
package/package.json
CHANGED
package/utils/smsCharCountV2.js
CHANGED
|
@@ -88,7 +88,7 @@ export function updateCharCount(content, isUnicodeEnabled) {
|
|
|
88
88
|
break;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
const actual_chars_used = showOptoutCount ? (chars_used + (((optoutUrl && optoutUrl.length) || 0) * noOfOptout) - (optoutTagLength * noOfOptout)) : chars_used;
|
|
92
92
|
if (coding == '7bit') {
|
|
93
93
|
if (chars_used > 160) {
|
|
94
94
|
var parts = Math.ceil(chars_used / 153);
|
|
@@ -147,5 +147,6 @@ export function updateCharCount(content, isUnicodeEnabled) {
|
|
|
147
147
|
optouturlLength: (optoutUrl && optoutUrl.length) || 0,
|
|
148
148
|
optoutUrlPresent: noOfOptout > 0,
|
|
149
149
|
responseState,
|
|
150
|
+
actual_chars_used,
|
|
150
151
|
};
|
|
151
152
|
}
|
|
@@ -54,7 +54,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
|
|
|
54
54
|
<CapRow>
|
|
55
55
|
{this.props.showCount && <CapColumn span={16}>
|
|
56
56
|
{channel && channel.toLowerCase() === 'sms' && <CapHeading type="h3">
|
|
57
|
-
<FormattedMessage {...messages.charactersTotal} values={{smsCount: smsDetails.parts, charCount: smsDetails.
|
|
57
|
+
<FormattedMessage {...messages.charactersTotal} values={{smsCount: smsDetails.parts, charCount: smsDetails.actual_chars_used}}/>
|
|
58
58
|
{smsDetails.unicode &&
|
|
59
59
|
<FormattedMessage {...messages.smsFormatType}/>
|
|
60
60
|
}
|
|
@@ -83,7 +83,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
|
|
|
83
83
|
{!this.props.showCount && <div>
|
|
84
84
|
<CapColumn className="character-count-col" span={22}>
|
|
85
85
|
{channel && channel.toLowerCase() === 'sms' && <CapHeading type="h3">
|
|
86
|
-
<FormattedMessage {...messages.charactersTotal} values={{smsCount: smsDetails.parts, charCount: smsDetails.
|
|
86
|
+
<FormattedMessage {...messages.charactersTotal} values={{smsCount: smsDetails.parts, charCount: smsDetails.actual_chars_used}}/>
|
|
87
87
|
{smsDetails.unicode &&
|
|
88
88
|
<FormattedMessage {...messages.smsFormatType}/>
|
|
89
89
|
}
|
|
@@ -24,7 +24,7 @@ export default defineMessages({
|
|
|
24
24
|
},
|
|
25
25
|
optoutCharactersTotal: {
|
|
26
26
|
id: 'app.components.TemplatePreview.optoutCharactersTotal',
|
|
27
|
-
defaultMessage: "Includes
|
|
27
|
+
defaultMessage: "Includes optout tag ({optoutUrlLength} characters)",
|
|
28
28
|
},
|
|
29
29
|
smsFormatType: {
|
|
30
30
|
id: 'creatives.componentsV2.TemplatePreview.smsFormatType',
|
|
@@ -60,6 +60,7 @@ function SlideBoxContent(props) {
|
|
|
60
60
|
onValidationFail,
|
|
61
61
|
channelsToHide,
|
|
62
62
|
forwardedTags,
|
|
63
|
+
channelsToDisable,
|
|
63
64
|
weChatTemplateType,
|
|
64
65
|
onWechatTemplateChange,
|
|
65
66
|
selectedWeChatAccount,
|
|
@@ -113,6 +114,7 @@ function SlideBoxContent(props) {
|
|
|
113
114
|
cap={cap}
|
|
114
115
|
channelsToHide={channelsToHide}
|
|
115
116
|
forwardedTags={forwardedTags}
|
|
117
|
+
channelsToDisable={channelsToDisable}
|
|
116
118
|
/>
|
|
117
119
|
)}
|
|
118
120
|
{isPreview && (
|
|
@@ -323,6 +325,7 @@ SlideBoxContent.propTypes = {
|
|
|
323
325
|
onValidationFail: PropTypes.func,
|
|
324
326
|
channelsToHide: PropTypes.array,
|
|
325
327
|
forwardedTags: PropTypes.object,
|
|
328
|
+
channelsToDisable: PropTypes.array,
|
|
326
329
|
weChatTemplateType: PropTypes.string,
|
|
327
330
|
onWechatTemplateChange: PropTypes.func,
|
|
328
331
|
selectedWeChatAccount: PropTypes.object,
|
|
@@ -463,7 +463,7 @@ class Creatives extends React.Component {
|
|
|
463
463
|
}
|
|
464
464
|
render() {
|
|
465
465
|
const {slidBoxContent, isGetFormData, showSlideBox, templateData, currentChannel, emailCreateMode, templateStep, isLoadingContent, mobilePushCreateMode, isDiscardMessage, weChatTemplateType, weChatMaptemplateStep} = this.state;
|
|
466
|
-
const {isFullMode, creativesMode, cap, isUploading, channelsToHide, selectedWeChatAccount, forwardedTags} = this.props;
|
|
466
|
+
const {isFullMode, creativesMode, cap, isUploading, channelsToHide, selectedWeChatAccount, forwardedTags, channelsToDisable} = this.props;
|
|
467
467
|
return (
|
|
468
468
|
<SlideBoxWrapper className={classnames(`${classPrefix} ${isFullMode ? 'creatives-full-mode' : 'creatives-library-mode'}`)}>
|
|
469
469
|
<CapSlideBox
|
|
@@ -519,6 +519,7 @@ class Creatives extends React.Component {
|
|
|
519
519
|
onValidationFail={this.onValidationFail}
|
|
520
520
|
channelsToHide={channelsToHide}
|
|
521
521
|
forwardedTags={forwardedTags}
|
|
522
|
+
channelsToDisable={channelsToDisable}
|
|
522
523
|
weChatTemplateType={weChatTemplateType}
|
|
523
524
|
onWechatTemplateChange={this.onWechatTemplateChange}
|
|
524
525
|
weChatMaptemplateStep={weChatMaptemplateStep}
|
|
@@ -570,6 +571,7 @@ Creatives.propTypes = {
|
|
|
570
571
|
EmailLayout: PropTypes.string,
|
|
571
572
|
channelsToHide: PropTypes.array,
|
|
572
573
|
forwardedTags: PropTypes.object,
|
|
574
|
+
channelsToDisable: PropTypes.array,
|
|
573
575
|
selectedWeChatAccount: PropTypes.object,
|
|
574
576
|
};
|
|
575
577
|
const mapStatesToProps = () => createStructuredSelector({
|
|
@@ -12,6 +12,7 @@ import { createStructuredSelector } from 'reselect';
|
|
|
12
12
|
import { bindActionCreators } from 'redux';
|
|
13
13
|
import { CapTab, CapCustomCard, CapButton, CapHeader, CapSpin, CapIcon } from '@capillarytech/cap-ui-library';
|
|
14
14
|
import { find, get } from 'lodash';
|
|
15
|
+
import isEmpty from 'lodash/isEmpty';
|
|
15
16
|
import Helmet from 'react-helmet';
|
|
16
17
|
|
|
17
18
|
import { UserIsAuthenticated } from '../../utils/authWrapper';
|
|
@@ -31,7 +32,7 @@ const StyledCapTab = withStyles(CapTab, CapTabStyle);
|
|
|
31
32
|
export class TemplatesV2 extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
32
33
|
constructor(props) {
|
|
33
34
|
super(props);
|
|
34
|
-
|
|
35
|
+
let defaultChannel = get(this, 'props.channel') || get(this, 'props.params.channel') || 'sms';
|
|
35
36
|
const defaultPanes = {
|
|
36
37
|
sms: {content: <div></div>, tab: props.intl.formatMessage(messages.sms), key: 'sms'},
|
|
37
38
|
email: {content: <div></div>, tab: props.intl.formatMessage(messages.email), key: 'email'},
|
|
@@ -40,8 +41,8 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
40
41
|
mPush: {content: <div></div>, tab: props.intl.formatMessage(messages.pushNotification), key: 'mobilepush'},
|
|
41
42
|
};
|
|
42
43
|
const channelsToHide = this.props.channelsToHide || [];
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
const channelsToDisable = this.props.channelsToDisable || [];
|
|
45
|
+
let filteredPanes = Object.keys(defaultPanes)
|
|
45
46
|
.filter((key) => !channelsToHide.includes(key)).reduce((obj = [], key) => {
|
|
46
47
|
obj.push(defaultPanes[key]);
|
|
47
48
|
return obj;
|
|
@@ -52,8 +53,26 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
52
53
|
} else if (!channelsToHide.includes('callTask')) {
|
|
53
54
|
filteredPanes.push({content: <div></div>, tab: props.intl.formatMessage(messages.callTask), key: 'call_task'});
|
|
54
55
|
}
|
|
56
|
+
/* eslint-disable no-param-reassign */
|
|
57
|
+
filteredPanes = filteredPanes.forEach( (pane) => {
|
|
58
|
+
if (channelsToDisable.includes(pane.key)) {
|
|
59
|
+
pane.disabled = true;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const channel = ['sms', 'email', 'mobilepush', 'call_task'];
|
|
64
|
+
if (!isEmpty(channelsToDisable)) {
|
|
65
|
+
channel.some((ch) => {
|
|
66
|
+
if (!channelsToDisable.includes(ch)) {
|
|
67
|
+
defaultChannel = ch;
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
55
73
|
|
|
56
74
|
const panes = this.setChannelContent(defaultChannel, filteredPanes);
|
|
75
|
+
|
|
57
76
|
this.state = {
|
|
58
77
|
selectedChannel: defaultChannel,
|
|
59
78
|
panes,
|
|
@@ -191,6 +210,7 @@ TemplatesV2.propTypes = {
|
|
|
191
210
|
onChannelChange: PropTypes.func,
|
|
192
211
|
channelsToHide: PropTypes.array,
|
|
193
212
|
className: PropTypes.string.isRequired,
|
|
213
|
+
channelsToDisable: PropTypes.array,
|
|
194
214
|
};
|
|
195
215
|
|
|
196
216
|
TemplatesV2.defaultProps = {
|