@capillarytech/creatives-library 7.17.22-alpha.0 → 7.17.23
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/config/app.js +0 -1
- package/containers/App/constants.js +0 -1
- package/package.json +1 -1
- package/utils/common.js +59 -6
- package/utils/commonUtils.js +6 -0
- package/utils/tests/common.test.js +81 -1
- package/v2Components/CapTagList/index.js +14 -3
- package/v2Components/CmsTemplatesComponent/index.js +0 -1
- package/v2Components/CmsTemplatesComponent/messages.js +0 -4
- package/v2Components/TemplatePreview/index.js +3 -8
- package/v2Containers/Cap/constants.js +3 -3
- 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/SlideBoxContent.js +0 -2
- package/v2Containers/LanguageProvider/reducer.js +3 -1
- package/v2Containers/LanguageProvider/tests/reducer.test.js +9 -0
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +3 -3
- package/v2Containers/Line/Container/index.js +0 -4
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +120 -120
- package/v2Containers/Sms/Create/tests/sagas.test.js +82 -0
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +16 -16
- package/v2Containers/TagList/index.js +40 -22
- package/v2Containers/TagList/messages.js +2 -1
- package/v2Containers/TagList/tests/TagList.test.js +41 -0
- package/v2Containers/TagList/tests/mockdata.js +108 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +16 -16
- package/assets/Line_Preview_English.svg +0 -24
- package/assets/Line_Preview_Japanese.svg +0 -24
package/config/app.js
CHANGED
|
@@ -16,7 +16,6 @@ const config = {
|
|
|
16
16
|
accountConfig: (strs, accountId) => `${window.location.origin}/org/config/AccountAdd?q=a&channelId=2&accountId=${accountId}&edit=1`,
|
|
17
17
|
},
|
|
18
18
|
development: {
|
|
19
|
-
// api_endpoint: 'http://localhost:2022/arya/api/v1/creatives',
|
|
20
19
|
api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
|
|
21
20
|
campaigns_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/campaigns',
|
|
22
21
|
campaigns_api_org_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/org/campaign',
|
|
@@ -6,7 +6,6 @@ export const STORE2DOOR_PLUS_ENABLED = 'STORE2DOOR_PLUS_ENABLED';
|
|
|
6
6
|
export const TRAI_DLT = 'TRAI_DLT';
|
|
7
7
|
export const CARD_BASED_SCOPE = 'CARD_BASED_SCOPE';
|
|
8
8
|
export const HOSPITALITY_BASED_SCOPE = 'HOSPITALITY_BASED_SCOPE';
|
|
9
|
-
export const JP_LOCALE_HIDE_FEATURE = 'JP_LOCALE_HIDE_FEATURE';
|
|
10
9
|
|
|
11
10
|
export const CARD_RELATED_TAGS = [
|
|
12
11
|
'card_series',
|
package/package.json
CHANGED
package/utils/common.js
CHANGED
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
CARD_BASED_SCOPE,
|
|
8
8
|
HOSPITALITY_RELATED_TAGS,
|
|
9
9
|
HOSPITALITY_BASED_SCOPE,
|
|
10
|
-
JP_LOCALE_HIDE_FEATURE,
|
|
11
10
|
} from '../containers/App/constants';
|
|
11
|
+
import { apiMessageFormatHandler } from './commonUtils';
|
|
12
12
|
|
|
13
13
|
export function getUserNameById(userId, allUserList) {
|
|
14
14
|
let userName = "";
|
|
@@ -61,11 +61,6 @@ export const hasHospitalityBasedScope = Auth.hasFeatureAccess.bind(
|
|
|
61
61
|
HOSPITALITY_BASED_SCOPE,
|
|
62
62
|
);
|
|
63
63
|
|
|
64
|
-
export const hasJPLocaleHideFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
65
|
-
null,
|
|
66
|
-
JP_LOCALE_HIDE_FEATURE,
|
|
67
|
-
);
|
|
68
|
-
|
|
69
64
|
//filtering tags based on scope
|
|
70
65
|
export const filterTags = (tagsToFilter, tagsList) => tagsList?.filter(
|
|
71
66
|
(tag) => !tagsToFilter?.includes(tag?.definition?.value)
|
|
@@ -282,3 +277,61 @@ export const isTraiDLTEnable = (isFullMode, smsRegister) => {
|
|
|
282
277
|
const isTraiDltFeature = isTraiDltFeatureForOrg && isTraiEnableforLib;
|
|
283
278
|
return isTraiDltFeature;
|
|
284
279
|
};
|
|
280
|
+
|
|
281
|
+
export const intlKeyGenerator = (value = "") => {
|
|
282
|
+
return value.replace(/[^a-zA-Z0-9_]/g, "");
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
export const handleInjectedData = (data, scope) => {
|
|
286
|
+
let temp = _.cloneDeep(data);
|
|
287
|
+
let tagType;
|
|
288
|
+
for (const tagKey in temp) {
|
|
289
|
+
if (temp.hasOwnProperty(tagKey)) {
|
|
290
|
+
const tag = temp[tagKey];
|
|
291
|
+
|
|
292
|
+
if (tag?.name === "Registration custom fields") {
|
|
293
|
+
tagType = "CustomTagMessage";
|
|
294
|
+
} else if (tag?.name === "Customer extended fields") {
|
|
295
|
+
tagType = "ExtendedTagMessage";
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (tag?.name) {
|
|
299
|
+
const name = tag?.name;
|
|
300
|
+
const key = intlKeyGenerator(name);
|
|
301
|
+
const id = tagType
|
|
302
|
+
? `${scope}.${key}_name.${tagType}`
|
|
303
|
+
: `${scope}.${key}`;
|
|
304
|
+
|
|
305
|
+
tag["name"] = apiMessageFormatHandler(id, name);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (tag["subtags"]) {
|
|
309
|
+
for (const subtagKey in tag["subtags"]) {
|
|
310
|
+
if (tag["subtags"].hasOwnProperty(subtagKey)) {
|
|
311
|
+
const subtag = tag["subtags"][subtagKey];
|
|
312
|
+
if (subtag?.name) {
|
|
313
|
+
const name = subtag?.name;
|
|
314
|
+
const key = intlKeyGenerator(name);
|
|
315
|
+
const id = tagType
|
|
316
|
+
? `${scope}.${key}_name.${tagType}`
|
|
317
|
+
: `${scope}.${key}`;
|
|
318
|
+
|
|
319
|
+
subtag["name"] = apiMessageFormatHandler(id, name);
|
|
320
|
+
}
|
|
321
|
+
if (subtag?.desc) {
|
|
322
|
+
const desc = subtag?.desc;
|
|
323
|
+
const key = intlKeyGenerator(desc);
|
|
324
|
+
const id = tagType
|
|
325
|
+
? `${scope}.${key}_desc.${tagType}`
|
|
326
|
+
: `${scope}.${key}`;
|
|
327
|
+
|
|
328
|
+
subtag["desc"] = apiMessageFormatHandler(id, desc);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
tagType="";
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return temp;
|
|
337
|
+
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl';
|
|
1
3
|
import "@testing-library/jest-dom";
|
|
2
|
-
import { filterTags, getTreeStructuredTags } from "../common";
|
|
4
|
+
import { filterTags, getTreeStructuredTags, handleInjectedData } from "../common";
|
|
3
5
|
import * as mockdata from "./common.mockdata";
|
|
4
6
|
|
|
5
7
|
describe("getTreeStructuredTags test", () => {
|
|
@@ -16,3 +18,81 @@ describe("getTreeStructuredTags test", () => {
|
|
|
16
18
|
expect(filterTags([], [])).toEqual([]);
|
|
17
19
|
});
|
|
18
20
|
});
|
|
21
|
+
|
|
22
|
+
describe("handleInjectedData", () => {
|
|
23
|
+
it("replaces name with intl key for top level tag", () => {
|
|
24
|
+
const data = {
|
|
25
|
+
tag1: {
|
|
26
|
+
name: "Registration Fields",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const result = handleInjectedData(data, "scope");
|
|
31
|
+
|
|
32
|
+
expect(result.tag1.name).toEqual(<FormattedMessage defaultMessage="Registration Fields" id="scope.RegistrationFields" values={{}} />);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("adds tagType for Registration custom fields", () => {
|
|
36
|
+
const data = {
|
|
37
|
+
tag1: {
|
|
38
|
+
name: "Registration custom fields",
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const result = handleInjectedData(data, "scope");
|
|
43
|
+
|
|
44
|
+
expect(result.tag1.name).toEqual(
|
|
45
|
+
<FormattedMessage defaultMessage="Registration custom fields" id="scope.Registrationcustomfields_name.CustomTagMessage" values={{}} />
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("adds tagType for Customer extended fields fields", () => {
|
|
50
|
+
const data = {
|
|
51
|
+
tag1: {
|
|
52
|
+
name: "Customer extended fields",
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const result = handleInjectedData(data, "scope");
|
|
57
|
+
|
|
58
|
+
expect(result.tag1.name).toEqual(
|
|
59
|
+
<FormattedMessage defaultMessage="Customer extended fields" id="scope.Customerextendedfields_name.ExtendedTagMessage" values={{}} />
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
it("replaces subtag name with intl key", () => {
|
|
65
|
+
const data = {
|
|
66
|
+
tag1: {
|
|
67
|
+
subtags: {
|
|
68
|
+
subtag1: {
|
|
69
|
+
name: "First Name",
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const result = handleInjectedData(data, "scope");
|
|
76
|
+
|
|
77
|
+
expect(result.tag1.subtags.subtag1.name).toEqual(<FormattedMessage defaultMessage="First Name" id="scope.FirstName" values={{}} />);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("replaces subtag desc with intl key", () => {
|
|
81
|
+
const data = {
|
|
82
|
+
tag1: {
|
|
83
|
+
subtags: {
|
|
84
|
+
subtag1: {
|
|
85
|
+
desc: "Enter your first name",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const result = handleInjectedData(data, "scope");
|
|
92
|
+
|
|
93
|
+
expect(result.tag1.subtags.subtag1.desc).toEqual(
|
|
94
|
+
<FormattedMessage defaultMessage="Enter your first name" id="scope.Enteryourfirstname" values={{}} />
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
@@ -44,6 +44,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
44
44
|
dynamicDateValue: '',
|
|
45
45
|
showModal: false,
|
|
46
46
|
translationLang: '',
|
|
47
|
+
tagsList: []
|
|
47
48
|
};
|
|
48
49
|
this.renderTags = this.renderTags.bind(this);
|
|
49
50
|
this.getSearchedExpandedKeys = this.getSearchedExpandedKeys.bind(this);
|
|
@@ -64,6 +65,15 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
67
|
|
|
68
|
+
componentDidUpdate(prevProps, prevState){
|
|
69
|
+
if (this.props.tags !== prevProps.tags || this.state.searchValue !== prevState.searchValue) {
|
|
70
|
+
let temp = this.renderTags(this.props.tags, this.state.searchValue);
|
|
71
|
+
this.setState({
|
|
72
|
+
tagsList: temp
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
67
77
|
onChange = (e) => {
|
|
68
78
|
const value = e.target.value;
|
|
69
79
|
let expandedKeys = this.getSearchedExpandedKeys(this.props.tags, value);
|
|
@@ -84,12 +94,12 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
84
94
|
let list = [];
|
|
85
95
|
_.forEach(tags, (val = {}, key) => {
|
|
86
96
|
if (_.has(val, 'subtags')) {
|
|
87
|
-
if ((val.name || '').toLowerCase().indexOf(value.toLowerCase()) !== -1) {
|
|
97
|
+
if (val.name && typeof val.name === 'string' && (val.name || '').toLowerCase().indexOf(value.toLowerCase()) !== -1) {
|
|
88
98
|
list.push(key);
|
|
89
99
|
}
|
|
90
100
|
const temp = this.getSearchedExpandedKeys(val.subtags, value);
|
|
91
101
|
list = list.concat(temp);
|
|
92
|
-
} else if ((val.name || '').toLowerCase().indexOf(value.toLowerCase()) !== -1) {
|
|
102
|
+
} else if (val.name && typeof val.name === 'string' && (val.name || '').toLowerCase().indexOf(value.toLowerCase()) !== -1) {
|
|
93
103
|
list.push(key);
|
|
94
104
|
}
|
|
95
105
|
});
|
|
@@ -259,7 +269,8 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
259
269
|
autoExpandParent={autoExpandParent}
|
|
260
270
|
onExpand={this.onExpand}
|
|
261
271
|
>
|
|
262
|
-
{this.renderTags(tg, searchValue)}
|
|
272
|
+
{/* {this.renderTags(tg, searchValue)} */}
|
|
273
|
+
{this.state.tagsList}
|
|
263
274
|
</CapTree>
|
|
264
275
|
{translationLang === "ja-JP" &&
|
|
265
276
|
<div className="tag-list-footer">
|
|
@@ -28,7 +28,6 @@ function CmsTemplatesComponent(props) {
|
|
|
28
28
|
// Determine if default email templates should be hidden based on feature control
|
|
29
29
|
if (hideDefaultEmailTemplates) {
|
|
30
30
|
if (name === START_FROM_SCRATCH) {
|
|
31
|
-
commonProperties.title = <FormattedMessage {...messages.startFromScratch}/>; // Show the START_FROM_SCRATCH template name text as per the locale
|
|
32
31
|
result.push(commonProperties);
|
|
33
32
|
}
|
|
34
33
|
} else {
|
|
@@ -14,8 +14,4 @@ export default defineMessages({
|
|
|
14
14
|
id: 'creatives.componentsV2.CmsTemplatesComponent.select',
|
|
15
15
|
defaultMessage: 'Select',
|
|
16
16
|
},
|
|
17
|
-
startFromScratch: {
|
|
18
|
-
id: 'creatives.componentsV2.CmsTemplatesComponent.startFromScratch',
|
|
19
|
-
defaultMessage: 'Start from Scratch',
|
|
20
|
-
},
|
|
21
17
|
});
|
|
@@ -26,9 +26,7 @@ import videoPlay from '../../assets/videoPlay.svg';
|
|
|
26
26
|
const wechatBodyNew = require('./assets/images/wechat_mobile_android.svg');
|
|
27
27
|
const smsMobileAndroid = require('./assets/images/sms_mobile_android.svg');
|
|
28
28
|
const smsMobileIos = require('./assets/images/sms_mobile_ios.svg');
|
|
29
|
-
|
|
30
|
-
const lineMobileAndroidDefaultImg = require('../../assets/Line_Preview_English.svg');
|
|
31
|
-
const lineMobileAndroidJapaneseImg = require('../../assets/Line_Preview_Japanese.svg');
|
|
29
|
+
const lineMobileAndroid = require('../../assets/line.png');
|
|
32
30
|
const viberMobileAndroid = require('./assets/images/viberMobile.svg');
|
|
33
31
|
|
|
34
32
|
const lineImgPlaceholder = require('../../assets/line-image-placeholder.svg');
|
|
@@ -162,10 +160,8 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
162
160
|
intl,
|
|
163
161
|
templateData,
|
|
164
162
|
rcsIosPreview,
|
|
165
|
-
hideTestAndPreviewBtn
|
|
166
|
-
hasJPLocaleHideFeatureEnabled
|
|
163
|
+
hideTestAndPreviewBtn
|
|
167
164
|
} = this.props;
|
|
168
|
-
console.log("Test ### preview", hasJPLocaleHideFeatureEnabled)
|
|
169
165
|
let content = channel && channel.toLowerCase() === 'sms' ? [this.props.content] : this.props.content;
|
|
170
166
|
|
|
171
167
|
const { formatMessage } = intl;
|
|
@@ -478,8 +474,7 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
478
474
|
{
|
|
479
475
|
channel && channel.toLowerCase() === 'line' ? (
|
|
480
476
|
<div className="shell-v2 align-center" id="sms-preview">
|
|
481
|
-
|
|
482
|
-
<CapImage className="preview-image" src={hasJPLocaleHideFeatureEnabled ? lineMobileAndroidJapaneseImg : lineMobileAndroidDefaultImg} alt={this.props.intl.formatMessage(messages.previewGenerated)}/>
|
|
477
|
+
<CapImage className="preview-image" src={lineMobileAndroid} alt={this.props.intl.formatMessage(messages.previewGenerated)}/>
|
|
483
478
|
<div
|
|
484
479
|
className="msg-container line-preview"
|
|
485
480
|
style={{
|
|
@@ -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
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* ChannelTemplates actions
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as types from './constants';
|
|
8
|
+
|
|
9
|
+
export function defaultAction() {
|
|
10
|
+
return {
|
|
11
|
+
type: types.DEFAULT_ACTION,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function getTemplates(channel) {
|
|
16
|
+
return {
|
|
17
|
+
type: types.GET_TEMPLATES_REQUEST,
|
|
18
|
+
channel,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* ChannelTemplates
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { connect } from 'react-redux';
|
|
11
|
+
import { FormattedMessage } from 'react-intl';
|
|
12
|
+
import { bindActionCreators } from 'redux';
|
|
13
|
+
import { createStructuredSelector } from 'reselect';
|
|
14
|
+
import makeSelectChannelTemplates from './selectors';
|
|
15
|
+
import * as actions from './actions';
|
|
16
|
+
import messages from './messages';
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
export class ChannelTemplates extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
20
|
+
componentDidMount() {
|
|
21
|
+
this.props.actions.getTemplates(this.props.channel);
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
return (
|
|
25
|
+
<CardGrid
|
|
26
|
+
cardDataList={[]}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
ChannelTemplates.propTypes = {
|
|
33
|
+
actions: PropTypes.object.isRequired,
|
|
34
|
+
channel: PropTypes.string,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const mapStateToProps = createStructuredSelector({
|
|
38
|
+
ChannelTemplates: makeSelectChannelTemplates(),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function mapDispatchToProps(dispatch) {
|
|
42
|
+
return {
|
|
43
|
+
actions: bindActionCreators(actions, dispatch),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default connect(mapStateToProps, mapDispatchToProps)(ChannelTemplates);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* ChannelTemplates Messages
|
|
3
|
+
*
|
|
4
|
+
* This contains all the text for the ChannelTemplates component.
|
|
5
|
+
*/
|
|
6
|
+
import { defineMessages } from 'react-intl';
|
|
7
|
+
|
|
8
|
+
export default defineMessages({
|
|
9
|
+
header: {
|
|
10
|
+
id: 'creatives.containersV2.ChannelTemplates.header',
|
|
11
|
+
defaultMessage: 'This is ChannelTemplates container !',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* ChannelTemplates reducer
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { fromJS } from 'immutable';
|
|
8
|
+
import * as types from './constants';
|
|
9
|
+
|
|
10
|
+
const initialState = fromJS({
|
|
11
|
+
loadingTemplates: true,
|
|
12
|
+
smsTemplates: [],
|
|
13
|
+
emailTemplates: [],
|
|
14
|
+
wechatTemplates: [],
|
|
15
|
+
mobilepushTemplates: [],
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
function channelTemplatesReducer(state = initialState, action) {
|
|
19
|
+
const channelTemplates = `${action.channel}Templates`;
|
|
20
|
+
switch (action.type) {
|
|
21
|
+
case types.DEFAULT_ACTION:
|
|
22
|
+
return state;
|
|
23
|
+
case types.GET_TEMPLATES_REQUEST:
|
|
24
|
+
return state.set('loadingTemplates', true);
|
|
25
|
+
case types.GET_TEMPLATES_SUCESS:
|
|
26
|
+
return state.set('loadingTemplates', false).set(channelTemplates, action.templates);
|
|
27
|
+
case types.GET_TEMPLATES_FAILURE:
|
|
28
|
+
return state.set('loadingTemplates', false).set('error', action.error);
|
|
29
|
+
default:
|
|
30
|
+
return state;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default channelTemplatesReducer;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { take, takeLatest, call, put, cancel } from 'redux-saga/effects';
|
|
2
|
+
import { LOCATION_CHANGE } from 'react-router-redux';
|
|
3
|
+
import * as Api from '../../services/api';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import * as types from './constants';
|
|
7
|
+
// Individual exports for testing
|
|
8
|
+
export function* defaultSaga() {
|
|
9
|
+
// See example in v2Containers/HomePage/sagas.js
|
|
10
|
+
}
|
|
11
|
+
function* getTemplates(action) {
|
|
12
|
+
try {
|
|
13
|
+
const req = {
|
|
14
|
+
channel: action.channel,
|
|
15
|
+
queryParams: action.query,
|
|
16
|
+
};
|
|
17
|
+
const res = call(Api.getAllTemplates, req);
|
|
18
|
+
put({type: types.GET_TEMPLATES_SUCESS, templates: res.response, channel: action.channel});
|
|
19
|
+
} catch (error) {
|
|
20
|
+
put({type: types.GET_TEMPLATES_FAILURE, error});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function* getTemplatesWatcher() {
|
|
24
|
+
const watcher = yield takeLatest(types.GET_TEMPLATES_REQUEST, getTemplates);
|
|
25
|
+
yield take(LOCATION_CHANGE);
|
|
26
|
+
yield cancel(watcher);
|
|
27
|
+
}
|
|
28
|
+
// All sagas to be loaded
|
|
29
|
+
export default [
|
|
30
|
+
defaultSaga,
|
|
31
|
+
getTemplatesWatcher,
|
|
32
|
+
];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createSelector } from 'reselect';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Direct selector to the channelTemplates state domain
|
|
5
|
+
*/
|
|
6
|
+
const selectChannelTemplatesDomain = () => (state) => state.get('templates');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Other specific selectors
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Default selector used by ChannelTemplates
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const makeSelectChannelTemplates = () => createSelector(
|
|
18
|
+
selectChannelTemplatesDomain(),
|
|
19
|
+
(substate) => substate.toJS()
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export default makeSelectChannelTemplates;
|
|
23
|
+
export {
|
|
24
|
+
selectChannelTemplatesDomain,
|
|
25
|
+
};
|
|
@@ -213,7 +213,6 @@ export function SlideBoxContent(props) {
|
|
|
213
213
|
isEditFTP = isEdit && [constants.NO_COMMUNICATION, constants.FTP].includes(channel);
|
|
214
214
|
}
|
|
215
215
|
const isDltEnabled = commonUtil.isTraiDLTEnable(isFullMode, smsRegister);
|
|
216
|
-
const hasJPLocaleHideFeatureEnabled = commonUtil?.hasJPLocaleHideFeatureEnabled();
|
|
217
216
|
|
|
218
217
|
const getChannelPreviewContent = (templateDataObject) => {
|
|
219
218
|
switch (templateDataObject.type.toUpperCase()) {
|
|
@@ -425,7 +424,6 @@ export function SlideBoxContent(props) {
|
|
|
425
424
|
templateData={templateData}
|
|
426
425
|
showCount
|
|
427
426
|
forwardedTags={forwardedTags}
|
|
428
|
-
hasJPLocaleHideFeatureEnabled={hasJPLocaleHideFeatureEnabled}
|
|
429
427
|
/>
|
|
430
428
|
)}
|
|
431
429
|
{isEmailPreview && (
|
|
@@ -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
|
});
|
|
@@ -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>
|
|
@@ -34,7 +34,6 @@ import * as templateActionsConfig from '../../Templates/actions';
|
|
|
34
34
|
import withCreatives from '../../../hoc/withCreatives';
|
|
35
35
|
import { gtmPush } from '../../../utils/gtmTrackers';
|
|
36
36
|
import { LINE } from '../../CreativesContainer/constants';
|
|
37
|
-
import * as commonUtil from '../../../utils/common';
|
|
38
37
|
|
|
39
38
|
const { stopTimer } = GA.timeTracker;
|
|
40
39
|
|
|
@@ -72,8 +71,6 @@ export const LineContainer = ({
|
|
|
72
71
|
const [uploadedAssetList, updateUploadedAssetList] = useState({});
|
|
73
72
|
const [selectedAccount, updateSelectedAccount] = useState('');
|
|
74
73
|
|
|
75
|
-
const hasJPLocaleHideFeatureEnabled = commonUtil?.hasJPLocaleHideFeatureEnabled();
|
|
76
|
-
|
|
77
74
|
useEffect(() => {
|
|
78
75
|
if (!isFullMode) {
|
|
79
76
|
templateActions.getWeCrmAccounts('Line');
|
|
@@ -692,7 +689,6 @@ export const LineContainer = ({
|
|
|
692
689
|
channel="LINE"
|
|
693
690
|
content={templateContent}
|
|
694
691
|
LineAccountName={accountName[0]}
|
|
695
|
-
hasJPLocaleHideFeatureEnabled={hasJPLocaleHideFeatureEnabled}
|
|
696
692
|
/>
|
|
697
693
|
)
|
|
698
694
|
}
|