@capillarytech/creatives-library 7.17.24 → 7.17.26-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/package.json +1 -1
- package/utils/common.js +11 -14
- package/v2Components/CapTagList/index.js +2 -2
- package/v2Containers/App/constants.js +1 -1
- package/v2Containers/TagList/index.js +30 -39
- package/v2Containers/TemplatesV2/index.js +3 -3
- package/v2Containers/TemplatesV2/tests/mockData.js +2 -2
package/package.json
CHANGED
package/utils/common.js
CHANGED
|
@@ -282,16 +282,13 @@ export const isTraiDLTEnable = (isFullMode, smsRegister) => {
|
|
|
282
282
|
return isTraiDltFeature;
|
|
283
283
|
};
|
|
284
284
|
|
|
285
|
-
export const intlKeyGenerator = (value = "") =>
|
|
286
|
-
return value.replace(/[^a-zA-Z0-9_]/g, "");
|
|
287
|
-
};
|
|
285
|
+
export const intlKeyGenerator = (value = "") => String(value).replace(/[^a-zA-Z0-9_]/g, "");
|
|
288
286
|
|
|
289
287
|
export const handleInjectedData = (data, scope) => {
|
|
290
|
-
const temp = _.cloneDeep(data);
|
|
291
288
|
let tagType;
|
|
292
|
-
for (const tagKey in
|
|
293
|
-
if (
|
|
294
|
-
const tag =
|
|
289
|
+
for (const tagKey in data) {
|
|
290
|
+
if (data.hasOwnProperty(tagKey)) {
|
|
291
|
+
const tag = data[tagKey];
|
|
295
292
|
|
|
296
293
|
if (tag?.name === REGISTRATION_CUSTOM_FIELD) {
|
|
297
294
|
tagType = CUSTOM_TAG;
|
|
@@ -300,19 +297,19 @@ export const handleInjectedData = (data, scope) => {
|
|
|
300
297
|
}
|
|
301
298
|
|
|
302
299
|
if (tag?.name) {
|
|
303
|
-
const name = tag
|
|
300
|
+
const name = tag.name;
|
|
304
301
|
const key = intlKeyGenerator(name);
|
|
305
302
|
const id = tagType
|
|
306
303
|
? `${scope}.${key}_name.${tagType}`
|
|
307
304
|
: `${scope}.${key}`;
|
|
308
305
|
|
|
309
|
-
tag
|
|
306
|
+
tag.name = apiMessageFormatHandler(id, name);
|
|
310
307
|
}
|
|
311
308
|
|
|
312
309
|
if (tag?.subtags) {
|
|
313
310
|
for (const subtagKey in tag.subtags) {
|
|
314
|
-
if (tag
|
|
315
|
-
const subtag = tag
|
|
311
|
+
if (tag.subtags.hasOwnProperty(subtagKey)) {
|
|
312
|
+
const subtag = tag.subtags[subtagKey];
|
|
316
313
|
if (subtag?.name) {
|
|
317
314
|
const name = subtag?.name;
|
|
318
315
|
const key = intlKeyGenerator(name);
|
|
@@ -320,7 +317,7 @@ export const handleInjectedData = (data, scope) => {
|
|
|
320
317
|
? `${scope}.${key}_name.${tagType}`
|
|
321
318
|
: `${scope}.${key}`;
|
|
322
319
|
|
|
323
|
-
subtag
|
|
320
|
+
subtag.name = apiMessageFormatHandler(id, name);
|
|
324
321
|
}
|
|
325
322
|
if (subtag?.desc) {
|
|
326
323
|
const desc = subtag?.desc;
|
|
@@ -329,7 +326,7 @@ export const handleInjectedData = (data, scope) => {
|
|
|
329
326
|
? `${scope}.${key}_desc.${tagType}`
|
|
330
327
|
: `${scope}.${key}`;
|
|
331
328
|
|
|
332
|
-
subtag
|
|
329
|
+
subtag.desc = apiMessageFormatHandler(id, desc);
|
|
333
330
|
}
|
|
334
331
|
}
|
|
335
332
|
}
|
|
@@ -337,5 +334,5 @@ export const handleInjectedData = (data, scope) => {
|
|
|
337
334
|
tagType = "";
|
|
338
335
|
}
|
|
339
336
|
}
|
|
340
|
-
return
|
|
337
|
+
return data;
|
|
341
338
|
};
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
JAPANESE_HELP_TEXT,
|
|
26
26
|
TAG_TRANSLATION_DOC,
|
|
27
27
|
} from "../../containers/TagList/constants";
|
|
28
|
-
import {
|
|
28
|
+
import { HIDE_FOR_JP_LOCALE } from '../../v2Containers/App/constants';
|
|
29
29
|
import { hidingDateTagsForJpLocale } from '../../v2Containers/TagList/utils';
|
|
30
30
|
|
|
31
31
|
|
|
@@ -175,7 +175,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
175
175
|
renderTags(tags, searchString = '') {
|
|
176
176
|
const { disableRelatedTags, childTagsToDisable, parentTagstoDisable, showCardsRelatedTags } = this?.props?.disableTagsDetails;
|
|
177
177
|
const { accessibleFeatures = [] } = this?.props?.currentOrgDetails || {};
|
|
178
|
-
const hideDateTagsForJpLocale = accessibleFeatures.includes(
|
|
178
|
+
const hideDateTagsForJpLocale = accessibleFeatures.includes(HIDE_FOR_JP_LOCALE);
|
|
179
179
|
const list = [];
|
|
180
180
|
const loyaltyAttrDisableText = <FormattedMessage {...messages.loyaltyAttributeDisable} />;
|
|
181
181
|
let clonedTags = _.cloneDeep(tags);
|
|
@@ -54,7 +54,7 @@ export const LINE = 'line';
|
|
|
54
54
|
export const EMAIL = 'email';
|
|
55
55
|
export const ASSETS = 'assets';
|
|
56
56
|
|
|
57
|
-
export const
|
|
57
|
+
export const HIDE_FOR_JP_LOCALE = 'HIDE_FOR_JP_LOCALE';
|
|
58
58
|
|
|
59
59
|
export const TRACK_EDIT_SMS = 'editSms';
|
|
60
60
|
export const TRACK_EDIT_EMAIL = 'editEmail';
|
|
@@ -20,17 +20,18 @@ import * as globalActions from '../Cap/actions';
|
|
|
20
20
|
import CapTagList from '../../v2Components/CapTagList';
|
|
21
21
|
import './_tagList.scss';
|
|
22
22
|
import { selectCurrentOrgDetails } from '../Cap/selectors';
|
|
23
|
-
const TreeNode = Tree.TreeNode;
|
|
24
23
|
import { injectIntl } from 'react-intl';
|
|
25
24
|
import { scope } from './messages';
|
|
26
25
|
import { handleInjectedData } from '../../utils/common';
|
|
27
26
|
|
|
27
|
+
const TreeNode = Tree.TreeNode;
|
|
28
|
+
|
|
28
29
|
export class TagList extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
29
30
|
constructor(props) {
|
|
30
31
|
super(props);
|
|
31
32
|
this.state = {
|
|
32
33
|
loading: false,
|
|
33
|
-
tags: []
|
|
34
|
+
tags: [],
|
|
34
35
|
};
|
|
35
36
|
this.renderTags = this.renderTags.bind(this);
|
|
36
37
|
this.populateTags = this.populateTags.bind(this);
|
|
@@ -40,35 +41,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
componentDidMount() {
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
componentDidUpdate(prevProps) {
|
|
47
|
-
if (this.props.tags !== prevProps.tags || this.props.injectedTags !== prevProps.injectedTags || this.props.selectedOfferDetails !== prevProps.selectedOfferDetails) {
|
|
48
|
-
this.setState({
|
|
49
|
-
tags: this.generateTags(this.props),
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
generateTags(props) {
|
|
55
|
-
let tags = {};
|
|
56
|
-
let injectedTags = {};
|
|
57
|
-
if (props.injectedTags && !_.isEmpty(props.injectedTags)) {
|
|
58
|
-
const formattedInjectedTags = handleInjectedData(
|
|
59
|
-
props.injectedTags,
|
|
60
|
-
scope
|
|
61
|
-
);
|
|
62
|
-
injectedTags = this.transformInjectedTags(formattedInjectedTags);
|
|
63
|
-
}
|
|
64
|
-
if (props.tags && props.tags.length > 0) {
|
|
65
|
-
tags = this.populateTags(props.tags);
|
|
66
|
-
console.log('populating tags', Object.keys(tags || {}).length);
|
|
67
|
-
}
|
|
68
|
-
if (props.selectedOfferDetails && !_.isEmpty(props.selectedOfferDetails) && (tags && tags.coupon)) {
|
|
69
|
-
this.transformCouponTags(props.selectedOfferDetails, tags);
|
|
70
|
-
}
|
|
71
|
-
return _.merge( {}, tags, injectedTags);
|
|
44
|
+
this.generateTags(this.props);
|
|
72
45
|
}
|
|
73
46
|
|
|
74
47
|
componentWillReceiveProps(nextProps) {
|
|
@@ -76,33 +49,52 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
76
49
|
this.setState({loading: true});
|
|
77
50
|
}
|
|
78
51
|
if (!_.isEqual(nextProps.injectedTags, this.props.injectedTags)) {
|
|
79
|
-
|
|
52
|
+
|
|
80
53
|
this.setState({loading: false});
|
|
81
54
|
}
|
|
82
55
|
if (!_.isEqual(nextProps.tags, this.props.tags)) {
|
|
83
|
-
|
|
56
|
+
|
|
84
57
|
this.setState({loading: false});
|
|
85
58
|
}
|
|
86
59
|
|
|
87
60
|
}
|
|
88
|
-
|
|
61
|
+
componentDidUpdate(prevProps) {
|
|
62
|
+
if (this.props.tags !== prevProps.tags || this.props.injectedTags !== prevProps.injectedTags || this.props.selectedOfferDetails !== prevProps.selectedOfferDetails) {
|
|
63
|
+
this.generateTags(this.props);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
89
66
|
onSelect = (selectedKeys) => {
|
|
90
67
|
this.props.onTagSelect(selectedKeys[0]);
|
|
91
68
|
};
|
|
92
69
|
|
|
93
70
|
onClick = (e, data) => {
|
|
94
|
-
|
|
71
|
+
|
|
95
72
|
};
|
|
96
73
|
|
|
97
74
|
getTagsforContext = (data) => {
|
|
98
75
|
//this.setState({loading: true});
|
|
99
76
|
this.props.onContextChange(data);
|
|
100
77
|
}
|
|
101
|
-
|
|
78
|
+
generateTags = (props) => {
|
|
79
|
+
let tags = {};
|
|
80
|
+
let injectedTags = {};
|
|
81
|
+
if (props.injectedTags && !_.isEmpty(props.injectedTags)) {
|
|
82
|
+
const formattedInjectedTags = handleInjectedData(
|
|
83
|
+
props.injectedTags,
|
|
84
|
+
scope
|
|
85
|
+
);
|
|
86
|
+
injectedTags = this.transformInjectedTags(formattedInjectedTags);
|
|
87
|
+
}
|
|
88
|
+
if (props.tags && props.tags.length > 0) {
|
|
89
|
+
tags = this.populateTags(props.tags);
|
|
90
|
+
}
|
|
91
|
+
if (props.selectedOfferDetails && !_.isEmpty(props.selectedOfferDetails) && (tags && tags.coupon)) {
|
|
92
|
+
this.transformCouponTags(props.selectedOfferDetails, tags);
|
|
93
|
+
}
|
|
94
|
+
this.setState({tags: _.merge( {}, tags, injectedTags)});
|
|
95
|
+
}
|
|
102
96
|
populateTags(tagsList) {
|
|
103
|
-
console.log('populating tags', (tagsList || []).length);
|
|
104
97
|
const mainTags = {};
|
|
105
|
-
|
|
106
98
|
//Form tags object with tag headers
|
|
107
99
|
_.forEach(tagsList, (temp) => {
|
|
108
100
|
const tag = temp.definition;
|
|
@@ -115,7 +107,6 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
115
107
|
} else if (tag['tag-header'] && mainTags[tag.value]) {
|
|
116
108
|
mainTags[tag.value].subtags = _.concat(mainTags[tag.value].subtags, tag.subtags);
|
|
117
109
|
} else if (!mainTags[tag.value]) {
|
|
118
|
-
//
|
|
119
110
|
mainTags[tag.value] = {
|
|
120
111
|
'tag-header': true,
|
|
121
112
|
"name": tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
|
|
@@ -29,7 +29,7 @@ import FTP from '../FTP';
|
|
|
29
29
|
import Gallery from '../Assets/Gallery';
|
|
30
30
|
import withStyles from '../../hoc/withStyles';
|
|
31
31
|
import styles, { CapTabStyle } from './TemplatesV2.style';
|
|
32
|
-
import { CREATIVES_UI_VIEW, LOYALTY, WHATSAPP, RCS, LINE, EMAIL, ASSETS,
|
|
32
|
+
import { CREATIVES_UI_VIEW, LOYALTY, WHATSAPP, RCS, LINE, EMAIL, ASSETS, HIDE_FOR_JP_LOCALE } from '../App/constants';
|
|
33
33
|
import AccessForbidden from '../../v2Components/AccessForbidden';
|
|
34
34
|
import { getObjFromQueryParams } from '../../utils/v2common';
|
|
35
35
|
import { selectCurrentOrgDetails } from "../../v2Containers/Cap/selectors";
|
|
@@ -119,8 +119,8 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
119
119
|
const { accessibleFeatures = [] } = currentOrgDetails || {};
|
|
120
120
|
// This data will be available when it will be accessed in library mode
|
|
121
121
|
const { currentOrgDetails: { accessibleFeatures: libModeAccessibleFeatures = [] } = {} } = cap || {};
|
|
122
|
-
const hideEngagementChannel = accessibleFeatures.includes(
|
|
123
|
-
// Show only line and email channel content with both channel tabs if the
|
|
122
|
+
const hideEngagementChannel = accessibleFeatures.includes(HIDE_FOR_JP_LOCALE) || libModeAccessibleFeatures.includes(HIDE_FOR_JP_LOCALE);
|
|
123
|
+
// Show only line and email channel content with both channel tabs if the HIDE_FOR_JP_LOCALE feature is enabled;
|
|
124
124
|
filteredPanes = hideEngagementChannel ? filteredPanes?.filter((pane) => [EMAIL, LINE, ASSETS].includes(pane?.key) && pane) : filteredPanes;
|
|
125
125
|
defaultChannel = hideEngagementChannel ? EMAIL : defaultChannel;
|
|
126
126
|
|
|
@@ -599,7 +599,7 @@ export const authData = {
|
|
|
599
599
|
"ENABLE_PRODUCT_SUPPORT_VIDEOS",
|
|
600
600
|
"ENABLE_RANDOM_COUPON_CODE",
|
|
601
601
|
"HIDE_DEFAULT_EMAIL_TEMPLATES",
|
|
602
|
-
"
|
|
602
|
+
"HIDE_FOR_JP_LOCALE",
|
|
603
603
|
],
|
|
604
604
|
org_loyalty_v2_status: true,
|
|
605
605
|
module_details: [
|
|
@@ -680,6 +680,6 @@ export const currentOrgDetails = {
|
|
|
680
680
|
"JOURNEY_UI",
|
|
681
681
|
"LOYALTY_PROMOTION_ENABLED",
|
|
682
682
|
"HIDE_DEFAULT_EMAIL_TEMPLATES",
|
|
683
|
-
"
|
|
683
|
+
"HIDE_FOR_JP_LOCALE",
|
|
684
684
|
],
|
|
685
685
|
};
|