@capillarytech/creatives-library 8.0.276-alpha.0 → 8.0.277
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/v2Containers/CreativesContainer/SlideBoxContent.js +2 -0
- package/v2Containers/CreativesContainer/index.js +10 -6
- package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +165 -41
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +6 -0
- package/v2Containers/Email/index.js +9 -10
- package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +9 -4
- package/v2Containers/EmailWrapper/components/EmailWrapperView.js +4 -1
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +7 -3
- package/v2Containers/EmailWrapper/index.js +3 -0
- package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +4 -2
package/package.json
CHANGED
|
@@ -643,6 +643,7 @@ export function SlideBoxContent(props) {
|
|
|
643
643
|
{isEmailCreate && (
|
|
644
644
|
<EmailWrapper
|
|
645
645
|
key="creatives-email-wrapper"
|
|
646
|
+
isEditEmail={false}
|
|
646
647
|
date={new Date().getMilliseconds()}
|
|
647
648
|
setIsLoadingContent={setIsLoadingContent}
|
|
648
649
|
onEmailModeChange={onEmailModeChange}
|
|
@@ -723,6 +724,7 @@ export function SlideBoxContent(props) {
|
|
|
723
724
|
return (
|
|
724
725
|
<EmailWrapper
|
|
725
726
|
key="cretives-container-email-edit-wrapper"
|
|
727
|
+
isEditEmail
|
|
726
728
|
setIsLoadingContent={setIsLoadingContent}
|
|
727
729
|
onEmailModeChange={onEmailModeChange}
|
|
728
730
|
emailCreateMode="editor"
|
|
@@ -1781,16 +1781,20 @@ export class Creatives extends React.Component {
|
|
|
1781
1781
|
const {
|
|
1782
1782
|
slidBoxContent, templateStep, currentChannel, emailCreateMode, mobilePushCreateMode, inAppEditorType, weChatTemplateType,
|
|
1783
1783
|
} = this.state;
|
|
1784
|
+
const { isFullMode } = this.props;
|
|
1785
|
+
const channel = currentChannel?.toUpperCase?.() || '';
|
|
1786
|
+
// In library/embedded mode show Continue only for EMAIL and MOBILE_PUSH; hide for other channels
|
|
1787
|
+
if (!isFullMode && channel !== constants.EMAIL && channel !== constants.MOBILE_PUSH) {
|
|
1788
|
+
return false;
|
|
1789
|
+
}
|
|
1784
1790
|
let isShowContinueFooter = false;
|
|
1785
1791
|
const currentStep = this.creativesTemplateSteps[templateStep];
|
|
1786
|
-
const channel = currentChannel.toUpperCase();
|
|
1787
1792
|
// Check if supportCKEditor is false (new flow)
|
|
1788
1793
|
const supportCKEditor = commonUtil.hasSupportCKEditor(); // Default to legacy flow
|
|
1789
1794
|
if (channel === constants.EMAIL || channel === constants.SMS) {
|
|
1790
|
-
// New flow: Show Continue button when supportCKEditor is false and in modeSelection
|
|
1791
|
-
// Always show it (even if disabled) - visibility is separate from enabled state
|
|
1795
|
+
// New flow: Show Continue button when supportCKEditor is false and in modeSelection (full mode only)
|
|
1792
1796
|
if (!supportCKEditor && currentStep === 'modeSelection' && slidBoxContent === 'createTemplate') {
|
|
1793
|
-
return true;
|
|
1797
|
+
return true;
|
|
1794
1798
|
}
|
|
1795
1799
|
|
|
1796
1800
|
// Legacy flow: Original logic (only when supportCKEditor is true)
|
|
@@ -1799,9 +1803,9 @@ export class Creatives extends React.Component {
|
|
|
1799
1803
|
isEmailCreate = currentChannel.toUpperCase() === constants.EMAIL && ((emailCreateMode === "upload" && currentStep !== 'createTemplateContent') || (emailCreateMode === "editor" && currentStep !== 'createTemplateContent' && currentStep !== "templateSelection"));
|
|
1800
1804
|
isShowContinueFooter = isEmailCreate && emailCreateMode;
|
|
1801
1805
|
}
|
|
1802
|
-
} else if (
|
|
1806
|
+
} else if (channel === constants.MOBILE_PUSH) {
|
|
1803
1807
|
isShowContinueFooter = !isEmpty(mobilePushCreateMode) && currentStep === "modeSelection";
|
|
1804
|
-
} else if (
|
|
1808
|
+
} else if (channel === constants.WECHAT) {
|
|
1805
1809
|
isShowContinueFooter = !isEmpty(weChatTemplateType) && currentStep === "modeSelection";
|
|
1806
1810
|
}
|
|
1807
1811
|
|
|
@@ -11,6 +11,11 @@ import {
|
|
|
11
11
|
} from '../../../utils/test-utils';
|
|
12
12
|
import SlideBoxFooter from "../SlideBoxFooter";
|
|
13
13
|
|
|
14
|
+
jest.mock('../../../utils/common', () => ({
|
|
15
|
+
...jest.requireActual('../../../utils/common'),
|
|
16
|
+
hasSupportCKEditor: jest.fn(),
|
|
17
|
+
}));
|
|
18
|
+
|
|
14
19
|
const ComponentToRender = injectIntl(SlideBoxFooter);
|
|
15
20
|
const renderComponent = props => {
|
|
16
21
|
const store = configureStore({}, initialReducer, history);
|
|
@@ -21,49 +26,168 @@ const renderComponent = props => {
|
|
|
21
26
|
);
|
|
22
27
|
};
|
|
23
28
|
|
|
29
|
+
const baseFooterProps = {
|
|
30
|
+
shouldShowDoneFooter: () => true,
|
|
31
|
+
shouldShowContinueFooter: () => false,
|
|
32
|
+
shouldShowFooter: () => true,
|
|
33
|
+
shouldShowHeader: () => true,
|
|
34
|
+
shouldShowTemplateName: () => true,
|
|
35
|
+
onSave: jest.fn(),
|
|
36
|
+
isFullMode: true,
|
|
37
|
+
messages: {},
|
|
38
|
+
slidBoxContent: 'editTemplate',
|
|
39
|
+
templateStep: 'modeSelection',
|
|
40
|
+
isTemplateNameEmpty: false,
|
|
41
|
+
isCreatingTemplate: false,
|
|
42
|
+
};
|
|
43
|
+
|
|
24
44
|
describe("test for empty email empty template name", () => {
|
|
25
45
|
it("check the error message and disabled button", async () => {
|
|
26
|
-
const
|
|
27
|
-
|
|
46
|
+
const { hasSupportCKEditor } = require('../../../utils/common');
|
|
47
|
+
hasSupportCKEditor.mockReturnValue(true);
|
|
48
|
+
const shouldShowDoneFooter = jest.fn().mockReturnValue(true);
|
|
28
49
|
const shouldShowContinueFooter = jest.fn();
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
50
|
+
const props = {
|
|
51
|
+
...baseFooterProps,
|
|
52
|
+
shouldShowDoneFooter,
|
|
53
|
+
shouldShowContinueFooter,
|
|
54
|
+
currentChannel: "EMAIL",
|
|
55
|
+
isTemplateNameEmpty: true,
|
|
56
|
+
htmlEditorValidationState: {
|
|
57
|
+
isContentEmpty: false,
|
|
58
|
+
issueCounts: { html: 0, label: 0, liquid: 0, total: 0 },
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
renderComponent(props);
|
|
62
|
+
const errorMessage = await screen.findByText(/template name cannot be empty/i);
|
|
63
|
+
expect(errorMessage).toBeInTheDocument();
|
|
64
|
+
const updateBtn = screen.getByRole('button', { name: /update/i });
|
|
65
|
+
expect(updateBtn).toBeDisabled();
|
|
66
|
+
renderComponent({
|
|
67
|
+
...props,
|
|
68
|
+
isTemplateNameEmpty: false,
|
|
69
|
+
htmlEditorValidationState: {
|
|
70
|
+
isContentEmpty: false,
|
|
71
|
+
issueCounts: { html: 0, label: 0, liquid: 0, total: 0 },
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
const updateBtns = screen.getAllByRole('button', { name: /update/i });
|
|
75
|
+
expect(updateBtns[1]).toBeEnabled();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('shouldCheckValidation (line 79)', () => {
|
|
80
|
+
beforeEach(() => {
|
|
81
|
+
jest.clearAllMocks();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('disables Save when shouldCheckValidation is true and validation has errors not acknowledged (HTML Editor, EMAIL, no CK)', () => {
|
|
85
|
+
const { hasSupportCKEditor } = require('../../../utils/common');
|
|
86
|
+
hasSupportCKEditor.mockReturnValue(false);
|
|
87
|
+
renderComponent({
|
|
88
|
+
...baseFooterProps,
|
|
89
|
+
currentChannel: 'EMAIL',
|
|
90
|
+
slidBoxContent: 'editTemplate',
|
|
91
|
+
htmlEditorValidationState: {
|
|
92
|
+
validationComplete: true,
|
|
93
|
+
hasErrors: true,
|
|
94
|
+
errorsAcknowledged: false,
|
|
95
|
+
isContentEmpty: false,
|
|
96
|
+
issueCounts: { html: 1, label: 0, liquid: 0, total: 1 },
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
const updateBtn = screen.getByRole('button', { name: /update/i });
|
|
100
|
+
expect(updateBtn).toBeDisabled();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('enables Save when shouldCheckValidation is true and validation complete with no blocking errors', () => {
|
|
104
|
+
const { hasSupportCKEditor } = require('../../../utils/common');
|
|
105
|
+
hasSupportCKEditor.mockReturnValue(false);
|
|
106
|
+
renderComponent({
|
|
107
|
+
...baseFooterProps,
|
|
108
|
+
currentChannel: 'EMAIL',
|
|
109
|
+
slidBoxContent: 'editTemplate',
|
|
110
|
+
htmlEditorValidationState: {
|
|
111
|
+
validationComplete: true,
|
|
112
|
+
hasErrors: false,
|
|
113
|
+
errorsAcknowledged: false,
|
|
114
|
+
isContentEmpty: false,
|
|
115
|
+
issueCounts: { html: 0, label: 0, liquid: 0, total: 0 },
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
const updateBtn = screen.getByRole('button', { name: /update/i });
|
|
119
|
+
expect(updateBtn).toBeEnabled();
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('does not disable Save based on validation when currentChannel is not EMAIL (shouldCheckValidation false)', () => {
|
|
123
|
+
const { hasSupportCKEditor } = require('../../../utils/common');
|
|
124
|
+
hasSupportCKEditor.mockReturnValue(false);
|
|
125
|
+
renderComponent({
|
|
126
|
+
...baseFooterProps,
|
|
127
|
+
currentChannel: 'SMS',
|
|
128
|
+
slidBoxContent: 'editTemplate',
|
|
129
|
+
htmlEditorValidationState: {
|
|
130
|
+
validationComplete: true,
|
|
131
|
+
hasErrors: true,
|
|
132
|
+
errorsAcknowledged: false,
|
|
133
|
+
isContentEmpty: false,
|
|
134
|
+
issueCounts: { html: 1, label: 0, liquid: 0, total: 1 },
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
const updateBtn = screen.getByRole('button', { name: /update/i });
|
|
138
|
+
expect(updateBtn).toBeEnabled();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('does not disable Save based on validation when htmlEditorValidationState is not provided (shouldCheckValidation false)', () => {
|
|
142
|
+
const { hasSupportCKEditor } = require('../../../utils/common');
|
|
143
|
+
hasSupportCKEditor.mockReturnValue(false);
|
|
144
|
+
renderComponent({
|
|
145
|
+
...baseFooterProps,
|
|
146
|
+
currentChannel: 'EMAIL',
|
|
147
|
+
slidBoxContent: 'editTemplate',
|
|
148
|
+
htmlEditorValidationState: null,
|
|
149
|
+
});
|
|
150
|
+
const updateBtn = screen.getByRole('button', { name: /update/i });
|
|
151
|
+
expect(updateBtn).toBeEnabled();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('does not disable Save based on validation when hasSupportCKEditor is true (shouldCheckValidation false)', () => {
|
|
155
|
+
const { hasSupportCKEditor } = require('../../../utils/common');
|
|
156
|
+
hasSupportCKEditor.mockReturnValue(true);
|
|
157
|
+
renderComponent({
|
|
158
|
+
...baseFooterProps,
|
|
159
|
+
currentChannel: 'EMAIL',
|
|
160
|
+
slidBoxContent: 'editTemplate',
|
|
161
|
+
htmlEditorValidationState: {
|
|
162
|
+
validationComplete: true,
|
|
163
|
+
hasErrors: true,
|
|
164
|
+
errorsAcknowledged: false,
|
|
165
|
+
isContentEmpty: false,
|
|
166
|
+
issueCounts: { html: 1, label: 0, liquid: 0, total: 1 },
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
const updateBtn = screen.getByRole('button', { name: /update/i });
|
|
170
|
+
expect(updateBtn).toBeEnabled();
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('disables Save when shouldCheckValidation true and content empty in create mode', () => {
|
|
174
|
+
const { hasSupportCKEditor } = require('../../../utils/common');
|
|
175
|
+
hasSupportCKEditor.mockReturnValue(false);
|
|
176
|
+
renderComponent({
|
|
177
|
+
...baseFooterProps,
|
|
178
|
+
currentChannel: 'EMAIL',
|
|
179
|
+
slidBoxContent: 'createTemplate',
|
|
180
|
+
emailCreateMode: 'html_editor',
|
|
181
|
+
selectedEmailCreateMode: 'html_editor',
|
|
182
|
+
htmlEditorValidationState: {
|
|
183
|
+
validationComplete: true,
|
|
184
|
+
hasErrors: false,
|
|
185
|
+
errorsAcknowledged: false,
|
|
186
|
+
isContentEmpty: true,
|
|
187
|
+
issueCounts: { html: 0, label: 0, liquid: 0, total: 0 },
|
|
188
|
+
},
|
|
68
189
|
});
|
|
190
|
+
const saveBtn = screen.getByRole('button', { name: /create/i });
|
|
191
|
+
expect(saveBtn).toBeDisabled();
|
|
192
|
+
});
|
|
69
193
|
});
|
|
@@ -10,6 +10,7 @@ exports[`Test SlideBoxContent container Email component isTestAndPreviewMode IIF
|
|
|
10
10
|
getCmsTemplatesInProgress={false}
|
|
11
11
|
handleCloseTestAndPreview={[MockFunction]}
|
|
12
12
|
handleTestAndPreview={[MockFunction]}
|
|
13
|
+
isEditEmail={true}
|
|
13
14
|
isLoyaltyModule={false}
|
|
14
15
|
isTestAndPreviewMode={true}
|
|
15
16
|
key="cretives-container-email-edit-wrapper"
|
|
@@ -60,6 +61,7 @@ exports[`Test SlideBoxContent container Email component isTestAndPreviewMode IIF
|
|
|
60
61
|
getCmsTemplatesInProgress={false}
|
|
61
62
|
handleCloseTestAndPreview={[MockFunction]}
|
|
62
63
|
handleTestAndPreview={[MockFunction]}
|
|
64
|
+
isEditEmail={true}
|
|
63
65
|
isLoyaltyModule={false}
|
|
64
66
|
isTestAndPreviewMode={false}
|
|
65
67
|
key="cretives-container-email-edit-wrapper"
|
|
@@ -110,6 +112,7 @@ exports[`Test SlideBoxContent container Email component isTestAndPreviewMode IIF
|
|
|
110
112
|
getCmsTemplatesInProgress={false}
|
|
111
113
|
handleCloseTestAndPreview={[MockFunction]}
|
|
112
114
|
handleTestAndPreview={[MockFunction]}
|
|
115
|
+
isEditEmail={true}
|
|
113
116
|
isLoyaltyModule={false}
|
|
114
117
|
isTestAndPreviewMode={true}
|
|
115
118
|
key="cretives-container-email-edit-wrapper"
|
|
@@ -159,6 +162,7 @@ exports[`Test SlideBoxContent container Email component isTestAndPreviewMode IIF
|
|
|
159
162
|
getCmsTemplatesInProgress={false}
|
|
160
163
|
handleCloseTestAndPreview={[MockFunction]}
|
|
161
164
|
handleTestAndPreview={[MockFunction]}
|
|
165
|
+
isEditEmail={true}
|
|
162
166
|
isLoyaltyModule={false}
|
|
163
167
|
isTestAndPreviewMode={false}
|
|
164
168
|
key="cretives-container-email-edit-wrapper"
|
|
@@ -1277,6 +1281,7 @@ exports[`Test SlideBoxContent container Should render correctly with isTestAndPr
|
|
|
1277
1281
|
<Connect(UserIsAuthenticated(Component))
|
|
1278
1282
|
date={0}
|
|
1279
1283
|
getCmsTemplatesInProgress={false}
|
|
1284
|
+
isEditEmail={false}
|
|
1280
1285
|
isTestAndPreviewMode={false}
|
|
1281
1286
|
key="creatives-email-wrapper"
|
|
1282
1287
|
templateData={
|
|
@@ -1352,6 +1357,7 @@ exports[`Test SlideBoxContent container Should render correctly with isTestAndPr
|
|
|
1352
1357
|
<Connect(UserIsAuthenticated(Component))
|
|
1353
1358
|
date={0}
|
|
1354
1359
|
getCmsTemplatesInProgress={false}
|
|
1360
|
+
isEditEmail={false}
|
|
1355
1361
|
isTestAndPreviewMode={true}
|
|
1356
1362
|
key="creatives-email-wrapper"
|
|
1357
1363
|
templateData={
|
|
@@ -95,6 +95,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
95
95
|
|
|
96
96
|
this.isTagLoaded = false;
|
|
97
97
|
this.edmEvent = undefined;
|
|
98
|
+
// When schema is set after CmsSettings (e.g. library create BEE), allow BEE init to run once
|
|
99
|
+
this.schemaJustFilledForBee = false;
|
|
98
100
|
this.supportedLanguages = this.getSupportedLanguages(props);
|
|
99
101
|
this.map = {
|
|
100
102
|
"template-name": {
|
|
@@ -336,7 +338,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
336
338
|
if (nextProps.metaEntities && nextProps.metaEntities.layouts && nextProps.metaEntities.layouts.length > 0 && _.isEmpty(this.state.schema)) {
|
|
337
339
|
const newSchema = this.injectEvents(nextProps.metaEntities.layouts[0].definition);
|
|
338
340
|
this.applyTabOptionIconVisibility(newSchema);
|
|
339
|
-
|
|
341
|
+
// So BEE init can run when CmsSettings already arrived (e.g. library create after default template selected)
|
|
342
|
+
this.schemaJustFilledForBee = true;
|
|
340
343
|
this.setState({schema: newSchema, loadingStatus: this.state.loadingStatus + 1});
|
|
341
344
|
if (this.props.location.query.module !== 'library' || (this.props.location.query.module === 'library' && this.props.getDefaultTags)) {
|
|
342
345
|
const query = {
|
|
@@ -498,7 +501,11 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
498
501
|
}
|
|
499
502
|
}
|
|
500
503
|
|
|
501
|
-
|
|
504
|
+
const cmsSettingsChanged = !_.isEqual(this.props.Email.CmsSettings, nextProps.Email.CmsSettings);
|
|
505
|
+
const hasCmsSettingsAndSchema = !_.isEmpty(nextProps.Email.CmsSettings) && !_.isEmpty(this.state.schema);
|
|
506
|
+
const shouldRunBeeInit = hasCmsSettingsAndSchema && (cmsSettingsChanged || this.schemaJustFilledForBee);
|
|
507
|
+
if (shouldRunBeeInit) {
|
|
508
|
+
this.schemaJustFilledForBee = false;
|
|
502
509
|
const apiLangId = nextProps.Email.CmsSettings.langId;
|
|
503
510
|
const langId = nextProps.Email.CmsSettings.langId !== "undefined" ? nextProps.Email.CmsSettings.langId : nextProps.currentOrgDetails.basic_details.base_language;
|
|
504
511
|
|
|
@@ -2927,14 +2934,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2927
2934
|
if (content) {
|
|
2928
2935
|
isLoading = false;
|
|
2929
2936
|
}
|
|
2930
|
-
if (typeof window !== 'undefined' && this.state.loadingStatus < 2) {
|
|
2931
|
-
console.log('[UPLOAD-DEBUG] Email isEmailLoading (upload path)', {
|
|
2932
|
-
loadingStatus: this.state.loadingStatus,
|
|
2933
|
-
hasContentInFormData: !!content,
|
|
2934
|
-
isLoadingResult: isLoading,
|
|
2935
|
-
hasSelectedEmailLayout: !!this.props.Templates?.selectedEmailLayout,
|
|
2936
|
-
});
|
|
2937
|
-
}
|
|
2938
2937
|
}
|
|
2939
2938
|
// if (isLoading) {
|
|
2940
2939
|
// this.props.creativesContainerActions.hideCreativesContanerLoader();
|
|
@@ -73,6 +73,7 @@ const EmailHTMLEditor = (props) => {
|
|
|
73
73
|
getFormdata,
|
|
74
74
|
// Library mode props
|
|
75
75
|
templateData: templateDataProp,
|
|
76
|
+
isEditEmail = true,
|
|
76
77
|
// Uploaded content from zip file
|
|
77
78
|
EmailLayout,
|
|
78
79
|
// Liquid validation
|
|
@@ -174,11 +175,13 @@ const EmailHTMLEditor = (props) => {
|
|
|
174
175
|
// Check if liquid support is enabled
|
|
175
176
|
const isLiquidEnabled = hasLiquidSupportFeature();
|
|
176
177
|
|
|
177
|
-
// Detect edit mode
|
|
178
|
+
// Detect edit mode: when isEditEmail is false (create flow), never treat as edit or fetch template details
|
|
178
179
|
const hasParamsId = params?.id || location?.query?.id || location?.params?.id || location?.pathname?.includes('/edit/');
|
|
179
|
-
const currentTemplateId =
|
|
180
|
-
|| location?.
|
|
181
|
-
|
|
180
|
+
const currentTemplateId = isEditEmail
|
|
181
|
+
? (templateDataProp?._id || params?.id || location?.query?.id || location?.params?.id
|
|
182
|
+
|| location?.pathname?.match(/\/edit\/([^/]+)/)?.[1])
|
|
183
|
+
: (params?.id || location?.query?.id || location?.params?.id || location?.pathname?.match(/\/edit\/([^/]+)/)?.[1]);
|
|
184
|
+
const isEditMode = isEditEmail && (!!currentTemplateId || !!hasParamsId);
|
|
182
185
|
|
|
183
186
|
// Load tags on component mount
|
|
184
187
|
useEffect(() => {
|
|
@@ -1204,6 +1207,7 @@ EmailHTMLEditor.propTypes = {
|
|
|
1204
1207
|
onValidationFail: PropTypes.func,
|
|
1205
1208
|
moduleType: PropTypes.string,
|
|
1206
1209
|
onHtmlEditorValidationStateChange: PropTypes.func,
|
|
1210
|
+
isEditEmail: PropTypes.bool,
|
|
1207
1211
|
};
|
|
1208
1212
|
|
|
1209
1213
|
EmailHTMLEditor.defaultProps = {
|
|
@@ -1239,6 +1243,7 @@ EmailHTMLEditor.defaultProps = {
|
|
|
1239
1243
|
onValidationFail: null,
|
|
1240
1244
|
moduleType: null,
|
|
1241
1245
|
onHtmlEditorValidationStateChange: null,
|
|
1246
|
+
isEditEmail: true,
|
|
1242
1247
|
};
|
|
1243
1248
|
|
|
1244
1249
|
const EmailHTMLEditorWithIntl = injectIntl(EmailHTMLEditor);
|
|
@@ -182,6 +182,7 @@ const EmailWrapperView = ({
|
|
|
182
182
|
Email,
|
|
183
183
|
templateData: templateDataProp,
|
|
184
184
|
params,
|
|
185
|
+
isEditEmail = true,
|
|
185
186
|
fetchingLiquidTags,
|
|
186
187
|
createTemplateInProgress,
|
|
187
188
|
fetchingCmsData,
|
|
@@ -198,7 +199,7 @@ const EmailWrapperView = ({
|
|
|
198
199
|
const isEditModeForEditor = hasParamsIdForEditor;
|
|
199
200
|
const isBEEFromProps = emailProps?.editor === 'BEE' && emailProps?.selectedEditorMode === null;
|
|
200
201
|
const isDragDropFromCreateMode = emailCreateMode === EMAIL_CREATE_MODES.DRAG_DROP;
|
|
201
|
-
const isExplicitlyBEEEditor = isBEEFromProps || isDragDropFromCreateMode
|
|
202
|
+
const isExplicitlyBEEEditor = isBEEFromProps || isDragDropFromCreateMode;
|
|
202
203
|
let isHTMLEditorMode = false;
|
|
203
204
|
|
|
204
205
|
if (supportCKEditor) {
|
|
@@ -258,6 +259,7 @@ const EmailWrapperView = ({
|
|
|
258
259
|
getFormdata,
|
|
259
260
|
// Library mode props
|
|
260
261
|
templateData: templateDataProp,
|
|
262
|
+
isEditEmail,
|
|
261
263
|
// Uploaded content from zip file
|
|
262
264
|
EmailLayout,
|
|
263
265
|
// Liquid validation
|
|
@@ -373,6 +375,7 @@ EmailWrapperView.propTypes = {
|
|
|
373
375
|
Email: PropTypes.object,
|
|
374
376
|
templateData: PropTypes.object,
|
|
375
377
|
params: PropTypes.object,
|
|
378
|
+
isEditEmail: PropTypes.bool,
|
|
376
379
|
fetchingLiquidTags: PropTypes.bool,
|
|
377
380
|
createTemplateInProgress: PropTypes.bool,
|
|
378
381
|
fetchingCmsData: PropTypes.bool,
|
|
@@ -66,6 +66,7 @@ const useEmailWrapper = ({
|
|
|
66
66
|
Email,
|
|
67
67
|
templateData,
|
|
68
68
|
params,
|
|
69
|
+
isEditEmail = true,
|
|
69
70
|
}) => {
|
|
70
71
|
// State management
|
|
71
72
|
const [templateName, setTemplateName] = useState('');
|
|
@@ -194,7 +195,10 @@ const useEmailWrapper = ({
|
|
|
194
195
|
return;
|
|
195
196
|
}
|
|
196
197
|
|
|
197
|
-
// New flow: Fetch template details
|
|
198
|
+
// New flow: Fetch template details only when editing (not when creating)
|
|
199
|
+
if (!isEditEmail) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
198
202
|
const hasParamsId = params?.id || location?.query?.id || location?.params?.id || location?.pathname?.includes('/edit/');
|
|
199
203
|
const hasTemplateDetails = Email?.templateDetails && !isEmpty(Email.templateDetails);
|
|
200
204
|
const hasTemplateDataProp = templateData && !isEmpty(templateData);
|
|
@@ -207,7 +211,7 @@ const useEmailWrapper = ({
|
|
|
207
211
|
emailActions.getTemplateDetails(templateId, 'email');
|
|
208
212
|
}
|
|
209
213
|
}
|
|
210
|
-
}, [params?.id, location?.query?.id, location?.params?.id, location?.pathname, Email?.templateDetails, Email?.getTemplateDetailsInProgress, templateData, emailActions]);
|
|
214
|
+
}, [isEditEmail, params?.id, location?.query?.id, location?.params?.id, location?.pathname, Email?.templateDetails, Email?.getTemplateDetailsInProgress, templateData, emailActions]);
|
|
211
215
|
|
|
212
216
|
// Effect to set BEETemplate when template details are loaded for BEE templates
|
|
213
217
|
// This ensures Email component can properly initialize BEE editor
|
|
@@ -643,7 +647,7 @@ const useEmailWrapper = ({
|
|
|
643
647
|
// If template was created in BEE AND BEE is enabled → open in BEE editor
|
|
644
648
|
// Otherwise → open in HTML editor (fallback)
|
|
645
649
|
// IMPORTANT: When supportCKEditor is false, default to HTML editor unless explicitly BEE
|
|
646
|
-
if ((isDragDrop && isBeeEnabled)
|
|
650
|
+
if ((isDragDrop && isBeeEnabled)) {
|
|
647
651
|
editorType = 'BEE';
|
|
648
652
|
selectedEditorMode = null; // BEE uses existing flow
|
|
649
653
|
} else {
|
|
@@ -85,6 +85,7 @@ const EmailWrapper = (props) => {
|
|
|
85
85
|
createTemplateInProgress,
|
|
86
86
|
fetchingCmsData,
|
|
87
87
|
onHtmlEditorValidationStateChange,
|
|
88
|
+
isEditEmail = true,
|
|
88
89
|
} = props;
|
|
89
90
|
|
|
90
91
|
// Pass destructured props to the custom hook
|
|
@@ -143,6 +144,7 @@ const EmailWrapper = (props) => {
|
|
|
143
144
|
Email,
|
|
144
145
|
templateData,
|
|
145
146
|
params,
|
|
147
|
+
isEditEmail,
|
|
146
148
|
});
|
|
147
149
|
|
|
148
150
|
// Render using the presentation component with data from the hook
|
|
@@ -195,6 +197,7 @@ const EmailWrapper = (props) => {
|
|
|
195
197
|
setIsLoadingContent={setIsLoadingContent}
|
|
196
198
|
templateData={templateData}
|
|
197
199
|
params={params}
|
|
200
|
+
isEditEmail={isEditEmail}
|
|
198
201
|
showTemplateName={showTemplateName}
|
|
199
202
|
fetchingLiquidTags={fetchingLiquidTags}
|
|
200
203
|
createTemplateInProgress={createTemplateInProgress}
|
|
@@ -732,7 +732,8 @@ describe('useEmailWrapper', () => {
|
|
|
732
732
|
|
|
733
733
|
await waitFor(() => {
|
|
734
734
|
const emailProps = result.current.emailProps;
|
|
735
|
-
expect(emailProps.editor).toBe('
|
|
735
|
+
expect(emailProps.editor).toBe('HTML');
|
|
736
|
+
expect(emailProps.selectedEditorMode).toBe(EMAIL_CREATE_MODES.HTML_EDITOR);
|
|
736
737
|
});
|
|
737
738
|
});
|
|
738
739
|
|
|
@@ -761,7 +762,8 @@ describe('useEmailWrapper', () => {
|
|
|
761
762
|
|
|
762
763
|
await waitFor(() => {
|
|
763
764
|
const emailProps = result.current.emailProps;
|
|
764
|
-
expect(emailProps.editor).toBe('
|
|
765
|
+
expect(emailProps.editor).toBe('HTML');
|
|
766
|
+
expect(emailProps.selectedEditorMode).toBe(EMAIL_CREATE_MODES.HTML_EDITOR);
|
|
765
767
|
});
|
|
766
768
|
});
|
|
767
769
|
});
|