@rh-support/react-context 0.3.8-beta.0 → 0.3.8-beta.3
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 +23 -4
- package/lib/esm/components/EmbeddedServiceChat/embeddedServiceChat.css +16 -2
- package/lib/esm/hooks/useChatInit.d.ts +1 -0
- package/lib/esm/hooks/useChatInit.d.ts.map +1 -1
- package/lib/esm/hooks/useChatInit.js +12 -0
- package/package.json +5 -5
|
@@ -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;
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedServiceChat.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/EmbeddedServiceChat.tsx"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,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,EAwDjC,CAAC"}
|
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
import './embeddedServiceChat.css';
|
|
2
|
-
import
|
|
2
|
+
import { Button, ButtonVariant, Popover, PopoverPosition, Spinner } from '@patternfly/react-core';
|
|
3
|
+
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
|
|
4
|
+
import React, { useEffect, useState } from 'react';
|
|
5
|
+
import { Trans, useTranslation } from 'react-i18next';
|
|
3
6
|
import { useChatInit } from '../..';
|
|
4
7
|
import { ChatSVGIcon } from './ChatSVGIcon';
|
|
5
8
|
export const EmbeddedServiceChat = () => {
|
|
6
|
-
const { loadingChat, isChatStarted, initEmbedChat, onStartChat } = useChatInit();
|
|
9
|
+
const { loadingChat, isChatStarted, initEmbedChat, onStartChat, hasBlocked } = useChatInit();
|
|
10
|
+
const [isBlockedErrorBoxVisible, setIsBlockedErrorBoxVisible] = useState(true);
|
|
11
|
+
const { t } = useTranslation();
|
|
12
|
+
const shouldClose = () => {
|
|
13
|
+
setIsBlockedErrorBoxVisible(false);
|
|
14
|
+
};
|
|
15
|
+
const shouldOpen = () => {
|
|
16
|
+
setIsBlockedErrorBoxVisible(true);
|
|
17
|
+
};
|
|
7
18
|
useEffect(() => {
|
|
8
19
|
initEmbedChat();
|
|
9
20
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10
21
|
}, []);
|
|
11
|
-
return
|
|
12
|
-
React.createElement(
|
|
22
|
+
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" },
|
|
31
|
+
React.createElement(ChatSVGIcon, null))) : (React.createElement(React.Fragment, null));
|
|
13
32
|
};
|
|
@@ -11,9 +11,8 @@
|
|
|
11
11
|
height: 44px;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
.
|
|
14
|
+
.chatError {
|
|
15
15
|
opacity: 0.7;
|
|
16
|
-
pointer-events: none;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
/* Requested by CCM team */
|
|
@@ -42,3 +41,18 @@
|
|
|
42
41
|
text-align: left;
|
|
43
42
|
font-family: 'Red Hat Text', 'RedHatText', 'Overpass', Overpass, Arial, sans-serif;
|
|
44
43
|
}
|
|
44
|
+
/* red hat chat icon */
|
|
45
|
+
.embeddedServiceLiveAgentStateChatAvatar.isLightningOutContext .agentIconColor0 {
|
|
46
|
+
background-image: url('https://access.redhat.com/chrome_themes/nimbus/img/red-hat-customer-portal.svg');
|
|
47
|
+
background-repeat: no-repeat;
|
|
48
|
+
background-size: 420% !important;
|
|
49
|
+
font-size: 0 !important;
|
|
50
|
+
background-color: #fff !important;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* user chat bubble */
|
|
54
|
+
.chasitor.chat-content[CLWCP-lwcchatpack_lwcchatpack] {
|
|
55
|
+
background: #fff !important;
|
|
56
|
+
color: #0066cc !important;
|
|
57
|
+
border: #0066cc 1px solid !important;
|
|
58
|
+
}
|
|
@@ -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,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,kBAAkB,OAAO,KAAW,
|
|
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"}
|
|
@@ -21,14 +21,25 @@ 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
25
|
const getChatFormDetails = usePreChatFormDetails();
|
|
25
26
|
const { host, sandBox, gslbBaseURL, key, appName, extra } = useChatConfig();
|
|
26
27
|
const onStartChat = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
28
|
setLoadingChat(true);
|
|
29
|
+
// if chat didn't start after a long wait
|
|
30
|
+
// then we assume browser has blocked the script
|
|
31
|
+
const blockedTimeOut = setTimeout(() => {
|
|
32
|
+
if (!window.$Lightning) {
|
|
33
|
+
setHasBlocked(true);
|
|
34
|
+
setLoadingChat(false);
|
|
35
|
+
}
|
|
36
|
+
}, 10000);
|
|
28
37
|
yield window.embedded_svc.liveAgentAPI.startChat({
|
|
29
38
|
extraPrechatInfo: extraPreChatInfo,
|
|
30
39
|
extraPrechatFormDetails: getChatFormDetails(),
|
|
31
40
|
});
|
|
41
|
+
clearTimeout(blockedTimeOut);
|
|
42
|
+
setHasBlocked(false);
|
|
32
43
|
setChatStart(true);
|
|
33
44
|
setLoadingChat(false);
|
|
34
45
|
});
|
|
@@ -56,6 +67,7 @@ export const useChatInit = (initialState = false) => {
|
|
|
56
67
|
return {
|
|
57
68
|
loadingChat,
|
|
58
69
|
isChatStarted,
|
|
70
|
+
hasBlocked,
|
|
59
71
|
initEmbedChat,
|
|
60
72
|
onStartChat,
|
|
61
73
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/react-context",
|
|
3
|
-
"version": "0.3.8-beta.
|
|
3
|
+
"version": "0.3.8-beta.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"@cee-eng/hydrajs": "4.12.7",
|
|
45
45
|
"@patternfly/react-core": "4.202.16",
|
|
46
46
|
"@patternfly/react-icons": "4.53.16",
|
|
47
|
-
"@rh-support/components": "1.1.84",
|
|
47
|
+
"@rh-support/components": "1.1.84-beta.3",
|
|
48
48
|
"@rh-support/types": "0.2.0",
|
|
49
|
-
"@rh-support/user-permissions": "0.2.68",
|
|
50
|
-
"@rh-support/utils": "0.2.50",
|
|
49
|
+
"@rh-support/user-permissions": "0.2.68-beta.3",
|
|
50
|
+
"@rh-support/utils": "0.2.50-beta.3",
|
|
51
51
|
"i18next": "^19.0.1",
|
|
52
52
|
"localforage": "^1.7.3",
|
|
53
53
|
"lodash": "^4.17.21",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"not ie <= 11",
|
|
88
88
|
"not op_mini all"
|
|
89
89
|
],
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "6c731cc33decd0c98d591d2117b95638306ef6c5"
|
|
91
91
|
}
|