@capillarytech/creatives-library 2.0.59 → 2.0.61
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/MobilePushPreviewV2/index.js +120 -0
- package/components/MobilePushPreviewV2/messages.js +13 -0
- package/components/MobilePushPreviewV2/tests/index.test.js +10 -0
- package/components/TemplatePreview/index.js +1 -1
- package/containers/CreativesContainer/index.js +11 -1
- package/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* PreviewSideBar
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { CapButton } from '@capillarytech/cap-ui-library';
|
|
11
|
+
// import styled from 'styled-components';
|
|
12
|
+
|
|
13
|
+
import { FormattedMessage } from 'react-intl';
|
|
14
|
+
import { Button } from 'antd';
|
|
15
|
+
import { get, map, isEmpty} from 'lodash';
|
|
16
|
+
import TemplatePreview from '../TemplatePreview';
|
|
17
|
+
import '../PreviewSideBar/_previewsidebar.scss';
|
|
18
|
+
import messages from './messages';
|
|
19
|
+
const ButtonGroup = Button.Group;
|
|
20
|
+
|
|
21
|
+
class MobilePushPreviewV2 extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
22
|
+
constructor(props) {
|
|
23
|
+
super(props);
|
|
24
|
+
this.goToEdit = this.goToEdit.bind(this);
|
|
25
|
+
this.goToDuplicate = this.goToDuplicate.bind(this);
|
|
26
|
+
this.changeDevice = this.changeDevice.bind(this);
|
|
27
|
+
const hasAndroid = get(props, 'templateData.versions.base.ANDROID') || get(props, 'templateData.androidContent');
|
|
28
|
+
const hasIos = get(props, 'templateData.versions.base.IOS') || get(props, 'templateData.iosContent');
|
|
29
|
+
let device = "android";
|
|
30
|
+
if (hasAndroid) {
|
|
31
|
+
device = 'android';
|
|
32
|
+
} else if (hasIos) {
|
|
33
|
+
device = 'ios';
|
|
34
|
+
}
|
|
35
|
+
this.state = {
|
|
36
|
+
device,
|
|
37
|
+
content: this.setContent(props.templateData, device),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
setContent = (templateData, device) => {
|
|
42
|
+
const androidContent = get(templateData, 'versions.base.ANDROID') || get(templateData, 'androidContent');
|
|
43
|
+
const iosContent = get(templateData, 'versions.base.IOS') || get(templateData, 'iosContent');
|
|
44
|
+
|
|
45
|
+
const data = device === "android" ? androidContent : iosContent;
|
|
46
|
+
const content = {
|
|
47
|
+
header: data.title,
|
|
48
|
+
bodyText: data.message,
|
|
49
|
+
bodyImage: data.expandableDetails && data.expandableDetails.image,
|
|
50
|
+
actions: [],
|
|
51
|
+
appName: templateData.appName,
|
|
52
|
+
};
|
|
53
|
+
if (data.expandableDetails && data.expandableDetails.ctas && data.expandableDetails.ctas.length) {
|
|
54
|
+
if (device === "android" ) {
|
|
55
|
+
content.actions = map(data.expandableDetails.ctas, (cta) => ({label: cta.actionText}));
|
|
56
|
+
} else {
|
|
57
|
+
content.actions = [{label: data.expandableDetails.ctas[0].actionLabel}, {label: data.expandableDetails.ctas[0].actionLabel2}];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return content;
|
|
61
|
+
}
|
|
62
|
+
goToDuplicate() {
|
|
63
|
+
this.props.onDuplicateClick(this.props.templateData);
|
|
64
|
+
this.props.handleClose();
|
|
65
|
+
}
|
|
66
|
+
changeDevice(ev) {
|
|
67
|
+
const device = ev.target.value;
|
|
68
|
+
const content = this.setContent(this.props.templateData, device);
|
|
69
|
+
this.setState({device, content });
|
|
70
|
+
}
|
|
71
|
+
goToEdit(e, path) {
|
|
72
|
+
this.props.onEditClick(e, this.props.templateData._id, this.props.templateData.modeType, path);
|
|
73
|
+
}
|
|
74
|
+
render() {
|
|
75
|
+
const {templateData, channel} = this.props;
|
|
76
|
+
|
|
77
|
+
const hasAndroid = get(templateData, 'versions.base.ANDROID') || get(templateData, 'androidContent');
|
|
78
|
+
const hasIos = get(templateData, 'versions.base.IOS') || get(templateData, 'iosContent');
|
|
79
|
+
|
|
80
|
+
const {device, content} = this.state;
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
|
|
84
|
+
<div>
|
|
85
|
+
<div className="devices">
|
|
86
|
+
{!isEmpty(templateData) && hasAndroid && hasIos &&
|
|
87
|
+
<ButtonGroup onClick={this.changeDevice}>
|
|
88
|
+
<CapButton type={device === "android" ? "primary" : "secondary"} value={"android"}>Android</CapButton>
|
|
89
|
+
<CapButton type={device === "iphone" ? "primary" : "secondary"} value={"iphone"}>IOS</CapButton>
|
|
90
|
+
</ButtonGroup>}
|
|
91
|
+
</div>
|
|
92
|
+
<TemplatePreview
|
|
93
|
+
device={device === "android" ? "android" : "iphone"}
|
|
94
|
+
channel={channel}
|
|
95
|
+
content={content || ''}
|
|
96
|
+
templateData={templateData}
|
|
97
|
+
>
|
|
98
|
+
</TemplatePreview>
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
MobilePushPreviewV2.propTypes = {
|
|
110
|
+
templateData: PropTypes.object.isRequired,
|
|
111
|
+
channel: PropTypes.string.isRequired,
|
|
112
|
+
showPreview: PropTypes.bool,
|
|
113
|
+
handleClose: PropTypes.func,
|
|
114
|
+
onEditClick: PropTypes.func,
|
|
115
|
+
onDuplicateClick: PropTypes.func,
|
|
116
|
+
location: PropTypes.object,
|
|
117
|
+
embedded: PropTypes.bool,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export default MobilePushPreviewV2;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MobilePushPreviewV2 Messages
|
|
3
|
+
*
|
|
4
|
+
* This contains all the text for the MobilePushPreviewV2 component.
|
|
5
|
+
*/
|
|
6
|
+
import { defineMessages } from 'react-intl';
|
|
7
|
+
|
|
8
|
+
export default defineMessages({
|
|
9
|
+
header: {
|
|
10
|
+
id: 'app.components.MobilePushPreviewV2.header',
|
|
11
|
+
defaultMessage: 'This is the MobilePushPreviewV2 component !',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// import React from 'react';
|
|
2
|
+
// import { shallow } from 'enzyme';
|
|
3
|
+
|
|
4
|
+
// import MobilePushPreviewV2 from '../index';
|
|
5
|
+
|
|
6
|
+
describe('<MobilePushPreviewV2 />', () => {
|
|
7
|
+
it('Expect to have unit tests specified', () => {
|
|
8
|
+
expect(true).toEqual(false);
|
|
9
|
+
});
|
|
10
|
+
});
|
|
@@ -155,7 +155,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
|
|
|
155
155
|
</div>
|
|
156
156
|
: ''
|
|
157
157
|
}
|
|
158
|
-
{this.props.templateData &&
|
|
158
|
+
{this.props.templateData && this.props.templateData.updatedByName &&
|
|
159
159
|
[<p className="preview-info" key="preview-info-modified"><FormattedMessage {...messages.lastModified} />: {moment(this.props.templateData.updatedAt).format('MM-DD-YYYY')}</p>,
|
|
160
160
|
<p style={{marginBottom: '8px'}} className="preview-info" key="preview-info-updated"><FormattedMessage {...messages.uploadedBy} /> : {this.props.templateData.updatedByName}</p>,
|
|
161
161
|
]
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from '@capillarytech/cap-ui-library';
|
|
6
6
|
import { injectIntl } from 'react-intl';
|
|
7
7
|
import classnames from 'classnames';
|
|
8
|
-
import {isEmpty, get} from 'lodash';
|
|
8
|
+
import {isEmpty, get, forEach} from 'lodash';
|
|
9
9
|
import { connect } from 'react-redux';
|
|
10
10
|
import { createStructuredSelector } from 'reselect';
|
|
11
11
|
import { bindActionCreators } from 'redux';
|
|
@@ -175,6 +175,11 @@ class Creatives extends React.Component {
|
|
|
175
175
|
delete androidContent.cuid;
|
|
176
176
|
delete androidContent.luid;
|
|
177
177
|
delete androidContent.communicationId;
|
|
178
|
+
const custom = {};
|
|
179
|
+
forEach(androidContent.custom, (customKeyValue) => {
|
|
180
|
+
custom[customKeyValue.key] = customKeyValue.value;
|
|
181
|
+
} );
|
|
182
|
+
androidContent.custom = custom;
|
|
178
183
|
templateData.androidContent = androidContent;
|
|
179
184
|
templateData.androidContent.type = get(mobilpushTemplate, 'definition.mode').toUpperCase();
|
|
180
185
|
templateData.androidContent.deviceType = 'ANDROID';
|
|
@@ -184,6 +189,11 @@ class Creatives extends React.Component {
|
|
|
184
189
|
delete iosContent.cuid;
|
|
185
190
|
delete iosContent.luid;
|
|
186
191
|
delete iosContent.communicationId;
|
|
192
|
+
const custom = {};
|
|
193
|
+
forEach(iosContent.custom, (customKeyValue) => {
|
|
194
|
+
custom[customKeyValue.key] = customKeyValue.value;
|
|
195
|
+
} );
|
|
196
|
+
iosContent.custom = custom;
|
|
187
197
|
templateData.iosContent = iosContent;
|
|
188
198
|
templateData.iosContent.type = get(mobilpushTemplate, 'definition.mode').toUpperCase();
|
|
189
199
|
templateData.iosContent.deviceType = 'IOS';
|
package/index.js
CHANGED
|
@@ -75,7 +75,7 @@ export {default as EmailPreview} from './components/EmailPreview';
|
|
|
75
75
|
export {default as EmailPreviewV2} from './components/EmailPreviewV2';
|
|
76
76
|
export {default as CallTaskPreview} from './components/CallTaskPreview';
|
|
77
77
|
export {default as EmailMobilePreview} from './components/EmailMobilePreview';
|
|
78
|
-
|
|
78
|
+
export {default as MobilePushPreview} from './components/MobilePushPreviewV2';
|
|
79
79
|
CreativesContainer.CreativesContainerReducer = CreativesContainerReducer;
|
|
80
80
|
|
|
81
81
|
export { CapContainer,
|