diff --git a/src/Apps/Article/Components/__tests__/ArticleSeries.jest.tsx b/src/Apps/Article/Components/__tests__/ArticleSeries.jest.tsx index 42145012590..30d3bde431f 100644 --- a/src/Apps/Article/Components/__tests__/ArticleSeries.jest.tsx +++ b/src/Apps/Article/Components/__tests__/ArticleSeries.jest.tsx @@ -1,7 +1,7 @@ import { screen } from "@testing-library/react" import { graphql } from "react-relay" import { setupTestWrapperTL } from "DevTools/setupTestWrapperTL" -import { ArticleSeriesFragmentContainer } from "../ArticleSeries" +import { ArticleSeriesFragmentContainer } from "Apps/Article/Components/ArticleSeries" jest.unmock("react-relay") diff --git a/src/Apps/Article/Components/__tests__/ArticleVideo.jest.tsx b/src/Apps/Article/Components/__tests__/ArticleVideo.jest.tsx index d984d6ec94c..583e69bf0ba 100644 --- a/src/Apps/Article/Components/__tests__/ArticleVideo.jest.tsx +++ b/src/Apps/Article/Components/__tests__/ArticleVideo.jest.tsx @@ -1,7 +1,7 @@ import { screen } from "@testing-library/react" import { graphql } from "react-relay" import { setupTestWrapperTL } from "DevTools/setupTestWrapperTL" -import { ArticleVideoFragmentContainer } from "../ArticleVideo" +import { ArticleVideoFragmentContainer } from "Apps/Article/Components/ArticleVideo" jest.unmock("react-relay") diff --git a/src/Apps/Articles/Components/__tests__/ArticlesIndexArticles.jest.tsx b/src/Apps/Articles/Components/__tests__/ArticlesIndexArticles.jest.tsx index 53d14404a9c..3178b4051ee 100644 --- a/src/Apps/Articles/Components/__tests__/ArticlesIndexArticles.jest.tsx +++ b/src/Apps/Articles/Components/__tests__/ArticlesIndexArticles.jest.tsx @@ -1,7 +1,7 @@ import { screen } from "@testing-library/react" import { graphql } from "react-relay" import { setupTestWrapperTL } from "DevTools/setupTestWrapperTL" -import { ArticlesIndexArticlesPaginationContainer } from "../ArticlesIndexArticles" +import { ArticlesIndexArticlesPaginationContainer } from "Apps/Articles/Components/ArticlesIndexArticles" jest.unmock("react-relay") diff --git a/src/Apps/Artist/Components/ArtistInsights/__tests__/ArtistInsightBadges.jest.tsx b/src/Apps/Artist/Components/ArtistInsights/__tests__/ArtistInsightBadges.jest.tsx index 8bcbdde15f9..be8ab489bdf 100644 --- a/src/Apps/Artist/Components/ArtistInsights/__tests__/ArtistInsightBadges.jest.tsx +++ b/src/Apps/Artist/Components/ArtistInsights/__tests__/ArtistInsightBadges.jest.tsx @@ -1,5 +1,5 @@ import { screen } from "@testing-library/react" -import { ArtistInsightBadgesFragmentContainer } from "../ArtistInsightBadges" +import { ArtistInsightBadgesFragmentContainer } from "Apps/Artist/Components/ArtistInsights/ArtistInsightBadges" import { setupTestWrapperTL } from "DevTools/setupTestWrapperTL" import { graphql } from "react-relay" diff --git a/src/Apps/Artist/Routes/Overview/Components/__tests__/ArtistRelatedGeneCategories.jest.tsx b/src/Apps/Artist/Routes/Overview/Components/__tests__/ArtistRelatedGeneCategories.jest.tsx index 26d19aecc97..415561de53f 100644 --- a/src/Apps/Artist/Routes/Overview/Components/__tests__/ArtistRelatedGeneCategories.jest.tsx +++ b/src/Apps/Artist/Routes/Overview/Components/__tests__/ArtistRelatedGeneCategories.jest.tsx @@ -1,7 +1,7 @@ import { graphql } from "react-relay" import { screen } from "@testing-library/react" import { setupTestWrapperTL } from "DevTools/setupTestWrapperTL" -import { ArtistRelatedGeneCategoriesFragmentContainer } from "../ArtistRelatedGeneCategories" +import { ArtistRelatedGeneCategoriesFragmentContainer } from "Apps/Artist/Routes/Overview/Components/ArtistRelatedGeneCategories" jest.unmock("react-relay") diff --git a/src/Apps/Artwork/Components/ArtworkChatBubble.tsx b/src/Apps/Artwork/Components/ArtworkChatBubble.tsx index 74c2cff0b39..f1dbc26a381 100644 --- a/src/Apps/Artwork/Components/ArtworkChatBubble.tsx +++ b/src/Apps/Artwork/Components/ArtworkChatBubble.tsx @@ -10,13 +10,14 @@ interface ArtworkChatBubbleProps { artwork: ArtworkChatBubble_artwork$data } -const ArtworkChatBubble: FC> = ({ artwork }) => { +const ArtworkChatBubble: FC> = ({ artwork }) => { const { isAcquireable, isInquireable, isOfferable, listPrice, - isInAuction, saleArtwork, } = artwork @@ -33,7 +34,7 @@ const ArtworkChatBubble: FC> = ( } }, [listPrice]) - if (!getENV("SALESFORCE_CHAT_ENABLED")) { + if (!getENV("SALESFORCE_MESSAGE_ENABLED")) { return null } @@ -47,7 +48,7 @@ const ArtworkChatBubble: FC> = ( ) { return ( - + ) } @@ -61,7 +62,7 @@ const ArtworkChatBubble: FC> = ( return ( - + ) } diff --git a/src/Apps/Auction/__tests__/AuctionApp.jest.enzyme.tsx b/src/Apps/Auction/__tests__/AuctionApp.jest.enzyme.tsx index d58b1851754..99fc8304e2a 100644 --- a/src/Apps/Auction/__tests__/AuctionApp.jest.enzyme.tsx +++ b/src/Apps/Auction/__tests__/AuctionApp.jest.enzyme.tsx @@ -104,14 +104,14 @@ describe("AuctionApp", () => { }) it("embeds Salesforce widget", () => { - mockGetENV.mockImplementation(() => ({ SALESFORCE_CHAT_ENABLED: true })) + mockGetENV.mockImplementation(() => ({ SALESFORCE_MESSAGE_ENABLED: true })) const { wrapper } = getWrapper() expect(wrapper.find("SalesforceWrapper").exists()).toBeFalsy() }) it("does not embed Salesforce widget on mobile", () => { breakpoint = "xs" - mockGetENV.mockImplementation(() => ({ SALESFORCE_CHAT_ENABLED: true })) + mockGetENV.mockImplementation(() => ({ SALESFORCE_MESSAGE_ENABLED: true })) const { wrapper } = getWrapper() expect(wrapper.find("SalesforceWrapper").exists()).toBeFalsy() }) diff --git a/src/Apps/Order/OrderApp.tsx b/src/Apps/Order/OrderApp.tsx index 1efe8adc331..ce6f1deab41 100644 --- a/src/Apps/Order/OrderApp.tsx +++ b/src/Apps/Order/OrderApp.tsx @@ -94,7 +94,7 @@ const OrderApp: FC> = props => { return null } - if (!getENV("SALESFORCE_CHAT_ENABLED")) { + if (!getENV("SALESFORCE_MESSAGE_ENABLED")) { return null } diff --git a/src/Apps/Order/__tests__/OrderApp.jest.enzyme.tsx b/src/Apps/Order/__tests__/OrderApp.jest.enzyme.tsx index 48e80947962..17f51ac9f4b 100644 --- a/src/Apps/Order/__tests__/OrderApp.jest.enzyme.tsx +++ b/src/Apps/Order/__tests__/OrderApp.jest.enzyme.tsx @@ -684,7 +684,9 @@ describe("OrderApp", () => { describe("chat bubble", () => { it("shows the Salesforce chat integration button", () => { - mockGetENV.mockImplementation(() => ({ SALESFORCE_CHAT_ENABLED: true })) + mockGetENV.mockImplementation(() => ({ + SALESFORCE_MESSAGE_ENABLED: true, + })) const props = getProps() as any const subject = getWrapper({ props }) as any @@ -692,14 +694,18 @@ describe("OrderApp", () => { }) it("does not show the Salesforce chat integration button on mobile", () => { - mockGetENV.mockImplementation(() => ({ SALESFORCE_CHAT_ENABLED: true })) + mockGetENV.mockImplementation(() => ({ + SALESFORCE_MESSAGE_ENABLED: true, + })) const props = getProps() as any const subject = getWrapper({ props, breakpoint: "xs" }) as any expect(subject.find("SalesforceWrapper")).toHaveLength(0) }) it("does not show the Salesforce chat integration button if in a modal", () => { - mockGetENV.mockImplementation(() => ({ SALESFORCE_CHAT_ENABLED: true })) + mockGetENV.mockImplementation(() => ({ + SALESFORCE_MESSAGE_ENABLED: true, + })) const props = getProps() const subject = getWrapper({ props: { ...props, match: { location: { query: { isModal: true } } } }, diff --git a/src/Apps/Settings/Routes/EditProfile/Components/__tests__/SettingsEditProfileAboutYou.jest.tsx b/src/Apps/Settings/Routes/EditProfile/Components/__tests__/SettingsEditProfileAboutYou.jest.tsx index 8d8dff91627..f20db7bc3a0 100644 --- a/src/Apps/Settings/Routes/EditProfile/Components/__tests__/SettingsEditProfileAboutYou.jest.tsx +++ b/src/Apps/Settings/Routes/EditProfile/Components/__tests__/SettingsEditProfileAboutYou.jest.tsx @@ -2,7 +2,7 @@ import { screen, fireEvent, waitFor } from "@testing-library/react" import { graphql } from "react-relay" import { setupTestWrapperTL } from "DevTools/setupTestWrapperTL" import { useUpdateMyUserProfile } from "Utils/Hooks/Mutations/useUpdateMyUserProfile" -import { SettingsEditProfileAboutYouFragmentContainer } from "../SettingsEditProfileAboutYou" +import { SettingsEditProfileAboutYouFragmentContainer } from "Apps/Settings/Routes/EditProfile/Components/SettingsEditProfileAboutYou" jest.unmock("react-relay") jest.mock("Utils/Hooks/Mutations/useUpdateMyUserProfile") diff --git a/src/Apps/Settings/Routes/EditSettings/Components/SettingsEditSettingsTwoFactor/TwoFactorAuthentication/Components/SmsSecondFactor/__tests__/SmsSecondFactor.jest.tsx b/src/Apps/Settings/Routes/EditSettings/Components/SettingsEditSettingsTwoFactor/TwoFactorAuthentication/Components/SmsSecondFactor/__tests__/SmsSecondFactor.jest.tsx index 8f4cb8756e2..4eb32972774 100644 --- a/src/Apps/Settings/Routes/EditSettings/Components/SettingsEditSettingsTwoFactor/TwoFactorAuthentication/Components/SmsSecondFactor/__tests__/SmsSecondFactor.jest.tsx +++ b/src/Apps/Settings/Routes/EditSettings/Components/SettingsEditSettingsTwoFactor/TwoFactorAuthentication/Components/SmsSecondFactor/__tests__/SmsSecondFactor.jest.tsx @@ -1,7 +1,7 @@ import { screen } from "@testing-library/react" import { graphql } from "react-relay" import { setupTestWrapperTL } from "DevTools/setupTestWrapperTL" -import { SmsSecondFactorRefetchContainer } from "../index" +import { SmsSecondFactorRefetchContainer } from "Apps/Settings/Routes/EditSettings/Components/SettingsEditSettingsTwoFactor/TwoFactorAuthentication/Components/SmsSecondFactor/index" jest.unmock("react-relay") diff --git a/src/Components/Onboarding/Components/__tests__/OnboardingOrderedSet.jest.tsx b/src/Components/Onboarding/Components/__tests__/OnboardingOrderedSet.jest.tsx index bda48e92456..6c78c2a6e87 100644 --- a/src/Components/Onboarding/Components/__tests__/OnboardingOrderedSet.jest.tsx +++ b/src/Components/Onboarding/Components/__tests__/OnboardingOrderedSet.jest.tsx @@ -1,5 +1,5 @@ import { setupTestWrapperTL } from "DevTools/setupTestWrapperTL" -import { OnboardingOrderedSetFragmentContainer } from "../OnboardingOrderedSet" +import { OnboardingOrderedSetFragmentContainer } from "Components/Onboarding/Components/OnboardingOrderedSet" import { graphql } from "react-relay" import { screen } from "@testing-library/react" diff --git a/src/Components/Onboarding/Components/__tests__/OnboardingSearchResults.jest.tsx b/src/Components/Onboarding/Components/__tests__/OnboardingSearchResults.jest.tsx index f1ddd2be846..bf74739e982 100644 --- a/src/Components/Onboarding/Components/__tests__/OnboardingSearchResults.jest.tsx +++ b/src/Components/Onboarding/Components/__tests__/OnboardingSearchResults.jest.tsx @@ -1,4 +1,4 @@ -import { OnboardingSearchResultsFragmentContainer } from "../OnboardingSearchResults" +import { OnboardingSearchResultsFragmentContainer } from "Components/Onboarding/Components/OnboardingSearchResults" import { graphql } from "react-relay" import { screen } from "@testing-library/react" import { setupTestWrapperTL } from "DevTools/setupTestWrapperTL" diff --git a/src/Components/SalesforceWrapper.tsx b/src/Components/SalesforceWrapper.tsx index 4b39fb0b131..e0111276acd 100644 --- a/src/Components/SalesforceWrapper.tsx +++ b/src/Components/SalesforceWrapper.tsx @@ -3,40 +3,8 @@ import { useLoadScript } from "Utils/Hooks/useLoadScript" import { useAppendStylesheet } from "Utils/Hooks/useAppendStylesheet" import { useEffect } from "react" -interface SalesforceWrapperProps { - isInAuction?: boolean | null -} - -export const SalesforceWrapper: React.FC> = ({ - isInAuction = false, -}) => { - const salesforceMessageEnabled = getENV("SALESFORCE_MESSAGE_ENABLED") - let embeddedService = null - let buttonId = null - let ewsLiveAgentDevName = null - let serviceName = null - let chatURL = null - - if (salesforceMessageEnabled) { - serviceName = getENV("SALESFORCE_MESSAGE_SERVICE_NAME") - chatURL = getENV("SALESFORCE_MESSAGE_INSTANCE_URL") - } else { - if (isInAuction) { - embeddedService = getENV("SALESFORCE_CHAT_EMBEDDED_SERVICE_AUCTION_NAME") - buttonId = getENV("SALESFORCE_CHAT_AUCTION_BUTTON_ID") - ewsLiveAgentDevName = getENV( - "SALESFORCE_CHAT_AUCTION_ESW_LIVE_AGENT_DEV_NAME" - ) - } else { - embeddedService = getENV( - "SALESFORCE_CHAT_EMBEDDED_SERVICE_COLLECTOR_NAME" - ) - buttonId = getENV("SALESFORCE_CHAT_COLLECTOR_BUTTON_ID") - ewsLiveAgentDevName = getENV( - "SALESFORCE_CHAT_COLLECTOR_ESW_LIVE_AGENT_DEV_NAME" - ) - } - } +export const SalesforceWrapper: React.FC<{}> = _props => { + const chatURL = getENV("SALESFORCE_MESSAGE_INSTANCE_URL") useAppendStylesheet({ id: "salesforce-chat-styles", @@ -60,77 +28,29 @@ export const SalesforceWrapper: React.FC { - if (salesforceMessageEnabled) { - return { - id: "salesforce-chat-script", - src: `${chatURL}/assets/js/bootstrap.min.js`, - removeOnUnmount: true, - onReady: () => { - if (window.embeddedservice_bootstrap?.settings) { - window.embeddedservice_bootstrap.settings.language = "en_US" - window.embeddedservice_bootstrap.init( - getENV("SALESFORCE_MESSAGE_ORG_ID"), - serviceName, - chatURL, - { - scrt2URL: getENV("SALESFORCE_MESSAGE_SCRT2_URL"), - } - ) - } - }, - } - } else { - return { - id: "salesforce-chat-script", - src: `${getENV( - "SALESFORCE_CHAT_INSTANCE_URL" - )}/embeddedservice/5.0/esw.min.js`, - removeOnUnmount: true, - onReady: () => { - if (window.embedded_svc?.settings) { - window.embedded_svc.settings.defaultMinimizedText = "Chat" - window.embedded_svc.settings.enabledFeatures = ["LiveAgent"] - window.embedded_svc.settings.entryFeature = "LiveAgent" - - window.embedded_svc.init( - getENV("SALESFORCE_CHAT_INSTANCE_URL"), - getENV("SALESFORCE_CHAT_HELP_URL"), - "https://service.force.com", - getENV("SALESFORCE_CHAT_ORG_ID"), - embeddedService, - { - baseLiveAgentContentURL: getENV( - "SALESFORCE_CHAT_LIVE_AGENT_CONTENT_URL" - ), - deploymentId: getENV("SALESFORCE_CHAT_DEPLOYMENT_ID"), - buttonId: buttonId, - baseLiveAgentURL: getENV("SALESFORCE_CHAT_LIVE_AGENT_URL"), - eswLiveAgentDevName: ewsLiveAgentDevName, - isOfflineSupportEnabled: true, - } - ) - } - }, - } + useLoadScript({ + id: "salesforce-chat-script", + src: `${chatURL}/assets/js/bootstrap.min.js`, + removeOnUnmount: true, + onReady: () => { + if (window.embeddedservice_bootstrap?.settings) { + window.embeddedservice_bootstrap.settings.language = "en_US" + window.embeddedservice_bootstrap.init( + getENV("SALESFORCE_MESSAGE_ORG_ID"), + getENV("SALESFORCE_MESSAGE_SERVICE_NAME"), + getENV("SALESFORCE_MESSAGE_INSTANCE_URL"), + { + scrt2URL: getENV("SALESFORCE_MESSAGE_SCRT2_URL"), + } + ) } - })() - ) + }, + }) useEffect(() => { - const salesforceMessageEnabled = getENV("SALESFORCE_MESSAGE_ENABLED") - - if (salesforceMessageEnabled) { - window.embeddedservice_bootstrap?.showHelpButton?.() - return () => { - window.embeddedservice_bootstrap?.hideHelpButton?.() - } - } else { - window.embedded_svc?.showHelpButton?.() - return () => { - window.embedded_svc?.hideHelpButton?.() - } + window.embeddedservice_bootstrap?.showHelpButton?.() + return () => { + window.embeddedservice_bootstrap?.hideHelpButton?.() } }, []) diff --git a/src/Server/config.ts b/src/Server/config.ts index d287843ae04..e2a7e58671d 100644 --- a/src/Server/config.ts +++ b/src/Server/config.ts @@ -85,19 +85,6 @@ export const RECAPTCHA_KEY: any = null export const S3_BUCKET: any = null export const S3_KEY: any = null export const S3_SECRET: any = null -export const SALESFORCE_CHAT_ENABLED: any = false -export const SALESFORCE_CHAT_INSTANCE_URL: any = null -export const SALESFORCE_CHAT_HELP_URL: any = null -export const SALESFORCE_CHAT_ORG_ID: any = null -export const SALESFORCE_CHAT_EMBEDDED_SERVICE_COLLECTOR_NAME: any = null -export const SALESFORCE_CHAT_EMBEDDED_SERVICE_AUCTION_NAME: any = null -export const SALESFORCE_CHAT_DEPLOYMENT_ID: any = null -export const SALESFORCE_CHAT_COLLECTOR_BUTTON_ID: any = null -export const SALESFORCE_CHAT_AUCTION_BUTTON_ID: any = null -export const SALESFORCE_CHAT_LIVE_AGENT_CONTENT_URL: any = null -export const SALESFORCE_CHAT_LIVE_AGENT_URL: any = null -export const SALESFORCE_CHAT_COLLECTOR_ESW_LIVE_AGENT_DEV_NAME: any = null -export const SALESFORCE_CHAT_AUCTION_ESW_LIVE_AGENT_DEV_NAME: any = null export const SALESFORCE_MESSAGE_ENABLED: any = false export const SALESFORCE_MESSAGE_ORG_ID: any = null export const SALESFORCE_MESSAGE_SCRT2_URL: any = null diff --git a/src/Server/setup_sharify.ts b/src/Server/setup_sharify.ts index 3de1c8b9191..8a3c7a54e6a 100644 --- a/src/Server/setup_sharify.ts +++ b/src/Server/setup_sharify.ts @@ -74,19 +74,6 @@ sharify.data = _.extend( "GRAPHQL_CACHE_TTL", "RESET_PASSWORD_TOKEN", "S3_BUCKET", - "SALESFORCE_CHAT_ENABLED", - "SALESFORCE_CHAT_INSTANCE_URL", - "SALESFORCE_CHAT_HELP_URL", - "SALESFORCE_CHAT_ORG_ID", - "SALESFORCE_CHAT_EMBEDDED_SERVICE_COLLECTOR_NAME", - "SALESFORCE_CHAT_EMBEDDED_SERVICE_AUCTION_NAME", - "SALESFORCE_CHAT_DEPLOYMENT_ID", - "SALESFORCE_CHAT_COLLECTOR_BUTTON_ID", - "SALESFORCE_CHAT_AUCTION_BUTTON_ID", - "SALESFORCE_CHAT_COLLECTOR_ESW_LIVE_AGENT_DEV_NAME", - "SALESFORCE_CHAT_AUCTION_ESW_LIVE_AGENT_DEV_NAME", - "SALESFORCE_CHAT_LIVE_AGENT_URL", - "SALESFORCE_CHAT_LIVE_AGENT_CONTENT_URL", "SALESFORCE_MESSAGE_ENABLED", "SALESFORCE_MESSAGE_ORG_ID", "SALESFORCE_MESSAGE_SCRT2_URL", diff --git a/src/Typings/global.d.ts b/src/Typings/global.d.ts index ff833616974..e86d781782b 100644 --- a/src/Typings/global.d.ts +++ b/src/Typings/global.d.ts @@ -45,7 +45,6 @@ declare global { analytics: any braze?: typeof Braze desktopPageTimeTrackers: [{ path: string; reset: (path) => void }] - embedded_svc?: any embeddedservice_bootstrap?: any grecaptcha: any ReactNativeWebView?: { postMessage: (message: string) => void } diff --git a/src/Typings/sharify.d.ts b/src/Typings/sharify.d.ts index 89c6cc2a6a7..53e3ebde151 100644 --- a/src/Typings/sharify.d.ts +++ b/src/Typings/sharify.d.ts @@ -80,19 +80,6 @@ declare module "sharify" { REQUEST_ID?: string RESET_PASSWORD_REDIRECT_TO: string RESET_PASSWORD_TOKEN: string - SALESFORCE_CHAT_ENABLED: boolean - SALESFORCE_CHAT_INSTANCE_URL: string - SALESFORCE_CHAT_HELP_URL: string - SALESFORCE_CHAT_ORG_ID: string - SALESFORCE_CHAT_EMBEDDED_SERVICE_COLLECTOR_NAME: string - SALESFORCE_CHAT_EMBEDDED_SERVICE_AUCTION_NAME: string - SALESFORCE_CHAT_DEPLOYMENT_ID: string - SALESFORCE_CHAT_LIVE_AGENT_URL: string - SALESFORCE_CHAT_COLLECTOR_BUTTON_ID: string - SALESFORCE_CHAT_AUCTION_BUTTON_ID: string - SALESFORCE_CHAT_COLLECTOR_ESW_LIVE_AGENT_DEV_NAME: string - SALESFORCE_CHAT_AUCTION_ESW_LIVE_AGENT_DEV_NAME: string - SALESFORCE_CHAT_LIVE_AGENT_CONTENT_URL: string SALESFORCE_MESSAGE_ENABLED: boolean SALESFORCE_MESSAGE_ORG_ID: string SALESFORCE_MESSAGE_SCRT2_URL: string