@rh-support/react-context 1.0.13-beta.1 → 1.0.14
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 +0 -2
- package/lib/esm/GlobalContextWrapper.d.ts.map +1 -1
- package/lib/esm/components/HostnameAwarenessModal/HostnameAwarenessModal.d.ts.map +1 -1
- package/lib/esm/components/HostnameAwarenessModal/HostnameAwarenessModal.js +7 -4
- package/lib/esm/components/index.d.ts +0 -1
- package/lib/esm/components/index.d.ts.map +1 -1
- package/lib/esm/components/index.js +0 -1
- package/lib/esm/hooks/index.d.ts +0 -3
- package/lib/esm/hooks/index.d.ts.map +1 -1
- package/lib/esm/hooks/index.js +0 -3
- package/package.json +6 -9
- package/lib/esm/components/EmbeddedServiceChat/ChatSVGIcon.d.ts +0 -2
- package/lib/esm/components/EmbeddedServiceChat/ChatSVGIcon.d.ts.map +0 -1
- package/lib/esm/components/EmbeddedServiceChat/ChatSVGIcon.js +0 -9
- package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.d.ts +0 -4
- package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.d.ts.map +0 -1
- package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.js +0 -32
- package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.d.ts +0 -12
- package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.d.ts.map +0 -1
- package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.js +0 -29
- package/lib/esm/components/EmbeddedServiceChat/embeddedServiceChat.css +0 -58
- package/lib/esm/components/EmbeddedServiceChat/index.d.ts +0 -2
- package/lib/esm/components/EmbeddedServiceChat/index.d.ts.map +0 -1
- package/lib/esm/components/EmbeddedServiceChat/index.js +0 -1
- package/lib/esm/hooks/useChatConfig.d.ts +0 -20
- package/lib/esm/hooks/useChatConfig.d.ts.map +0 -1
- package/lib/esm/hooks/useChatConfig.js +0 -58
- package/lib/esm/hooks/useChatInit.d.ts +0 -16
- package/lib/esm/hooks/useChatInit.d.ts.map +0 -1
- package/lib/esm/hooks/useChatInit.js +0 -74
- package/lib/esm/hooks/usePreChatFormDetails.d.ts +0 -12
- package/lib/esm/hooks/usePreChatFormDetails.d.ts.map +0 -1
- package/lib/esm/hooks/usePreChatFormDetails.js +0 -78
|
@@ -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;
|
|
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;KACxB;IAED,UAAU,QAAQ;QACd,YAAY,EAAE,GAAG,CAAC;KACrB;CACJ;AA6FD,eAAO,MAAM,oBAAoB,UAAW,MAAM,gBAKjD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HostnameAwarenessModal.d.ts","sourceRoot":"","sources":["../../../../src/components/HostnameAwarenessModal/HostnameAwarenessModal.tsx"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,CAAC;AAatC,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"HostnameAwarenessModal.d.ts","sourceRoot":"","sources":["../../../../src/components/HostnameAwarenessModal/HostnameAwarenessModal.tsx"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,CAAC;AAatC,eAAO,MAAM,sBAAsB,mBA4KlC,CAAC"}
|
|
@@ -22,7 +22,8 @@ export const HostnameAwarenessModal = () => {
|
|
|
22
22
|
const { getHostnamesVisibilityObj, updateShowHostnamesCount } = useUserPreferences();
|
|
23
23
|
//Setting State for original data value which are used to open/finalize close modal
|
|
24
24
|
const [originalViewedCountValue, setViewedCountValue] = useState(null);
|
|
25
|
-
const [doNotShowModal, setDoNotShowModal] = useState(
|
|
25
|
+
const [doNotShowModal, setDoNotShowModal] = useState(undefined);
|
|
26
|
+
const [doNotShowNotClicked, setDoNotShowNotClicked] = useState(true);
|
|
26
27
|
const [isModalOpen, setIsModalOpen] = useState(true);
|
|
27
28
|
const [isHostnamesChecked, setisHostnamesChecked] = useState(false);
|
|
28
29
|
const [isLoadingHostnamesVisibilityObj, setIsLoadingHostnamesVisibilityObj] = useState(false);
|
|
@@ -84,6 +85,8 @@ export const HostnameAwarenessModal = () => {
|
|
|
84
85
|
//for the checkbox
|
|
85
86
|
const onDoNotAskAgain = () => {
|
|
86
87
|
try {
|
|
88
|
+
setDoNotShowNotClicked(false);
|
|
89
|
+
setDoNotShowModal(+!doNotShowModal);
|
|
87
90
|
const updateObjValue = { shownCount: originalViewedCountValue, doNotShow: 1 };
|
|
88
91
|
updateShowHostnamesCount(updateObjValue);
|
|
89
92
|
}
|
|
@@ -110,15 +113,15 @@ export const HostnameAwarenessModal = () => {
|
|
|
110
113
|
isLoadingHostnamesVisibilityObj ||
|
|
111
114
|
!canUseHostName ||
|
|
112
115
|
alreadyCheckedCloseModal ||
|
|
113
|
-
originalViewedCountValue >
|
|
114
|
-
doNotShowModal === 1) {
|
|
116
|
+
originalViewedCountValue > 8 ||
|
|
117
|
+
(doNotShowModal === 1 && doNotShowNotClicked)) {
|
|
115
118
|
return React.createElement(React.Fragment, null);
|
|
116
119
|
}
|
|
117
120
|
return (React.createElement(React.Fragment, null,
|
|
118
121
|
React.createElement(Modal, { variant: ModalVariant.medium, title: "Share hostnames with Red Hat?", isOpen: isModalOpen, onClose: onCloseModal, actions: [
|
|
119
122
|
React.createElement(Button, { "data-tracking-id": "close-hostname-modal", key: "close", variant: "primary", onClick: onCloseModal }, "Close"),
|
|
120
123
|
React.createElement("div", { className: "dontAskCheckbox" },
|
|
121
|
-
React.createElement(Checkbox, { isChecked: !!doNotShowModal, label: "Don't ask me again", id: "dont-ask-again", "data-tracking-id": "dont-ask-again-hostname-modal",
|
|
124
|
+
React.createElement(Checkbox, { isChecked: !!doNotShowModal, label: "Don't ask me again", id: "dont-ask-again", "data-tracking-id": "dont-ask-again-hostname-modal", onChange: onDoNotAskAgain })),
|
|
122
125
|
] },
|
|
123
126
|
React.createElement("div", null,
|
|
124
127
|
React.createElement(Trans, null, "Red Hat Support cannot currently access hostnames that have been entered on a case. You can share this information at any time to improve your support experience, or you can ignore this.")),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC"}
|
package/lib/esm/hooks/index.d.ts
CHANGED
|
@@ -5,7 +5,4 @@ export * from './useSubscriptionAbused';
|
|
|
5
5
|
export * from './useCanEditCase';
|
|
6
6
|
export * from './useCanCreateCase';
|
|
7
7
|
export * from './useUserPreferences';
|
|
8
|
-
export * from './useChatInit';
|
|
9
|
-
export * from './usePreChatFormDetails';
|
|
10
|
-
export * from './useChatConfig';
|
|
11
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
|
package/lib/esm/hooks/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/react-context",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -44,17 +44,16 @@
|
|
|
44
44
|
"@cee-eng/hydrajs": "4.14.53",
|
|
45
45
|
"@patternfly/react-core": "4.264.0",
|
|
46
46
|
"@patternfly/react-icons": "4.92.10",
|
|
47
|
-
"@rh-support/components": "1.2.
|
|
47
|
+
"@rh-support/components": "1.2.12",
|
|
48
48
|
"@rh-support/types": "0.2.0",
|
|
49
|
-
"@rh-support/user-permissions": "1.0.
|
|
50
|
-
"@rh-support/utils": "1.0.
|
|
49
|
+
"@rh-support/user-permissions": "1.0.10",
|
|
50
|
+
"@rh-support/utils": "1.0.8",
|
|
51
51
|
"i18next": "^19.0.1",
|
|
52
52
|
"localforage": "^1.7.3",
|
|
53
53
|
"lodash": "^4.17.21",
|
|
54
54
|
"react": "17.0.2",
|
|
55
55
|
"react-dom": "17.0.2",
|
|
56
56
|
"react-i18next": "^11.2.5",
|
|
57
|
-
"react-router-dom": "^5.1.2",
|
|
58
57
|
"react-test-renderer": "^16.9.0"
|
|
59
58
|
},
|
|
60
59
|
"devDependencies": {
|
|
@@ -65,9 +64,7 @@
|
|
|
65
64
|
"@types/i18next": "^12.1.0",
|
|
66
65
|
"@types/lodash": "^4.14.136",
|
|
67
66
|
"@types/react": "^17.0.14",
|
|
68
|
-
"@types/react-i18next": "^8.1.0"
|
|
69
|
-
"@types/react-router-dom": "^5.1.2",
|
|
70
|
-
"history": "4.10.1"
|
|
67
|
+
"@types/react-i18next": "^8.1.0"
|
|
71
68
|
},
|
|
72
69
|
"scripts": {
|
|
73
70
|
"build:watch": "../../node_modules/.bin/tsc -w -p config/tsconfig.json & npm run watch:css",
|
|
@@ -90,5 +87,5 @@
|
|
|
90
87
|
"not ie <= 11",
|
|
91
88
|
"not op_mini all"
|
|
92
89
|
],
|
|
93
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "e37bef728cf73aec23bea1060d855aeb01ae62b6"
|
|
94
91
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChatSVGIcon.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/ChatSVGIcon.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,mBAwBvB,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export const ChatSVGIcon = () => {
|
|
3
|
-
return (React.createElement("svg", { width: "36", height: "36", viewBox: "0 0 36 36", fill: "none", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink" },
|
|
4
|
-
React.createElement("rect", { width: "36", height: "36", fill: "url(#pattern0)" }),
|
|
5
|
-
React.createElement("defs", null,
|
|
6
|
-
React.createElement("pattern", { id: "pattern0", patternContentUnits: "objectBoundingBox", width: "1", height: "1" },
|
|
7
|
-
React.createElement("use", { xlinkHref: "#image0_726_235", transform: "scale(0.00277778)" })),
|
|
8
|
-
React.createElement("image", { id: "image0_726_235", width: "360", height: "360", xlinkHref: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAWgAAAFoCAYAAAB65WHVAAAACXBIWXMAAG66AABuugHW3rEXAAAKZ0lEQVR4nO3d4XHUSAKG4e6r/Y8VAc4Ah0AISwSwERwXwXkjgAzAEawzWEIgBByBvBH0lfa0V7t7gGfs0eiT+nmq+OOyB01LvMgaqbu21goAef5hnwBkEmiAUAINEEqgAUIJNEAogQYIJdAAoQQaIJRAA4QSaIBQAg0QSqABQgk0QCiBBggl0AChBBoglEADhBJogFACDRBKoAFCCTRAKIEGCCXQAKEEGiCUQAOEEmiAUAINEEqgAUIJNEAogQYIJdAAoQQaIJRAA4QSaIBQAg0QSqABQgk0QCiBBggl0AChBBoglEADhBJogFACDRBKoAFCCTRAKIEGCCXQAKEEGiCUQAOEEmiAUAINEEqg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-
{"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,32 +0,0 @@
|
|
|
1
|
-
import './embeddedServiceChat.css';
|
|
2
|
-
import { Button, ButtonVariant, Popover, PopoverPosition, Spinner } from '@patternfly/react-core';
|
|
3
|
-
import ExclamationCircleIcon from '@patternfly/react-icons/dist/js/icons/exclamation-circle-icon';
|
|
4
|
-
import React, { useEffect, useState } from 'react';
|
|
5
|
-
import { Trans, useTranslation } from 'react-i18next';
|
|
6
|
-
import { useChatInit } from '../..';
|
|
7
|
-
import { ChatSVGIcon } from './ChatSVGIcon';
|
|
8
|
-
export const EmbeddedServiceChat = () => {
|
|
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
|
-
};
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
initEmbedChat();
|
|
20
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21
|
-
}, []);
|
|
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));
|
|
32
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare const extraPreChatInfo: {
|
|
2
|
-
entityFieldMaps: {
|
|
3
|
-
doCreate: boolean;
|
|
4
|
-
doFind: boolean;
|
|
5
|
-
fieldName: string;
|
|
6
|
-
isExactMatch: boolean;
|
|
7
|
-
label: string;
|
|
8
|
-
}[];
|
|
9
|
-
entityName: string;
|
|
10
|
-
saveToTranscript: string;
|
|
11
|
-
}[];
|
|
12
|
-
//# sourceMappingURL=ExtraPreChatInfo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExtraPreChatInfo.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/ExtraPreChatInfo.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;;;;;;;;GA6B5B,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export const extraPreChatInfo = [
|
|
2
|
-
{
|
|
3
|
-
entityFieldMaps: [
|
|
4
|
-
{
|
|
5
|
-
doCreate: false,
|
|
6
|
-
doFind: true,
|
|
7
|
-
fieldName: 'SSO_Username__c',
|
|
8
|
-
isExactMatch: true,
|
|
9
|
-
label: 'SSO Name',
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
doCreate: false,
|
|
13
|
-
doFind: true,
|
|
14
|
-
fieldName: 'ContactSessionId__c',
|
|
15
|
-
isExactMatch: false,
|
|
16
|
-
label: 'SessionId',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
doCreate: false,
|
|
20
|
-
doFind: true,
|
|
21
|
-
fieldName: 'Account',
|
|
22
|
-
isExactMatch: true,
|
|
23
|
-
label: 'account',
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
entityName: '',
|
|
27
|
-
saveToTranscript: 'SSO_Username__c',
|
|
28
|
-
},
|
|
29
|
-
];
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
.chatButton {
|
|
2
|
-
position: fixed;
|
|
3
|
-
right: 4rem;
|
|
4
|
-
bottom: 1rem;
|
|
5
|
-
background: #ffffff;
|
|
6
|
-
box-shadow: 0px 2px 3px rgb(0 0 0 / 15%);
|
|
7
|
-
border-radius: 3px;
|
|
8
|
-
cursor: pointer;
|
|
9
|
-
padding: 4px;
|
|
10
|
-
width: 44px;
|
|
11
|
-
height: 44px;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.chatError {
|
|
15
|
-
opacity: 0.7;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/* Requested by CCM team */
|
|
19
|
-
.agent .chat-content[CLWCP-lwcchatpack_lwcchatpack] {
|
|
20
|
-
text-align: left;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/* Adding fowling CSS as requested by CCM team (Sudhir Panda) */
|
|
24
|
-
.embeddedServiceLiveAgentStateChat .chatSessionStartTime {
|
|
25
|
-
font-family: 'Red Hat Text', 'RedHatText', 'Overpass', Overpass, Arial, sans-serif;
|
|
26
|
-
}
|
|
27
|
-
.embeddedServiceLiveAgentStateChatItem.chatMessage {
|
|
28
|
-
font-family: 'Red Hat Text', 'RedHatText', 'Overpass', Overpass, Arial, sans-serif;
|
|
29
|
-
}
|
|
30
|
-
.embeddedServiceLiveAgentStateChatItem.chatMessage button {
|
|
31
|
-
font-family: 'Red Hat Text', 'RedHatText', 'Overpass', Overpass, Arial, sans-serif;
|
|
32
|
-
}
|
|
33
|
-
.embeddedServiceHelpButton .helpButton .uiButton {
|
|
34
|
-
background-color: #005290;
|
|
35
|
-
font-family: 'Arial', sans-serif;
|
|
36
|
-
}
|
|
37
|
-
.embeddedServiceHelpButton .helpButton .uiButton:focus {
|
|
38
|
-
outline: 1px solid #005290;
|
|
39
|
-
}
|
|
40
|
-
.agent .chat-content[CLWCP-lwcchatpack_lwcchatpack] {
|
|
41
|
-
text-align: left;
|
|
42
|
-
font-family: 'Red Hat Text', 'RedHatText', 'Overpass', Overpass, Arial, sans-serif;
|
|
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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './EmbeddedServiceChat';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* This hook is used for selected chat configuration based on environment
|
|
4
|
-
*/
|
|
5
|
-
export declare const useChatConfig: () => {
|
|
6
|
-
host: string;
|
|
7
|
-
sandBox: string;
|
|
8
|
-
gslbBaseURL: string;
|
|
9
|
-
key: string;
|
|
10
|
-
appName: string;
|
|
11
|
-
extra: {
|
|
12
|
-
baseLiveAgentContentURL: string;
|
|
13
|
-
deploymentId: string;
|
|
14
|
-
buttonId: string;
|
|
15
|
-
baseLiveAgentURL: string;
|
|
16
|
-
eswLiveAgentDevName: string;
|
|
17
|
-
isOfflineSupportEnabled: boolean;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=useChatConfig.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useChatConfig.d.ts","sourceRoot":"","sources":["../../../src/hooks/useChatConfig.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;CAoDzB,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Env } from '@cee-eng/hydrajs';
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* This hook is used for selected chat configuration based on environment
|
|
5
|
-
*/
|
|
6
|
-
export const useChatConfig = () => {
|
|
7
|
-
const env = Env.getEnvName();
|
|
8
|
-
switch (env) {
|
|
9
|
-
case Env.EnvNames.QA:
|
|
10
|
-
return {
|
|
11
|
-
host: 'https://gss--qa.sandbox.my.salesforce.com',
|
|
12
|
-
sandBox: 'https://gss--qa.sandbox.my.site.com/botchat',
|
|
13
|
-
gslbBaseURL: 'https://service.force.com',
|
|
14
|
-
key: '00D7j0000008oSo',
|
|
15
|
-
appName: 'RedHatChatBot',
|
|
16
|
-
extra: {
|
|
17
|
-
baseLiveAgentContentURL: 'https://c.la3-c1cs-ia5.salesforceliveagent.com/content',
|
|
18
|
-
deploymentId: '5727j0000004CqR',
|
|
19
|
-
buttonId: '5737j0000004CKB',
|
|
20
|
-
baseLiveAgentURL: 'https://d.la3-c1cs-ia5.salesforceliveagent.com/chat',
|
|
21
|
-
eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I7j000000CadEEAS_180b2280b37',
|
|
22
|
-
isOfflineSupportEnabled: false,
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
case Env.EnvNames.STAGE:
|
|
26
|
-
return {
|
|
27
|
-
host: 'https://gss--Stage2.my.salesforce.com',
|
|
28
|
-
sandBox: 'https://stage2-gssdex.cs16.force.com/botchat',
|
|
29
|
-
gslbBaseURL: 'https://service.force.com',
|
|
30
|
-
key: '00Df0000003f0P8',
|
|
31
|
-
appName: 'RedHatChatBot',
|
|
32
|
-
extra: {
|
|
33
|
-
baseLiveAgentContentURL: 'https://c.la1-c1cs-ord.salesforceliveagent.com/content',
|
|
34
|
-
deploymentId: '572f00000008QON',
|
|
35
|
-
buttonId: '573f00000008QWv',
|
|
36
|
-
baseLiveAgentURL: 'https://d.la1-c1cs-ord.salesforceliveagent.com/chat',
|
|
37
|
-
eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04If00000004CPqEAM_180cd4fc482',
|
|
38
|
-
isOfflineSupportEnabled: false,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
default:
|
|
42
|
-
return {
|
|
43
|
-
host: 'https://gss--qa.my.salesforce.com',
|
|
44
|
-
sandBox: 'https://qa-gssdex.cs203.force.com/botchat',
|
|
45
|
-
gslbBaseURL: 'https://service.force.com',
|
|
46
|
-
key: '00D7j0000008oSo',
|
|
47
|
-
appName: 'RedHatChatBot',
|
|
48
|
-
extra: {
|
|
49
|
-
baseLiveAgentContentURL: 'https://c.la3-c1cs-ia4.salesforceliveagent.com/content',
|
|
50
|
-
deploymentId: '5727j0000004CqR',
|
|
51
|
-
buttonId: '5737j0000004CKB',
|
|
52
|
-
baseLiveAgentURL: 'https://d.la3-c1cs-ia4.salesforceliveagent.com/chat',
|
|
53
|
-
eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I7j000000CadEEAS_180b2280b37',
|
|
54
|
-
isOfflineSupportEnabled: false,
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
interface IChatOptions {
|
|
2
|
-
loadingChat: boolean;
|
|
3
|
-
isChatStarted: boolean;
|
|
4
|
-
hasBlocked: boolean;
|
|
5
|
-
initEmbedChat: () => void;
|
|
6
|
-
onStartChat: () => void;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* This hook is used for setting chat up and listing custom event of chat.
|
|
10
|
-
* for more details https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_chat_events.htm
|
|
11
|
-
* @param initialState
|
|
12
|
-
* @returns
|
|
13
|
-
*/
|
|
14
|
-
export declare const useChatInit: (initialState?: boolean) => IChatOptions;
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=useChatInit.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,74 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { useState } from 'react';
|
|
11
|
-
import { extraPreChatInfo } from '../components/EmbeddedServiceChat/ExtraPreChatInfo';
|
|
12
|
-
import { useChatConfig } from './useChatConfig';
|
|
13
|
-
import { usePreChatFormDetails } from './usePreChatFormDetails';
|
|
14
|
-
/**
|
|
15
|
-
* This hook is used for setting chat up and listing custom event of chat.
|
|
16
|
-
* for more details https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_chat_events.htm
|
|
17
|
-
* @param initialState
|
|
18
|
-
* @returns
|
|
19
|
-
*/
|
|
20
|
-
export const useChatInit = (initialState = false) => {
|
|
21
|
-
const [isChatStarted, setChatStart] = useState(initialState);
|
|
22
|
-
// Need to set loading status true as it will prevent starting chat before loading necessary dependencies
|
|
23
|
-
const [loadingChat, setLoadingChat] = useState(true);
|
|
24
|
-
const [hasBlocked, setHasBlocked] = useState(false);
|
|
25
|
-
const getChatFormDetails = usePreChatFormDetails();
|
|
26
|
-
const { host, sandBox, gslbBaseURL, key, appName, extra } = useChatConfig();
|
|
27
|
-
const onStartChat = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
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);
|
|
37
|
-
yield window.embedded_svc.liveAgentAPI.startChat({
|
|
38
|
-
extraPrechatInfo: extraPreChatInfo,
|
|
39
|
-
extraPrechatFormDetails: getChatFormDetails(),
|
|
40
|
-
});
|
|
41
|
-
clearTimeout(blockedTimeOut);
|
|
42
|
-
setHasBlocked(false);
|
|
43
|
-
setChatStart(true);
|
|
44
|
-
setLoadingChat(false);
|
|
45
|
-
});
|
|
46
|
-
const initEmbedChat = () => {
|
|
47
|
-
const extraPreChatFormDetails = getChatFormDetails();
|
|
48
|
-
initESW(extraPreChatFormDetails);
|
|
49
|
-
};
|
|
50
|
-
const initESW = (extraPreChatFormDetails) => {
|
|
51
|
-
window.embedded_svc.settings.displayHelpButton = false; //Or false
|
|
52
|
-
window.embedded_svc.settings.language = 'en'; //For example, enter 'en' or 'en-US'
|
|
53
|
-
window.embedded_svc.settings.enabledFeatures = ['LiveAgent'];
|
|
54
|
-
window.embedded_svc.settings.entryFeature = 'LiveAgent';
|
|
55
|
-
window.embedded_svc.settings.extraPrechatFormDetails = extraPreChatFormDetails;
|
|
56
|
-
window.embedded_svc.settings.extraPrechatInfo = extraPreChatInfo;
|
|
57
|
-
window.embedded_svc.init(host, sandBox, gslbBaseURL, key, appName, extra);
|
|
58
|
-
// Fired when Embedded Service Chat has ended and the application is closed.
|
|
59
|
-
window.embedded_svc.addEventHandler('afterDestroy', function (data) {
|
|
60
|
-
setChatStart(false);
|
|
61
|
-
});
|
|
62
|
-
// After loading and setting step is complete we are good to call `bootstrapEmbeddedService`
|
|
63
|
-
window.embedded_svc.addEventHandler('onSettingsCallCompleted', function (data) {
|
|
64
|
-
setLoadingChat(false);
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
return {
|
|
68
|
-
loadingChat,
|
|
69
|
-
isChatStarted,
|
|
70
|
-
hasBlocked,
|
|
71
|
-
initEmbedChat,
|
|
72
|
-
onStartChat,
|
|
73
|
-
};
|
|
74
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface IPreChatFormDetails {
|
|
2
|
-
label: string;
|
|
3
|
-
value: string;
|
|
4
|
-
transcriptFields?: Array<string>;
|
|
5
|
-
displayToAgent: boolean;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* The use of this hook is to generate form details based on user current screen
|
|
10
|
-
*/
|
|
11
|
-
export declare const usePreChatFormDetails: () => (() => IPreChatFormDetails[]);
|
|
12
|
-
//# sourceMappingURL=usePreChatFormDetails.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePreChatFormDetails.d.ts","sourceRoot":"","sources":["../../../src/hooks/usePreChatFormDetails.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,mBAAmB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,cAAc,EAAE,OAAO,CAAC;CAC3B;AAED;;;GAGG;AAEH,eAAO,MAAM,qBAAqB,QAAO,CAAC,MAAM,mBAAmB,EAAE,CA6DpE,CAAC"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { publicApi } from '@cee-eng/hydrajs';
|
|
11
|
-
import { isValidCaseNumber } from '@rh-support/utils';
|
|
12
|
-
import { useContext, useEffect, useState } from 'react';
|
|
13
|
-
import { useRouteMatch } from 'react-router-dom';
|
|
14
|
-
import { GlobalMetadataStateContext } from '../context/GlobalMetadataContext';
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
* The use of this hook is to generate form details based on user current screen
|
|
18
|
-
*/
|
|
19
|
-
export const usePreChatFormDetails = () => {
|
|
20
|
-
var _a;
|
|
21
|
-
const { globalMetadataState: { loggedInUserRights }, } = useContext(GlobalMetadataStateContext);
|
|
22
|
-
const [sessionId, setSessionId] = useState('');
|
|
23
|
-
const loggedInUserRightsData = loggedInUserRights === null || loggedInUserRights === void 0 ? void 0 : loggedInUserRights.data;
|
|
24
|
-
const ssoName = loggedInUserRightsData.getSSOUsername();
|
|
25
|
-
const name = loggedInUserRightsData.getUserFullName();
|
|
26
|
-
const accountNumber = loggedInUserRightsData.getAccountNumber();
|
|
27
|
-
const match = useRouteMatch('/case/:caseNumber');
|
|
28
|
-
const caseNumber = (_a = match === null || match === void 0 ? void 0 : match.params) === null || _a === void 0 ? void 0 : _a.caseNumber;
|
|
29
|
-
const isCaseDetailsPage = isValidCaseNumber(caseNumber);
|
|
30
|
-
const currentCaseNumber = isCaseDetailsPage ? caseNumber : undefined;
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
try {
|
|
33
|
-
const fetchChatSessionId = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
const { message } = yield publicApi.chat.getChatSession();
|
|
35
|
-
setSessionId(message);
|
|
36
|
-
});
|
|
37
|
-
fetchChatSessionId();
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
console.log('Error', error);
|
|
41
|
-
}
|
|
42
|
-
}, []);
|
|
43
|
-
const getChatFormDetails = () => [
|
|
44
|
-
{
|
|
45
|
-
label: 'SSO Name',
|
|
46
|
-
value: ssoName,
|
|
47
|
-
transcriptFields: ['SSO_Username__c'],
|
|
48
|
-
displayToAgent: true,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
label: 'SessionId',
|
|
52
|
-
value: sessionId,
|
|
53
|
-
transcriptFields: ['SessionId__c'],
|
|
54
|
-
displayToAgent: true,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
label: 'name',
|
|
58
|
-
value: name,
|
|
59
|
-
displayToAgent: true,
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
label: 'account',
|
|
63
|
-
value: accountNumber,
|
|
64
|
-
displayToAgent: true,
|
|
65
|
-
},
|
|
66
|
-
...(currentCaseNumber
|
|
67
|
-
? [
|
|
68
|
-
{
|
|
69
|
-
label: 'currentCaseNumber',
|
|
70
|
-
transcriptFields: ['CaseNumber__c'],
|
|
71
|
-
value: currentCaseNumber,
|
|
72
|
-
displayToAgent: true,
|
|
73
|
-
},
|
|
74
|
-
]
|
|
75
|
-
: []),
|
|
76
|
-
];
|
|
77
|
-
return getChatFormDetails;
|
|
78
|
-
};
|