@capillarytech/creatives-library 7.17.12 → 7.17.14-alpha.0
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/Ckeditor/index.js +2 -2
- package/containers/TagList/constants.js +10 -1
- package/package.json +1 -1
- package/utils/common.js +59 -0
- package/utils/commonUtils.js +6 -0
- package/v2Components/CapTagList/index.js +21 -27
- package/v2Components/Ckeditor/index.js +2 -2
- package/v2Components/Ckeditor/tests/index.test.js +44 -0
- package/v2Containers/Cap/constants.js +3 -3
- package/v2Containers/Email/initialSchema.js +1 -1
- package/v2Containers/LanguageProvider/reducer.js +3 -1
- package/v2Containers/LanguageProvider/tests/reducer.test.js +9 -0
- package/v2Containers/Line/Container/Text/index.js +11 -13
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +3 -3
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +120 -120
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +16 -16
- package/v2Containers/TagList/index.js +14 -8
- package/v2Containers/TagList/messages.js +2 -1
- package/v2Containers/TagList/tests/TagList.test.js +43 -0
- package/v2Containers/TagList/tests/mockdata.js +148 -0
- package/v2Containers/TagList/tests/utils.test.js +17 -0
- package/v2Containers/TagList/utils.js +15 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +16 -16
|
@@ -13,14 +13,14 @@ import React from 'react';
|
|
|
13
13
|
import _ from 'lodash';
|
|
14
14
|
// import messages from './messages';
|
|
15
15
|
const loadScript = require('load-script');
|
|
16
|
-
const defaultScriptUrl = "https://storage.crm.n.content-cdn.io/
|
|
16
|
+
const defaultScriptUrl = "https://storage.crm.n.content-cdn.io/ckeditor_full/ckeditor/ckeditor.js";
|
|
17
17
|
const user = localStorage.getItem('user');
|
|
18
18
|
let locale = 'en';
|
|
19
19
|
if (user && JSON.parse(user).lang) {
|
|
20
20
|
locale = JSON.parse(user).lang;
|
|
21
21
|
}
|
|
22
22
|
const CKEditorConfig = {
|
|
23
|
-
skin: 'moono',
|
|
23
|
+
skin: 'moono-lisa',
|
|
24
24
|
toolbar: [
|
|
25
25
|
{ name: 'document', items: ['Source', '-'] },
|
|
26
26
|
{ name: 'clipboard', items: ['Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] },
|
|
@@ -18,4 +18,13 @@ export const GET_TRANSLATION_MAPPED = {
|
|
|
18
18
|
'ja-JP': 'ja-JP',
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export const
|
|
21
|
+
export const JAPANESE_HIDE_DATE_TAGS = [
|
|
22
|
+
"mm/dd/yyyy",
|
|
23
|
+
"dd/mm/yyyy",
|
|
24
|
+
"mm/dd/yy",
|
|
25
|
+
"dd Mon yyyy",
|
|
26
|
+
"Day, Mon dd, yy",
|
|
27
|
+
"dd.mm.yy",
|
|
28
|
+
"dd Mon",
|
|
29
|
+
"dd/m/yyyy",
|
|
30
|
+
];
|
package/package.json
CHANGED
package/utils/common.js
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
CARD_RELATED_TAGS,
|
|
7
7
|
CARD_BASED_SCOPE,
|
|
8
8
|
} from '../containers/App/constants';
|
|
9
|
+
import { apiMessageFormatHandler } from './commonUtils';
|
|
9
10
|
|
|
10
11
|
export function getUserNameById(userId, allUserList) {
|
|
11
12
|
let userName = "";
|
|
@@ -262,3 +263,61 @@ export const isTraiDLTEnable = (isFullMode, smsRegister) => {
|
|
|
262
263
|
const isTraiDltFeature = isTraiDltFeatureForOrg && isTraiEnableforLib;
|
|
263
264
|
return isTraiDltFeature;
|
|
264
265
|
};
|
|
266
|
+
|
|
267
|
+
export const intlKeyGenerator = (value = "") => {
|
|
268
|
+
if (value && typeof value === "string")
|
|
269
|
+
return value.replace(/[^a-zA-Z0-9_]/g, "");
|
|
270
|
+
return value.props.defaultMessage.replace(/[^a-zA-Z0-9_]/g, "");
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
export const handleInjectedData = (data, scope) => {
|
|
274
|
+
let tagType;
|
|
275
|
+
for (const tagKey in data) {
|
|
276
|
+
if (data.hasOwnProperty(tagKey)) {
|
|
277
|
+
const tag = data[tagKey];
|
|
278
|
+
|
|
279
|
+
if (tag?.name === "Registration custom fields") {
|
|
280
|
+
tagType = "CustomTagMessage";
|
|
281
|
+
} else if (tag?.name === "Customer extended fields") {
|
|
282
|
+
tagType = "ExtendedTagMessage";
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (tag?.name) {
|
|
286
|
+
const name = tag?.name;
|
|
287
|
+
const key = intlKeyGenerator(name);
|
|
288
|
+
const id = tagType
|
|
289
|
+
? `${scope}.${key}_name.${tagType}`
|
|
290
|
+
: `${scope}.${key}`;
|
|
291
|
+
|
|
292
|
+
tag["name"] = apiMessageFormatHandler(id, name);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (tag["subtags"]) {
|
|
296
|
+
for (const subtagKey in tag["subtags"]) {
|
|
297
|
+
if (tag["subtags"].hasOwnProperty(subtagKey)) {
|
|
298
|
+
const subtag = tag["subtags"][subtagKey];
|
|
299
|
+
if (subtag?.name) {
|
|
300
|
+
const name = subtag?.name;
|
|
301
|
+
const key = intlKeyGenerator(name);
|
|
302
|
+
const id = tagType
|
|
303
|
+
? `${scope}.${key}_name.${tagType}`
|
|
304
|
+
: `${scope}.${key}`;
|
|
305
|
+
|
|
306
|
+
subtag["name"] = apiMessageFormatHandler(id, name);
|
|
307
|
+
}
|
|
308
|
+
if (subtag?.desc) {
|
|
309
|
+
const desc = subtag?.desc;
|
|
310
|
+
const key = intlKeyGenerator(desc);
|
|
311
|
+
const id = tagType
|
|
312
|
+
? `${scope}.${key}_desc.${tagType}`
|
|
313
|
+
: `${scope}.${key}`;
|
|
314
|
+
|
|
315
|
+
subtag["desc"] = apiMessageFormatHandler(id, desc);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return data;
|
|
323
|
+
};
|
|
@@ -19,8 +19,14 @@ import { CARD_RELATED_TAGS } from '../../containers/App/constants';
|
|
|
19
19
|
import { hasCardBasedScope } from '../../utils/common';
|
|
20
20
|
import moment from 'moment';
|
|
21
21
|
import { FONT_COLOR_05 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
GET_TRANSLATION_MAPPED,
|
|
24
|
+
JAPANESE_HELP_TEXT,
|
|
25
|
+
TAG_TRANSLATION_DOC,
|
|
26
|
+
} from "../../containers/TagList/constants";
|
|
23
27
|
import { HIDE_ENGAGEMENT_CHANNELS } from '../../v2Containers/App/constants';
|
|
28
|
+
import { hidingDateTagsForJpLocale } from '../../v2Containers/TagList/utils';
|
|
29
|
+
|
|
24
30
|
|
|
25
31
|
const {Search} = CapInput;
|
|
26
32
|
const {CapTreeNode} = CapTree;
|
|
@@ -156,9 +162,9 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
156
162
|
};
|
|
157
163
|
|
|
158
164
|
renderTags(tags, searchString = '') {
|
|
159
|
-
const { disableRelatedTags, childTagsToDisable, parentTagstoDisable, showCardsRelatedTags } = this
|
|
160
|
-
const { accessibleFeatures = [] } = this
|
|
161
|
-
const
|
|
165
|
+
const { disableRelatedTags, childTagsToDisable, parentTagstoDisable, showCardsRelatedTags } = this?.props?.disableTagsDetails;
|
|
166
|
+
const { accessibleFeatures = [] } = this?.props?.currentOrgDetails || {};
|
|
167
|
+
const hideDateTagsForJpLocale = accessibleFeatures.includes(HIDE_ENGAGEMENT_CHANNELS);
|
|
162
168
|
const list = [];
|
|
163
169
|
const loyaltyAttrDisableText = <FormattedMessage {...messages.loyaltyAttributeDisable} />;
|
|
164
170
|
let clonedTags = _.cloneDeep(tags);
|
|
@@ -174,7 +180,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
174
180
|
if (_.has(val, 'subtags')) {
|
|
175
181
|
const disabled = disableRelatedTags ? parentTagstoDisable.includes(key) : false;
|
|
176
182
|
const temp = this.renderTags(val.subtags, '', disabled);
|
|
177
|
-
const
|
|
183
|
+
const tagValue = (
|
|
178
184
|
<CapTreeNode
|
|
179
185
|
title={disabled ? <CapTooltip title={loyaltyAttrDisableText}>{val.name}</CapTooltip> : val.name}
|
|
180
186
|
tag={val}
|
|
@@ -184,13 +190,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
184
190
|
{temp}
|
|
185
191
|
</CapTreeNode>
|
|
186
192
|
);
|
|
187
|
-
|
|
188
|
-
if (!JAPANESE_HIDE_DATE_ARRAY.includes(val.name)) {
|
|
189
|
-
list.push(tempNode);
|
|
190
|
-
}
|
|
191
|
-
} else {
|
|
192
|
-
list.push(tempNode);
|
|
193
|
-
}
|
|
193
|
+
hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tagValue);
|
|
194
194
|
} else if (searchString === '' || !searchString || ((val.name || '').toLowerCase().indexOf(searchString.toLowerCase()) !== -1)) {
|
|
195
195
|
const childDisabled = disableRelatedTags ? childTagsToDisable.includes(key) : false;
|
|
196
196
|
const tempNode = (
|
|
@@ -202,13 +202,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
202
202
|
disabled={childDisabled}
|
|
203
203
|
>
|
|
204
204
|
</CapTreeNode>);
|
|
205
|
-
|
|
206
|
-
if (!JAPANESE_HIDE_DATE_ARRAY.includes(val.name)) {
|
|
207
|
-
list.push(tempNode);
|
|
208
|
-
}
|
|
209
|
-
} else {
|
|
210
|
-
list.push(tempNode);
|
|
211
|
-
}
|
|
205
|
+
hidingDateTagsForJpLocale(hideDateTagsForJpLocale, val, list, tempNode);
|
|
212
206
|
}
|
|
213
207
|
});
|
|
214
208
|
return list;
|
|
@@ -294,15 +288,15 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
294
288
|
>
|
|
295
289
|
{contentSection}
|
|
296
290
|
</CapModal> :
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
291
|
+
<CapPopover
|
|
292
|
+
visible={visible}
|
|
293
|
+
onVisibleChange={this.togglePopoverVisibility}
|
|
294
|
+
content={contentSection}
|
|
295
|
+
trigger="click"
|
|
296
|
+
placement="rightTop"
|
|
303
297
|
>
|
|
304
|
-
|
|
305
|
-
|
|
298
|
+
<CapButton isAddBtn type="flat">{label || ''}</CapButton>
|
|
299
|
+
</CapPopover>
|
|
306
300
|
}
|
|
307
301
|
<CapModal
|
|
308
302
|
visible={this.state.showModal}
|
|
@@ -13,14 +13,14 @@ import React from 'react';
|
|
|
13
13
|
import _ from 'lodash';
|
|
14
14
|
// import messages from './messages';
|
|
15
15
|
const loadScript = require('load-script');
|
|
16
|
-
const defaultScriptUrl = "https://storage.crm.n.content-cdn.io/
|
|
16
|
+
const defaultScriptUrl = "https://storage.crm.n.content-cdn.io/ckeditor_full/ckeditor/ckeditor.js";
|
|
17
17
|
const user = localStorage.getItem('user');
|
|
18
18
|
let locale = 'en';
|
|
19
19
|
if (user && JSON.parse(user).lang) {
|
|
20
20
|
locale = JSON.parse(user).lang;
|
|
21
21
|
}
|
|
22
22
|
const CKEditorConfig = {
|
|
23
|
-
skin: 'moono',
|
|
23
|
+
skin: 'moono-lisa',
|
|
24
24
|
toolbar: [
|
|
25
25
|
{ name: 'document', items: ['Source', '-'] },
|
|
26
26
|
{ name: 'clipboard', items: ['Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] },
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, { Component } from "react";
|
|
2
|
+
import { injectIntl } from "react-intl";
|
|
3
|
+
import "@testing-library/jest-dom";
|
|
4
|
+
import { render, getByText, screen } from "../../../utils/test-utils";
|
|
5
|
+
import Ckeditor from "../index";
|
|
6
|
+
|
|
7
|
+
const initializeComponent = () => {
|
|
8
|
+
const Component = injectIntl(Ckeditor);
|
|
9
|
+
|
|
10
|
+
//const originalComponentDidMount = Ckeditor.prototype.componentDidMount;
|
|
11
|
+
Ckeditor.prototype.componentDidMount = jest.fn();
|
|
12
|
+
Ckeditor.prototype.handleContentChange = jest.fn();
|
|
13
|
+
|
|
14
|
+
//Render with default props.
|
|
15
|
+
return render(<Component />);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe("Load Ckeditor", () => {
|
|
19
|
+
it("Test if Ckeditor Mounts", () => {
|
|
20
|
+
initializeComponent();
|
|
21
|
+
|
|
22
|
+
expect(Ckeditor.prototype.componentDidMount).toHaveBeenCalled();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("Test if Ckeditor un-Mounts", () => {
|
|
26
|
+
// Spy on the componentWillUnmount method
|
|
27
|
+
const componentWillUnmountSpy = jest.spyOn(
|
|
28
|
+
Ckeditor.prototype,
|
|
29
|
+
"componentWillUnmount"
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// Render the component
|
|
33
|
+
const { unmount } = initializeComponent();
|
|
34
|
+
|
|
35
|
+
// Manually unmount the component (simulate unmounting)
|
|
36
|
+
unmount();
|
|
37
|
+
|
|
38
|
+
// Assert that componentWillUnmount has been called
|
|
39
|
+
expect(componentWillUnmountSpy).toHaveBeenCalled();
|
|
40
|
+
|
|
41
|
+
// Clean up the spy
|
|
42
|
+
componentWillUnmountSpy.mockRestore();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -15,9 +15,9 @@ export const GET_USER_DATA_REQUEST = 'cap/GET_USER_DATA_REQUEST_V2';
|
|
|
15
15
|
export const GET_USER_DATA_SUCCESS = 'cap/GET_USER_DATA_SUCCESS_V2';
|
|
16
16
|
export const GET_USER_DATA_FAILURE = 'cap/GET_USER_DATA_FAILURE_V2';
|
|
17
17
|
|
|
18
|
-
export const GET_SCHEMA_FOR_ENTITY_FAILURE = 'cap/
|
|
19
|
-
export const GET_SCHEMA_FOR_ENTITY_REQUEST = 'cap/
|
|
20
|
-
export const GET_SCHEMA_FOR_ENTITY_SUCCESS = 'cap/
|
|
18
|
+
export const GET_SCHEMA_FOR_ENTITY_FAILURE = 'cap/GET_SCHEMA_FOR_ENTITY_FAILURE_V2';
|
|
19
|
+
export const GET_SCHEMA_FOR_ENTITY_REQUEST = 'cap/GET_SCHEMA_FOR_ENTITY_REQUEST_V2';
|
|
20
|
+
export const GET_SCHEMA_FOR_ENTITY_SUCCESS = 'cap/GET_SCHEMA_FOR_ENTITY_SUCCESS_V2';
|
|
21
21
|
export const CLEAR_META_ENTITIES = 'cap/CLEAR_META_ENTITIES';
|
|
22
22
|
export const HIDE_TAGS = 'cap/HIDE_TAGS';
|
|
23
23
|
|
|
@@ -17,7 +17,9 @@ const initialState = fromJS({
|
|
|
17
17
|
function languageProviderReducer(state = initialState, action) {
|
|
18
18
|
switch (action.type) {
|
|
19
19
|
case types.GET_LOCIZ_MESSAGE_REQUEST:
|
|
20
|
-
return state
|
|
20
|
+
return state
|
|
21
|
+
.set('localeLoading', true)
|
|
22
|
+
.set('locale', action.locale);
|
|
21
23
|
case types.GET_LOCIZ_MESSAGE_SUCCESS:
|
|
22
24
|
return state
|
|
23
25
|
.set('localeLoading', false)
|
|
@@ -3,6 +3,7 @@ import { fromJS } from 'immutable';
|
|
|
3
3
|
import languageProviderReducer from '../reducer';
|
|
4
4
|
import {
|
|
5
5
|
CHANGE_LOCALE,
|
|
6
|
+
GET_LOCIZ_MESSAGE_REQUEST,
|
|
6
7
|
} from '../constants';
|
|
7
8
|
|
|
8
9
|
describe('languageProviderReducer', () => {
|
|
@@ -21,4 +22,12 @@ describe('languageProviderReducer', () => {
|
|
|
21
22
|
messages: {},
|
|
22
23
|
});
|
|
23
24
|
});
|
|
25
|
+
|
|
26
|
+
it('make locize message request', () => {
|
|
27
|
+
expect(languageProviderReducer(undefined, { type: GET_LOCIZ_MESSAGE_REQUEST, locale: 'de' }).toJS()).toEqual({
|
|
28
|
+
locale: "de",
|
|
29
|
+
localeLoading: true,
|
|
30
|
+
messages: {},
|
|
31
|
+
});
|
|
32
|
+
});
|
|
24
33
|
});
|
|
@@ -56,7 +56,7 @@ export const LineText = ({
|
|
|
56
56
|
const [messageTitle, updateTextMessageTitle] = useState('');
|
|
57
57
|
const [isDrawerRequired, updateDrawerRequirement] = useState(false);
|
|
58
58
|
const [selectedTemplate, updateSelectedTemplate] = useState();
|
|
59
|
-
const [translationLang, updateTranslationLang] = useState('');
|
|
59
|
+
const [translationLang, updateTranslationLang] = useState('en');
|
|
60
60
|
|
|
61
61
|
useEffect(() => {
|
|
62
62
|
const { messageTitle = '', messageContent = '', type, isInit } = content;
|
|
@@ -73,19 +73,17 @@ export const LineText = ({
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
}, [content]);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
76
|
+
|
|
77
|
+
//To Find from which locale user is loggedin
|
|
80
78
|
useEffect(() => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
79
|
+
const user = localStorage.getItem("user");
|
|
80
|
+
let locale = "en";
|
|
81
|
+
if (user) {
|
|
82
|
+
locale = JSON.parse(user)?.lang || locale;
|
|
83
|
+
}
|
|
84
|
+
locale = GET_TRANSLATION_MAPPED?.[locale];
|
|
85
|
+
moment.locale(locale);
|
|
86
|
+
updateTranslationLang(locale);
|
|
89
87
|
}, []);
|
|
90
88
|
|
|
91
89
|
useEffect(() => {
|
|
@@ -23058,7 +23058,7 @@ new message content.",
|
|
|
23058
23058
|
</div>
|
|
23059
23059
|
</ComponentWithLabelHOC__CapComponentStyled>
|
|
23060
23060
|
</_class>
|
|
23061
|
-
<Connect(UserIsAuthenticated(Connect(TagList)))
|
|
23061
|
+
<Connect(UserIsAuthenticated(Connect(InjectIntl(TagList))))
|
|
23062
23062
|
id="undefined_tags"
|
|
23063
23063
|
injectedTags={Object {}}
|
|
23064
23064
|
key="undefined_tags"
|
|
@@ -23079,7 +23079,7 @@ new message content.",
|
|
|
23079
23079
|
tags={Array []}
|
|
23080
23080
|
userLocale="en-US"
|
|
23081
23081
|
>
|
|
23082
|
-
<UserIsAuthenticated(Connect(TagList))
|
|
23082
|
+
<UserIsAuthenticated(Connect(InjectIntl(TagList)))
|
|
23083
23083
|
authData={
|
|
23084
23084
|
Object {
|
|
23085
23085
|
"app": Object {},
|
|
@@ -23125,7 +23125,7 @@ new message content.",
|
|
|
23125
23125
|
tags={Array []}
|
|
23126
23126
|
userLocale="en-US"
|
|
23127
23127
|
/>
|
|
23128
|
-
</Connect(UserIsAuthenticated(Connect(TagList)))>
|
|
23128
|
+
</Connect(UserIsAuthenticated(Connect(InjectIntl(TagList))))>
|
|
23129
23129
|
<CapDrawer
|
|
23130
23130
|
content={
|
|
23131
23131
|
<React.Fragment>
|