@capillarytech/creatives-library 7.17.194-alpha.2 → 7.17.194
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 -2
- package/containers/App/constants.js +0 -1
- package/initialState.js +0 -3
- package/package.json +1 -1
- package/services/api.js +0 -20
- package/services/tests/api.test.js +0 -148
- package/utils/common.js +0 -7
- package/utils/tagValidations.js +1 -97
- package/utils/tests/tagValidations.test.js +2 -381
- package/v2Components/Ckeditor/index.js +3 -3
- package/v2Components/FormBuilder/_formBuilder.scss +1 -4
- package/v2Components/FormBuilder/index.js +69 -170
- package/v2Components/FormBuilder/messages.js +0 -8
- package/v2Containers/Cap/actions.js +0 -8
- package/v2Containers/Cap/constants.js +0 -4
- package/v2Containers/Cap/reducer.js +0 -11
- package/v2Containers/Cap/sagas.js +1 -28
- package/v2Containers/Cap/selectors.js +0 -5
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +0 -1
- package/v2Containers/Cap/tests/reducer.test.js +0 -50
- package/v2Containers/Cap/tests/saga.test.js +1 -81
- package/v2Containers/CreativesContainer/SlideBoxContent.js +3 -4
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +17 -28
- package/v2Containers/CreativesContainer/constants.js +0 -1
- package/v2Containers/CreativesContainer/index.js +6 -45
- package/v2Containers/CreativesContainer/index.scss +1 -13
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +0 -16
- package/v2Containers/Email/_email.scss +0 -3
- package/v2Containers/Email/index.js +0 -2
- package/v2Containers/EmailWrapper/index.js +0 -3
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +0 -3
- package/v2Containers/MobilePush/Edit/constants.js +2 -0
- package/v2Containers/MobilePush/Edit/index.js +71 -15
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +0 -93
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +0 -12
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +0 -12
- package/v2Components/ErrorInfoNote/index.js +0 -89
- package/v2Components/ErrorInfoNote/messages.js +0 -34
- package/v2Components/ErrorInfoNote/style.scss +0 -72
- package/v2Containers/Cap/mockData.js +0 -74
|
@@ -44,22 +44,19 @@ import EDMEditor from "../Edmeditor";
|
|
|
44
44
|
import BeeEditor from '../../v2Containers/BeeEditor';
|
|
45
45
|
import CustomPopOver from '../CustomPopOver';
|
|
46
46
|
import messages from './messages';
|
|
47
|
-
import {
|
|
48
|
-
import * as actions from "../../v2Containers/Cap/actions";
|
|
47
|
+
import { selectCurrentOrgDetails } from "../../v2Containers/Cap/selectors";
|
|
49
48
|
import './_formBuilder.scss';
|
|
50
49
|
import {updateCharCount, checkUnicode} from "../../utils/smsCharCountV2";
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
50
|
+
import { SMS, MOBILE_PUSH, LINE, ENABLE_AI_SUGGESTIONS,AI_CONTENT_BOT_DISABLED, EMAIL } from '../../v2Containers/CreativesContainer/constants';
|
|
51
|
+
import { validateIfTagClosed } from '../../utils/tagValidations';
|
|
53
52
|
import globalMessages from '../../v2Containers/Cap/messages';
|
|
54
53
|
import { convert } from 'html-to-text';
|
|
55
54
|
import { OUTBOUND } from './constants';
|
|
56
55
|
import { GET_TRANSLATION_MAPPED } from '../../containers/TagList/constants';
|
|
57
56
|
import moment from 'moment';
|
|
58
57
|
import { CUSTOMER_BARCODE_TAG , COPY_OF} from '../../containers/App/constants';
|
|
59
|
-
import {
|
|
58
|
+
import { isEmailUnsubscribeTagMandatory } from '../../utils/common';
|
|
60
59
|
import { isUrl } from '../../v2Containers/Line/Container/Wrapper/utils';
|
|
61
|
-
import { bindActionCreators } from 'redux';
|
|
62
|
-
|
|
63
60
|
const TabPane = Tabs.TabPane;
|
|
64
61
|
const {Column} = Table;
|
|
65
62
|
const {TextArea} = CapInput;
|
|
@@ -98,11 +95,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
98
95
|
customPopoverVisible: false,
|
|
99
96
|
isDrawerVisible: false,
|
|
100
97
|
translationLang: 'en',
|
|
101
|
-
showLiquidValidation: false,
|
|
102
|
-
liquidErrorMessage: {
|
|
103
|
-
STANDARD_ERROR_MSG: [],
|
|
104
|
-
LIQUID_ERROR_MSG: [],
|
|
105
|
-
},
|
|
106
98
|
};
|
|
107
99
|
this.renderForm = this.renderForm.bind(this);
|
|
108
100
|
this.updateFormData = this.updateFormData.bind(this);
|
|
@@ -134,8 +126,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
134
126
|
this.transformInjectedTags = this.transformInjectedTags.bind(this);
|
|
135
127
|
this.handleSetRadioValue = this.handleSetRadioValue.bind(this);
|
|
136
128
|
this.formElements = [];
|
|
137
|
-
// Check if the liquid flow feature is supported and the channel is in the supported list.
|
|
138
|
-
this.liquidFlow = hasLiquidSupportFeature() && LIQUID_SUPPORTED_CHANNELS.includes(props?.schema?.channel?.toUpperCase());
|
|
139
129
|
}
|
|
140
130
|
|
|
141
131
|
componentWillMount() {
|
|
@@ -490,7 +480,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
490
480
|
validateForm(tags, injectedTags, isSave, showMessages, onValidationComplete) {
|
|
491
481
|
const channel = _.get(this, "props.schema.channel");
|
|
492
482
|
let isValid = true;
|
|
493
|
-
let isLiquidValid = true;
|
|
494
483
|
const type = (this.props.location && this.props.location.query.type) ? this.props.location.query.type : 'full';
|
|
495
484
|
const currentModule = (this.props.location && this.props.location.query.module) ? this.props.location.query.module : 'default';
|
|
496
485
|
let errorData = _.cloneDeep(this.state.errorData);
|
|
@@ -926,10 +915,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
926
915
|
}
|
|
927
916
|
|
|
928
917
|
// Form Data Validation for Email Channel
|
|
929
|
-
if (this.props
|
|
918
|
+
if (this.props.schema && this.props.schema.channel && this.props.schema.channel.toUpperCase() === "EMAIL") {
|
|
930
919
|
// Validating Email By iterating all elements of FormBuilder
|
|
931
920
|
const isEmail = true;
|
|
932
|
-
_.forEach(this.state.formData,(data, index) => {
|
|
921
|
+
_.forEach(this.state.formData, (data, index) => {
|
|
933
922
|
|
|
934
923
|
if (!this.state.formData["template-subject"] && type.toLowerCase() === 'embedded' && (currentModule.toLowerCase() === 'loyalty' || currentModule.toLowerCase() === 'dvs' || currentModule.toLowerCase() === 'timeline' || currentModule.toLowerCase() === 'library')) {
|
|
935
924
|
errorData["template-subject"] = true;
|
|
@@ -974,59 +963,37 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
974
963
|
if (!content) {
|
|
975
964
|
return false;
|
|
976
965
|
}
|
|
977
|
-
const tagValidationResponse = this.validateTags(content, tags, injectedTags, isEmail)
|
|
966
|
+
const tagValidationResponse = this.validateTags(content, tags, injectedTags, isEmail);;
|
|
978
967
|
if (errorData[index][currentLang] === undefined) {
|
|
979
968
|
errorData[index][currentLang] = {};
|
|
980
969
|
}
|
|
981
|
-
|
|
970
|
+
|
|
971
|
+
if (tagValidationResponse.valid) {
|
|
982
972
|
errorData[index][currentLang]['template-content'] = false;
|
|
983
973
|
} else {
|
|
984
974
|
errorData[index][currentLang]['template-content'] = true;
|
|
985
975
|
isValid = false;
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
if (tagValidationResponse?.missingTags?.length > 0 || tagValidationResponse?.unsupportedTags?.length > 0) {
|
|
976
|
+
if (showMessages && !isNaN(index)) {
|
|
977
|
+
if (tagValidationResponse.missingTags.length > 0 || tagValidationResponse.unsupportedTags.length > 0) {
|
|
989
978
|
errorString += `${this.props.intl.formatMessage(messages.contentNotValidLanguage)} ${currentLang}\n`;
|
|
990
979
|
}
|
|
991
|
-
if (tagValidationResponse
|
|
980
|
+
if (tagValidationResponse.missingTags.length > 0) {
|
|
992
981
|
errorString += `${this.props.intl.formatMessage(messages.missingTags)} ${tagValidationResponse.missingTags.toString()}\n`;
|
|
993
982
|
}
|
|
994
|
-
if (tagValidationResponse
|
|
983
|
+
if (tagValidationResponse.unsupportedTags.length > 0) {
|
|
995
984
|
errorString += `${this.props.intl.formatMessage(messages.unsupportedTags)} ${tagValidationResponse.unsupportedTags.toString()}\n`;
|
|
996
985
|
}
|
|
997
|
-
if (tagValidationResponse
|
|
986
|
+
if (tagValidationResponse.isBraceError){
|
|
998
987
|
errorString += this.props.intl.formatMessage(globalMessages.unbalanacedCurlyBraces);
|
|
999
988
|
}
|
|
1000
989
|
if (tagValidationResponse?.isContentEmpty) {
|
|
1001
990
|
errorString += this.props.intl.formatMessage(messages.emailBodyEmptyError);
|
|
1002
|
-
// Adds a bypass for cases where content is initially empty in the creation flow.
|
|
1003
|
-
if(this.liquidFlow && !this.props.isEdit){
|
|
1004
|
-
errorString = "";
|
|
1005
|
-
isValid = true;
|
|
1006
|
-
isLiquidValid = true;
|
|
1007
|
-
}
|
|
1008
991
|
}
|
|
1009
992
|
}
|
|
1010
993
|
}
|
|
1011
994
|
}
|
|
1012
995
|
if (errorString !== "") {
|
|
1013
|
-
|
|
1014
|
-
this.setState(
|
|
1015
|
-
(prevState) => ({
|
|
1016
|
-
showLiquidValidation: true,
|
|
1017
|
-
liquidErrorMessage: {
|
|
1018
|
-
...prevState.liquidErrorMessage,
|
|
1019
|
-
STANDARD_ERROR_MSG: [errorString],
|
|
1020
|
-
},
|
|
1021
|
-
}),
|
|
1022
|
-
() => {
|
|
1023
|
-
// Callback after the state is updated
|
|
1024
|
-
this.props.showLiquidErrorInFooter(this.state.liquidErrorMessage);
|
|
1025
|
-
}
|
|
1026
|
-
);
|
|
1027
|
-
} else {
|
|
1028
|
-
this.openNotificationWithIcon('error', errorString, "email-validation-error");
|
|
1029
|
-
}
|
|
996
|
+
this.openNotificationWithIcon('error', errorString, "email-validation-error");
|
|
1030
997
|
}
|
|
1031
998
|
_.forEach(errorData[index], (versionData, key) => {
|
|
1032
999
|
if (data.selectedLanguages.indexOf(key) === -1) {
|
|
@@ -1035,20 +1002,32 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1035
1002
|
});
|
|
1036
1003
|
}
|
|
1037
1004
|
});
|
|
1005
|
+
// for (let count = 0; count < this.state.tabCount; count += 1) {
|
|
1006
|
+
// const index = count + 1;
|
|
1007
|
+
// // const content = this.state.formData[count][`template-content${index > 1 ? index : ''}`];
|
|
1008
|
+
// // const tagValidationResponse = this.validateTags(content, tags, injectedTags);
|
|
1009
|
+
// //
|
|
1010
|
+
// // if (tagValidationResponse.valid) {
|
|
1011
|
+
// // errorData[count][`template-content${index > 1 ? index : ''}`] = false;
|
|
1012
|
+
// // } else {
|
|
1013
|
+
// // errorData[count][`template-content${index > 1 ? index : ''}`] = true;
|
|
1014
|
+
// // isValid = false;
|
|
1015
|
+
// // }
|
|
1016
|
+
// }
|
|
1017
|
+
// if (type.toLowerCase() === 'embedded' && (currentModule.toLowerCase() === 'loyalty' || currentModule.toLowerCase() === 'dvs' || currentModule.toLowerCase() === 'timeline')) {
|
|
1018
|
+
// if (this.state.formData['template-subject'] && this.state.formData['template-subject'].trim() === '') {
|
|
1019
|
+
// errorData['template-subject'] = true;
|
|
1020
|
+
// isValid = false;
|
|
1021
|
+
// }
|
|
1022
|
+
// }
|
|
1023
|
+
// if(type !== 'embedded' && (!this.state.formData['template-name'] || this.state.formData['template-name'] === '')) {
|
|
1024
|
+
// errorData['template-name'] = true;
|
|
1025
|
+
// isValid = false;
|
|
1026
|
+
// } else {
|
|
1027
|
+
// errorData['template-name'] = false;
|
|
1028
|
+
// }
|
|
1038
1029
|
}
|
|
1039
|
-
|
|
1040
|
-
this.setState((prevState) => ({
|
|
1041
|
-
isFormValid: isValid,
|
|
1042
|
-
showLiquidValidation: prevState.liquidErrorMessage?.LIQUID_ERROR_MSG?.length > 0 ? true : !isLiquidValid,
|
|
1043
|
-
liquidErrorMessage: {
|
|
1044
|
-
//Do not update the LIQUID_ERROR_MSG validation error message
|
|
1045
|
-
...prevState.liquidErrorMessage,
|
|
1046
|
-
//update Standard error message based on the updated content
|
|
1047
|
-
STANDARD_ERROR_MSG: isValid ? [] : prevState.liquidErrorMessage?.STANDARD_ERROR_MSG,
|
|
1048
|
-
},
|
|
1049
|
-
errorData,
|
|
1050
|
-
}), () => {
|
|
1051
|
-
this.props.showLiquidErrorInFooter(this.state.liquidErrorMessage);
|
|
1030
|
+
this.setState({isFormValid : isValid, errorData}, () => {
|
|
1052
1031
|
if (onValidationComplete) {
|
|
1053
1032
|
onValidationComplete();
|
|
1054
1033
|
}
|
|
@@ -1070,70 +1049,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1070
1049
|
this.props.getValidationData();
|
|
1071
1050
|
return;
|
|
1072
1051
|
}
|
|
1073
|
-
if (
|
|
1074
|
-
|
|
1075
|
-
//Converts given HTML content to plain text string.
|
|
1076
|
-
const content = convert(
|
|
1077
|
-
this.state.formData?.base?.en?.["template-content"]
|
|
1078
|
-
);
|
|
1079
|
-
/*
|
|
1080
|
-
The `handleResult` function is used as a callback for `getLiquidTags` to handle the results post-processing.
|
|
1081
|
-
It checks for errors and unsupported tags in the fetched liquid tags, displays any necessary validation messages,
|
|
1082
|
-
and proceeds with form submission if all checks pass.
|
|
1083
|
-
*/
|
|
1084
|
-
const handleResult = (result) => {
|
|
1085
|
-
const {formatMessage} = this.props.intl;
|
|
1086
|
-
if (result?.errors?.length > 0) {
|
|
1087
|
-
this.setState((prevState) => ({
|
|
1088
|
-
showLiquidValidation: true,
|
|
1089
|
-
liquidErrorMessage: {
|
|
1090
|
-
...prevState.liquidErrorMessage,
|
|
1091
|
-
LIQUID_ERROR_MSG: result?.errors?.map(error => error?.message) ?? [formatMessage(messages.somethingWentWrong)],
|
|
1092
|
-
},
|
|
1093
|
-
}) , () => {
|
|
1094
|
-
this.props.showLiquidErrorInFooter(this.state.liquidErrorMessage);
|
|
1095
|
-
});
|
|
1096
|
-
this.props.stopValidation();
|
|
1097
|
-
return;
|
|
1098
|
-
}
|
|
1099
|
-
else if (result?.data?.length > 0) {
|
|
1100
|
-
const extractedLiquidTags = extractNames(result?.data);
|
|
1101
|
-
// Extracts the supported liquid tags from the given content.
|
|
1102
|
-
const supportedLiquidTags = checkSupport(
|
|
1103
|
-
result,
|
|
1104
|
-
this.props?.metaEntities?.tagLookupMap
|
|
1105
|
-
);
|
|
1106
|
-
const unsupportedLiquidTags = extractedLiquidTags?.filter(
|
|
1107
|
-
(tag) => !supportedLiquidTags?.includes(tag)
|
|
1108
|
-
);
|
|
1109
|
-
if (
|
|
1110
|
-
unsupportedLiquidTags?.length > 0
|
|
1111
|
-
) {
|
|
1112
|
-
this.setState(
|
|
1113
|
-
(prevState) => ({
|
|
1114
|
-
showLiquidValidation: true,
|
|
1115
|
-
liquidErrorMessage: {
|
|
1116
|
-
...prevState.liquidErrorMessage,
|
|
1117
|
-
LIQUID_ERROR_MSG: [formatMessage(messages.unsupportedTagsValidationError, {
|
|
1118
|
-
unsupportedTags: unsupportedLiquidTags.join(", ")})],
|
|
1119
|
-
},
|
|
1120
|
-
}),
|
|
1121
|
-
() => {
|
|
1122
|
-
this.props.showLiquidErrorInFooter(
|
|
1123
|
-
this.state.liquidErrorMessage
|
|
1124
|
-
);
|
|
1125
|
-
}
|
|
1126
|
-
);
|
|
1127
|
-
this.props.stopValidation();
|
|
1128
|
-
return;
|
|
1129
|
-
}
|
|
1130
|
-
this.props.onSubmit(this.state.formData);
|
|
1131
|
-
}
|
|
1132
|
-
};
|
|
1133
|
-
this.props.actions.getLiquidTags(preprocessHtml(content), handleResult);
|
|
1134
|
-
} else {
|
|
1135
|
-
this.props.onSubmit(this.state.formData);
|
|
1136
|
-
}
|
|
1052
|
+
if (this.state.isFormValid) {
|
|
1053
|
+
this.props.onSubmit(this.state.formData);
|
|
1137
1054
|
} else {
|
|
1138
1055
|
this.setState({checkValidation: true});
|
|
1139
1056
|
this.validateForm(null, null, true);
|
|
@@ -1175,7 +1092,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1175
1092
|
});
|
|
1176
1093
|
|
|
1177
1094
|
return result;
|
|
1178
|
-
}
|
|
1095
|
+
}
|
|
1179
1096
|
|
|
1180
1097
|
skipTags(tag) {
|
|
1181
1098
|
const regexGroups = ["dynamic_expiry_date_after_\\d+_days.FORMAT_\\d", "unsubscribe\\(#[a-zA-Z\\d]{6}\\)","Link_to_[a-zA-z]","SURVEY.*.TOKEN","^[A-Za-z].*\\([a-zA-Z\\d]*\\)"];
|
|
@@ -1234,14 +1151,14 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1234
1151
|
if (isEmailUnsubscribeTagMandatory() && isEmail && this.props?.moduleType === OUTBOUND) {
|
|
1235
1152
|
const missingTagIndex = response?.missingTags?.indexOf("unsubscribe");
|
|
1236
1153
|
if(missingTagIndex != -1) { //skip regex tags for mandatory tags also
|
|
1237
|
-
response?.missingTags?.splice(missingTagIndex, 1);
|
|
1154
|
+
response?.missingTags?.splice(missingTagIndex, 1);
|
|
1155
|
+
if (validString) {
|
|
1156
|
+
response.valid = true;
|
|
1157
|
+
} else {
|
|
1158
|
+
response.isContentEmpty = true;
|
|
1159
|
+
}
|
|
1238
1160
|
}
|
|
1239
1161
|
}
|
|
1240
|
-
if (validString) {
|
|
1241
|
-
response.valid = true;
|
|
1242
|
-
} else {
|
|
1243
|
-
response.isContentEmpty = true;
|
|
1244
|
-
}
|
|
1245
1162
|
while (match !== null ) {
|
|
1246
1163
|
const tagValue = match[0].substring(this.indexOfEnd(match[0], '{{'), match[0].indexOf('}}'));
|
|
1247
1164
|
match = regex.exec(content);
|
|
@@ -1266,11 +1183,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1266
1183
|
}
|
|
1267
1184
|
}
|
|
1268
1185
|
ifSupported = ifSupported || this.checkIfSupportedTag(tagValue, injectedTags);
|
|
1269
|
-
if (!ifSupported
|
|
1186
|
+
if (!ifSupported) {
|
|
1270
1187
|
response.unsupportedTags.push(tagValue);
|
|
1271
1188
|
response.valid = false;
|
|
1272
1189
|
}
|
|
1273
|
-
|
|
1274
1190
|
if (response.unsupportedTags.length == 0 && response.missingTags.length == 0 ) {
|
|
1275
1191
|
response.valid = true;
|
|
1276
1192
|
}
|
|
@@ -3422,11 +3338,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
3422
3338
|
const currentLang = ((!_.isEmpty(this.state.formData) && !_.isEmpty(this.state.formData[`${this.state.currentTab - 1}`]) && !_.isEmpty(this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages) && this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages[langIndex]) ? this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages[langIndex] : this.props.baseLanguage) || 'en';
|
|
3423
3339
|
const content = (!_.isEmpty(this.state.formData) && this.state.formData[`${this.state.currentTab - 1}`] && this.state.formData[`${this.state.currentTab - 1}`][currentLang] && this.state.formData[`${this.state.currentTab - 1}`][currentLang]['template-content'] || '');
|
|
3424
3340
|
columns.push(
|
|
3425
|
-
<CapColumn
|
|
3426
|
-
style={val.colStyle ? val.colStyle : {border : ""}}
|
|
3427
|
-
span={val.width}
|
|
3428
|
-
className={`${this.state.showLiquidValidation && this.liquidFlow && "error-boundary"} `}
|
|
3429
|
-
>
|
|
3341
|
+
<CapColumn style={val.colStyle ? val.colStyle : {}} span={val.width}>
|
|
3430
3342
|
<CKEditor
|
|
3431
3343
|
id={val.id}
|
|
3432
3344
|
content={content}
|
|
@@ -3469,7 +3381,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
3469
3381
|
isModuleFilterEnabled = this.props.isFullMode;
|
|
3470
3382
|
}
|
|
3471
3383
|
columns.push(
|
|
3472
|
-
<CapColumn style={val.colStyle ? val.colStyle : {}} span={val.width}
|
|
3384
|
+
<CapColumn style={val.colStyle ? val.colStyle : {}} span={val.width}>
|
|
3473
3385
|
<BeeEditor
|
|
3474
3386
|
uid={uuid}
|
|
3475
3387
|
tokenData={beeToken}
|
|
@@ -3573,7 +3485,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
3573
3485
|
fields.push(row);
|
|
3574
3486
|
}
|
|
3575
3487
|
});
|
|
3576
|
-
if (!this.props.isEmailLoading && this.props.schema.channel.toUpperCase() === EMAIL && !fields.length) {
|
|
3488
|
+
if (!this.props.isEmailLoading && this.props.schema.channel.toUpperCase() === 'EMAIL' && !fields.length) {
|
|
3577
3489
|
return (
|
|
3578
3490
|
<div style={{ textAlign: 'center' }}>
|
|
3579
3491
|
<CapSpin spinning />
|
|
@@ -3754,32 +3666,30 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
3754
3666
|
|
|
3755
3667
|
|
|
3756
3668
|
return (
|
|
3757
|
-
<CapSpin spinning={this.liquidFlow && this.props.liquidExtractionInProgress} tip={this.props.intl.formatMessage(messages.liquidSpinText)} >
|
|
3758
3669
|
<CapRow>
|
|
3759
|
-
{
|
|
3670
|
+
{
|
|
3671
|
+
this.props.schema ? this.renderForm() : ''
|
|
3672
|
+
}
|
|
3760
3673
|
<SlideBox
|
|
3761
|
-
header={
|
|
3762
|
-
<h3>{this.props.intl.formatMessage(messages.layoutSelection)}</h3>
|
|
3763
|
-
}
|
|
3674
|
+
header={(<h3>{this.props.intl.formatMessage(messages.layoutSelection)}</h3>)}
|
|
3764
3675
|
width={60}
|
|
3765
3676
|
content={cmsTemplateSelectionContent}
|
|
3766
3677
|
show={this.props.showEdmEmailTemplates}
|
|
3767
3678
|
handleClose={this.props.toggleEdmEmailTemplateSelection}
|
|
3768
|
-
loadingText={this.props.intl.formatMessage(
|
|
3769
|
-
messages.loadingEDMTemplates
|
|
3770
|
-
)}
|
|
3679
|
+
loadingText={this.props.intl.formatMessage(messages.loadingEDMTemplates)}
|
|
3771
3680
|
isLoading={this.props.getCmsTemplatesInProgress}
|
|
3772
3681
|
/>
|
|
3773
|
-
{
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3682
|
+
{
|
|
3683
|
+
this.props.capDrawerContent && (
|
|
3684
|
+
<CapDrawer
|
|
3685
|
+
content={this.props.capDrawerContent}
|
|
3686
|
+
visible={this.state.isDrawerVisible}
|
|
3687
|
+
width={380}
|
|
3688
|
+
onClose={() => this.props.setDrawerVisibility(false)}
|
|
3689
|
+
/>
|
|
3690
|
+
)
|
|
3691
|
+
}
|
|
3781
3692
|
</CapRow>
|
|
3782
|
-
</CapSpin>
|
|
3783
3693
|
);
|
|
3784
3694
|
}
|
|
3785
3695
|
}
|
|
@@ -3787,7 +3697,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
3787
3697
|
FormBuilder.defaultProps = {
|
|
3788
3698
|
isNewVersionFlow: false,
|
|
3789
3699
|
userLocale: localStorage.getItem('jlocale') || 'en',
|
|
3790
|
-
showLiquidErrorInFooter: () => {},
|
|
3791
3700
|
};
|
|
3792
3701
|
|
|
3793
3702
|
FormBuilder.propTypes = {
|
|
@@ -3834,20 +3743,10 @@ FormBuilder.propTypes = {
|
|
|
3834
3743
|
capDrawerContent: PropTypes.array,
|
|
3835
3744
|
isFullMode: PropTypes.bool,
|
|
3836
3745
|
currentOrgDetails: PropTypes.object,
|
|
3837
|
-
liquidExtractionInProgress: PropTypes.bool,
|
|
3838
|
-
showLiquidErrorInFooter: PropTypes.func,
|
|
3839
3746
|
};
|
|
3840
3747
|
|
|
3841
3748
|
const mapStateToProps = createStructuredSelector({
|
|
3842
3749
|
currentOrgDetails: selectCurrentOrgDetails(),
|
|
3843
|
-
liquidExtractionInProgress: selectLiquidStateDetails(),
|
|
3844
|
-
metaEntities: makeSelectMetaEntities(),
|
|
3845
3750
|
});
|
|
3846
3751
|
|
|
3847
|
-
|
|
3848
|
-
return {
|
|
3849
|
-
actions: bindActionCreators(actions, dispatch),
|
|
3850
|
-
};
|
|
3851
|
-
}
|
|
3852
|
-
|
|
3853
|
-
export default connect(mapStateToProps,mapDispatchToProps)(injectIntl(FormBuilder));
|
|
3752
|
+
export default connect(mapStateToProps)(injectIntl(FormBuilder));
|
|
@@ -90,12 +90,4 @@ export default defineMessages({
|
|
|
90
90
|
id: 'creatives.componentsV2.FormBuilder.emailBodyEmptyError',
|
|
91
91
|
defaultMessage: 'Email body cannot be empty',
|
|
92
92
|
},
|
|
93
|
-
somethingWentWrong: {
|
|
94
|
-
id: 'creatives.componentsV2.FormBuilder.somethingWentWrong',
|
|
95
|
-
defaultMessage: 'Something went wrong while validating content, please try again later',
|
|
96
|
-
},
|
|
97
|
-
liquidSpinText:{
|
|
98
|
-
id: 'creatives.componentsV2.FormBuilder.liquidSpinText',
|
|
99
|
-
defaultMessage: 'Validating the template, it might take a few seconds',
|
|
100
|
-
},
|
|
101
93
|
});
|
|
@@ -77,11 +77,3 @@ export function clearTopbarMenuData() {
|
|
|
77
77
|
export const getSupportVideosConfig = () => ({
|
|
78
78
|
type: types.GET_SUPPORT_VIDEOS_CONFIG_REQUEST,
|
|
79
79
|
});
|
|
80
|
-
|
|
81
|
-
export const getLiquidTags = (data,callback) => {
|
|
82
|
-
return{
|
|
83
|
-
type: types.GET_LIQUID_TAGS_REQUEST,
|
|
84
|
-
data,
|
|
85
|
-
callback,
|
|
86
|
-
};
|
|
87
|
-
};
|
|
@@ -59,7 +59,3 @@ export const FAILURE = 'FAILURE';
|
|
|
59
59
|
export const ENABLE_PRODUCT_SUPPORT_VIDEOS = 'ENABLE_PRODUCT_SUPPORT_VIDEOS';
|
|
60
60
|
export const DEFAULT = 'default';
|
|
61
61
|
export const DEFAULT_MODULE = 'creatives';
|
|
62
|
-
|
|
63
|
-
export const GET_LIQUID_TAGS_FAILURE = 'cap/GET_LIQUID_TAGS_FAILURE_V2';
|
|
64
|
-
export const GET_LIQUID_TAGS_REQUEST = 'cap/GET_LIQUID_TAGS_REQUEST_V2';
|
|
65
|
-
export const GET_LIQUID_TAGS_SUCCESS = 'cap/GET_LIQUID_TAGS_SUCCESS_V2';
|
|
@@ -85,24 +85,13 @@ function capReducer(state = fromJS(initialState.cap), action) {
|
|
|
85
85
|
return state
|
|
86
86
|
.set('fetchingSchema', false)
|
|
87
87
|
.set('fetchingSchemaError', true);
|
|
88
|
-
case types.GET_LIQUID_TAGS_REQUEST:
|
|
89
|
-
return state
|
|
90
|
-
.set('fetchingLiquidTags', true)
|
|
91
|
-
case types.GET_LIQUID_TAGS_FAILURE:
|
|
92
|
-
return state
|
|
93
|
-
.set('fetchingLiquidTags', false)
|
|
94
|
-
case types.GET_LIQUID_TAGS_SUCCESS:
|
|
95
|
-
return state
|
|
96
|
-
.set('fetchingLiquidTags', false)
|
|
97
88
|
case types.GET_SCHEMA_FOR_ENTITY_SUCCESS: {
|
|
98
89
|
const stateMeta = state.get('metaEntities');
|
|
99
|
-
const standardTagMap = _.keyBy(action?.data?.metaEntities?.standard, item => item?.definition?.value);
|
|
100
90
|
return state
|
|
101
91
|
.set('fetchingSchema', false)
|
|
102
92
|
.set('metaEntities', {
|
|
103
93
|
layouts: action.data && action.entityType === 'LAYOUT' ? action.data.metaEntities : stateMeta.layouts,
|
|
104
94
|
tags: action.data && action.entityType === 'TAG' ? action.data.metaEntities : stateMeta.tags,
|
|
105
|
-
tagLookupMap: action.data && action.entityType === 'TAG' ? standardTagMap : stateMeta.tagLookupMap,
|
|
106
95
|
})
|
|
107
96
|
.set('fetchingSchemaError', false);
|
|
108
97
|
}
|
|
@@ -150,30 +150,6 @@ export function* fetchSchemaForEntity(queryParams) {
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
export function* getLiquidTags(action) {
|
|
154
|
-
try {
|
|
155
|
-
let result = yield call(Api.getLiquidTags, action?.data);
|
|
156
|
-
if (result) {
|
|
157
|
-
if (result?.errors?.length > 0) {
|
|
158
|
-
const getAskAiraErrorResponse = yield call(Api.askAiraForLiquid, {
|
|
159
|
-
templateContent: action?.data,
|
|
160
|
-
errorMessage: result?.errors?.[0]?.message,
|
|
161
|
-
});
|
|
162
|
-
if (getAskAiraErrorResponse?.result?.errors?.length) {
|
|
163
|
-
result = getAskAiraErrorResponse?.result;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
if (action?.callback) {
|
|
167
|
-
yield call(action?.callback, result);
|
|
168
|
-
}
|
|
169
|
-
yield put({ type: types.GET_LIQUID_TAGS_SUCCESS });
|
|
170
|
-
} else {
|
|
171
|
-
yield put({ type: types.GET_LIQUID_TAGS_FAILURE });
|
|
172
|
-
}
|
|
173
|
-
} catch (error) {
|
|
174
|
-
yield put({ type: types.GET_LIQUID_TAGS_FAILURE });
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
153
|
const getTopbarData = (parentModule) => {
|
|
178
154
|
switch (parentModule) {
|
|
179
155
|
case LOYALTY:
|
|
@@ -218,9 +194,7 @@ export function* getSupportVideosConfig({ callback }) {
|
|
|
218
194
|
export function* watchFetchSchemaForEntity() {
|
|
219
195
|
yield takeLatest(types.GET_SCHEMA_FOR_ENTITY_REQUEST, fetchSchemaForEntity);
|
|
220
196
|
}
|
|
221
|
-
|
|
222
|
-
yield takeLatest(types.GET_LIQUID_TAGS_REQUEST, getLiquidTags);
|
|
223
|
-
}
|
|
197
|
+
|
|
224
198
|
|
|
225
199
|
function* watchForOrgChange() {
|
|
226
200
|
yield takeLatest(types.SWITCH_ORG_REQUEST, switchOrg);
|
|
@@ -253,6 +227,5 @@ export default [
|
|
|
253
227
|
watchFetchSchemaForEntity,
|
|
254
228
|
watchGetTopbarMenuData,
|
|
255
229
|
watchForGetVideosConfig,
|
|
256
|
-
watchLiquidEntity,
|
|
257
230
|
];
|
|
258
231
|
|
|
@@ -67,10 +67,6 @@ const selectCurrentOrgDetails = () => createSelector(
|
|
|
67
67
|
return currentOrgDetails ? currentOrgDetails.toJS() : null;
|
|
68
68
|
}
|
|
69
69
|
);
|
|
70
|
-
const selectLiquidStateDetails = () => createSelector(
|
|
71
|
-
selectCapDomain,
|
|
72
|
-
(globalState) => globalState.get('fetchingLiquidTags')
|
|
73
|
-
);
|
|
74
70
|
|
|
75
71
|
const makeSelectFetchingSchema = () => createSelector(
|
|
76
72
|
selectCapDomain,
|
|
@@ -112,5 +108,4 @@ export {
|
|
|
112
108
|
makeSelectLoyaltyPromotionDisplay,
|
|
113
109
|
makeSelectFetchingSchemaError,
|
|
114
110
|
makeSelectDemoVideoAndLink,
|
|
115
|
-
selectLiquidStateDetails,
|
|
116
111
|
};
|
|
@@ -41,7 +41,6 @@ exports[`<Cap /> should render correct component 1`] = `
|
|
|
41
41
|
"clearMetaEntities": [Function],
|
|
42
42
|
"clearTopbarMenuData": [Function],
|
|
43
43
|
"fetchSchemaForEntity": [Function],
|
|
44
|
-
"getLiquidTags": [Function],
|
|
45
44
|
"getSupportVideosConfig": [Function],
|
|
46
45
|
"getTopbarMenuData": [Function],
|
|
47
46
|
"getUserData": [Function],
|
|
@@ -6,20 +6,9 @@ import {
|
|
|
6
6
|
REQUEST,
|
|
7
7
|
SUCCESS,
|
|
8
8
|
FAILURE,
|
|
9
|
-
GET_LIQUID_TAGS_SUCCESS,
|
|
10
|
-
GET_LIQUID_TAGS_FAILURE,
|
|
11
|
-
GET_LIQUID_TAGS_REQUEST,
|
|
12
|
-
GET_SCHEMA_FOR_ENTITY_SUCCESS,
|
|
13
9
|
} from '../constants';
|
|
14
10
|
import reducer from '../reducer';
|
|
15
11
|
import initialState from '../../../initialState';
|
|
16
|
-
import {
|
|
17
|
-
expectedStateGetLiquidTagsRequest,
|
|
18
|
-
expectedStateGetLiquidTagsFailure,
|
|
19
|
-
expectedStateGetLiquidTagsSuccess,
|
|
20
|
-
expectedStateGetSchemaForEntitySuccessTAG,
|
|
21
|
-
expectedStateGetSchemaForEntitySuccess
|
|
22
|
-
} from '../mockData';
|
|
23
12
|
|
|
24
13
|
const mockedInitialState = fromJS(initialState.cap);
|
|
25
14
|
|
|
@@ -67,43 +56,4 @@ describe('should handle GET_SUPPORT_VIDEOS_CONFIG', () => {
|
|
|
67
56
|
demoVideoAndLinkJSONStatus: FAILURE,
|
|
68
57
|
});
|
|
69
58
|
});
|
|
70
|
-
it('handles the GET_LIQUID_TAGS_REQUEST action', () => {
|
|
71
|
-
const action = {
|
|
72
|
-
type: GET_LIQUID_TAGS_REQUEST,
|
|
73
|
-
};
|
|
74
|
-
expect(reducer(mockedInitialState, action).toJS()).toEqual(expectedStateGetLiquidTagsRequest);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('handles the GET_LIQUID_TAGS_FAILURE action', () => {
|
|
78
|
-
const action = {
|
|
79
|
-
type: GET_LIQUID_TAGS_FAILURE,
|
|
80
|
-
};
|
|
81
|
-
expect(reducer(mockedInitialState, action).toJS()).toEqual(expectedStateGetLiquidTagsFailure);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('handles the GET_LIQUID_TAGS_SUCCESS action', () => {
|
|
85
|
-
const action = {
|
|
86
|
-
type: GET_LIQUID_TAGS_SUCCESS,
|
|
87
|
-
};
|
|
88
|
-
expect(reducer(mockedInitialState, action).toJS()).toEqual(expectedStateGetLiquidTagsSuccess);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('handles the GET_SCHEMA_FOR_ENTITY_SUCCESS action with action type as TAG', () => {
|
|
92
|
-
const action = {
|
|
93
|
-
type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
|
|
94
|
-
data: {metaEntities:{standard:{"random": "32"}}},
|
|
95
|
-
entityType: "TAG"
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
expect(reducer(mockedInitialState, action).toJS()).toEqual(expectedStateGetSchemaForEntitySuccessTAG);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('handles the GET_SCHEMA_FOR_ENTITY_SUCCESS action', () => {
|
|
102
|
-
const action = {
|
|
103
|
-
type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
|
|
104
|
-
data: {metaEntities:{standard:{"random": "32"}}},
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
expect(reducer(mockedInitialState, action).toJS()).toEqual(expectedStateGetSchemaForEntitySuccess);
|
|
108
|
-
});
|
|
109
59
|
});
|