@capillarytech/creatives-library 7.18.0-beta.0 → 8.0.1
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/app.js +27 -54
- package/assets/Line_Preview_English.svg +24 -0
- package/assets/Line_Preview_Japanese.svg +24 -0
- package/components/CapTagList/index.js +2 -2
- package/components/CapTagList/messages.js +8 -0
- package/components/Ckeditor/index.js +4 -2
- package/components/Ckeditor/style.scss +3 -0
- package/components/FormBuilder/_formBuilder.scss +4 -16
- package/components/FormBuilder/index.js +4 -3
- package/components/FormBuilder/messages.js +4 -0
- package/components/Sidebar/index.js +4 -4
- package/config/path.js +1 -1
- package/containers/App/constants.js +95 -0
- package/containers/App/index.js +52 -0
- package/containers/App/sagas.js +8 -3
- package/containers/Assets/Gallery/index.js +17 -3
- package/containers/Assets/Gallery/messages.js +4 -0
- package/containers/Assets/Gallery/sagas.js +14 -14
- package/containers/Cap/index.js +84 -50
- package/containers/Cap/sagas.js +20 -12
- package/containers/Cap/selectors.js +13 -13
- package/containers/Cap/tests/__snapshots__/index.test.js.snap +1 -1
- package/containers/Cap/tests/saga.test.js +81 -1
- package/containers/Dashboard/index.js +34 -17
- package/containers/Dashboard/sagas.js +7 -1
- package/containers/Ebill/index.js +16 -3
- package/containers/Ebill/sagas.js +18 -11
- package/containers/Email/index.js +20 -3
- package/containers/Email/sagas.js +34 -23
- package/containers/LanguageProvider/index.js +49 -31
- package/containers/LanguageProvider/tests/index.test.js +5 -3
- package/containers/Line/Create/index.js +15 -2
- package/containers/Line/Create/sagas.js +26 -17
- package/containers/Line/Edit/sagas.js +12 -13
- package/containers/Login/index.js +36 -11
- package/containers/MobilePush/Create/index.js +17 -2
- package/containers/MobilePush/Create/sagas.js +18 -12
- package/containers/MobilePush/Edit/index.js +20 -3
- package/containers/MobilePush/Edit/sagas.js +30 -20
- package/containers/Sms/Create/index.js +15 -2
- package/containers/Sms/Create/sagas.js +8 -6
- package/containers/Sms/Edit/index.js +15 -3
- package/containers/Sms/Edit/sagas.js +14 -8
- package/containers/TagList/constants.js +23 -0
- package/containers/Templates/actions.js +0 -5
- package/containers/Templates/index.js +47 -14
- package/containers/Templates/sagas.js +20 -23
- package/containers/WeChat/MapTemplates/index.js +19 -2
- package/containers/WeChat/MapTemplates/sagas.js +17 -17
- package/containers/WeChat/RichmediaTemplates/Create/index.js +18 -2
- package/containers/WeChat/RichmediaTemplates/Create/sagas.js +11 -8
- package/containers/WeChat/RichmediaTemplates/Edit/index.js +21 -2
- package/containers/WeChat/RichmediaTemplates/Edit/sagas.js +9 -5
- package/entry.js +2 -0
- package/global-styles.js +2 -2
- package/gtm/eventDefinitionsMap.js +1 -1
- package/helpers/intl-enzym-test-helpers.js +1 -1
- package/hoc/withReactRouterV3Compatibility.js +66 -0
- package/index.js +12 -0
- package/initialReducer.js +32 -0
- package/initialState.js +1 -0
- package/mfe-exposed-components.js +8 -0
- package/package.json +16 -11
- package/routes.js +206 -749
- package/services/api.js +62 -17
- package/services/tests/api.test.js +248 -1
- package/styles/components/navigation/_leftnav.scss +13 -0
- package/styles/containers/layout/_layoutPage.scss +14 -0
- package/tests/integration/TemplateCreation/TemplateCreation.integration.test.js +21 -16
- package/tests/store.test.js +5 -3
- package/translations/en.json +1 -9
- package/translations/ja-JP.json +0 -8
- package/translations/zh.json +0 -8
- package/utils/authWrapper.js +43 -17
- package/utils/cdnTransformation.js +73 -44
- package/utils/checkStore.js +21 -0
- package/utils/common.js +198 -8
- package/utils/commonUtils.js +17 -1
- package/utils/customAuthWrapper.js +62 -0
- package/utils/customConnectedAuthWrapper.js +26 -0
- package/utils/history.js +8 -0
- package/utils/injectReducer.js +2 -0
- package/utils/injectSaga.js +2 -0
- package/utils/tagValidations.js +2 -2
- package/utils/tests/cdnTransformation.test.js +6 -4
- package/utils/tests/common.mockdata.js +623 -0
- package/utils/tests/common.test.js +273 -0
- package/utils/tests/commonUtil.test.js +79 -0
- package/v2Components/CapDeviceContent/index.js +330 -0
- package/v2Components/CapDeviceContent/index.scss +115 -0
- package/v2Components/CapDeviceContent/messages.js +94 -0
- package/v2Components/CapDeviceContent/tests/index.test.js +89 -0
- package/v2Components/CapImageUpload/constants.js +6 -0
- package/v2Components/CapImageUpload/index.js +23 -15
- package/v2Components/CapImageUpload/index.scss +6 -0
- package/v2Components/CapImageUpload/messages.js +7 -7
- package/v2Components/CapInAppCTA/constants.js +25 -0
- package/v2Components/CapInAppCTA/index.js +279 -0
- package/v2Components/CapInAppCTA/index.scss +99 -0
- package/v2Components/CapInAppCTA/messages.js +85 -0
- package/v2Components/CapTagList/index.js +149 -26
- package/v2Components/CapTagList/messages.js +12 -0
- package/v2Components/CapTagList/style.scss +26 -0
- package/v2Components/CapVideoUpload/constants.js +6 -0
- package/v2Components/CapVideoUpload/index.js +48 -22
- package/v2Components/CapVideoUpload/index.scss +4 -2
- package/v2Components/CapVideoUpload/messages.js +10 -6
- package/v2Components/CapWhatsappQuickReply/index.js +255 -0
- package/v2Components/CapWhatsappQuickReply/index.scss +54 -0
- package/v2Components/CapWhatsappQuickReply/messages.js +32 -0
- package/v2Components/Ckeditor/index.js +56 -22
- package/v2Components/Ckeditor/style.scss +3 -0
- package/v2Components/Ckeditor/tests/index.test.js +44 -0
- package/v2Components/CmsTemplatesComponent/index.js +1 -0
- package/v2Components/CmsTemplatesComponent/messages.js +4 -0
- package/v2Components/EmailMobilePreview/index.js +4 -2
- package/v2Components/EmailPreviewV2/index.js +6 -4
- package/v2Components/EmailPreviewV2/tests/__snapshots__/index.test.js.snap +0 -3
- package/v2Components/FormBuilder/_formBuilder.scss +1 -0
- package/v2Components/FormBuilder/constants.js +1 -1
- package/v2Components/FormBuilder/index.js +111 -29
- package/v2Components/FormBuilder/messages.js +4 -0
- package/v2Components/FormBuilder/tests/index.test.js +5 -2
- package/v2Components/MobilePushPreviewV2/index.js +57 -22
- package/v2Components/NavigationBar/constants.js +1 -0
- package/v2Components/NavigationBar/index.js +84 -113
- package/v2Components/NavigationBar/messages.js +8 -0
- package/v2Components/NavigationBar/style.js +9 -0
- package/v2Components/NavigationBar/tests/index.test.js +32 -9
- package/v2Components/NavigationBar/tests/mockData.js +1 -0
- package/v2Components/NewCallTask/tests/index.test.js +5 -3
- package/v2Components/Pagination/index.js +2 -1
- package/v2Components/RenderRoute/RenderRoute.js +11 -0
- package/v2Components/RenderRoute/index.js +1 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +535 -0
- package/v2Components/TemplatePreview/assets/images/inapp_mobile_android_bottom.svg +11 -0
- package/v2Components/TemplatePreview/assets/images/inapp_mobile_android_full.svg +11 -0
- package/v2Components/TemplatePreview/assets/images/inapp_mobile_android_modal.svg +11 -0
- package/v2Components/TemplatePreview/assets/images/inapp_mobile_android_top.svg +11 -0
- package/v2Components/TemplatePreview/assets/images/inapp_mobile_ios_bottom.svg +6 -0
- package/v2Components/TemplatePreview/assets/images/inapp_mobile_ios_full.svg +18 -0
- package/v2Components/TemplatePreview/assets/images/inapp_mobile_ios_modal.svg +7 -0
- package/v2Components/TemplatePreview/assets/images/inapp_mobile_ios_top.svg +13 -0
- package/v2Components/TemplatePreview/index.js +745 -362
- package/v2Components/TemplatePreview/messages.js +8 -0
- package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +47 -14
- package/v2Components/TemplatePreview/tests/index.test.js +9 -0
- package/v2Components/WhatsappStatusContainer/_whatsappStatusContainer.scss +8 -1
- package/v2Containers/App/constants.js +12 -6
- package/v2Containers/App/sagas.js +0 -1
- package/v2Containers/Assets/Gallery/index.js +1 -0
- package/v2Containers/Assets/Gallery/sagas.js +15 -14
- package/v2Containers/BeeEditor/index.js +3 -1
- package/v2Containers/BeeEditor/sagas.js +8 -5
- package/v2Containers/CallTask/sagas.js +7 -1
- package/v2Containers/Cap/actions.js +4 -0
- package/v2Containers/Cap/constants.js +20 -1
- package/v2Containers/Cap/index.js +116 -17
- package/v2Containers/Cap/messages.js +8 -0
- package/v2Containers/Cap/reducer.js +18 -3
- package/v2Containers/Cap/sagas.js +64 -9
- package/v2Containers/Cap/selectors.js +27 -13
- package/v2Containers/Cap/tests/Cap.test.js +164 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +2 -1
- package/v2Containers/Cap/tests/actions.test.js +11 -0
- package/v2Containers/Cap/tests/reducer.test.js +59 -0
- package/v2Containers/Cap/tests/saga.test.js +181 -2
- package/v2Containers/Cap/tests/selectors.test.js +42 -18
- package/v2Containers/CapFacebookPreview/sagas.js +7 -5
- package/v2Containers/CreativesContainer/SlideBoxContent.js +86 -4
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +4 -3
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +30 -14
- package/v2Containers/CreativesContainer/constants.js +5 -0
- package/v2Containers/CreativesContainer/index.js +157 -38
- package/v2Containers/CreativesContainer/index.scss +12 -0
- package/v2Containers/CreativesContainer/messages.js +33 -1
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +11 -0
- package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +5 -2
- package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +7 -1
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +227 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +73 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +80 -0
- package/v2Containers/CreativesContainer/tests/index.test.js +16 -0
- package/v2Containers/Ebill/sagas.js +3 -10
- package/v2Containers/Email/index.js +38 -19
- package/v2Containers/Email/initialSchema.js +1 -1
- package/v2Containers/Email/sagas.js +22 -26
- package/v2Containers/EmailWrapper/index.js +18 -8
- package/v2Containers/FTP/index.js +2 -2
- package/v2Containers/FTP/sagas.js +3 -4
- package/v2Containers/Facebook/sagas.js +26 -17
- package/v2Containers/InApp/actions.js +64 -0
- package/v2Containers/InApp/constants.js +160 -0
- package/v2Containers/InApp/index.js +792 -0
- package/v2Containers/InApp/index.scss +50 -0
- package/v2Containers/InApp/messages.js +114 -0
- package/v2Containers/InApp/reducer.js +109 -0
- package/v2Containers/InApp/sagas.js +151 -0
- package/v2Containers/InApp/selectors.js +12 -0
- package/v2Containers/InApp/tests/action.test.js +53 -0
- package/v2Containers/InApp/tests/index.test.js +165 -0
- package/v2Containers/InApp/tests/mockData.js +898 -0
- package/v2Containers/InApp/tests/reducer.test.js +177 -0
- package/v2Containers/InApp/tests/sagas.test.js +391 -0
- package/v2Containers/InApp/utils.js +12 -0
- package/v2Containers/LanguageProvider/index.js +17 -5
- package/v2Containers/LanguageProvider/reducer.js +3 -2
- package/v2Containers/LanguageProvider/sagas.js +7 -8
- package/v2Containers/LanguageProvider/selectors.js +2 -1
- package/v2Containers/LanguageProvider/tests/index.test.js +5 -2
- package/v2Containers/LanguageProvider/tests/reducer.test.js +6 -3
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +28 -16
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -2
- package/v2Containers/Line/Container/ImageCarousel/tests/content.test.js +5 -3
- package/v2Containers/Line/Container/ImageCarousel/tests/index.test.js +5 -3
- package/v2Containers/Line/Container/ImageMap/index.js +1 -1
- package/v2Containers/Line/Container/Text/index.js +16 -1
- package/v2Containers/Line/Container/Video/index.js +2 -1
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +18134 -107
- package/v2Containers/Line/Container/Wrapper/tests/index.test.js +5 -3
- package/v2Containers/Line/Container/Wrapper/utils.js +1 -1
- package/v2Containers/Line/Container/index.js +4 -0
- package/v2Containers/Line/Container/sagas.js +30 -20
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +123 -81
- package/v2Containers/Line/Container/tests/index.test.js +5 -2
- package/v2Containers/Login/index.js +1 -2
- package/v2Containers/MobilePush/Create/index.js +40 -17
- package/v2Containers/MobilePush/Create/sagas.js +18 -12
- package/v2Containers/MobilePush/Edit/index.js +16 -7
- package/v2Containers/MobilePush/Edit/sagas.js +30 -20
- package/v2Containers/MobilepushWrapper/index.js +3 -0
- package/v2Containers/Rcs/sagas.js +14 -14
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +123 -87
- package/v2Containers/Rcs/tests/index.test.js +5 -3
- package/v2Containers/Sms/Create/sagas.js +10 -6
- package/v2Containers/Sms/Edit/sagas.js +14 -8
- package/v2Containers/SmsTrai/Create/sagas.js +9 -10
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -4
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +12 -8
- package/v2Containers/SmsTrai/Edit/tests/index.test.js +5 -3
- package/v2Containers/TagList/_tagList.scss +18 -0
- package/v2Containers/TagList/index.js +81 -42
- package/v2Containers/TagList/tests/TagList.test.js +6 -7
- package/v2Containers/TagList/tests/mockdata.js +10 -166
- package/v2Containers/TagList/tests/utils.test.js +17 -0
- package/v2Containers/TagList/utils.js +15 -0
- package/v2Containers/Templates/_templates.scss +60 -5
- package/v2Containers/Templates/actions.js +6 -5
- package/v2Containers/Templates/constants.js +2 -1
- package/v2Containers/Templates/index.js +576 -181
- package/v2Containers/Templates/messages.js +52 -8
- package/v2Containers/Templates/reducer.js +3 -1
- package/v2Containers/Templates/sagas.js +54 -38
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +669 -43
- package/v2Containers/Templates/tests/actions.test.js +19 -0
- package/v2Containers/Templates/tests/index.test.js +53 -1
- package/v2Containers/Templates/tests/mockData.js +45 -1
- package/v2Containers/Templates/tests/reducer.test.js +50 -0
- package/v2Containers/Templates/tests/sagas.test.js +116 -3
- package/v2Containers/Templates/tests/selector.test.js +17 -0
- package/v2Containers/TemplatesV2/index.js +180 -8
- package/v2Containers/TemplatesV2/messages.js +8 -0
- package/v2Containers/TemplatesV2/tests/index.test.js +104 -0
- package/v2Containers/TemplatesV2/tests/mockData.js +685 -0
- package/v2Containers/Viber/constants.js +58 -0
- package/v2Containers/Viber/index.js +404 -421
- package/v2Containers/Viber/index.scss +107 -0
- package/v2Containers/Viber/messages.js +70 -2
- package/v2Containers/Viber/sagas.js +22 -14
- package/v2Containers/Viber/style.js +20 -0
- package/v2Containers/Viber/tests/index.test.js +299 -0
- package/v2Containers/Viber/tests/mockData.js +134 -0
- package/v2Containers/WeChat/MapTemplates/sagas.js +22 -14
- package/v2Containers/WeChat/RichmediaTemplates/Create/sagas.js +12 -11
- package/v2Containers/WeChat/RichmediaTemplates/Edit/sagas.js +9 -5
- package/v2Containers/Whatsapp/actions.js +16 -0
- package/v2Containers/Whatsapp/constants.js +24 -0
- package/v2Containers/Whatsapp/index.js +892 -222
- package/v2Containers/Whatsapp/index.scss +91 -1
- package/v2Containers/Whatsapp/messages.js +98 -1
- package/v2Containers/Whatsapp/reducer.js +19 -0
- package/v2Containers/Whatsapp/sagas.js +67 -12
- package/v2Containers/Whatsapp/styles.scss +35 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +34983 -24886
- package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +12 -0
- package/v2Containers/Whatsapp/tests/actions.test.js +21 -0
- package/v2Containers/Whatsapp/tests/index.test.js +17 -4
- package/v2Containers/Whatsapp/tests/mockData.js +77 -0
- package/v2Containers/Whatsapp/tests/reducer.test.js +67 -0
- package/v2Containers/Whatsapp/tests/saga.test.js +201 -0
- package/v2Containers/Whatsapp/tests/utils.test.js +18 -0
- package/v2Containers/Whatsapp/utils.js +65 -4
- package/v2Containers/Zalo/actions.js +24 -0
- package/v2Containers/Zalo/constants.js +59 -0
- package/v2Containers/Zalo/index.js +548 -0
- package/v2Containers/Zalo/index.scss +75 -0
- package/v2Containers/Zalo/messages.js +86 -0
- package/v2Containers/Zalo/reducer.js +63 -0
- package/v2Containers/Zalo/saga.js +45 -0
- package/v2Containers/Zalo/selectors.js +19 -0
- package/v2Containers/Zalo/tests/actions.test.js +26 -0
- package/v2Containers/Zalo/tests/index.test.js +149 -0
- package/v2Containers/Zalo/tests/mockData.js +11527 -0
- package/v2Containers/Zalo/tests/reducer.test.js +96 -0
- package/v2Containers/Zalo/tests/saga.test.js +118 -0
- package/v2Containers/Zalo/tests/selector.test.js +51 -0
- package/v2Containers/mockdata.js +1531 -680
- package/containers/TestPage/constants.js +0 -7
- package/containers/TestPage/index.js +0 -31
- package/containers/TestPage/messages.js +0 -13
- package/containers/TestPage/reducer.js +0 -21
- package/containers/TestPage/sagas.js +0 -11
- package/containers/Testv2/actions.js +0 -15
- package/containers/Testv2/constants.js +0 -7
- package/containers/Testv2/index.js +0 -47
- package/containers/Testv2/messages.js +0 -21
- package/containers/Testv2/reducer.js +0 -23
- package/containers/Testv2/sagas.js +0 -11
- package/containers/Testv2/selectors.js +0 -25
- package/reducers.js +0 -73
- package/store.js +0 -61
- package/utils/tests/asyncInjectors.test.js +0 -173
- package/v2Containers/TestPage/constants.js +0 -7
- package/v2Containers/TestPage/index.js +0 -31
- package/v2Containers/TestPage/messages.js +0 -13
- package/v2Containers/TestPage/reducer.js +0 -21
- package/v2Containers/TestPage/sagas.js +0 -11
- package/v2Containers/Testv2/actions.js +0 -15
- package/v2Containers/Testv2/constants.js +0 -7
- package/v2Containers/Testv2/index.js +0 -47
- package/v2Containers/Testv2/messages.js +0 -21
- package/v2Containers/Testv2/reducer.js +0 -23
- package/v2Containers/Testv2/sagas.js +0 -11
- package/v2Containers/Testv2/selectors.js +0 -25
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { injectIntl, intlShape } from "react-intl";
|
|
4
|
+
import cloneDeep from "lodash/cloneDeep";
|
|
5
|
+
import CapRow from "@capillarytech/cap-ui-library/CapRow";
|
|
6
|
+
import CapHeader from "@capillarytech/cap-ui-library/CapHeader";
|
|
7
|
+
import CapHeading from "@capillarytech/cap-ui-library/CapHeading";
|
|
8
|
+
import CapTooltipWithInfo from "@capillarytech/cap-ui-library/CapTooltipWithInfo";
|
|
9
|
+
import CapInput from "@capillarytech/cap-ui-library/CapInput";
|
|
10
|
+
import CapError from "@capillarytech/cap-ui-library/CapError";
|
|
11
|
+
import CapTooltip from "@capillarytech/cap-ui-library/CapTooltip";
|
|
12
|
+
import CapButton from "@capillarytech/cap-ui-library/CapButton";
|
|
13
|
+
import CapColumn from "@capillarytech/cap-ui-library/CapColumn";
|
|
14
|
+
import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
|
|
15
|
+
import CapLabel from "@capillarytech/cap-ui-library/CapLabel";
|
|
16
|
+
import CapInfoNote from "@capillarytech/cap-ui-library/CapInfoNote";
|
|
17
|
+
import messages from "./messages";
|
|
18
|
+
import "./index.scss";
|
|
19
|
+
import globalMessages from "../../v2Containers/Cap/messages";
|
|
20
|
+
import { BUTTON_TEXT, INITIAL_QUICK_REPLY_DATA } from "../../v2Containers/Whatsapp/constants";
|
|
21
|
+
import ctaMessages from "../CapWhatsappCTA/messages";
|
|
22
|
+
|
|
23
|
+
export const CapWhatsappQuickReply = (props) => {
|
|
24
|
+
const { quickReplyData = [], renderMessageLength, setQuickReplyData, isEditFlow, intl,authenticationFlow } = props;
|
|
25
|
+
const { TextArea } = CapInput;
|
|
26
|
+
const { formatMessage } = intl;
|
|
27
|
+
const quickReplyDataLength = quickReplyData?.length;
|
|
28
|
+
//this function is used for handle text field value change
|
|
29
|
+
const handleTextChange = ({target: {value = ''} = {}}, index) => {
|
|
30
|
+
let error = false;
|
|
31
|
+
if (value?.length > 20) {
|
|
32
|
+
error = formatMessage(messages.templateButtonTextLengthError);
|
|
33
|
+
}
|
|
34
|
+
//this check is for same repeated value is not allowed in another text field of quick reply
|
|
35
|
+
const checkIsValueAvailable = quickReplyData?.find((reply) => reply?.text === value);
|
|
36
|
+
if (checkIsValueAvailable) {
|
|
37
|
+
error = formatMessage(messages.templateButtonTextSameValue);
|
|
38
|
+
}
|
|
39
|
+
setQuickReplyData(
|
|
40
|
+
quickReplyData?.map((quickReply) => {
|
|
41
|
+
if (quickReply?.index === index) {
|
|
42
|
+
return {
|
|
43
|
+
...quickReply,
|
|
44
|
+
text: value,
|
|
45
|
+
error,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return quickReply;
|
|
49
|
+
})
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
//this function is used for save the quick reply text field data and same edit the data
|
|
54
|
+
const handleSaveAndEditBtn = (index, value) => {
|
|
55
|
+
setQuickReplyData(
|
|
56
|
+
quickReplyData.map((quickReply) => {
|
|
57
|
+
if (quickReply?.index === index) {
|
|
58
|
+
return {
|
|
59
|
+
...quickReply,
|
|
60
|
+
isSaved: value,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return quickReply;
|
|
64
|
+
})
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
//This function is used for delete the quick reply data for a row
|
|
69
|
+
const handleDelete = (index) => {
|
|
70
|
+
setQuickReplyData((prevState) => {
|
|
71
|
+
const clonedQuickReplyData = cloneDeep(prevState);
|
|
72
|
+
const filteredQuickReplyData = clonedQuickReplyData.filter(
|
|
73
|
+
(i) => i?.index !== index
|
|
74
|
+
);
|
|
75
|
+
return filteredQuickReplyData.map((quickReply, i) => ({
|
|
76
|
+
...quickReply,
|
|
77
|
+
index: i,
|
|
78
|
+
}));
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
const quickReplyConfiguredBtn = ({ text, index, authenticationFlow = false }) => (
|
|
82
|
+
<CapRow className={`cap-whatsapp-quick-reply ${authenticationFlow && 'whatsapp-autofill-container'}`}>
|
|
83
|
+
<CapRow className="whatsapp-quick-reply-save-container">
|
|
84
|
+
{!authenticationFlow && <CapColumn>
|
|
85
|
+
<CapIcon type="six-dots" />
|
|
86
|
+
</CapColumn>}
|
|
87
|
+
<CapColumn className="text-container">{text}</CapColumn>
|
|
88
|
+
<CapColumn className={`quick-reply-icon ${authenticationFlow && 'whatsapp-quick-reply-disabled-icons'}`}>
|
|
89
|
+
<CapIcon
|
|
90
|
+
onClick={() => handleSaveAndEditBtn(index, false)}
|
|
91
|
+
type="edit"
|
|
92
|
+
aria-label="quick-reply-edit"
|
|
93
|
+
/>
|
|
94
|
+
<CapIcon
|
|
95
|
+
onClick={() => handleDelete(index)}
|
|
96
|
+
type="delete"
|
|
97
|
+
aria-label="quick-reply-delete"
|
|
98
|
+
/>
|
|
99
|
+
</CapColumn>
|
|
100
|
+
</CapRow>
|
|
101
|
+
</CapRow>
|
|
102
|
+
)
|
|
103
|
+
const addQuickReply = () => {
|
|
104
|
+
const cloneInitialQuickReplyData = cloneDeep(INITIAL_QUICK_REPLY_DATA);
|
|
105
|
+
cloneInitialQuickReplyData[0].index = quickReplyDataLength || 0;
|
|
106
|
+
const clonedQuickReplyData = [
|
|
107
|
+
...quickReplyData,
|
|
108
|
+
...cloneInitialQuickReplyData,
|
|
109
|
+
];
|
|
110
|
+
setQuickReplyData(clonedQuickReplyData);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const isQuickReplyDisable =
|
|
114
|
+
quickReplyDataLength === 1 && !quickReplyData?.[0]?.isSaved;
|
|
115
|
+
return (
|
|
116
|
+
<>
|
|
117
|
+
{authenticationFlow ?
|
|
118
|
+
<>
|
|
119
|
+
{quickReplyConfiguredBtn({ text: formatMessage(globalMessages.autofill), index: '0', authenticationFlow: true })}
|
|
120
|
+
<CapInfoNote className="margin-l-26" message={formatMessage(messages.autofillInfo)}/>
|
|
121
|
+
</> :
|
|
122
|
+
<>
|
|
123
|
+
{quickReplyDataLength > 0 && !isEditFlow && (
|
|
124
|
+
<CapRow>
|
|
125
|
+
{quickReplyData?.map(({ index, isSaved, text, error }) => {
|
|
126
|
+
if (!isSaved) {
|
|
127
|
+
//this section is render textfield when its not saved or in edit condition
|
|
128
|
+
return (
|
|
129
|
+
<CapRow className="cap-whatsapp-quick-reply">
|
|
130
|
+
<CapRow
|
|
131
|
+
className="whatsapp-button-text-container"
|
|
132
|
+
key={index}
|
|
133
|
+
>
|
|
134
|
+
<CapHeader
|
|
135
|
+
title={
|
|
136
|
+
<CapHeading
|
|
137
|
+
type="h4"
|
|
138
|
+
className="whatsapp-button-text-heading"
|
|
139
|
+
>
|
|
140
|
+
{formatMessage(messages.buttonText)}
|
|
141
|
+
<CapTooltipWithInfo
|
|
142
|
+
placement="right"
|
|
143
|
+
className="whatsapp-button-text-tooltip"
|
|
144
|
+
autoAdjustOverflow
|
|
145
|
+
title={formatMessage(messages.buttonTextTooltip)}
|
|
146
|
+
/>
|
|
147
|
+
</CapHeading>
|
|
148
|
+
}
|
|
149
|
+
/>
|
|
150
|
+
<CapRow className="whatsapp-button-text-input">
|
|
151
|
+
<TextArea
|
|
152
|
+
autosize={{ minRows: 1, maxRows: 5 }}
|
|
153
|
+
placeholder={formatMessage(
|
|
154
|
+
messages.buttonTextPlaceholder
|
|
155
|
+
)}
|
|
156
|
+
onChange={(e) => handleTextChange(e, index)}
|
|
157
|
+
errorMessage={
|
|
158
|
+
error && (
|
|
159
|
+
<CapError className="whatsapp-template-message-error">
|
|
160
|
+
{error}
|
|
161
|
+
</CapError>
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
value={text || ""}
|
|
165
|
+
/>
|
|
166
|
+
</CapRow>
|
|
167
|
+
{renderMessageLength(BUTTON_TEXT, text?.length || 0)}
|
|
168
|
+
{/* it render save and delete button */}
|
|
169
|
+
<CapRow className="whatsapp-cta-save-delete-btn">
|
|
170
|
+
<CapTooltip
|
|
171
|
+
title={
|
|
172
|
+
(text === "" || error)
|
|
173
|
+
&& formatMessage(ctaMessages.ctaSaveDisabled)
|
|
174
|
+
}
|
|
175
|
+
placement={"bottom"}
|
|
176
|
+
>
|
|
177
|
+
<div className="button-disabled-tooltip-wrapper">
|
|
178
|
+
<CapButton
|
|
179
|
+
onClick={() => {
|
|
180
|
+
handleSaveAndEditBtn(index, true);
|
|
181
|
+
}}
|
|
182
|
+
disabled={text === "" || error}
|
|
183
|
+
className="whatsapp-cta-save-btn"
|
|
184
|
+
>
|
|
185
|
+
{formatMessage(globalMessages.save)}
|
|
186
|
+
</CapButton>
|
|
187
|
+
</div>
|
|
188
|
+
</CapTooltip>
|
|
189
|
+
<CapButton
|
|
190
|
+
onClick={() => {
|
|
191
|
+
handleDelete(index);
|
|
192
|
+
}}
|
|
193
|
+
className="whatsapp-cta-delete-btn whatsapp-quick-reply-delete-button"
|
|
194
|
+
type="secondary"
|
|
195
|
+
>
|
|
196
|
+
{formatMessage(globalMessages.delete)}
|
|
197
|
+
</CapButton>
|
|
198
|
+
</CapRow>
|
|
199
|
+
</CapRow>
|
|
200
|
+
</CapRow>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
return (
|
|
204
|
+
//this section render when data is saved and user can edit it
|
|
205
|
+
quickReplyConfiguredBtn({text,index})
|
|
206
|
+
);
|
|
207
|
+
})}
|
|
208
|
+
</CapRow>
|
|
209
|
+
)}
|
|
210
|
+
{/* this section render in edit mode from campaign side */}
|
|
211
|
+
{quickReplyDataLength > 0 && isEditFlow &&
|
|
212
|
+
quickReplyData.map(({text, index}) => (
|
|
213
|
+
<CapRow className="cap-whatsapp-quick-reply whatsapp-quick-reply-edit-container" key={index}>
|
|
214
|
+
<CapLabel type="label16">{text}</CapLabel>
|
|
215
|
+
</CapRow>
|
|
216
|
+
))
|
|
217
|
+
}
|
|
218
|
+
{/* this section render add button section with condition */}
|
|
219
|
+
{quickReplyDataLength < 3 && !isEditFlow && (
|
|
220
|
+
<CapRow>
|
|
221
|
+
<CapTooltip
|
|
222
|
+
title={
|
|
223
|
+
isQuickReplyDisable ? formatMessage(ctaMessages.ctaAddDisabled) : ""
|
|
224
|
+
}
|
|
225
|
+
placement={"right"}
|
|
226
|
+
>
|
|
227
|
+
<div className="button-disabled-tooltip-wrapper">
|
|
228
|
+
<CapButton
|
|
229
|
+
type="flat"
|
|
230
|
+
id="whatsapp-quick-reply-add-button"
|
|
231
|
+
disabled={isQuickReplyDisable}
|
|
232
|
+
className="margin-t-12 margin-l-24"
|
|
233
|
+
isAddBtn
|
|
234
|
+
onClick={addQuickReply}
|
|
235
|
+
>
|
|
236
|
+
{formatMessage(ctaMessages.addButton)}
|
|
237
|
+
</CapButton>
|
|
238
|
+
</div>
|
|
239
|
+
</CapTooltip>
|
|
240
|
+
</CapRow>
|
|
241
|
+
)}</>}
|
|
242
|
+
</>
|
|
243
|
+
);
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
CapWhatsappQuickReply.propTypes = {
|
|
247
|
+
quickReplyData: PropTypes.array,
|
|
248
|
+
renderMessageLength: PropTypes.func,
|
|
249
|
+
setQuickReplyData: PropTypes.func,
|
|
250
|
+
isEditFlow: PropTypes.func,
|
|
251
|
+
intl: intlShape.isRequired,
|
|
252
|
+
authenticationFlow : PropTypes.bool,
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
export default injectIntl(CapWhatsappQuickReply);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
@import "~@capillarytech/cap-ui-library/styles/_variables";
|
|
2
|
+
|
|
3
|
+
.cap-whatsapp-quick-reply {
|
|
4
|
+
border: solid 0.063rem $CAP_G06;
|
|
5
|
+
margin-left: $CAP_SPACE_24;
|
|
6
|
+
margin-top: 0.75rem;
|
|
7
|
+
border-radius: 0.285rem;
|
|
8
|
+
margin-right: 0.5rem;
|
|
9
|
+
.whatsapp-button-text-container {
|
|
10
|
+
padding: $CAP_SPACE_16 $CAP_SPACE_24;
|
|
11
|
+
}
|
|
12
|
+
.whatsapp-button-text-heading {
|
|
13
|
+
display: flex;
|
|
14
|
+
text-align: center;
|
|
15
|
+
}
|
|
16
|
+
.whatsapp-quick-reply-delete-button {
|
|
17
|
+
margin-left: $CAP_SPACE_12;
|
|
18
|
+
}
|
|
19
|
+
.whatsapp-button-text-input {
|
|
20
|
+
margin-top: $CAP_SPACE_08;
|
|
21
|
+
margin-bottom: $CAP_SPACE_12;
|
|
22
|
+
}
|
|
23
|
+
.whatsapp-quick-reply-save-container {
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
padding: $CAP_SPACE_08 $CAP_SPACE_12;
|
|
27
|
+
.text-container {
|
|
28
|
+
padding-left: $CAP_SPACE_12;
|
|
29
|
+
}
|
|
30
|
+
.quick-reply-icon {
|
|
31
|
+
position: absolute;
|
|
32
|
+
right: $CAP_SPACE_12;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
.whatsapp-button-text-tooltip {
|
|
36
|
+
margin-left: $CAP_SPACE_04;
|
|
37
|
+
}
|
|
38
|
+
.whatsapp-quick-reply-disabled-icons{
|
|
39
|
+
color: $FONT_COLOR_04;
|
|
40
|
+
cursor: not-allowed;
|
|
41
|
+
pointer-events: none;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.whatsapp-quick-reply-edit-container {
|
|
46
|
+
padding: $CAP_SPACE_12;
|
|
47
|
+
margin-left: 0;
|
|
48
|
+
margin-top: 0.75rem;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.whatsapp-autofill-container {
|
|
52
|
+
margin-left: 0;
|
|
53
|
+
cursor: not-allowed;
|
|
54
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl';
|
|
2
|
+
const prefix = `creatives.componentsV2.CapWhatsappQuickReply`;
|
|
3
|
+
export default defineMessages({
|
|
4
|
+
buttonText: {
|
|
5
|
+
id: `${prefix}.buttonText`,
|
|
6
|
+
defaultMessage: 'Button text',
|
|
7
|
+
},
|
|
8
|
+
buttonTextPlaceholder: {
|
|
9
|
+
id: `${prefix}.buttonTextPlaceholder`,
|
|
10
|
+
defaultMessage: 'Enter button text',
|
|
11
|
+
},
|
|
12
|
+
templateButtonTextError: {
|
|
13
|
+
id: `${prefix}.templateButtonTextError`,
|
|
14
|
+
defaultMessage: 'Template footer length cannot exceed 20',
|
|
15
|
+
},
|
|
16
|
+
templateButtonTextLengthError: {
|
|
17
|
+
id: `${prefix}.templateButtonTextLengthError`,
|
|
18
|
+
defaultMessage: 'Text field length cannot exceed 20',
|
|
19
|
+
},
|
|
20
|
+
templateButtonTextSameValue: {
|
|
21
|
+
id: `${prefix}.templateButtonTextSameValue`,
|
|
22
|
+
defaultMessage: 'Text field value cannot be same with other text fields',
|
|
23
|
+
},
|
|
24
|
+
buttonTextTooltip: {
|
|
25
|
+
id: `${prefix}.buttonTextTooltip`,
|
|
26
|
+
defaultMessage: 'Use this to name the button. We would recommend not to use special characters for the button text.'
|
|
27
|
+
},
|
|
28
|
+
autofillInfo:{
|
|
29
|
+
id: `${prefix}.autofillInfo`,
|
|
30
|
+
defaultMessage: 'One-tap autofill buttons are only supported on Android. If you send an authentication template to a WhatsApp user who is using a non-Android device, the WhatsApp client will display a copy code button instead.'
|
|
31
|
+
}
|
|
32
|
+
});
|
|
@@ -11,16 +11,22 @@ import React from 'react';
|
|
|
11
11
|
|
|
12
12
|
// import { FormattedMessage } from 'react-intl';
|
|
13
13
|
import _ from 'lodash';
|
|
14
|
+
import CapSpin from '@capillarytech/cap-ui-library/CapSpin';
|
|
15
|
+
import './style.scss';
|
|
14
16
|
// import messages from './messages';
|
|
15
17
|
const loadScript = require('load-script');
|
|
16
|
-
|
|
18
|
+
|
|
19
|
+
const defaultScriptUrl = `${window.location.origin}/arya/ui/library/ckeditor/ckeditor.js`;
|
|
20
|
+
/*const defaultScriptUrl = 'https://nightly.intouch.capillarytech.com/arya/ui/library/ckeditor/ckeditor.js';
|
|
21
|
+
**Uncomment the above line to use CKEDITOR in local
|
|
22
|
+
*/
|
|
17
23
|
const user = localStorage.getItem('user');
|
|
18
24
|
let locale = 'en';
|
|
19
25
|
if (user && JSON.parse(user).lang) {
|
|
20
26
|
locale = JSON.parse(user).lang;
|
|
21
27
|
}
|
|
22
28
|
const CKEditorConfig = {
|
|
23
|
-
skin: 'moono',
|
|
29
|
+
skin: 'moono-lisa',
|
|
24
30
|
toolbar: [
|
|
25
31
|
{ name: 'document', items: ['Source', '-'] },
|
|
26
32
|
{ name: 'clipboard', items: ['Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'] },
|
|
@@ -134,6 +140,8 @@ class Ckeditor extends React.Component { // eslint-disable-line react/prefer-sta
|
|
|
134
140
|
content: "",
|
|
135
141
|
editorInstance: undefined,
|
|
136
142
|
setInitData: false,
|
|
143
|
+
isLoading: true,
|
|
144
|
+
scriptLoaded: false,
|
|
137
145
|
};
|
|
138
146
|
|
|
139
147
|
this.delayTimer = 0;
|
|
@@ -166,7 +174,7 @@ class Ckeditor extends React.Component { // eslint-disable-line react/prefer-sta
|
|
|
166
174
|
// setTimeout(() => {
|
|
167
175
|
// this.editorInstance.name = this.id;
|
|
168
176
|
// }, 5000);
|
|
169
|
-
|
|
177
|
+
|
|
170
178
|
}
|
|
171
179
|
}
|
|
172
180
|
|
|
@@ -180,10 +188,35 @@ class Ckeditor extends React.Component { // eslint-disable-line react/prefer-sta
|
|
|
180
188
|
}
|
|
181
189
|
}
|
|
182
190
|
|
|
183
|
-
|
|
191
|
+
componentDidUpdate(prevProps) {
|
|
192
|
+
if (this.props.content !== prevProps.content) {
|
|
193
|
+
let content = '';
|
|
194
|
+
this.id = this.props.id;
|
|
195
|
+
if (this.props.content !== '') {
|
|
196
|
+
content = this.props.content;
|
|
197
|
+
content = content.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\\"/g, "\"");
|
|
198
|
+
}
|
|
199
|
+
this.setState({ content }, () => {
|
|
200
|
+
if (this.editorInstance) {
|
|
201
|
+
//Check if the current editor content is different from the new content
|
|
202
|
+
const currentEditorData = this.editorInstance?.getData();
|
|
203
|
+
if (!_.isEqual(currentEditorData, content)) {
|
|
204
|
+
this.editorInstance?.setData(content);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
onLoad = () => {
|
|
212
|
+
this.setState({ scriptLoaded: true }, () => {
|
|
213
|
+
this.initializeEditor();
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
initializeEditor = () => {
|
|
184
218
|
if (this.unmounting) return;
|
|
185
219
|
|
|
186
|
-
|
|
187
220
|
if (!window.CKEDITOR) {
|
|
188
221
|
console.error("CKEditor not found");
|
|
189
222
|
return;
|
|
@@ -191,13 +224,13 @@ class Ckeditor extends React.Component { // eslint-disable-line react/prefer-sta
|
|
|
191
224
|
|
|
192
225
|
let html = this.props.content;
|
|
193
226
|
html = html.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, "\"");
|
|
194
|
-
|
|
227
|
+
|
|
195
228
|
this.editorInstance = window.CKEDITOR.appendTo(
|
|
196
229
|
this.node,
|
|
197
230
|
this.state.config,
|
|
198
231
|
html
|
|
199
232
|
);
|
|
200
|
-
|
|
233
|
+
|
|
201
234
|
|
|
202
235
|
if (this.props.getEditorInstanse) {
|
|
203
236
|
this.props.getEditorInstanse(this.editorInstance, this.props.id);
|
|
@@ -208,23 +241,22 @@ class Ckeditor extends React.Component { // eslint-disable-line react/prefer-sta
|
|
|
208
241
|
// this.editorInstance.on('change', this.handleContentChange);
|
|
209
242
|
|
|
210
243
|
// mode event is fired whenever mode is toggled from normal to source mode or vice versa
|
|
211
|
-
// change event works only in wysiwyg(non-source) mode, key event works in both source & wysiwyg(non-source) mode but,
|
|
244
|
+
// change event works only in wysiwyg(non-source) mode, key event works in both source & wysiwyg(non-source) mode but,
|
|
212
245
|
// key event doesn't get fired up while setting text to bold,italic etc..
|
|
213
|
-
this.editorInstance.on('mode',()=>{
|
|
214
|
-
if(this.editorInstance.mode==="source"){
|
|
215
|
-
this.editorInstance.on('key',this.handleContentChange)
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if(this.editorInstance.hasListeners("key")){
|
|
246
|
+
this.editorInstance.on('mode', () => {
|
|
247
|
+
if (this.editorInstance.mode === "source") {
|
|
248
|
+
this.editorInstance.on('key', this.handleContentChange);
|
|
249
|
+
} else {
|
|
250
|
+
if (this.editorInstance.hasListeners("key")) {
|
|
219
251
|
/*Removing the 'key' listener is necessary. If not removed and the mode is switched in the following manner :
|
|
220
252
|
source mode -> Non-source mode -> source mode,
|
|
221
|
-
then under this scenario both 'key' and 'change' listener will get fired on entering text. Except that 'key' listener will not get fired when setting text to 'bold', 'italic' etc.
|
|
253
|
+
then under this scenario both 'key' and 'change' listener will get fired on entering text. Except that 'key' listener will not get fired when setting text to 'bold', 'italic' etc.
|
|
222
254
|
*/
|
|
223
|
-
this.editorInstance.removeListener("key",this.handleContentChange)
|
|
255
|
+
this.editorInstance.removeListener("key", this.handleContentChange);
|
|
224
256
|
}
|
|
225
|
-
this.editorInstance.on('change',this.handleContentChange)
|
|
257
|
+
this.editorInstance.on('change', this.handleContentChange);
|
|
226
258
|
}
|
|
227
|
-
})
|
|
259
|
+
});
|
|
228
260
|
|
|
229
261
|
_.forEach(this.props.events, (event, index) => {
|
|
230
262
|
this.editorInstance.on(index, event);
|
|
@@ -240,6 +272,7 @@ class Ckeditor extends React.Component { // eslint-disable-line react/prefer-sta
|
|
|
240
272
|
this.editorInstance.on(index, event);
|
|
241
273
|
});
|
|
242
274
|
}
|
|
275
|
+
this.setState({ isLoading: false });
|
|
243
276
|
}
|
|
244
277
|
|
|
245
278
|
onFocusOut = () => {
|
|
@@ -268,11 +301,12 @@ class Ckeditor extends React.Component { // eslint-disable-line react/prefer-sta
|
|
|
268
301
|
};
|
|
269
302
|
|
|
270
303
|
render() {
|
|
271
|
-
|
|
272
304
|
return (
|
|
273
|
-
<
|
|
274
|
-
<div
|
|
275
|
-
|
|
305
|
+
<CapSpin spinning={this.state.isLoading}>
|
|
306
|
+
<div id={this.props.id} style={{borderRight: "1px solid #000 !important"}}>
|
|
307
|
+
<div className={this.props.activeClass} ref={(node) => (this.node = node)}/>
|
|
308
|
+
</div>
|
|
309
|
+
</CapSpin>
|
|
276
310
|
);
|
|
277
311
|
}
|
|
278
312
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, { Component } from "react";
|
|
2
|
+
import { injectIntl } from "react-intl";
|
|
3
|
+
import "@testing-library/jest-dom";
|
|
4
|
+
import { render, getByText, screen } from "../../../utils/test-utils";
|
|
5
|
+
import Ckeditor from "../index";
|
|
6
|
+
|
|
7
|
+
const initializeComponent = () => {
|
|
8
|
+
const Component = injectIntl(Ckeditor);
|
|
9
|
+
|
|
10
|
+
//const originalComponentDidMount = Ckeditor.prototype.componentDidMount;
|
|
11
|
+
Ckeditor.prototype.componentDidMount = jest.fn();
|
|
12
|
+
Ckeditor.prototype.handleContentChange = jest.fn();
|
|
13
|
+
|
|
14
|
+
//Render with default props.
|
|
15
|
+
return render(<Component />);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe("Load Ckeditor", () => {
|
|
19
|
+
it("Test if Ckeditor Mounts", () => {
|
|
20
|
+
initializeComponent();
|
|
21
|
+
|
|
22
|
+
expect(Ckeditor.prototype.componentDidMount).toHaveBeenCalled();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("Test if Ckeditor un-Mounts", () => {
|
|
26
|
+
// Spy on the componentWillUnmount method
|
|
27
|
+
const componentWillUnmountSpy = jest.spyOn(
|
|
28
|
+
Ckeditor.prototype,
|
|
29
|
+
"componentWillUnmount"
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// Render the component
|
|
33
|
+
const { unmount } = initializeComponent();
|
|
34
|
+
|
|
35
|
+
// Manually unmount the component (simulate unmounting)
|
|
36
|
+
unmount();
|
|
37
|
+
|
|
38
|
+
// Assert that componentWillUnmount has been called
|
|
39
|
+
expect(componentWillUnmountSpy).toHaveBeenCalled();
|
|
40
|
+
|
|
41
|
+
// Clean up the spy
|
|
42
|
+
componentWillUnmountSpy.mockRestore();
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -28,6 +28,7 @@ function CmsTemplatesComponent(props) {
|
|
|
28
28
|
// Determine if default email templates should be hidden based on feature control
|
|
29
29
|
if (hideDefaultEmailTemplates) {
|
|
30
30
|
if (name === START_FROM_SCRATCH) {
|
|
31
|
+
commonProperties.title = <FormattedMessage {...messages.startFromScratch}/>; // Show the START_FROM_SCRATCH template name text as per the locale
|
|
31
32
|
result.push(commonProperties);
|
|
32
33
|
}
|
|
33
34
|
} else {
|
|
@@ -14,4 +14,8 @@ export default defineMessages({
|
|
|
14
14
|
id: 'creatives.componentsV2.CmsTemplatesComponent.select',
|
|
15
15
|
defaultMessage: 'Select',
|
|
16
16
|
},
|
|
17
|
+
startFromScratch: {
|
|
18
|
+
id: 'creatives.componentsV2.CmsTemplatesComponent.startFromScratch',
|
|
19
|
+
defaultMessage: 'Start from Scratch',
|
|
20
|
+
},
|
|
17
21
|
});
|
|
@@ -18,7 +18,7 @@ import EmailPreviewV2 from '../EmailPreviewV2';
|
|
|
18
18
|
import messages from '../EmailPreviewV2/messages';
|
|
19
19
|
import './index.scss';
|
|
20
20
|
import mobileBody from '../../assets/DeviceForEmail.png';
|
|
21
|
-
import { removeLinksFromHtmlContent } from './../../utils/common';
|
|
21
|
+
import { iframePreviewAdjustWidth, removeLinksFromHtmlContent } from './../../utils/common';
|
|
22
22
|
import {selectTemplateContent} from '../../containers/Templates/selectors';
|
|
23
23
|
import * as templateActions from '../../containers/Templates/actions';
|
|
24
24
|
|
|
@@ -68,6 +68,8 @@ class EmailMobilePreview extends React.Component {
|
|
|
68
68
|
templateSubject,
|
|
69
69
|
} = this.props;
|
|
70
70
|
const copyContent = templateContent && removeLinksFromHtmlContent(templateContent);
|
|
71
|
+
const updateCopyContent = templateContent && iframePreviewAdjustWidth(copyContent);
|
|
72
|
+
|
|
71
73
|
const { showAllDevices } = this.state;
|
|
72
74
|
|
|
73
75
|
const emailSubjectLabel = templateSubject && (
|
|
@@ -98,7 +100,7 @@ class EmailMobilePreview extends React.Component {
|
|
|
98
100
|
<img src={mobileBody} alt="capillary" width="386" />
|
|
99
101
|
<div className={`${messageContainerName} ${emailSubjectLabel ? 'with-subject' : ''}`}>
|
|
100
102
|
{emailSubjectLabel}
|
|
101
|
-
<iframe srcDoc={
|
|
103
|
+
<iframe srcDoc={updateCopyContent} {...deviceAspectRatio.mobile} >
|
|
102
104
|
<p><FormattedMessage {...messages.noIframeSupport}/></p>
|
|
103
105
|
</iframe>
|
|
104
106
|
</div>
|
|
@@ -19,10 +19,11 @@ import messages from './messages';
|
|
|
19
19
|
import './_emailPreviewV2.scss';
|
|
20
20
|
import tabletBody from '../../assets/iPad.svg';
|
|
21
21
|
import mobileBody from '../../assets/DeviceForEmail.png';
|
|
22
|
-
import { removeLinksFromHtmlContent } from './../../utils/common';
|
|
22
|
+
import { iframePreviewAdjustWidth, removeLinksFromHtmlContent } from './../../utils/common';
|
|
23
23
|
|
|
24
24
|
import {selectTemplateContent} from '../../v2Containers/Templates/selectors';
|
|
25
25
|
import * as templateActions from '../../v2Containers/Templates/actions';
|
|
26
|
+
import { EMAIL } from '../../v2Containers/CreativesContainer/constants';
|
|
26
27
|
|
|
27
28
|
const deviceAspectRatio = {
|
|
28
29
|
desktop: () => ({
|
|
@@ -59,7 +60,7 @@ export class EmailPreviewV2 extends React.Component {
|
|
|
59
60
|
componentWillMount() {
|
|
60
61
|
const {templateData, templateContent} = this.props;
|
|
61
62
|
if (isEmpty(templateContent) && !isEmpty(templateData) && templateData._id) { // templateData: comes from templates list email preview
|
|
62
|
-
this.props.templateActions.getTemplateDetails(templateData._id); // templateContent: html data to be shown in iframe
|
|
63
|
+
this.props.templateActions.getTemplateDetails(templateData._id, EMAIL); // templateContent: html data to be shown in iframe
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
componentWillUnmount() {
|
|
@@ -72,7 +73,8 @@ export class EmailPreviewV2 extends React.Component {
|
|
|
72
73
|
let messageContainerName = '';
|
|
73
74
|
const {currentDevice} = this.state;
|
|
74
75
|
const { templateContent, templateData = {}, templateSubject } = this.props;
|
|
75
|
-
const copyContent = removeLinksFromHtmlContent(templateContent);
|
|
76
|
+
const copyContent = templateContent && removeLinksFromHtmlContent(templateContent);
|
|
77
|
+
const updateCopyContent = templateContent && iframePreviewAdjustWidth(copyContent);
|
|
76
78
|
let subjectClassName = 'email-subject-desktop';
|
|
77
79
|
if (currentDevice === devices.tablet) {
|
|
78
80
|
messageContainerName = 'tablet-message-container';
|
|
@@ -88,7 +90,7 @@ export class EmailPreviewV2 extends React.Component {
|
|
|
88
90
|
);
|
|
89
91
|
const iframeDiv = (<div className={`${messageContainerName}`}>
|
|
90
92
|
{emailSubjectLabel}
|
|
91
|
-
<iframe srcDoc={
|
|
93
|
+
<iframe srcDoc={updateCopyContent} {...deviceAspectRatio[currentDevice](emailSubject)} >
|
|
92
94
|
<p><FormattedMessage {...messages.browserDoesntSupportIframe} /></p>
|
|
93
95
|
</iframe>
|
|
94
96
|
</div>);
|
|
@@ -31,7 +31,6 @@ exports[`<EmailPreviewV2 /> <EmailPreviewV2 /> without the templateData 1`] = `
|
|
|
31
31
|
>
|
|
32
32
|
<iframe
|
|
33
33
|
height="500"
|
|
34
|
-
srcDoc="<html><head></head><body>undefined</body></html>"
|
|
35
34
|
width="1024"
|
|
36
35
|
>
|
|
37
36
|
<p>
|
|
@@ -67,7 +66,6 @@ exports[`<EmailPreviewV2 /> <EmailPreviewV2 /> without the templateData 1`] = `
|
|
|
67
66
|
>
|
|
68
67
|
<iframe
|
|
69
68
|
height="500"
|
|
70
|
-
srcDoc="<html><head></head><body>undefined</body></html>"
|
|
71
69
|
width="1024"
|
|
72
70
|
>
|
|
73
71
|
<p>
|
|
@@ -104,7 +102,6 @@ exports[`<EmailPreviewV2 /> <EmailPreviewV2 /> without the templateData 1`] = `
|
|
|
104
102
|
>
|
|
105
103
|
<iframe
|
|
106
104
|
height="500"
|
|
107
|
-
srcDoc="<html><head></head><body>undefined</body></html>"
|
|
108
105
|
width="1024"
|
|
109
106
|
>
|
|
110
107
|
<p>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const OUTBOUND = 'OUTBOUND';
|