@capillarytech/creatives-library 8.0.69-alpha.1 → 8.0.69-alpha.4
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/package.json +1 -1
- package/v2Components/CapImageUpload/index.js +1 -1
- package/v2Components/CapVideoUpload/messages.js +1 -1
- package/v2Components/FormBuilder/index.js +1 -1
- package/v2Containers/Assets/Gallery/constants.js +2 -0
- package/v2Containers/Assets/Gallery/index.js +16 -3
- package/v2Containers/Assets/Gallery/messages.js +8 -0
- package/v2Containers/CreativesContainer/index.js +22 -15
- package/v2Containers/Email/index.js +1 -1
- package/v2Containers/Line/Container/Image/index.js +1 -1
- package/v2Containers/Line/Container/Image/messages.js +1 -1
- package/v2Containers/Line/Container/ImageCarousel/messages.js +1 -1
- package/v2Containers/Line/Container/ImageMap/messages.js +1 -1
- package/v2Containers/Line/Container/Video/messages.js +1 -1
- package/v2Containers/MobilePush/Create/messages.js +1 -1
- package/v2Containers/Templates/index.js +175 -106
- package/v2Containers/Templates/sagas.js +7 -0
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +0 -72
- package/v2Containers/Whatsapp/constants.js +1 -39
- package/v2Containers/Whatsapp/index.js +13 -50
- package/v2Containers/Whatsapp/index.scss +0 -8
- package/v2Containers/Whatsapp/messages.js +0 -21
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +7738 -2600
- package/v2Containers/Whatsapp/tests/utils.test.js +2 -9
- package/v2Containers/Whatsapp/utils.js +4 -13
- package/v2Containers/mockdata.js +0 -11
package/package.json
CHANGED
|
@@ -96,7 +96,7 @@ function CapImageUpload(props) {
|
|
|
96
96
|
const fileParams = {
|
|
97
97
|
width: img.width,
|
|
98
98
|
height: img.height,
|
|
99
|
-
error: file && (file.size / (1e+6) >
|
|
99
|
+
error: file && (file.size / (1e+6) > 5), // Checking if file exists and its size is greater than 5MB (5 * 10^6 bytes)
|
|
100
100
|
};
|
|
101
101
|
submitAction({file, type: 'image', fileParams}, incorrectFile);
|
|
102
102
|
};
|
|
@@ -37,7 +37,7 @@ export default defineMessages({
|
|
|
37
37
|
},
|
|
38
38
|
videoIncorrectSize: {
|
|
39
39
|
id: `${scope}.videoIncorrectSize`,
|
|
40
|
-
defaultMessage: '
|
|
40
|
+
defaultMessage: 'Please upload the video with allowed file extension, size, dimension and aspect ratio',
|
|
41
41
|
},
|
|
42
42
|
whatsappErrorMessage: {
|
|
43
43
|
id: `${scope}.whatsappErrorMessage`,
|
|
@@ -2350,7 +2350,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2350
2350
|
const fileParams = {
|
|
2351
2351
|
width: this.width || img.width,
|
|
2352
2352
|
height: this.height || img.height,
|
|
2353
|
-
error: file && (file.size / (1e+6) >
|
|
2353
|
+
error: file && (file.size / (1e+6) > 5), // Checking if file exists and its size is greater than 5MB (5 * 10^6 bytes)
|
|
2354
2354
|
};
|
|
2355
2355
|
this.callChildEvent({file, type: 'image', fileParams}, val, val.submitAction);
|
|
2356
2356
|
};
|
|
@@ -21,3 +21,5 @@ export const DELETE_ASSET_FAILURE = 'app/Gallery/DELETE_ASSET_FAILURE';
|
|
|
21
21
|
export const GET_USER_LIST_REQUEST = "app/Gallery/GET_USER_LIST_REQUEST";
|
|
22
22
|
export const GET_USER_LIST_SUCCESS = "app/Gallery/GET_USER_LIST_SUCCESS";
|
|
23
23
|
export const GET_USER_LIST_FAILURE = "app/Gallery/GET_USER_LIST_FAILURE";
|
|
24
|
+
|
|
25
|
+
export const GALLERY_ALLOWED_EXTENSION = /(\.bmp|\.jpeg|\.png|\.gif|\.avif|\.jpg)$/i;
|
|
@@ -8,12 +8,12 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import { connect } from 'react-redux';
|
|
11
|
-
import { bindActionCreators } from 'redux';
|
|
11
|
+
import { bindActionCreators, compose } from 'redux';
|
|
12
12
|
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 { CapHeading, CapHeader, CapInput, CapButton, CapIcon, CapDropdown, CapMenu, CapCustomCard, CapSlideBox, CapLabel, CapIllustration} from '@capillarytech/cap-ui-library';
|
|
16
|
+
import { CapHeading, CapHeader, CapInput, CapButton, CapIcon, CapDropdown, CapMenu, CapCustomCard, CapSlideBox, CapLabel, CapIllustration, CapNotification,} from '@capillarytech/cap-ui-library';
|
|
17
17
|
import { Popover } from 'antd';
|
|
18
18
|
import makeSelectGallery from './selectors';
|
|
19
19
|
import messages from './messages';
|
|
@@ -30,7 +30,7 @@ import injectSaga from '../../../utils/injectSaga';
|
|
|
30
30
|
import injectReducer from '../../../utils/injectReducer';
|
|
31
31
|
import { v2GallerySagas } from './sagas';
|
|
32
32
|
import v2GalleryReducer from './reducer';
|
|
33
|
-
import {
|
|
33
|
+
import { GALLERY_ALLOWED_EXTENSION } from './constants';
|
|
34
34
|
|
|
35
35
|
const {CapCustomCardList} = CapCustomCard;
|
|
36
36
|
export class Gallery extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
@@ -238,6 +238,19 @@ export class Gallery extends React.Component { // eslint-disable-line react/pref
|
|
|
238
238
|
const _URL = window.URL || window.webkitURL;
|
|
239
239
|
for (const file in files) {
|
|
240
240
|
if (files.hasOwnProperty(file)) {
|
|
241
|
+
const {size = '', name = ''} = files[file];
|
|
242
|
+
const fileSize = size / (1024 * 1024);
|
|
243
|
+
const allowedExtensions = GALLERY_ALLOWED_EXTENSION;
|
|
244
|
+
if (fileSize > 10 || !allowedExtensions?.test(name)) {
|
|
245
|
+
const { formatMessage } = this.props.intl;
|
|
246
|
+
const fileErrorMessage = {
|
|
247
|
+
key: "image-gallery-upload-error",
|
|
248
|
+
message: formatMessage(messages.invalidUploadFileError),
|
|
249
|
+
description: formatMessage(messages.invalidUploadFileErrorDesc3),
|
|
250
|
+
};
|
|
251
|
+
CapNotification.error(fileErrorMessage);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
241
254
|
const img = new Image();
|
|
242
255
|
const that = this;
|
|
243
256
|
img.src = _URL.createObjectURL(files[file]);
|
|
@@ -106,4 +106,12 @@ export default defineMessages({
|
|
|
106
106
|
id: `creatives.containersV2.Assets.Gallery.loadingGallery`,
|
|
107
107
|
defaultMessage: 'Loading gallery...',
|
|
108
108
|
},
|
|
109
|
+
invalidUploadFileError: {
|
|
110
|
+
id: `creatives.containersV2.Assets.Gallery.invalidUploadFileError`,
|
|
111
|
+
defaultMessage: `File cannot be uploaded.`,
|
|
112
|
+
},
|
|
113
|
+
invalidUploadFileErrorDesc3: {
|
|
114
|
+
id: `creatives.containersV2.Assets.Gallery.invalidUploadFileErrorDesc3`,
|
|
115
|
+
defaultMessage: `Please select another file with valid file size less than 10MB`,
|
|
116
|
+
},
|
|
109
117
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
import Bugsnag from "@bugsnag/js";
|
|
3
4
|
import {
|
|
4
5
|
CapSlideBox,
|
|
5
6
|
CapHeader,
|
|
@@ -139,21 +140,27 @@ export class Creatives extends React.Component {
|
|
|
139
140
|
templateData.updatedByName = commonUtil.getUserNameById(userId, usersList);
|
|
140
141
|
this.setState({ slidBoxContent: constants.PREVIEW, templateData });
|
|
141
142
|
} else {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
143
|
+
if (get(template, 'versions.base.content.zalo.previewUrl')) {
|
|
144
|
+
commonUtil.handlePreviewInNewTab(
|
|
145
|
+
template.versions.base.content.zalo.previewUrl
|
|
146
|
+
);
|
|
147
|
+
} else {
|
|
148
|
+
const {
|
|
149
|
+
name = "",
|
|
150
|
+
sourceAccountIdentifier = "",
|
|
151
|
+
configs: { token = "" } = {},
|
|
152
|
+
hostName = ""
|
|
153
|
+
} = get(this.props, "Templates.selectedZaloAccount", {});
|
|
154
|
+
this.props.zaloActions.getTemplateInfoById({
|
|
155
|
+
username: name,
|
|
156
|
+
oa_id: sourceAccountIdentifier,
|
|
157
|
+
token,
|
|
158
|
+
host: hostName || this.props?.hostName || this.props.Templates?.senderDetails?.hostName,
|
|
159
|
+
id: template?._id,
|
|
160
|
+
preview: true,
|
|
161
|
+
actionCallback: this.actionCallback,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
157
164
|
}
|
|
158
165
|
};
|
|
159
166
|
|
|
@@ -1179,7 +1179,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
1179
1179
|
const _URL = window.URL || window.webkitURL;
|
|
1180
1180
|
const file = files[0];
|
|
1181
1181
|
const fileSize = file && (file.size / ( 1024 * 1024 ));
|
|
1182
|
-
if (fileSize >
|
|
1182
|
+
if (fileSize > 10) {
|
|
1183
1183
|
const message = this.props.intl.formatMessage(messages.uploadSizeError);
|
|
1184
1184
|
CapNotification.error({key: 'uploadImageIssue', message});
|
|
1185
1185
|
document.getElementById("fileName").value = "";
|
|
@@ -182,7 +182,7 @@ export const LineImage = ({
|
|
|
182
182
|
const fileParams = {
|
|
183
183
|
width: img.width,
|
|
184
184
|
height: img.height,
|
|
185
|
-
error: file && (file.size / (1e+6) >
|
|
185
|
+
error: file && (file.size / (1e+6) > 5), // Checking if file exists and its size is greater than 5MB (5 * 10^6 bytes)
|
|
186
186
|
};
|
|
187
187
|
submitAction({file, type: 'image', fileParams}, incorrectFile);
|
|
188
188
|
};
|
|
@@ -61,7 +61,7 @@ export default defineMessages({
|
|
|
61
61
|
},
|
|
62
62
|
"lineImageIncorrectSize": {
|
|
63
63
|
id: `${scope}.lineImageIncorrectSize`,
|
|
64
|
-
defaultMessage: 'Please upload the image with
|
|
64
|
+
defaultMessage: 'Please upload the image with allowed file extension, size, dimension and aspect ratio',
|
|
65
65
|
},
|
|
66
66
|
"imageGallery": {
|
|
67
67
|
id: `${scope}.imageGallery`,
|
|
@@ -65,7 +65,7 @@ export default defineMessages({
|
|
|
65
65
|
},
|
|
66
66
|
"lineImageIncorrectSize": {
|
|
67
67
|
id: `${scope}.lineImageIncorrectSize`,
|
|
68
|
-
defaultMessage: 'Please upload the image with
|
|
68
|
+
defaultMessage: 'Please upload the image with allowed file extension, size, dimension and aspect ratio',
|
|
69
69
|
},
|
|
70
70
|
"imageGallery": {
|
|
71
71
|
id: `${scope}.imageGallery`,
|
|
@@ -57,7 +57,7 @@ export default defineMessages({
|
|
|
57
57
|
},
|
|
58
58
|
"lineImageMapIncorrectSize": {
|
|
59
59
|
id: `${scope}.lineImageMapIncorrectSize`,
|
|
60
|
-
defaultMessage: 'Please upload the image with
|
|
60
|
+
defaultMessage: 'Please upload the image with allowed file extension, size, dimension and aspect ratio',
|
|
61
61
|
},
|
|
62
62
|
"imageGallery": {
|
|
63
63
|
id: `${scope}.imageGallery`,
|
|
@@ -65,7 +65,7 @@ export default defineMessages({
|
|
|
65
65
|
},
|
|
66
66
|
"lineVideoIncorrectSize": {
|
|
67
67
|
id: `${scope}.lineVideoIncorrectSize`,
|
|
68
|
-
defaultMessage: '
|
|
68
|
+
defaultMessage: 'Please upload the video with allowed file extension, size, dimension and aspect ratio',
|
|
69
69
|
},
|
|
70
70
|
"imageGallery": {
|
|
71
71
|
id: `${scope}.imageGallery`,
|
|
@@ -240,7 +240,7 @@ export default defineMessages({
|
|
|
240
240
|
},
|
|
241
241
|
"uploadImageSizeErrorDescription": {
|
|
242
242
|
id: 'creatives.containersV2.MobilePush.Create.uploadImageSizeErrorDescription',
|
|
243
|
-
defaultMessage: 'File size cannot be more than
|
|
243
|
+
defaultMessage: 'File size cannot be more than 5mb',
|
|
244
244
|
},
|
|
245
245
|
"validationError": {
|
|
246
246
|
id: 'creatives.containersV2.MobilePush.Create.validationError',
|