@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.
- package/lib/esm/GlobalContextWrapper.d.ts +1 -0
- package/lib/esm/GlobalContextWrapper.d.ts.map +1 -1
- package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.d.ts.map +1 -1
- package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.js +14 -9
- package/lib/esm/hooks/useChatConfig.js +4 -4
- package/lib/esm/hooks/useChatInit.d.ts +2 -1
- package/lib/esm/hooks/useChatInit.d.ts.map +1 -1
- package/lib/esm/hooks/useChatInit.js +15 -4
- package/package.json +2 -2
|
@@ -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;
|
|
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,
|
|
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,
|
|
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" }))) :
|
|
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--
|
|
28
|
-
sandBox: 'https://stage2
|
|
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-
|
|
33
|
+
baseLiveAgentContentURL: 'https://c.la1-c1cs-ia7.salesforceliveagent.com/content',
|
|
34
34
|
deploymentId: '572f00000008QON',
|
|
35
35
|
buttonId: '573f00000008QWv',
|
|
36
|
-
baseLiveAgentURL: 'https://d.la1-c1cs-
|
|
36
|
+
baseLiveAgentURL: 'https://d.la1-c1cs-ia7.salesforceliveagent.com/chat',
|
|
37
37
|
eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04If00000004CPqEAM_180cd4fc482',
|
|
38
38
|
isOfflineSupportEnabled: false,
|
|
39
39
|
},
|
|
@@ -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,
|
|
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 [
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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": "
|
|
93
|
+
"gitHead": "30ad8b43003ef94256e1e9ab7eb5f802f345e233"
|
|
94
94
|
}
|