@capillarytech/creatives-library 7.16.9-alpha.1 → 7.16.10
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/app.js +2 -2
- package/components/TemplatePreview/index.js +0 -1
- package/containers/Assets/Gallery/messages.js +1 -1
- package/containers/Cap/sagas.js +3 -4
- package/containers/Cap/tests/__snapshots__/index.test.js.snap +4 -4
- package/containers/Email/messages.js +1 -1
- package/package.json +1 -1
- package/services/api.js +9 -1
- package/styles/vendor/semantic/src/definitions/collections/form.less +2 -2
- package/styles/vendor/semantic/src/definitions/elements/flag.less +1 -1
- package/styles/vendor/semantic/src/definitions/elements/icon.less +1 -0
- package/styles/vendor/semantic/src/definitions/globals/site.less +1 -1
- package/translations/en.json +4 -4
- package/utils/common.js +0 -22
- package/utils/smsCharCountV2.js +13 -0
- package/utils/test-utils.js +17 -0
- package/utils/tests/v2Common.test.js +2 -44
- package/v2Components/CapDocumentUpload/index.js +6 -3
- package/v2Components/CapImageUpload/index.js +5 -2
- package/v2Components/CapVideoUpload/index.js +6 -2
- package/v2Components/FormBuilder/index.js +31 -9
- package/v2Containers/Assets/Gallery/index.js +3 -28
- package/v2Containers/Assets/Gallery/messages.js +1 -1
- package/v2Containers/Cap/sagas.js +3 -4
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +4 -4
- package/v2Containers/ChannelTemplates/actions.js +20 -0
- package/v2Containers/ChannelTemplates/constants.js +8 -0
- package/v2Containers/ChannelTemplates/index.js +47 -0
- package/v2Containers/ChannelTemplates/messages.js +13 -0
- package/v2Containers/ChannelTemplates/reducer.js +34 -0
- package/v2Containers/ChannelTemplates/sagas.js +32 -0
- package/v2Containers/ChannelTemplates/selectors.js +25 -0
- package/v2Containers/CreativesContainer/constants.js +2 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +8 -0
- package/v2Containers/Email/index.js +2 -4
- package/v2Containers/Email/messages.js +1 -1
- package/v2Containers/LanguageProvider/index.js +0 -3
- package/v2Containers/Line/Container/Image/index.js +5 -2
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +12 -3397
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +8 -8
- package/v2Containers/Line/Container/ImageMap/index.js +2 -4
- package/v2Containers/Line/Container/Video/index.js +8 -5
- package/v2Containers/Line/Container/Video/messages.js +0 -9
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +68 -68
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +72 -72
- package/v2Containers/MobilePush/Create/index.js +3 -21
- package/v2Containers/MobilePush/Create/messages.js +0 -48
- package/v2Containers/MobilePush/Edit/index.js +1 -19
- package/v2Containers/MobilePush/Edit/messages.js +0 -16
- package/v2Containers/MobilePush/commonMethods.js +2 -2
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +197 -191
- package/v2Containers/Sms/Create/actions.js +9 -0
- package/v2Containers/Sms/Create/constants.js +2 -0
- package/v2Containers/Sms/Create/index.js +12 -0
- package/v2Containers/Sms/Create/sagas.js +19 -3
- package/v2Containers/Sms/Create/tests/sagas.test.js +82 -0
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +16 -16
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +32 -32
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +16 -0
- package/v2Containers/Viber/index.js +5 -2
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +336 -284
package/app.js
CHANGED
|
@@ -38,8 +38,6 @@ const store = configureStore(initialState, browserHistory);
|
|
|
38
38
|
const history = syncHistoryWithStore(browserHistory, store, {
|
|
39
39
|
selectLocationState: makeSelectLocationState(),
|
|
40
40
|
});
|
|
41
|
-
const BUGSNAG_APP_VERSION = `creatives-ui__${new Date().getTime()}`;
|
|
42
|
-
const BUGSNAG_API_KEY = 'c4d96446438ff7dc7c08da08ef94c5b2';
|
|
43
41
|
|
|
44
42
|
const bugSnagErrorCallback = (event) => {
|
|
45
43
|
const { app: { releaseStage } = {}, originalError } = event || {};
|
|
@@ -89,7 +87,9 @@ const bugSnagErrorCallback = (event) => {
|
|
|
89
87
|
};
|
|
90
88
|
|
|
91
89
|
Bugsnag.start({
|
|
90
|
+
// eslint-disable-next-line no-undef
|
|
92
91
|
appVersion: BUGSNAG_APP_VERSION,
|
|
92
|
+
// eslint-disable-next-line no-undef
|
|
93
93
|
apiKey: BUGSNAG_API_KEY,
|
|
94
94
|
releaseStage: window.location.hostname,
|
|
95
95
|
plugins: [new BugsnagPluginReact()],
|
|
@@ -27,7 +27,6 @@ const wechatBody = require('./assets/images/WECHAT_5x.png');
|
|
|
27
27
|
const smsBody = require('./assets/images/mobile.svg');
|
|
28
28
|
const androidPushMessagePhone = require('./assets/images/androidPushMessage.svg');
|
|
29
29
|
const iPhonePushMessagePhone = require('./assets/images/iPhonePushMessage.svg');
|
|
30
|
-
const lineVideoPlaceholder = require('../../assets/rich-video-placeholder.svg');
|
|
31
30
|
import { CAP_COLOR_03, CAP_WHITE, FONT_COLOR_01, CAP_G08, CAP_G06 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
32
31
|
import { TEMPLATE, IMAGE_CAROUSEL, IMAGE_MAP_CAMEL_CASE, IMAGE, STICKER, TEXT, VIDEO } from '../../v2Containers/Line/Container/constants';
|
|
33
32
|
|
|
@@ -76,7 +76,7 @@ export default defineMessages({
|
|
|
76
76
|
},
|
|
77
77
|
assetUploadFailed: {
|
|
78
78
|
id: 'creatives.containers.Assets.Gallery.assetUploadFailed',
|
|
79
|
-
defaultMessage: 'Image
|
|
79
|
+
defaultMessage: 'Image uploaded failed',
|
|
80
80
|
},
|
|
81
81
|
assetDeleteSuccess: {
|
|
82
82
|
id: 'creatives.containers.Assets.Gallery.assetDeleteSuccess',
|
package/containers/Cap/sagas.js
CHANGED
|
@@ -7,7 +7,7 @@ import * as types from './constants';
|
|
|
7
7
|
import config from '../../config/app';
|
|
8
8
|
// import {makeSelectOrgId} from './selectors';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
function* authorize(user) {
|
|
11
11
|
try {
|
|
12
12
|
const res = yield call(Api.authorize, user);
|
|
13
13
|
yield call(LocalStorage.saveItem, 'token', res.token);
|
|
@@ -35,14 +35,13 @@ function* switchOrg({orgID}) {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
function* loginFlow() {
|
|
39
|
+
const condition = true;
|
|
40
40
|
while (condition) {
|
|
41
41
|
const { user } = yield take(types.LOGIN_REQUEST);
|
|
42
42
|
const task = yield fork(authorize, user);
|
|
43
43
|
const action = yield take([types.LOGOUT_REQUEST, types.LOGIN_FAILURE]);
|
|
44
44
|
if (action.type === types.LOGOUT_REQUEST) {
|
|
45
|
-
condition = false;
|
|
46
45
|
yield cancel(task);
|
|
47
46
|
}
|
|
48
47
|
// yield call(LocalStorage.clearItem, 'token');
|
|
@@ -323,7 +323,7 @@ exports[`<Cap /> should render its children 1`] = `
|
|
|
323
323
|
"creatives.containers.Assets.Gallery.alphabetically": "Alphabetically",
|
|
324
324
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "Image deletion failed.",
|
|
325
325
|
"creatives.containers.Assets.Gallery.assetDeleteSuccess": "Image deleted successfully.",
|
|
326
|
-
"creatives.containers.Assets.Gallery.assetUploadFailed": "Image
|
|
326
|
+
"creatives.containers.Assets.Gallery.assetUploadFailed": "Image uploaded failed",
|
|
327
327
|
"creatives.containers.Assets.Gallery.assetUploadSuccess": "Image uploaded successfully",
|
|
328
328
|
"creatives.containers.Assets.Gallery.backToGallery": "Back to image gallery",
|
|
329
329
|
"creatives.containers.Assets.Gallery.delete": "Delete",
|
|
@@ -470,7 +470,7 @@ exports[`<Cap /> should render its children 1`] = `
|
|
|
470
470
|
"creatives.containers.Email.Tags": "Tags",
|
|
471
471
|
"creatives.containers.Email.alphabetically": "Alphabetically",
|
|
472
472
|
"creatives.containers.Email.alphabeticallyOption": "Alphabetically",
|
|
473
|
-
"creatives.containers.Email.assetUploadFailed": "Image
|
|
473
|
+
"creatives.containers.Email.assetUploadFailed": "Image uploaded failed",
|
|
474
474
|
"creatives.containers.Email.blankTemplate": "Blank template",
|
|
475
475
|
"creatives.containers.Email.cancel": "Cancel",
|
|
476
476
|
"creatives.containers.Email.createHeading": "Create email template",
|
|
@@ -875,7 +875,7 @@ exports[`<Cap /> should render its children 1`] = `
|
|
|
875
875
|
"creatives.containersV2.Assets.Gallery.alphabetically": "Alphabetically",
|
|
876
876
|
"creatives.containersV2.Assets.Gallery.assetDeleteFailed": "Image deletion failed.",
|
|
877
877
|
"creatives.containersV2.Assets.Gallery.assetDeleteSuccess": "Image deleted successfully.",
|
|
878
|
-
"creatives.containersV2.Assets.Gallery.assetUploadFailed": "Image
|
|
878
|
+
"creatives.containersV2.Assets.Gallery.assetUploadFailed": "Image uploaded failed",
|
|
879
879
|
"creatives.containersV2.Assets.Gallery.assetUploadSuccess": "Image uploaded successfully",
|
|
880
880
|
"creatives.containersV2.Assets.Gallery.backToGallery": "Back to image gallery",
|
|
881
881
|
"creatives.containersV2.Assets.Gallery.delete": "Delete",
|
|
@@ -1133,7 +1133,7 @@ exports[`<Cap /> should render its children 1`] = `
|
|
|
1133
1133
|
"creatives.containersV2.Email.alertMessage": "Alert",
|
|
1134
1134
|
"creatives.containersV2.Email.alphabetically": "Alphabetically",
|
|
1135
1135
|
"creatives.containersV2.Email.alphabeticallyOption": "Alphabetically",
|
|
1136
|
-
"creatives.containersV2.Email.assetUploadFailed": "Image
|
|
1136
|
+
"creatives.containersV2.Email.assetUploadFailed": "Image uploaded failed",
|
|
1137
1137
|
"creatives.containersV2.Email.blankTemplate": "Blank template",
|
|
1138
1138
|
"creatives.containersV2.Email.cancel": "Cancel",
|
|
1139
1139
|
"creatives.containersV2.Email.copyPrimaryLanguage": "Copy Primary Language",
|
|
@@ -228,7 +228,7 @@ export default defineMessages({
|
|
|
228
228
|
},
|
|
229
229
|
"assetUploadFailed": {
|
|
230
230
|
id: 'creatives.containers.Email.assetUploadFailed',
|
|
231
|
-
defaultMessage: 'Image
|
|
231
|
+
defaultMessage: 'Image uploaded failed',
|
|
232
232
|
},
|
|
233
233
|
"goBackConfirmation": {
|
|
234
234
|
id: 'creatives.containers.Email.Create.goBackConfirmation',
|
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -498,4 +498,12 @@ export const getCdnTransformationConfig = () => {
|
|
|
498
498
|
export const getS3UrlFileSizes = (data) => {
|
|
499
499
|
const url = `${API_ENDPOINT}/assets/files/metadata`;
|
|
500
500
|
return request(url, getAPICallObject('POST', data));
|
|
501
|
-
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// TODO: Update this url with Aira node API
|
|
504
|
+
export const getAiSuggestions = (data) => {
|
|
505
|
+
const url = `https://capgpt.chinmayjain.live/chat-completion`;
|
|
506
|
+
return request(url, getAPICallObject('POST', {...data,
|
|
507
|
+
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiY2hpbm1heWphaW4wOEBnbWFpbC5jb20iLCJpYXQiOjE2ODE3OTc5NzN9.-o_9fiZqvrdx_prcW0Qicu1fKVJU2ysO5t4g9HkYb2M"
|
|
508
|
+
}));
|
|
509
|
+
};
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
margin: 0em;
|
|
116
116
|
outline: none;
|
|
117
117
|
-webkit-appearance: none;
|
|
118
|
-
|
|
118
|
+
tap-highlight-color: rgba(255, 255, 255, 0);
|
|
119
119
|
|
|
120
120
|
line-height: @inputLineHeight;
|
|
121
121
|
padding: @inputPadding;
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
.ui.form textarea {
|
|
134
134
|
margin: 0em;
|
|
135
135
|
-webkit-appearance: none;
|
|
136
|
-
|
|
136
|
+
tap-highlight-color: rgba(255, 255, 255, 0);
|
|
137
137
|
|
|
138
138
|
padding: @textAreaPadding;
|
|
139
139
|
font-size: @textAreaFontSize;
|
package/translations/en.json
CHANGED
|
@@ -281,7 +281,7 @@
|
|
|
281
281
|
"creatives.containers.Assets.Gallery.alphabetically": "Alphabetically",
|
|
282
282
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "Image deletion failed.",
|
|
283
283
|
"creatives.containers.Assets.Gallery.assetDeleteSuccess": "Image deleted successfully.",
|
|
284
|
-
"creatives.containers.Assets.Gallery.assetUploadFailed": "Image
|
|
284
|
+
"creatives.containers.Assets.Gallery.assetUploadFailed": "Image uploaded failed",
|
|
285
285
|
"creatives.containers.Assets.Gallery.assetUploadSuccess": "Image uploaded successfully",
|
|
286
286
|
"creatives.containers.Assets.Gallery.backToGallery": "Back to image gallery",
|
|
287
287
|
"creatives.containers.Assets.Gallery.delete": "Delete",
|
|
@@ -428,7 +428,7 @@
|
|
|
428
428
|
"creatives.containers.Email.Tags": "Tags",
|
|
429
429
|
"creatives.containers.Email.alphabetically": "Alphabetically",
|
|
430
430
|
"creatives.containers.Email.alphabeticallyOption": "Alphabetically",
|
|
431
|
-
"creatives.containers.Email.assetUploadFailed": "Image
|
|
431
|
+
"creatives.containers.Email.assetUploadFailed": "Image uploaded failed",
|
|
432
432
|
"creatives.containers.Email.blankTemplate": "Blank template",
|
|
433
433
|
"creatives.containers.Email.cancel": "Cancel",
|
|
434
434
|
"creatives.containers.Email.createHeading": "Create email template",
|
|
@@ -833,7 +833,7 @@
|
|
|
833
833
|
"creatives.containersV2.Assets.Gallery.alphabetically": "Alphabetically",
|
|
834
834
|
"creatives.containersV2.Assets.Gallery.assetDeleteFailed": "Image deletion failed.",
|
|
835
835
|
"creatives.containersV2.Assets.Gallery.assetDeleteSuccess": "Image deleted successfully.",
|
|
836
|
-
"creatives.containersV2.Assets.Gallery.assetUploadFailed": "Image
|
|
836
|
+
"creatives.containersV2.Assets.Gallery.assetUploadFailed": "Image uploaded failed",
|
|
837
837
|
"creatives.containersV2.Assets.Gallery.assetUploadSuccess": "Image uploaded successfully",
|
|
838
838
|
"creatives.containersV2.Assets.Gallery.backToGallery": "Back to image gallery",
|
|
839
839
|
"creatives.containersV2.Assets.Gallery.delete": "Delete",
|
|
@@ -1091,7 +1091,7 @@
|
|
|
1091
1091
|
"creatives.containersV2.Email.alertMessage": "Alert",
|
|
1092
1092
|
"creatives.containersV2.Email.alphabetically": "Alphabetically",
|
|
1093
1093
|
"creatives.containersV2.Email.alphabeticallyOption": "Alphabetically",
|
|
1094
|
-
"creatives.containersV2.Email.assetUploadFailed": "Image
|
|
1094
|
+
"creatives.containersV2.Email.assetUploadFailed": "Image uploaded failed",
|
|
1095
1095
|
"creatives.containersV2.Email.blankTemplate": "Blank template",
|
|
1096
1096
|
"creatives.containersV2.Email.cancel": "Cancel",
|
|
1097
1097
|
"creatives.containersV2.Email.copyPrimaryLanguage": "Copy Primary Language",
|
package/utils/common.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { Auth } from '@capillarytech/cap-ui-utils';
|
|
3
|
-
|
|
4
3
|
import {
|
|
5
4
|
STORE2DOOR_PLUS_ENABLED,
|
|
6
5
|
TRAI_DLT,
|
|
@@ -263,24 +262,3 @@ export const isTraiDLTEnable = (isFullMode, smsRegister) => {
|
|
|
263
262
|
const isTraiDltFeature = isTraiDltFeatureForOrg && isTraiEnableforLib;
|
|
264
263
|
return isTraiDltFeature;
|
|
265
264
|
};
|
|
266
|
-
|
|
267
|
-
/* function used to encode filename and check file name
|
|
268
|
-
pattern based on the given regex */
|
|
269
|
-
export function createNewFile(Files, allowedExtensionsRegex) {
|
|
270
|
-
const fileObject = Files[0];
|
|
271
|
-
let incorrectFile = false;
|
|
272
|
-
|
|
273
|
-
if (allowedExtensionsRegex && !allowedExtensionsRegex.test(fileObject?.name)) {
|
|
274
|
-
incorrectFile = true;
|
|
275
|
-
return [fileObject, incorrectFile];
|
|
276
|
-
}
|
|
277
|
-
const encodedName = fileObject?.name.replace(/(.+?)(\.[^.]*$|$)/, (match, name, extension) => {
|
|
278
|
-
const filename = encodeURIComponent(name);
|
|
279
|
-
return filename + extension;
|
|
280
|
-
});
|
|
281
|
-
const { type, ...rest } = fileObject;
|
|
282
|
-
const newFile = new File([fileObject], encodedName, { type, ...rest });
|
|
283
|
-
newFile.uid = fileObject.uid;
|
|
284
|
-
return [newFile, incorrectFile];
|
|
285
|
-
}
|
|
286
|
-
|
package/utils/smsCharCountV2.js
CHANGED
|
@@ -30,6 +30,19 @@ function charToSpan(chr, coding, isUnicodeEnabled) {
|
|
|
30
30
|
return <span className={isUnicode ? 'unicode-disabled' : ''}>{isUnicode ? ` \u2588 ` : chr}</span>
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
function getUHDHtml(parts, part) {
|
|
34
|
+
if (parts < 15) {
|
|
35
|
+
udh.find('.udh-total').html('0x0' + parts.toString(16));
|
|
36
|
+
} else {
|
|
37
|
+
udh.find('.udh-total').html('0x' + parts.toString(16));
|
|
38
|
+
}
|
|
39
|
+
if (part < 15) {
|
|
40
|
+
udh.find('.udh-part').html('0x0' + part.toString(16));
|
|
41
|
+
} else {
|
|
42
|
+
udh.find('.udh-part').html('0x' + part.toString(16));
|
|
43
|
+
}
|
|
44
|
+
return udh;
|
|
45
|
+
}
|
|
33
46
|
export function checkUnicode(content) {
|
|
34
47
|
var chars_arr = content.split("");
|
|
35
48
|
for (let i = 0; i < chars_arr.length; i++) {
|
package/utils/test-utils.js
CHANGED
|
@@ -42,5 +42,22 @@ function renderWithRouter(
|
|
|
42
42
|
// re-export everything
|
|
43
43
|
export * from '@testing-library/react';
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Custom text matcher to find element if text is broken/made up of multiple elements.
|
|
47
|
+
* @param {string or regex} textMatch
|
|
48
|
+
* @returns for string entire text should match, use regex for partial matching.
|
|
49
|
+
*/
|
|
50
|
+
export function textContentMatcher(textMatch) {
|
|
51
|
+
return function (_content, node) {
|
|
52
|
+
const hasText = (n) =>
|
|
53
|
+
node.textContent === textMatch || node.textContent.match(textMatch);
|
|
54
|
+
const nodeHasText = hasText(node);
|
|
55
|
+
const childrenDontHaveText = Array.from(n?.children || []).every(
|
|
56
|
+
(child) => !hasText(child),
|
|
57
|
+
);
|
|
58
|
+
return nodeHasText && childrenDontHaveText;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
45
62
|
// override render method
|
|
46
63
|
export { render, renderWithRouter };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { getObjFromQueryParams} from '../v2common';
|
|
3
|
-
|
|
2
|
+
import { getObjFromQueryParams } from '../v2common';
|
|
3
|
+
|
|
4
4
|
describe('Test v2common container', () => {
|
|
5
5
|
it('test getObjFromQueryParams', () => {
|
|
6
6
|
expect(getObjFromQueryParams("?channel=WHATSAPP&mode=CREATE")).toEqual({
|
|
@@ -9,45 +9,3 @@ describe('Test v2common container', () => {
|
|
|
9
9
|
});
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
|
-
|
|
13
|
-
describe('Test createNewFile function', () => {
|
|
14
|
-
const allowedExtensionsRegex = /(\.png|\.jpg)$/i;
|
|
15
|
-
const tempFile = [{
|
|
16
|
-
name: '#image.png',
|
|
17
|
-
type: 'image/jpeg',
|
|
18
|
-
size: 2048,
|
|
19
|
-
uid: 'def456',
|
|
20
|
-
}];
|
|
21
|
-
const expectedFile = new File([tempFile], '%23image.png', {
|
|
22
|
-
type: 'image/jpeg',
|
|
23
|
-
size: 2048,
|
|
24
|
-
uid: 'def456',
|
|
25
|
-
});
|
|
26
|
-
it('should create a new file with encoded name', () => {
|
|
27
|
-
const [resultFile, incorrectFile] = createNewFile(tempFile, allowedExtensionsRegex);
|
|
28
|
-
expect(resultFile).toMatchObject(expectedFile);
|
|
29
|
-
expect(incorrectFile).toBe(false);
|
|
30
|
-
});
|
|
31
|
-
it('should return incorrect file true', () => {
|
|
32
|
-
const tempFileWrong = [{
|
|
33
|
-
name: '#song.mov',
|
|
34
|
-
type: 'video/mov',
|
|
35
|
-
size: 2048,
|
|
36
|
-
uid: 'def4516',
|
|
37
|
-
}];
|
|
38
|
-
|
|
39
|
-
const expectedFileWrong = new File([tempFileWrong], '%23song.mov', {
|
|
40
|
-
type: 'video/mov',
|
|
41
|
-
size: 2048,
|
|
42
|
-
uid: 'def4516',
|
|
43
|
-
});
|
|
44
|
-
const [resultFile, incorrectFile] = createNewFile(tempFileWrong, allowedExtensionsRegex);
|
|
45
|
-
expect(resultFile).toMatchObject(expectedFileWrong);
|
|
46
|
-
expect(incorrectFile).toBe(true);
|
|
47
|
-
});
|
|
48
|
-
it('should return only the updated file as the validation is handled differently for some channels', () => {
|
|
49
|
-
const resultFile = createNewFile(tempFile)[0];
|
|
50
|
-
expect(resultFile).toMatchObject(expectedFile);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
@@ -13,7 +13,6 @@ import isEmpty from 'lodash/isEmpty';
|
|
|
13
13
|
import './index.scss';
|
|
14
14
|
import messages from './messages';
|
|
15
15
|
import { convertPdfToImages } from '../WhatsappDocumentPreview/index';
|
|
16
|
-
import { createNewFile } from '../../utils/common';
|
|
17
16
|
|
|
18
17
|
function CapDocumentUpload(props) {
|
|
19
18
|
const {
|
|
@@ -40,7 +39,7 @@ function CapDocumentUpload(props) {
|
|
|
40
39
|
const { secure_file_path = '', karixFileHandle = '', name = '', file_size = ''} = get(docDataObj, 'metaInfo', {});
|
|
41
40
|
setWhatsappDocParams({
|
|
42
41
|
...whatsappDocParams,
|
|
43
|
-
whatsappDocName: `${
|
|
42
|
+
whatsappDocName: `${name.slice(0, -13)}.pdf`,
|
|
44
43
|
//sliced to show the actual name of the pdf to the user and in the preview, this remove suffix appended to the name on creatives node side
|
|
45
44
|
whatsappDocSize: file_size,
|
|
46
45
|
});
|
|
@@ -70,7 +69,11 @@ function CapDocumentUpload(props) {
|
|
|
70
69
|
e.preventDefault();
|
|
71
70
|
}
|
|
72
71
|
const _URL = window.URL || window.webkitURL;
|
|
73
|
-
|
|
72
|
+
let incorrectFile = false;
|
|
73
|
+
const file = files[0];
|
|
74
|
+
if (!allowedExtensionsRegex.test(file.name)) {
|
|
75
|
+
incorrectFile = true;
|
|
76
|
+
}
|
|
74
77
|
const doc = new FileReader();
|
|
75
78
|
doc.src = _URL.createObjectURL(file);
|
|
76
79
|
const fileParams = {
|
|
@@ -23,7 +23,6 @@ import Gallery from '../../v2Containers/Assets/Gallery';
|
|
|
23
23
|
import { FACEBOOK, RCS, WHATSAPP } from "../../v2Containers/CreativesContainer/constants";
|
|
24
24
|
|
|
25
25
|
import messages from './messages';
|
|
26
|
-
import { createNewFile } from '../../utils/common';
|
|
27
26
|
function CapImageUpload(props) {
|
|
28
27
|
const {
|
|
29
28
|
intl,
|
|
@@ -79,7 +78,11 @@ function CapImageUpload(props) {
|
|
|
79
78
|
e.preventDefault();
|
|
80
79
|
}
|
|
81
80
|
const _URL = window.URL || window.webkitURL;
|
|
82
|
-
|
|
81
|
+
let incorrectFile = false;
|
|
82
|
+
const file = files[0];
|
|
83
|
+
if (!allowedExtensionsRegex.test(file.name)) {
|
|
84
|
+
incorrectFile = true;
|
|
85
|
+
}
|
|
83
86
|
const img = new Image();
|
|
84
87
|
img.src = _URL.createObjectURL(file);
|
|
85
88
|
img.onload = () => {
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
CapSpin,
|
|
19
19
|
} from '@capillarytech/cap-ui-library';
|
|
20
20
|
import messages from './messages';
|
|
21
|
-
import {bytes2Size
|
|
21
|
+
import {bytes2Size} from '../../utils/common';
|
|
22
22
|
import { WHATSAPP } from './constants';
|
|
23
23
|
import './index.scss';
|
|
24
24
|
|
|
@@ -64,7 +64,11 @@ function CapVideoUpload(props) {
|
|
|
64
64
|
e.preventDefault();
|
|
65
65
|
}
|
|
66
66
|
const _URL = window.URL || window.webkitURL;
|
|
67
|
-
|
|
67
|
+
let incorrectFile = false;
|
|
68
|
+
const file = files[0];
|
|
69
|
+
if (!allowedExtensionsRegex.test(file.name)) {
|
|
70
|
+
incorrectFile = true;
|
|
71
|
+
}
|
|
68
72
|
const video = new FileReader();
|
|
69
73
|
video.src = _URL.createObjectURL(file);
|
|
70
74
|
const fileParams = {
|
|
@@ -11,9 +11,11 @@ import PropTypes from 'prop-types';
|
|
|
11
11
|
import React from 'react';
|
|
12
12
|
import _ from 'lodash';
|
|
13
13
|
import { Tabs, Table, Modal} from 'antd';
|
|
14
|
-
import {
|
|
14
|
+
import { connect } from 'react-redux';
|
|
15
|
+
import { CapSpin, CapDrawer, CapButton, CapInput, CapPopover, CapImage, CapCheckbox, CapRadio, CapSelect, CapTable, CapRow, CapColumn, CapNotification, CapUploader, CapHeading, CapIcon, CapTooltip, CapAiSuggestions} from '@capillarytech/cap-ui-library';
|
|
15
16
|
import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
|
|
16
17
|
import LabelHOC from '@capillarytech/cap-ui-library/assets/HOCs/ComponentWithLabelHOC';
|
|
18
|
+
import { createStructuredSelector } from 'reselect';
|
|
17
19
|
import { CAP_SPACE_12, CAP_SPACE_08, FONT_COLOR_05, FONT_COLOR_04 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
18
20
|
import TemplatePreview from '../TemplatePreview';
|
|
19
21
|
import TagList from '../../v2Containers/TagList';
|
|
@@ -24,13 +26,13 @@ import EDMEditor from "../Edmeditor";
|
|
|
24
26
|
import BeeEditor from '../../v2Containers/BeeEditor';
|
|
25
27
|
import CustomPopOver from '../CustomPopOver';
|
|
26
28
|
import messages from './messages';
|
|
29
|
+
import { selectCurrentOrgDetails } from "../../v2Containers/Cap/selectors";
|
|
27
30
|
import './_formBuilder.scss';
|
|
28
31
|
import {updateCharCount, checkUnicode} from "../../utils/smsCharCountV2";
|
|
29
|
-
import { SMS, LINE } from '../../v2Containers/CreativesContainer/constants';
|
|
32
|
+
import { SMS, LINE, ENABLE_AI_SUGGESTIONS } from '../../v2Containers/CreativesContainer/constants';
|
|
30
33
|
import { validateIfTagClosed } from '../../utils/tagValidations';
|
|
31
34
|
import globalMessages from '../../v2Containers/Cap/messages';
|
|
32
35
|
import { convert } from 'html-to-text';
|
|
33
|
-
import { createNewFile } from '../../utils/common';
|
|
34
36
|
const TabPane = Tabs.TabPane;
|
|
35
37
|
const {Column} = Table;
|
|
36
38
|
const {TextArea} = CapInput;
|
|
@@ -2162,14 +2164,13 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2162
2164
|
e.preventDefault();
|
|
2163
2165
|
}
|
|
2164
2166
|
const _URL = window.URL || window.webkitURL;
|
|
2165
|
-
const
|
|
2167
|
+
const file = files[0];
|
|
2166
2168
|
if (val.supportedExtensions) {
|
|
2167
2169
|
const allowedExtensions = /(\.bmp|\.jpeg|\.png|\.gif|\.jpg)$/i;
|
|
2168
|
-
if (!allowedExtensions.exec(
|
|
2169
|
-
this.callChildEvent({
|
|
2170
|
+
if (!allowedExtensions.exec(file.name)) {
|
|
2171
|
+
this.callChildEvent({file, type: 'wrong file'}, val, val.submitAction);
|
|
2170
2172
|
}
|
|
2171
2173
|
}
|
|
2172
|
-
const file = createNewFile(files)[0];
|
|
2173
2174
|
const img = new Image();
|
|
2174
2175
|
img.src = _URL.createObjectURL(file);
|
|
2175
2176
|
img.onload = () => {
|
|
@@ -2280,6 +2281,12 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2280
2281
|
const messageContent = isVersionEnable ? formData[`${currentTab - 1}`][val.id] : formData[val.id];
|
|
2281
2282
|
const { MISSING_TAG_ERROR, UNSUPPORTED_TAG_ERROR, TAG_BRACKET_COUNT_MISMATCH_ERROR } = errorMessageForTags;
|
|
2282
2283
|
const { formatMessage } = this.props.intl;
|
|
2284
|
+
|
|
2285
|
+
const { accessibleFeatures = [] } = this.props.currentOrgDetails || {};
|
|
2286
|
+
const hasAiSuggestionsEnabled = accessibleFeatures.includes(
|
|
2287
|
+
ENABLE_AI_SUGGESTIONS
|
|
2288
|
+
);
|
|
2289
|
+
|
|
2283
2290
|
let errorMessageText = false;
|
|
2284
2291
|
switch (errorType) {
|
|
2285
2292
|
case MISSING_TAG_ERROR:
|
|
@@ -2315,6 +2322,16 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
2315
2322
|
disabled={val.disabled}
|
|
2316
2323
|
cols={cols}
|
|
2317
2324
|
/>
|
|
2325
|
+
{this.props.schema.channel === "SMS" && this.props.fetchAiSuggestions && hasAiSuggestionsEnabled && (
|
|
2326
|
+
<CapAiSuggestions
|
|
2327
|
+
style={{ bottom: "1rem" }}
|
|
2328
|
+
text={messageContent || ""}
|
|
2329
|
+
setText={(x) => {
|
|
2330
|
+
this.updateFormData(x, val);
|
|
2331
|
+
}}
|
|
2332
|
+
getCompletions={this.props.fetchAiSuggestions}
|
|
2333
|
+
/>
|
|
2334
|
+
)}
|
|
2318
2335
|
</CapColumn>
|
|
2319
2336
|
);
|
|
2320
2337
|
}
|
|
@@ -3619,7 +3636,12 @@ FormBuilder.propTypes = {
|
|
|
3619
3636
|
setDrawerVisibility: PropTypes.bool,
|
|
3620
3637
|
capDrawerContent: PropTypes.array,
|
|
3621
3638
|
isFullMode: PropTypes.bool,
|
|
3622
|
-
|
|
3639
|
+
fetchAiSuggestions: PropTypes.func,
|
|
3640
|
+
currentOrgDetails: PropTypes.object,
|
|
3623
3641
|
};
|
|
3624
3642
|
|
|
3625
|
-
|
|
3643
|
+
const mapStateToProps = createStructuredSelector({
|
|
3644
|
+
currentOrgDetails: selectCurrentOrgDetails(),
|
|
3645
|
+
});
|
|
3646
|
+
|
|
3647
|
+
export default connect(mapStateToProps)(injectIntl(FormBuilder));
|
|
@@ -13,10 +13,8 @@ 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 Bugsnag from '@bugsnag/js';
|
|
17
16
|
import { CapHeading, CapHeader, CapInput, CapButton, CapSpin, CapIcon, CapDropdown, CapMenu, CapCustomCard, CapSlideBox, CapLabel, CapIllustration} from '@capillarytech/cap-ui-library';
|
|
18
17
|
import { Popover } from 'antd';
|
|
19
|
-
import { createNewFile } from '../../../utils/common';
|
|
20
18
|
import makeSelectGallery from './selectors';
|
|
21
19
|
import messages from './messages';
|
|
22
20
|
import * as actions from './actions';
|
|
@@ -233,18 +231,16 @@ export class Gallery extends React.Component { // eslint-disable-line react/pref
|
|
|
233
231
|
const _URL = window.URL || window.webkitURL;
|
|
234
232
|
for (const file in files) {
|
|
235
233
|
if (files.hasOwnProperty(file)) {
|
|
236
|
-
const tempFile = files[file];
|
|
237
|
-
const [uploadFile] = createNewFile([tempFile]);
|
|
238
234
|
const img = new Image();
|
|
239
235
|
const that = this;
|
|
240
|
-
img.src = _URL.createObjectURL(
|
|
236
|
+
img.src = _URL.createObjectURL(files[file]);
|
|
241
237
|
img.onload = function () {
|
|
242
238
|
const fileParams = {
|
|
243
239
|
width: this.width,
|
|
244
240
|
height: this.height,
|
|
245
241
|
isGeneratePreview: true,
|
|
246
242
|
};
|
|
247
|
-
that.props.actions.uploadAsset(
|
|
243
|
+
that.props.actions.uploadAsset(files[file], 'image', fileParams);
|
|
248
244
|
};
|
|
249
245
|
}
|
|
250
246
|
}
|
|
@@ -311,10 +307,6 @@ export class Gallery extends React.Component { // eslint-disable-line react/pref
|
|
|
311
307
|
const currentChannel = 'gallery';
|
|
312
308
|
const { searchLoader, searchText } = this.state;
|
|
313
309
|
const cardDataList = templates?.length ? _.map(templates, (template) => {
|
|
314
|
-
const nameParts = template.name.split('.');
|
|
315
|
-
if (encodeURIComponent(decodeURIComponent(nameParts[0])) === nameParts[0]) {
|
|
316
|
-
template.name = `${decodeURIComponent(nameParts[0])}.${nameParts[1]}`;
|
|
317
|
-
}
|
|
318
310
|
const templateData =
|
|
319
311
|
{
|
|
320
312
|
key: `${currentChannel}-card-${template.name}`,
|
|
@@ -398,26 +390,9 @@ export class Gallery extends React.Component { // eslint-disable-line react/pref
|
|
|
398
390
|
const by = commonUtil.getUserNameById(parseInt(this.state.selectedAsset.updatedBy, 10), commonUtil.getMergedUserList(this.props.Gallery.userList));
|
|
399
391
|
const width = this.state.selectedAsset.metaInfo.width;
|
|
400
392
|
const height = this.state.selectedAsset.metaInfo.height;
|
|
401
|
-
/*
|
|
402
|
-
splitting the name on . and verifying
|
|
403
|
-
whether the filename is already encoded or not,
|
|
404
|
-
if yes decoding it ,to be shown on ui
|
|
405
|
-
*/
|
|
406
|
-
const nameParts = this.state.selectedAsset.name.split('.');
|
|
407
|
-
let updatedTitle = this.state.selectedAsset.name;
|
|
408
|
-
try {
|
|
409
|
-
if (encodeURIComponent(decodeURIComponent(nameParts[0])) === nameParts[0]) {
|
|
410
|
-
updatedTitle = `${decodeURIComponent(nameParts[0])}.${nameParts[1]}`;
|
|
411
|
-
}
|
|
412
|
-
} catch (error) {
|
|
413
|
-
Bugsnag.leaveBreadcrumb("Error decoding the string:", error);
|
|
414
|
-
Bugsnag.notify(error, (event) => {
|
|
415
|
-
event.severity = "error";
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
393
|
const slideboxHeader = (<div>
|
|
419
394
|
<CapHeader
|
|
420
|
-
title={
|
|
395
|
+
title={this.state.selectedAsset.name}
|
|
421
396
|
description={<FormattedMessage
|
|
422
397
|
{...messages.lastUpdated}
|
|
423
398
|
values={{on, by }}
|
|
@@ -80,7 +80,7 @@ export default defineMessages({
|
|
|
80
80
|
},
|
|
81
81
|
assetUploadFailed: {
|
|
82
82
|
id: 'creatives.containersV2.Assets.Gallery.assetUploadFailed',
|
|
83
|
-
defaultMessage: 'Image
|
|
83
|
+
defaultMessage: 'Image uploaded failed',
|
|
84
84
|
},
|
|
85
85
|
assetDeleteSuccess: {
|
|
86
86
|
id: 'creatives.containersV2.Assets.Gallery.assetDeleteSuccess',
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from '../../v2Containers/App/constants';
|
|
14
14
|
// import {makeSelectOrgId} from './selectors';
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
function* authorize(user) {
|
|
17
17
|
try {
|
|
18
18
|
const res = yield call(Api.authorize, user);
|
|
19
19
|
yield call(LocalStorage.saveItem, 'token', res.token);
|
|
@@ -41,14 +41,13 @@ function* switchOrg({orgID}) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
function* loginFlow() {
|
|
45
|
+
const condition = true;
|
|
46
46
|
while (condition) {
|
|
47
47
|
const { user } = yield take(types.LOGIN_REQUEST);
|
|
48
48
|
const task = yield fork(authorize, user);
|
|
49
49
|
const action = yield take([types.LOGOUT_REQUEST_V2, types.LOGIN_FAILURE]);
|
|
50
50
|
if (action.type === types.LOGOUT_REQUEST_V2) {
|
|
51
|
-
condition = false;
|
|
52
51
|
yield cancel(task);
|
|
53
52
|
}
|
|
54
53
|
// yield call(LocalStorage.clearItem, 'token');
|