@rh-support/react-context 1.0.13-beta.1 → 1.0.13-beta.2

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.
@@ -11,6 +11,7 @@ declare global {
11
11
  chrometwo_ready: any;
12
12
  embedded_svc: any;
13
13
  $Lightning: any;
14
+ liveAgentDeployment: any;
14
15
  }
15
16
  interface Document {
16
17
  documentMode: any;
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalContextWrapper.d.ts","sourceRoot":"","sources":["../../src/GlobalContextWrapper.tsx"],"names":[],"mappings":"AAmBA,UAAU,MAAM;IACZ,QAAQ,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;CACzC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,SAAS,EAAE,GAAG,CAAC;QACf,oBAAoB,EAAE,GAAG,CAAC;QAC1B,iBAAiB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,OAAA,KAAK,GAAG,KAAK,GAAG,CAAC;QAC9E,MAAM,EAAE,GAAG,CAAC;QACZ,KAAK,EAAE,GAAG,CAAC;QACX,eAAe,EAAE,GAAG,CAAC;QACrB,YAAY,EAAE,GAAG,CAAC;QAClB,UAAU,EAAE,GAAG,CAAC;KACnB;IAED,UAAU,QAAQ;QACd,YAAY,EAAE,GAAG,CAAC;KACrB;CACJ;AA6FD,eAAO,MAAM,oBAAoB,UAAW,MAAM,gBAKjD,CAAC"}
1
+ {"version":3,"file":"GlobalContextWrapper.d.ts","sourceRoot":"","sources":["../../src/GlobalContextWrapper.tsx"],"names":[],"mappings":"AAmBA,UAAU,MAAM;IACZ,QAAQ,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;CACzC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,SAAS,EAAE,GAAG,CAAC;QACf,oBAAoB,EAAE,GAAG,CAAC;QAC1B,iBAAiB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,OAAA,KAAK,GAAG,KAAK,GAAG,CAAC;QAC9E,MAAM,EAAE,GAAG,CAAC;QACZ,KAAK,EAAE,GAAG,CAAC;QACX,eAAe,EAAE,GAAG,CAAC;QACrB,YAAY,EAAE,GAAG,CAAC;QAClB,UAAU,EAAE,GAAG,CAAC;QAChB,mBAAmB,EAAE,GAAG,CAAC;KAC5B;IAED,UAAU,QAAQ;QACd,YAAY,EAAE,GAAG,CAAC;KACrB;CACJ;AA6FD,eAAO,MAAM,oBAAoB,UAAW,MAAM,gBAKjD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"EmbeddedServiceChat.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/EmbeddedServiceChat.tsx"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AAInC,OAAc,EAAE,EAAE,EAAuB,MAAM,OAAO,CAAC;AAMvD,eAAO,MAAM,mBAAmB,EAAE,EAwDjC,CAAC"}
1
+ {"version":3,"file":"EmbeddedServiceChat.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/EmbeddedServiceChat.tsx"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AAInC,OAAc,EAAE,EAAE,EAAuB,MAAM,OAAO,CAAC;AAMvD,eAAO,MAAM,mBAAmB,EAAE,EAwEjC,CAAC"}
@@ -6,7 +6,7 @@ import { Trans, useTranslation } from 'react-i18next';
6
6
  import { useChatInit } from '../..';
7
7
  import { ChatSVGIcon } from './ChatSVGIcon';
8
8
  export const EmbeddedServiceChat = () => {
9
- const { loadingChat, isChatStarted, initEmbedChat, onStartChat, hasBlocked } = useChatInit();
9
+ const { loadingChat, isChatStarted, initEmbedChat, onStartChat, hasChatDomainsBlocked, hasBlockedByBrowser } = useChatInit();
10
10
  const [isBlockedErrorBoxVisible, setIsBlockedErrorBoxVisible] = useState(true);
11
11
  const { t } = useTranslation();
12
12
  const shouldClose = () => {
@@ -15,18 +15,23 @@ export const EmbeddedServiceChat = () => {
15
15
  const shouldOpen = () => {
16
16
  setIsBlockedErrorBoxVisible(true);
17
17
  };
18
+ const chatErrorMessagePopover = () => (React.createElement("div", { className: "chatButton chatError", id: "chat-blocked-popover-selector" },
19
+ React.createElement(Popover, { "aria-label": t('Cannot connect to chat support'), alertSeverityVariant: 'danger', position: PopoverPosition.top, hasAutoWidth: true, headerIcon: React.createElement(ExclamationCircleIcon, { className: "pf-u-danger-color-100" }), headerComponent: "h1", headerContent: React.createElement(Trans, null, "Cannot connect to chat support"), bodyContent: React.createElement("p", { className: "pf-u-px-md" },
20
+ React.createElement(Trans, null, "There are multiple problems that can cause this error."),
21
+ React.createElement("br", null),
22
+ React.createElement("a", { href: `https://access.redhat.com/articles/313583#${hasBlockedByBrowser
23
+ ? 'troubleshoot_browser'
24
+ : hasChatDomainsBlocked
25
+ ? 'troubleshoot_network'
26
+ : ''}`, target: "_blank", rel: "noreferrer noopener" },
27
+ React.createElement(Trans, null, "See a list of possible causes."))), isVisible: isBlockedErrorBoxVisible, shouldClose: shouldClose, shouldOpen: shouldOpen },
28
+ React.createElement(Button, { variant: ButtonVariant.link, className: "pf-u-m-0 pf-u-p-0" },
29
+ React.createElement(ChatSVGIcon, null)))));
18
30
  useEffect(() => {
19
31
  initEmbedChat();
20
32
  // eslint-disable-next-line react-hooks/exhaustive-deps
21
33
  }, []);
22
34
  return loadingChat ? (React.createElement("div", { className: "chatButton" },
23
- React.createElement(Spinner, { isSVG: true, diameter: "28px", className: "pf-u-m-xs" }))) : hasBlocked ? (React.createElement("div", { className: "chatButton chatError", id: "chat-blocked-popover-selector" },
24
- React.createElement(Popover, { "aria-label": t('Cannot connect to chat support'), alertSeverityVariant: 'danger', position: PopoverPosition.left, hasAutoWidth: true, headerIcon: React.createElement(ExclamationCircleIcon, { className: "pf-u-danger-color-100" }), headerComponent: "h1", headerContent: React.createElement(Trans, null, "Cannot connect to chat support"), bodyContent: React.createElement("p", { className: "pf-u-mb-3xl pf-u-px-md" },
25
- React.createElement(Trans, null, "There are multiple problems that can cause this error."),
26
- React.createElement("br", null),
27
- React.createElement("a", { href: "https://redhat.com", target: "_blank", rel: "noreferrer noopener" },
28
- React.createElement(Trans, null, "See a list of possible causes."))), isVisible: isBlockedErrorBoxVisible, shouldClose: shouldClose, shouldOpen: shouldOpen },
29
- React.createElement(Button, { variant: ButtonVariant.link, className: "pf-u-m-0 pf-u-p-0" },
30
- React.createElement(ChatSVGIcon, null))))) : !isChatStarted ? (React.createElement("div", { className: "chatButton", onClick: onStartChat, "data-tracking-id": "embedded-service-chat" },
35
+ React.createElement(Spinner, { isSVG: true, diameter: "28px", className: "pf-u-m-xs" }))) : hasBlockedByBrowser || hasChatDomainsBlocked ? (chatErrorMessagePopover()) : !isChatStarted ? (React.createElement("div", { className: "chatButton", onClick: onStartChat, "data-tracking-id": "embedded-service-chat" },
31
36
  React.createElement(ChatSVGIcon, null))) : (React.createElement(React.Fragment, null));
32
37
  };
@@ -24,16 +24,16 @@ export const useChatConfig = () => {
24
24
  };
25
25
  case Env.EnvNames.STAGE:
26
26
  return {
27
- host: 'https://gss--Stage2.my.salesforce.com',
28
- sandBox: 'https://stage2-gssdex.cs16.force.com/botchat',
27
+ host: 'https://gss--stage2.sandbox.my.salesforce.com',
28
+ sandBox: 'https://gss--stage2.sandbox.my.site.com/botchat',
29
29
  gslbBaseURL: 'https://service.force.com',
30
30
  key: '00Df0000003f0P8',
31
31
  appName: 'RedHatChatBot',
32
32
  extra: {
33
- baseLiveAgentContentURL: 'https://c.la1-c1cs-ord.salesforceliveagent.com/content',
33
+ baseLiveAgentContentURL: 'https://c.la1-c1cs-ia7.salesforceliveagent.com/content',
34
34
  deploymentId: '572f00000008QON',
35
35
  buttonId: '573f00000008QWv',
36
- baseLiveAgentURL: 'https://d.la1-c1cs-ord.salesforceliveagent.com/chat',
36
+ baseLiveAgentURL: 'https://d.la1-c1cs-ia7.salesforceliveagent.com/chat',
37
37
  eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04If00000004CPqEAM_180cd4fc482',
38
38
  isOfflineSupportEnabled: false,
39
39
  },
@@ -1,7 +1,8 @@
1
1
  interface IChatOptions {
2
2
  loadingChat: boolean;
3
3
  isChatStarted: boolean;
4
- hasBlocked: boolean;
4
+ hasBlockedByBrowser: boolean;
5
+ hasChatDomainsBlocked: boolean;
5
6
  initEmbedChat: () => void;
6
7
  onStartChat: () => void;
7
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useChatInit.d.ts","sourceRoot":"","sources":["../../../src/hooks/useChatInit.ts"],"names":[],"mappings":"AAMA,UAAU,YAAY;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,kBAAkB,OAAO,KAAW,YAiE3D,CAAC"}
1
+ {"version":3,"file":"useChatInit.d.ts","sourceRoot":"","sources":["../../../src/hooks/useChatInit.ts"],"names":[],"mappings":"AAMA,UAAU,YAAY;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,kBAAkB,OAAO,KAAW,YA6E3D,CAAC"}
@@ -21,7 +21,8 @@ export const useChatInit = (initialState = false) => {
21
21
  const [isChatStarted, setChatStart] = useState(initialState);
22
22
  // Need to set loading status true as it will prevent starting chat before loading necessary dependencies
23
23
  const [loadingChat, setLoadingChat] = useState(true);
24
- const [hasBlocked, setHasBlocked] = useState(false);
24
+ const [hasBlockedByBrowser, setHasBlockedByBrowser] = useState(false);
25
+ const [hasChatDomainsBlocked, setHasChatDomainsBlocked] = useState(false);
25
26
  const getChatFormDetails = usePreChatFormDetails();
26
27
  const { host, sandBox, gslbBaseURL, key, appName, extra } = useChatConfig();
27
28
  const onStartChat = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -30,7 +31,7 @@ export const useChatInit = (initialState = false) => {
30
31
  // then we assume browser has blocked the script
31
32
  const blockedTimeOut = setTimeout(() => {
32
33
  if (!window.$Lightning) {
33
- setHasBlocked(true);
34
+ setHasBlockedByBrowser(true);
34
35
  setLoadingChat(false);
35
36
  }
36
37
  }, 10000);
@@ -39,7 +40,7 @@ export const useChatInit = (initialState = false) => {
39
40
  extraPrechatFormDetails: getChatFormDetails(),
40
41
  });
41
42
  clearTimeout(blockedTimeOut);
42
- setHasBlocked(false);
43
+ setHasBlockedByBrowser(false);
43
44
  setChatStart(true);
44
45
  setLoadingChat(false);
45
46
  });
@@ -59,15 +60,25 @@ export const useChatInit = (initialState = false) => {
59
60
  window.embedded_svc.addEventHandler('afterDestroy', function (data) {
60
61
  setChatStart(false);
61
62
  });
63
+ // if chat didn't initialized after a long wait then we assume
64
+ // chat domains blocked by client network or browser
65
+ const blockedByNetworkTimeOut = setTimeout(() => {
66
+ if (!window.liveAgentDeployment) {
67
+ setHasChatDomainsBlocked(true);
68
+ setLoadingChat(false);
69
+ }
70
+ }, 10000);
62
71
  // After loading and setting step is complete we are good to call `bootstrapEmbeddedService`
63
72
  window.embedded_svc.addEventHandler('onSettingsCallCompleted', function (data) {
64
73
  setLoadingChat(false);
74
+ clearTimeout(blockedByNetworkTimeOut);
65
75
  });
66
76
  };
67
77
  return {
68
78
  loadingChat,
69
79
  isChatStarted,
70
- hasBlocked,
80
+ hasChatDomainsBlocked,
81
+ hasBlockedByBrowser,
71
82
  initEmbedChat,
72
83
  onStartChat,
73
84
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/react-context",
3
- "version": "1.0.13-beta.1",
3
+ "version": "1.0.13-beta.2",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -90,5 +90,5 @@
90
90
  "not ie <= 11",
91
91
  "not op_mini all"
92
92
  ],
93
- "gitHead": "b93a1b02b7f249c7183d7f9a559df374a83e0d2b"
93
+ "gitHead": "30ad8b43003ef94256e1e9ab7eb5f802f345e233"
94
94
  }