@capillarytech/creatives-library 8.0.17 → 8.0.19
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/tagValidations.js +9 -0
- package/utils/tests/tagValidations.test.js +23 -1
- package/v2Containers/Cap/mockData.js +1 -1
- package/v2Containers/Cap/reducer.js +24 -3
- package/v2Containers/FTP/index.js +1 -1
- package/v2Containers/MobilePush/Create/constants.js +1 -0
- package/v2Containers/MobilePush/Create/index.js +19 -4
package/package.json
CHANGED
package/utils/tagValidations.js
CHANGED
|
@@ -265,4 +265,13 @@ export const preprocessHtml = (content) => {
|
|
|
265
265
|
|
|
266
266
|
// Step 2: Perform the standard replacements on the entire content
|
|
267
267
|
return contentWithStyleFixes?.replace(/'|"|&|<|>|"|\n/g, match => replacements[match]);
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
//this is used to get the subtags from custom or extended tags
|
|
271
|
+
export const getTagMapValue = (object = {}) => {
|
|
272
|
+
return Object.values(
|
|
273
|
+
object
|
|
274
|
+
).reduce((acc, current) => {
|
|
275
|
+
return { ...acc?.subtags ?? {}, ...current?.subtags ?? {} };
|
|
276
|
+
}, {});
|
|
268
277
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import '@testing-library/jest-dom';
|
|
3
|
-
import { checkSupport, extractNames, preprocessHtml, validateIfTagClosed,validateTags} from '../tagValidations';
|
|
3
|
+
import { checkSupport, extractNames, getTagMapValue, preprocessHtml, validateIfTagClosed,validateTags} from '../tagValidations';
|
|
4
4
|
|
|
5
5
|
describe("check if curly brackets are balanced", () => {
|
|
6
6
|
it("test for balanced curly brackets", () => {
|
|
@@ -421,4 +421,26 @@ describe('preprocessHtml', () => {
|
|
|
421
421
|
expect(preprocessHtml(input)).toEqual(expectedOutput);
|
|
422
422
|
});
|
|
423
423
|
|
|
424
|
+
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
describe("getTagMapValue", () => {
|
|
429
|
+
it("should return an empty object when no object is provided", () => {
|
|
430
|
+
const result = getTagMapValue();
|
|
431
|
+
expect(result).toEqual({});
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
it("should return the tag map value when an object is provided", () => {
|
|
435
|
+
const object = {
|
|
436
|
+
"key 1": {
|
|
437
|
+
name: "23",
|
|
438
|
+
subtags: {
|
|
439
|
+
name: "233",
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
};
|
|
443
|
+
const result = getTagMapValue(object);
|
|
444
|
+
expect(result).toEqual({ name: "233" });
|
|
445
|
+
});
|
|
424
446
|
});
|
|
@@ -7,6 +7,7 @@ import * as types from './constants';
|
|
|
7
7
|
import initialState from '../../initialState';
|
|
8
8
|
import { FAILURE } from '../App/constants';
|
|
9
9
|
import { TAG } from '../Whatsapp/constants';
|
|
10
|
+
import { getTagMapValue } from '../../utils/tagValidations';
|
|
10
11
|
|
|
11
12
|
function capReducer(state = fromJS(initialState.cap), action) {
|
|
12
13
|
switch (action.type) {
|
|
@@ -96,14 +97,34 @@ function capReducer(state = fromJS(initialState.cap), action) {
|
|
|
96
97
|
return state
|
|
97
98
|
.set('fetchingLiquidTags', false)
|
|
98
99
|
case types.GET_SCHEMA_FOR_ENTITY_SUCCESS: {
|
|
99
|
-
|
|
100
|
-
const
|
|
100
|
+
//Process standard tags
|
|
101
|
+
const standardTagMapInitial = _.keyBy(
|
|
102
|
+
action?.data?.metaEntities?.standard,
|
|
103
|
+
item => item?.definition?.value
|
|
104
|
+
);
|
|
105
|
+
// Mapping only the `definition` object instead of the entire item, to reduce space used
|
|
106
|
+
const standardTagMap = _.mapValues(standardTagMapInitial, item => ({
|
|
107
|
+
definition: item?.definition ?? {},
|
|
108
|
+
}));
|
|
109
|
+
|
|
110
|
+
// Process custom tags
|
|
111
|
+
const customSubtags = getTagMapValue(action?.data?.metaEntities?.custom)
|
|
112
|
+
// Process extended tags
|
|
113
|
+
const extendedSubtags = getTagMapValue(action?.data?.metaEntities?.extended);
|
|
114
|
+
|
|
115
|
+
// Combine all maps
|
|
116
|
+
const combinedTagMap = {
|
|
117
|
+
...standardTagMap,
|
|
118
|
+
...customSubtags,
|
|
119
|
+
...extendedSubtags
|
|
120
|
+
};
|
|
121
|
+
const stateMeta = state.get("metaEntities");
|
|
101
122
|
return state
|
|
102
123
|
.set('fetchingSchema', false)
|
|
103
124
|
.set('metaEntities', {
|
|
104
125
|
layouts: action.data && action.entityType === 'LAYOUT' ? action.data.metaEntities : stateMeta.layouts,
|
|
105
126
|
tags: action.data && action.entityType === 'TAG' ? action.data.metaEntities : stateMeta.tags,
|
|
106
|
-
tagLookupMap: action?.data && action?.entityType === TAG ?
|
|
127
|
+
tagLookupMap: action?.data && action?.entityType === TAG ? combinedTagMap : stateMeta?.tagLookupMap,
|
|
107
128
|
})
|
|
108
129
|
.set('fetchingSchemaError', false);
|
|
109
130
|
}
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
CapTooltip,
|
|
23
23
|
} from '@capillarytech/cap-ui-library';
|
|
24
24
|
import { FONT_SIZE_L } from '@capillarytech/cap-ui-library/styled/variables';
|
|
25
|
-
import { find, cloneDeep, findIndex, isEmpty, isEqual, filter, flattenDeep, replace } from 'lodash';
|
|
25
|
+
import _, { find, cloneDeep, findIndex, isEmpty, isEqual, filter, flattenDeep, replace } from 'lodash';
|
|
26
26
|
import * as actions from './actions';
|
|
27
27
|
import { makeSelectFTP, makeSelectMetaEntities } from './selectors';
|
|
28
28
|
import { makeSelectLoyaltyPromotionDisplay, setInjectedTags } from '../Cap/selectors';
|
|
@@ -22,3 +22,4 @@ export const GET_IOS_CTAS = 'app/v2Containers/PushMessage/Create/GET_IOS_CTAS';
|
|
|
22
22
|
export const GET_IOS_CTAS_SUCCESS = 'app/v2Containers/PushMessage/Create/GET_IOS_CTAS_SUCCESS';
|
|
23
23
|
export const GET_IOS_CTAS_FAILURE = 'app/v2Containers/PushMessage/Create/GET_IOS_CTAS_FAILURE';
|
|
24
24
|
export const RESET_STORE = 'app/v2Containers/PushMessage/Create/RESET_STORE';
|
|
25
|
+
export const EXTERNAL_LINK_LOWERCASE = 'external link';
|
|
@@ -36,6 +36,7 @@ import injectReducer from '../../../utils/injectReducer';
|
|
|
36
36
|
import injectSaga from '../../../utils/injectSaga';
|
|
37
37
|
import v2MobilePushCreateReducer from './reducer';
|
|
38
38
|
import { v2MobilePushWatchDuplicateTemplateSaga } from './sagas';
|
|
39
|
+
import { EXTERNAL_LINK_LOWERCASE } from './constants';
|
|
39
40
|
|
|
40
41
|
const PrefixWrapper = styled.div`
|
|
41
42
|
margin-right: 16px;
|
|
@@ -200,11 +201,25 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
200
201
|
newFormData[0]["add-sec-cta-2"] = false;
|
|
201
202
|
}
|
|
202
203
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
204
|
+
const compareValue =
|
|
205
|
+
newFormData?.[this.state?.currentTab - 1]?.[inputField?.id] || "";
|
|
206
|
+
this.setState(
|
|
207
|
+
{
|
|
208
|
+
formData: newFormData,
|
|
209
|
+
tabCount,
|
|
210
|
+
isSchemaChanged:
|
|
211
|
+
compareValue.toLowerCase() === EXTERNAL_LINK_LOWERCASE ||
|
|
212
|
+
!this.state?.isSchemaChanged,
|
|
213
|
+
},
|
|
214
|
+
() => {
|
|
215
|
+
if (isFullMode && showTemplateName) {
|
|
216
|
+
showTemplateName({
|
|
217
|
+
formData: this.state?.formData,
|
|
218
|
+
onFormDataChange: this.onFormDataChange,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
206
221
|
}
|
|
207
|
-
|
|
222
|
+
);
|
|
208
223
|
};
|
|
209
224
|
|
|
210
225
|
onTagSelect = (data, currentTab, srcComp) => {
|