@capillarytech/creatives-library 8.0.245 → 8.0.246-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
CHANGED
|
@@ -102,13 +102,11 @@ function SlideBoxFooter(props) {
|
|
|
102
102
|
// 2. htmlEditorValidationState exists but has no actual errors (meaning errors are from FormBuilder/BEE editor)
|
|
103
103
|
// IMPORTANT: Only check for BEE editor errors when NOT in HTML Editor mode (upload or html_editor)
|
|
104
104
|
// Upload mode uses HTML Editor, so BEE editor errors don't apply
|
|
105
|
+
// IMPORTANT: BEE editor doesn't have real-time content updates,
|
|
106
|
+
// so we should NOT disable buttons based on validation errors
|
|
105
107
|
const isBEEEditorMode = !isHTMLEditorMode;
|
|
106
108
|
const hasBEEEditorErrors = isEmailChannel && isBEEEditorMode && (hasStandardErrors || hasLiquidErrors) && (!htmlEditorValidationState || !htmlEditorHasErrors);
|
|
107
109
|
|
|
108
|
-
// Also disable buttons if there are BEE editor errors (only when using BEE Editor, not HTML Editor/upload)
|
|
109
|
-
if (hasBEEEditorErrors) {
|
|
110
|
-
shouldDisableButtons = true;
|
|
111
|
-
}
|
|
112
110
|
|
|
113
111
|
const shouldShowErrorInfoNote = hasBEEEditorErrors;
|
|
114
112
|
return (
|
|
@@ -289,8 +289,18 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
|
|
292
|
-
checkBeeEditorAllowedForLibrary = () => {
|
|
293
|
-
|
|
292
|
+
checkBeeEditorAllowedForLibrary = (props = null) => {
|
|
293
|
+
// Allow passing props for use in componentWillReceiveProps (to use nextProps)
|
|
294
|
+
const componentProps = props || this.props;
|
|
295
|
+
const { isFullMode = false, editor, Email } = componentProps || {};
|
|
296
|
+
// IMPORTANT: For isBEEAppEnable API parameter, use API response if available
|
|
297
|
+
// This ensures consistent behavior across full mode and library mode
|
|
298
|
+
// The API response (Email.isBeeEnabled) represents the actual org setting
|
|
299
|
+
if (Email?.isBeeEnabled !== undefined && Email?.isBeeEnabled !== null) {
|
|
300
|
+
return Email.isBeeEnabled;
|
|
301
|
+
}
|
|
302
|
+
// Fallback to mode-based logic for UI purposes (editor selection, etc.)
|
|
303
|
+
// But for API calls, this should ideally use the API response
|
|
294
304
|
if ((editor === "BEE" && !isFullMode) || isFullMode) {
|
|
295
305
|
return true;
|
|
296
306
|
}
|
|
@@ -395,7 +405,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
395
405
|
// This handles the case where BEETemplate is set after componentWillMount
|
|
396
406
|
const wasBEETemplateEmpty = _.isEmpty(this.props.Templates.BEETemplate);
|
|
397
407
|
const isBEETemplateNowSet = !_.isEmpty(nextProps.Templates.BEETemplate);
|
|
398
|
-
const isBEEAppEnable = this.checkBeeEditorAllowedForLibrary();
|
|
408
|
+
const isBEEAppEnable = this.checkBeeEditorAllowedForLibrary(nextProps);
|
|
399
409
|
const isBEESupport = (nextProps.location.query.isBEESupport !== "false") || false;
|
|
400
410
|
|
|
401
411
|
if (wasBEETemplateEmpty && isBEETemplateNowSet && isBEEAppEnable) {
|
|
@@ -104,17 +104,17 @@ const useEmailWrapper = ({
|
|
|
104
104
|
// BEE is enabled if isDragDrop is true in the API response
|
|
105
105
|
// This should work for both full mode and library mode
|
|
106
106
|
const checkBeeEditorEnabled = useCallback(() => {
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
// If we have checked the API and got a response, use that
|
|
107
|
+
// IMPORTANT: Always use API response when available, regardless of mode
|
|
108
|
+
// This ensures consistent behavior across full mode and library mode
|
|
109
|
+
// The API response represents whether BEE is enabled for the organization
|
|
112
110
|
if (isBeeEditorEnabled !== null) {
|
|
113
111
|
return isBeeEditorEnabled;
|
|
114
112
|
}
|
|
115
113
|
// If we haven't checked yet, return false (disabled) until API responds
|
|
114
|
+
// Note: In full mode, BEE might still be allowed for UI purposes (editor selection),
|
|
115
|
+
// but for API calls (isBEEAppEnable), we should use the actual org setting
|
|
116
116
|
return false;
|
|
117
|
-
}, [isBeeEditorEnabled
|
|
117
|
+
}, [isBeeEditorEnabled]);
|
|
118
118
|
|
|
119
119
|
// Helper function to convert numeric templateStep to string step
|
|
120
120
|
const getStepFromTemplateStep = useCallback((templateStepValue) => {
|
|
@@ -138,7 +138,7 @@ const useEmailWrapper = ({
|
|
|
138
138
|
// Convert step to string format if it's numeric
|
|
139
139
|
const currentStep = useMemo(() => getStepFromTemplateStep(step), [step, getStepFromTemplateStep]);
|
|
140
140
|
|
|
141
|
-
// Effect to check BEE enabled status via new API when entering MODE_SELECTION step
|
|
141
|
+
// Effect to check BEE enabled status via new API when entering MODE_SELECTION step or edit mode
|
|
142
142
|
useEffect(() => {
|
|
143
143
|
const supportCKEditor = hasSupportCKEditor();
|
|
144
144
|
// Only check BEE enabled status for new flow (when supportCKEditor is false)
|
|
@@ -147,10 +147,16 @@ const useEmailWrapper = ({
|
|
|
147
147
|
beeStatusCheckRef.current = false;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
// Check if we're in edit mode (need to check BEE status for editor selection)
|
|
151
|
+
const hasParamsId = params?.id || location?.query?.id || location?.params?.id || location?.pathname?.includes('/edit/');
|
|
152
|
+
console.log('***hasParamsId', hasParamsId, location, params);
|
|
153
|
+
const isEditMode = hasParamsId;
|
|
154
|
+
|
|
150
155
|
// Only check BEE enabled status for new flow (when supportCKEditor is false)
|
|
156
|
+
// Call API in MODE_SELECTION step OR in edit mode (if not already called)
|
|
151
157
|
// Check all conditions
|
|
152
158
|
const shouldMakeCall = !supportCKEditor
|
|
153
|
-
&& currentStep === STEPS.MODE_SELECTION
|
|
159
|
+
&& (currentStep === STEPS.MODE_SELECTION || isEditMode)
|
|
154
160
|
&& !beeStatusCheckRef.current
|
|
155
161
|
&& emailActions;
|
|
156
162
|
|
|
@@ -161,16 +167,16 @@ const useEmailWrapper = ({
|
|
|
161
167
|
// Make API call to check BEE enabled status using new endpoint
|
|
162
168
|
emailActions.getCmsAccounts('BEE_PLUGIN');
|
|
163
169
|
}
|
|
164
|
-
}, [currentStep, emailActions]);
|
|
170
|
+
}, [currentStep, emailActions, params?.id, location?.query?.id, location?.params?.id, location?.pathname]);
|
|
165
171
|
|
|
166
172
|
// Effect to update isBeeEditorEnabled based on new API response
|
|
167
173
|
// This effect watches for isBeeEnabled from the new API response
|
|
168
174
|
useEffect(() => {
|
|
169
|
-
//
|
|
175
|
+
// Process API response regardless of step (needed for edit mode editor selection)
|
|
170
176
|
// Also check if we've made the API call (beeStatusCheckRef.current === true)
|
|
171
|
-
if (
|
|
177
|
+
if (beeStatusCheckRef.current) {
|
|
172
178
|
// Use isBeeEnabled from the new API response
|
|
173
|
-
if (Email?.isBeeEnabled !== undefined) {
|
|
179
|
+
if (Email?.isBeeEnabled !== undefined && Email?.isBeeEnabled !== null) {
|
|
174
180
|
setIsBeeEditorEnabled(Email.isBeeEnabled);
|
|
175
181
|
}
|
|
176
182
|
}
|
|
@@ -178,7 +184,7 @@ const useEmailWrapper = ({
|
|
|
178
184
|
if (Email?.fetchingCmsAccountsError && beeStatusCheckRef.current) {
|
|
179
185
|
setIsBeeEditorEnabled(false);
|
|
180
186
|
}
|
|
181
|
-
}, [Email?.isBeeEnabled, Email?.fetchingCmsAccountsError
|
|
187
|
+
}, [Email?.isBeeEnabled, Email?.fetchingCmsAccountsError]);
|
|
182
188
|
|
|
183
189
|
// Effect to fetch template details when in edit mode
|
|
184
190
|
// This ensures template data is loaded so editor type can be determined correctly
|
|
@@ -255,8 +261,10 @@ const useEmailWrapper = ({
|
|
|
255
261
|
|| editTemplateData._id;
|
|
256
262
|
|
|
257
263
|
const isBEESupport = (location?.query?.isBEESupport !== "false") || false;
|
|
258
|
-
//
|
|
259
|
-
|
|
264
|
+
// IMPORTANT: isBEEAppEnable should be consistent across full mode and library mode
|
|
265
|
+
// It represents whether BEE is enabled for the organization, not the mode
|
|
266
|
+
// This ensures the same template behaves the same way in both modes
|
|
267
|
+
const isBEEAppEnable = checkBeeEditorEnabled();
|
|
260
268
|
// Check if we're in edit mode - check multiple sources for id
|
|
261
269
|
const hasParamsId = params?.id
|
|
262
270
|
|| location?.query?.id
|
|
@@ -624,9 +632,17 @@ const useEmailWrapper = ({
|
|
|
624
632
|
const isDragDrop = getIsDragDrop(editTemplateData);
|
|
625
633
|
|
|
626
634
|
// Check if BEE is enabled for org (equivalent to checkBeeEditorAllowedForLibrary)
|
|
627
|
-
// For
|
|
628
|
-
//
|
|
629
|
-
|
|
635
|
+
// For editor selection:
|
|
636
|
+
// - In full mode: BEE is always enabled
|
|
637
|
+
// - In library mode: Check API response, but if API hasn't responded yet and template is BEE, allow BEE (optimistic)
|
|
638
|
+
// - Also check if editor prop is explicitly "BEE"
|
|
639
|
+
const beeEnabledFromAPI = checkBeeEditorEnabled();
|
|
640
|
+
const isAPIResponsePending = isBeeEditorEnabled === null;
|
|
641
|
+
console.log('***isAPIResponsePending', isAPIResponsePending, 'isDragDrop', isDragDrop, 'isFullMode', isFullMode, 'editor', editor, 'beeEnabledFromAPI', beeEnabledFromAPI, 'isAPIResponsePending && isDragDrop && !isFullMode', isAPIResponsePending && isDragDrop && !isFullMode);
|
|
642
|
+
const isBeeEnabled = isFullMode
|
|
643
|
+
|| (editor === "BEE" && !isFullMode)
|
|
644
|
+
|| beeEnabledFromAPI
|
|
645
|
+
|| (isAPIResponsePending && isDragDrop && !isFullMode); // Optimistic: if template is BEE and API pending, allow BEE
|
|
630
646
|
|
|
631
647
|
// If template was created in BEE AND BEE is enabled → open in BEE editor
|
|
632
648
|
// Otherwise → open in HTML editor (fallback)
|
|
@@ -754,6 +770,7 @@ const useEmailWrapper = ({
|
|
|
754
770
|
selectedCreateMode,
|
|
755
771
|
supportCKEditorFlag,
|
|
756
772
|
checkBeeEditorEnabled,
|
|
773
|
+
isBeeEditorEnabled, // Include to recalculate when API response arrives
|
|
757
774
|
Email,
|
|
758
775
|
location,
|
|
759
776
|
params,
|