@rh-support/react-context 1.0.211-beta.3 → 1.0.211-beta.7

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.
@@ -1,5 +1,4 @@
1
1
  export * from './bookmarks';
2
- export * from './LiveAgentChat';
3
2
  export * from './AccountSelector';
4
3
  export * from './NewFeatureAnnouncement';
5
4
  export * from './SharedModals';
@@ -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;AACzC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC"}
@@ -1,5 +1,4 @@
1
1
  export * from './bookmarks';
2
- export * from './LiveAgentChat';
3
2
  export * from './AccountSelector';
4
3
  export * from './NewFeatureAnnouncement';
5
4
  export * from './SharedModals';
@@ -27,14 +27,14 @@ export const useChatConfig = () => {
27
27
  host: 'https://gss--stage2.sandbox.my.salesforce.com',
28
28
  sandBox: 'https://gss--stage2.sandbox.my.site.com/botchat',
29
29
  gslbBaseURL: 'https://service.force.com',
30
- key: '00Df0000003f0P8',
30
+ key: '00DDJ0000009qNz',
31
31
  appName: 'RedHatChatBot',
32
32
  extra: {
33
33
  baseLiveAgentContentURL: 'https://c.la1-c1cs-ia7.salesforceliveagent.com/content',
34
- deploymentId: '572f00000008QON',
35
- buttonId: '573f00000008QWv',
36
- baseLiveAgentURL: 'https://d.la1-c1cs-ia7.salesforceliveagent.com/chat',
37
- eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04If00000004CPqEAM_180cd4fc482',
34
+ deploymentId: '5726R000000sXtR',
35
+ buttonId: '5736R000000wk2n',
36
+ baseLiveAgentURL: 'https://d.la1-c1cs-ia6.salesforceliveagent.com/chat',
37
+ eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I6R000000wk2oUAA_180f4e169cb',
38
38
  isOfflineSupportEnabled: false,
39
39
  },
40
40
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/react-context",
3
- "version": "1.0.211-beta.3",
3
+ "version": "1.0.211-beta.7",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -44,10 +44,10 @@
44
44
  "@cee-eng/hydrajs": "4.15.0",
45
45
  "@patternfly/react-core": "4.264.0",
46
46
  "@patternfly/react-icons": "4.92.10",
47
- "@rh-support/components": "1.2.141-beta.1",
48
- "@rh-support/types": "0.2.0",
49
- "@rh-support/user-permissions": "1.0.111-beta.0",
50
- "@rh-support/utils": "1.0.91-beta.0",
47
+ "@rh-support/components": "1.2.141-beta.5",
48
+ "@rh-support/types": "0.2.0-beta.0",
49
+ "@rh-support/user-permissions": "1.0.111-beta.4",
50
+ "@rh-support/utils": "1.0.91-beta.4",
51
51
  "i18next": "^19.0.1",
52
52
  "localforage": "^1.7.3",
53
53
  "lodash": "^4.17.21",
@@ -90,5 +90,5 @@
90
90
  "not ie <= 11",
91
91
  "not op_mini all"
92
92
  ],
93
- "gitHead": "692bf3b3e8ee8f475d166e61a116f16ff5e9d8d6"
93
+ "gitHead": "1867e1006794475582e60255c45339c902126d5c"
94
94
  }
@@ -1,17 +0,0 @@
1
- import './liveAgentChat.css';
2
- interface IProps {
3
- chatOnlineText: string;
4
- chatOfflineText: string;
5
- }
6
- declare global {
7
- interface Window {
8
- liveagent: any;
9
- chatInitialized: boolean;
10
- _laq: any;
11
- fakeOnlineButton: any;
12
- fakeOfflineButton: any;
13
- }
14
- }
15
- export declare function LiveAgentChat({ chatOnlineText, chatOfflineText }: IProps): JSX.Element;
16
- export {};
17
- //# sourceMappingURL=LiveAgentChat.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LiveAgentChat.d.ts","sourceRoot":"","sources":["../../../../src/components/LiveAgentChat/LiveAgentChat.tsx"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAc7B,UAAU,MAAM;IACZ,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CAC3B;AAID,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,SAAS,EAAE,GAAG,CAAC;QACf,eAAe,EAAE,OAAO,CAAC;QACzB,IAAI,EAAE,GAAG,CAAC;QACV,gBAAgB,EAAE,GAAG,CAAC;QACtB,iBAAiB,EAAE,GAAG,CAAC;KAC1B;CACJ;AAWD,wBAAgB,aAAa,CAAC,EAAE,cAAoC,EAAE,eAAgC,EAAE,EAAE,MAAM,eAqG/G"}
@@ -1,108 +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 './liveAgentChat.css';
11
- import { publicApi } from '@cee-eng/hydrajs';
12
- import { ability, Can, resourceActions, resources } from '@rh-support/user-permissions';
13
- import React, { useContext, useEffect, useRef, useState } from 'react';
14
- import { GlobalMetadataStateContext } from '../../context/GlobalMetadataContext';
15
- import { getChatConfig } from './chatConfig';
16
- const BUTTON_STATE_INTERVAL = 5000;
17
- // we need these fake online buttons because we will pass these buttons
18
- // to liveagent and set a watcher on this button
19
- // basically liveagent needs an online button and offline button so that it can change
20
- // the display property of the button whenever the chat becomes online
21
- // There is no real rest api to check if any support user is really online from the salesforce UI
22
- window.fakeOnlineButton = { style: { display: 'none' } };
23
- window.fakeOfflineButton = { style: { display: 'none' } };
24
- const CHAT_SUPPORT = getChatConfig();
25
- export function LiveAgentChat({ chatOnlineText = 'Chat with support', chatOfflineText = 'Chat offline' }) {
26
- const canAccessChat = ability.can(resourceActions.READ, resources.CHAT);
27
- const [isChatAvailable, setIsChatAvailable] = useState(false);
28
- const [chatHackUrl, setChatHackUrl] = useState(CHAT_SUPPORT.chatIframeHackUrlPrefix);
29
- const { globalMetadataState: { loggedInUserRights }, } = useContext(GlobalMetadataStateContext);
30
- const statusCheckTimer = useRef(null);
31
- const openChatWindow = () => {
32
- window.liveagent.startChat(CHAT_SUPPORT.chatButtonToken);
33
- };
34
- // watcher that will be run every 5s to check if chat is online
35
- // whenever chat becomes online liveagaent sdk will change the display
36
- // property from none
37
- const checkChatButtonStates = function () {
38
- const buttonState = window.fakeOnlineButton.style.display !== 'none';
39
- setIsChatAvailable(buttonState);
40
- };
41
- const setChatIframeHackUrl = () => __awaiter(this, void 0, void 0, function* () {
42
- var _a;
43
- try {
44
- // here we make a call to strata to get a random session id. Why we need this random session id ?
45
- // the contact has to have a session generated when you login to the portal
46
- // and that session id is set in SFDC via an API call.
47
- // We can fake it by storing a session id on a contact that you're making the chat request
48
- // on behalf of. If you look in the brower's history you'll see a request to chatHidden in there too(our iframe).
49
- // That's what makes stores the session id in the browser
50
- const { message: sessionId } = yield publicApi.chat.getChatSession();
51
- const url = `${CHAT_SUPPORT.chatIframeHackUrlPrefix}?sessionId=${sessionId}&ssoName=${encodeURIComponent((_a = loggedInUserRights === null || loggedInUserRights === void 0 ? void 0 : loggedInUserRights.data) === null || _a === void 0 ? void 0 : _a.getSSOUsername())}`;
52
- // setting the final url in state because we set this url in the hidden iframe in the render function
53
- // iframe makes the call to set the temp sessionID on contact in SFDC
54
- setChatHackUrl(url);
55
- }
56
- catch (e) {
57
- console.error(e);
58
- }
59
- });
60
- const initializeChat = function () {
61
- var _a, _b;
62
- if (!canAccessChat || window.chatInitialized)
63
- return;
64
- if (!window._laq) {
65
- window._laq = [];
66
- }
67
- window._laq.push(function () {
68
- // here we pass the fake buttons to liveagent.
69
- // we don't even use the fakeOffline button to check the status of chat
70
- // we just check the state of fakeOnlineButton in checkChatButtonStates since both buttons complement
71
- // each other. Liveagent SDK will change the display property of buttons internally
72
- window.liveagent.showWhenOnline(CHAT_SUPPORT.chatButtonToken, window.fakeOnlineButton);
73
- window.liveagent.showWhenOffline(CHAT_SUPPORT.chatButtonToken, window.fakeOfflineButton);
74
- });
75
- const ssoName = (_a = loggedInUserRights === null || loggedInUserRights === void 0 ? void 0 : loggedInUserRights.data) === null || _a === void 0 ? void 0 : _a.getSSOUsername();
76
- const name = loggedInUserRights.data.getUserFullName();
77
- const accountNumber = (_b = loggedInUserRights === null || loggedInUserRights === void 0 ? void 0 : loggedInUserRights.data) === null || _b === void 0 ? void 0 : _b.getAccountNumber();
78
- window.liveagent
79
- .addCustomDetail('Contact Login', ssoName)
80
- .map('Contact', 'SSO_Username__c', true, true, true)
81
- .saveToTranscript('SSO_Username__c');
82
- accountNumber &&
83
- window.liveagent
84
- .addCustomDetail('Account Number', accountNumber)
85
- .map('Account', 'AccountNumber', true, true, true);
86
- name && window.liveagent.setName(name);
87
- window.liveagent.addCustomDetail('Name', name);
88
- window.liveagent.setChatWindowHeight('552');
89
- // the first step to intialise the chat..remeber this should only be done once in the lifecycle of the user journey in the app
90
- window.liveagent.init(CHAT_SUPPORT.chatLiveAgentUrlPrefix, CHAT_SUPPORT.chatInitHashOne, CHAT_SUPPORT.chatInitHashTwo);
91
- window.chatInitialized = true;
92
- };
93
- useEffect(() => {
94
- if (!canAccessChat || !window.liveagent)
95
- return;
96
- setChatIframeHackUrl();
97
- statusCheckTimer.current = window.setInterval(checkChatButtonStates, BUTTON_STATE_INTERVAL);
98
- initializeChat();
99
- return function cleanup() {
100
- window._laq = null;
101
- clearInterval(statusCheckTimer.current);
102
- };
103
- // eslint-disable-next-line react-hooks/exhaustive-deps
104
- }, [canAccessChat]);
105
- return (React.createElement(Can, { do: resourceActions.READ, on: resources.CHAT },
106
- React.createElement("iframe", { title: "Chat With Support", src: chatHackUrl, className: "chat-iframe" }),
107
- React.createElement("button", { disabled: !isChatAvailable, onClick: openChatWindow, className: "pf-c-button pf-m-link pf-m-inline liveagent-chat", "data-tracking-id": `chat-with-support-${isChatAvailable ? 'online' : 'offline'}` }, isChatAvailable ? chatOnlineText : chatOfflineText)));
108
- }
@@ -1,8 +0,0 @@
1
- export declare function getChatConfig(): {
2
- chatButtonToken: string;
3
- chatLiveAgentUrlPrefix: string;
4
- chatInitHashOne: string;
5
- chatInitHashTwo: string;
6
- chatIframeHackUrlPrefix: string;
7
- };
8
- //# sourceMappingURL=chatConfig.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chatConfig.d.ts","sourceRoot":"","sources":["../../../../src/components/LiveAgentChat/chatConfig.ts"],"names":[],"mappings":"AAOA,wBAAgB,aAAa;;;;;;EAqC5B"}
@@ -1,43 +0,0 @@
1
- import { Env } from '@cee-eng/hydrajs';
2
- // these config needs to updated if any sandbox gets refreshed
3
- // pcon(Patrick Connelly) is the right person to get the latest configs.
4
- // The link below also contains some info around the meaning of each config
5
- // https://developer.salesforce.com/docs/atlas.en-us.noversion.service_sdk_ios.meta/service_sdk_ios/live_agent_cloud_setup_get_settings.htm
6
- export function getChatConfig() {
7
- const env = Env.getEnvName();
8
- switch (env) {
9
- case Env.EnvNames.QA:
10
- return {
11
- chatButtonToken: '573A0000000GmiP',
12
- chatLiveAgentUrlPrefix: 'https://d.la3-c1cs-ia4.salesforceliveagent.com/chat',
13
- chatInitHashOne: '572A0000000GmiP',
14
- chatInitHashTwo: '00D7j0000008oSo',
15
- chatIframeHackUrlPrefix: 'https://qa-rogsstest.cs203.force.com/chatHidden',
16
- };
17
- case Env.EnvNames.STAGE:
18
- return {
19
- chatButtonToken: '573A0000000GmiP',
20
- chatLiveAgentUrlPrefix: 'https://d.la1-c1cs-iad.salesforceliveagent.com/chat',
21
- chatInitHashOne: '572A0000000GmiP',
22
- chatInitHashTwo: '00Df0000003f0P8',
23
- chatIframeHackUrlPrefix: 'https://stage2-rogsstest.cs16.force.com/chatHidden',
24
- };
25
- case Env.EnvNames.PROD_BETA:
26
- case Env.EnvNames.PROD:
27
- return {
28
- chatButtonToken: '573A0000000GmiP',
29
- chatLiveAgentUrlPrefix: 'https://d.la2-c2-ph2.salesforceliveagent.com/chat',
30
- chatInitHashOne: '572A0000000GmiP',
31
- chatInitHashTwo: '00DA0000000HxWH',
32
- chatIframeHackUrlPrefix: 'https://rogsstest.secure.force.com/chatHidden',
33
- };
34
- default:
35
- return {
36
- chatButtonToken: '573A0000000GmiP',
37
- chatLiveAgentUrlPrefix: 'https://d.la3-c1cs-ph2.salesforceliveagent.com/chat',
38
- chatInitHashOne: '572A0000000GmiP',
39
- chatInitHashTwo: '00D2i0000000Ml4',
40
- chatIframeHackUrlPrefix: 'https://qa-rogsstest.cs37.force.com/chatHidden',
41
- };
42
- }
43
- }
@@ -1,3 +0,0 @@
1
- export * from './LiveAgentChat';
2
- export * from './chatConfig';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/LiveAgentChat/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './LiveAgentChat';
2
- export * from './chatConfig';
@@ -1,3 +0,0 @@
1
- .chat-iframe {
2
- display: none;
3
- }