@rh-support/react-context 2.5.318 → 2.5.321
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 -3
- package/lib/esm/GlobalContextWrapper.d.ts.map +1 -1
- package/lib/esm/GlobalContextWrapper.js +26 -8
- package/lib/esm/components/AccountSelector/AccountSelectorInternal.d.ts +1 -2
- package/lib/esm/components/AccountSelector/AccountSelectorInternal.d.ts.map +1 -1
- package/lib/esm/components/AccountSelector/AccountSelectorInternal.js +93 -37
- package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.d.ts +6 -0
- package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.d.ts.map +1 -1
- package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.js +17 -51
- package/lib/esm/components/EmbeddedServiceChat/embeddedServiceChat.css +1 -51
- package/lib/esm/components/SharedModals/CloseCaseModal.js +1 -1
- package/lib/esm/context/CaseStatusContext.d.ts +9 -0
- package/lib/esm/context/CaseStatusContext.d.ts.map +1 -0
- package/lib/esm/context/CaseStatusContext.js +5 -0
- package/lib/esm/hooks/index.d.ts +0 -1
- package/lib/esm/hooks/index.d.ts.map +1 -1
- package/lib/esm/hooks/index.js +0 -1
- package/lib/esm/hooks/useCanEditCase.d.ts +2 -1
- package/lib/esm/hooks/useCanEditCase.d.ts.map +1 -1
- package/lib/esm/hooks/useCanEditCase.js +20 -3
- package/lib/esm/hooks/useChatConfig.d.ts +9 -17
- package/lib/esm/hooks/useChatConfig.d.ts.map +1 -1
- package/lib/esm/hooks/useChatConfig.js +11 -43
- package/lib/esm/hooks/useChatInit.d.ts +9 -13
- package/lib/esm/hooks/useChatInit.d.ts.map +1 -1
- package/lib/esm/hooks/useChatInit.js +63 -119
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +2 -0
- package/lib/esm/reducers/GlobalMetadataHelpers.d.ts.map +1 -1
- package/lib/esm/reducers/GlobalMetadataHelpers.js +2 -6
- package/lib/esm/reducers/GlobalMetadataReducer.d.ts +51 -16
- package/lib/esm/reducers/GlobalMetadataReducer.d.ts.map +1 -1
- package/lib/esm/reducers/GlobalMetadataReducer.js +265 -89
- package/package.json +10 -7
- 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/hooks/usePreChatFormDetails.d.ts +0 -12
- package/lib/esm/hooks/usePreChatFormDetails.d.ts.map +0 -1
- package/lib/esm/hooks/usePreChatFormDetails.js +0 -61
|
@@ -7,14 +7,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { accounts, caseMetadata,
|
|
11
|
-
import {
|
|
10
|
+
import { accounts, caseMetadata, customEmail, maintenance, publicApi, userPreferences } from '@cee-eng/hydrajs';
|
|
11
|
+
import { getPhoneObj } from '@rh-support/components';
|
|
12
|
+
import { beginCaseRecordTypesLoad, buildPicklistInput, CSS_ACCESS_RESTRICTION_ERROR_DETAIL, fetchCaseDetailsByCaseNumber, fetchLoggedInUserFromGraphQL, fetchPicklistValues, GET_ACCOUNT, GET_CASE_GROUP, GET_CASE_RECORD_TYPES, GET_PRODUCTS, getAccountQueryVariables, getApiResourceObject, getCaseRecordTypes, getTechnicalSupportRecordTypeId, handleGraphQLAccountResponse, handleGraphQLProductsResponse, isCssRestrictedAccess, mapGraphQLCaseContactToOwnerState, mapGraphQLCaseDetailsToCasePayload, mapGraphQLContactPhoneToCasePhoneFields, setCaseRecordTypes, severitySort, } from '@rh-support/utils';
|
|
12
13
|
import differenceBy from 'lodash/differenceBy';
|
|
13
14
|
import filter from 'lodash/filter';
|
|
14
15
|
import find from 'lodash/find';
|
|
15
16
|
import isEmpty from 'lodash/isEmpty';
|
|
16
17
|
import reduce from 'lodash/reduce';
|
|
17
18
|
import sortBy from 'lodash/sortBy';
|
|
19
|
+
import unescape from 'lodash/unescape';
|
|
18
20
|
import unionBy from 'lodash/unionBy';
|
|
19
21
|
import { getProcessedCaseTypes } from './GlobalMetadataHelpers';
|
|
20
22
|
export var UserPreferencesKeys;
|
|
@@ -79,7 +81,8 @@ export var GlobalMetadataReducerConstants;
|
|
|
79
81
|
GlobalMetadataReducerConstants["setReferrerUrl"] = "setReferrerUrl";
|
|
80
82
|
GlobalMetadataReducerConstants["getNoclusteridreasons"] = "getNoclusteridreasons";
|
|
81
83
|
GlobalMetadataReducerConstants["setIsSharingHostnameswithRHt"] = "setIsSharingHostnameswithRHt";
|
|
82
|
-
GlobalMetadataReducerConstants["
|
|
84
|
+
GlobalMetadataReducerConstants["setTraditionalSupportSessionAgreed"] = "setTraditionalSupportSessionAgreed";
|
|
85
|
+
GlobalMetadataReducerConstants["setCaseRecordTypes"] = "setCaseRecordTypes";
|
|
83
86
|
})(GlobalMetadataReducerConstants || (GlobalMetadataReducerConstants = {}));
|
|
84
87
|
const initialProductResponse = {
|
|
85
88
|
topProducts: [],
|
|
@@ -118,11 +121,13 @@ export const initialGlobalMetadataState = {
|
|
|
118
121
|
},
|
|
119
122
|
referrerUrl: null,
|
|
120
123
|
caseNoClusterIdReasons: getApiResourceObject([]),
|
|
124
|
+
caseRecordTypes: getApiResourceObject({}),
|
|
121
125
|
caseListTraditionalSupportAgreed: false,
|
|
126
|
+
troubleshootTraditionalSupportAgreed: false,
|
|
122
127
|
};
|
|
123
128
|
// Resucers
|
|
124
129
|
export const globalMetadataReducer = (pState, action) => {
|
|
125
|
-
var _a;
|
|
130
|
+
var _a, _b;
|
|
126
131
|
switch (action.type) {
|
|
127
132
|
case GlobalMetadataReducerConstants.setCaseTypes: {
|
|
128
133
|
return Object.assign(Object.assign({}, pState), { allCaseTypes: action.payload.allCaseTypes });
|
|
@@ -215,8 +220,11 @@ export const globalMetadataReducer = (pState, action) => {
|
|
|
215
220
|
case GlobalMetadataReducerConstants.getNoclusteridreasons: {
|
|
216
221
|
return Object.assign(Object.assign({}, pState), { caseNoClusterIdReasons: action.payload.caseNoClusterIdReasons });
|
|
217
222
|
}
|
|
218
|
-
case GlobalMetadataReducerConstants.
|
|
219
|
-
return Object.assign(Object.assign({}, pState), { caseListTraditionalSupportAgreed: (_a = action.payload) === null || _a === void 0 ? void 0 : _a.caseListTraditionalSupportAgreed });
|
|
223
|
+
case GlobalMetadataReducerConstants.setTraditionalSupportSessionAgreed: {
|
|
224
|
+
return Object.assign(Object.assign({}, pState), { caseListTraditionalSupportAgreed: (_a = action.payload) === null || _a === void 0 ? void 0 : _a.caseListTraditionalSupportAgreed, troubleshootTraditionalSupportAgreed: (_b = action.payload) === null || _b === void 0 ? void 0 : _b.troubleshootTraditionalSupportAgreed });
|
|
225
|
+
}
|
|
226
|
+
case GlobalMetadataReducerConstants.setCaseRecordTypes: {
|
|
227
|
+
return Object.assign(Object.assign({}, pState), { caseRecordTypes: action.payload.caseRecordTypes });
|
|
220
228
|
}
|
|
221
229
|
default: {
|
|
222
230
|
return pState;
|
|
@@ -278,7 +286,35 @@ export const addEditbookmarks = (dispatch, allBookmarks, updatedAccounts, select
|
|
|
278
286
|
payload: { bookmarkedGroupAccounts: getApiResourceObject(allBookmarksCopy, false) },
|
|
279
287
|
});
|
|
280
288
|
};
|
|
281
|
-
export const fetchCaseTypes = (dispatch,
|
|
289
|
+
export const fetchCaseTypes = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
290
|
+
var _a;
|
|
291
|
+
dispatch({
|
|
292
|
+
type: GlobalMetadataReducerConstants.setCaseTypes,
|
|
293
|
+
payload: { allCaseTypes: getApiResourceObject([], true) },
|
|
294
|
+
});
|
|
295
|
+
try {
|
|
296
|
+
// Picklists require Technical Support record type ID - await it to avoid race on first load
|
|
297
|
+
yield fetchCaseRecordTypes(dispatch, apolloClient);
|
|
298
|
+
const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Type']));
|
|
299
|
+
const allCaseTypes = getProcessedCaseTypes((_a = picklists.Type) !== null && _a !== void 0 ? _a : []);
|
|
300
|
+
dispatch({
|
|
301
|
+
type: GlobalMetadataReducerConstants.setCaseTypes,
|
|
302
|
+
payload: { allCaseTypes: getApiResourceObject(allCaseTypes) },
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
catch (e) {
|
|
306
|
+
dispatch({
|
|
307
|
+
type: GlobalMetadataReducerConstants.setCaseTypes,
|
|
308
|
+
payload: { allCaseTypes: getApiResourceObject([], false, true, e.message) },
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
// const caseTypes = await caseMetadata.getTypes(isSecureSupport);
|
|
312
|
+
// dispatch({
|
|
313
|
+
// type: GlobalMetadataReducerConstants.setCaseTypes,
|
|
314
|
+
// payload: { allCaseTypes: getApiResourceObject(getProcessedCaseTypes(caseTypes.items)) },
|
|
315
|
+
// });
|
|
316
|
+
});
|
|
317
|
+
export const fetchCaseTypesHydra = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
|
|
282
318
|
dispatch({
|
|
283
319
|
type: GlobalMetadataReducerConstants.setCaseTypes,
|
|
284
320
|
payload: { allCaseTypes: getApiResourceObject([], true) },
|
|
@@ -297,7 +333,29 @@ export const fetchCaseTypes = (dispatch, isSecureSupport) => __awaiter(void 0, v
|
|
|
297
333
|
});
|
|
298
334
|
}
|
|
299
335
|
});
|
|
300
|
-
export const fetchCaseSeverities = (dispatch,
|
|
336
|
+
export const fetchCaseSeverities = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
337
|
+
var _a;
|
|
338
|
+
dispatch({
|
|
339
|
+
type: GlobalMetadataReducerConstants.setCaseSeverities,
|
|
340
|
+
payload: { allCaseSeverities: getApiResourceObject([], true) },
|
|
341
|
+
});
|
|
342
|
+
try {
|
|
343
|
+
yield fetchCaseRecordTypes(dispatch, apolloClient);
|
|
344
|
+
const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Priority']));
|
|
345
|
+
const allCaseSeverities = [...((_a = picklists.Priority) !== null && _a !== void 0 ? _a : [])].sort((sevA, sevB) => severitySort(sevA, sevB));
|
|
346
|
+
dispatch({
|
|
347
|
+
type: GlobalMetadataReducerConstants.setCaseSeverities,
|
|
348
|
+
payload: { allCaseSeverities: getApiResourceObject(allCaseSeverities) },
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
catch (e) {
|
|
352
|
+
dispatch({
|
|
353
|
+
type: GlobalMetadataReducerConstants.setCaseSeverities,
|
|
354
|
+
payload: { allCaseSeverities: getApiResourceObject([], false, true, e.message) },
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
export const fetchCaseSeveritiesHydra = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
|
|
301
359
|
dispatch({
|
|
302
360
|
type: GlobalMetadataReducerConstants.setCaseSeverities,
|
|
303
361
|
payload: { allCaseSeverities: getApiResourceObject([], true) },
|
|
@@ -317,16 +375,71 @@ export const fetchCaseSeverities = (dispatch, isSecureSupport) => __awaiter(void
|
|
|
317
375
|
});
|
|
318
376
|
}
|
|
319
377
|
});
|
|
320
|
-
|
|
378
|
+
/** Case reducer action types — kept in sync with CaseReducerConstants in troubleshoot */
|
|
379
|
+
const CaseDetailsFetchActions = {
|
|
380
|
+
requestCaseDetails: 'requestCaseDetails',
|
|
381
|
+
receivedCaseDetails: 'receivedCaseDetails',
|
|
382
|
+
receivedCaseDetailsError: 'receivedCaseDetailsError',
|
|
383
|
+
};
|
|
384
|
+
export const fetchCaseDetails = (caseDispatch_1, apolloClient_1, caseNumber_1, setCaseAccountNumber_1, ...args_1) => __awaiter(void 0, [caseDispatch_1, apolloClient_1, caseNumber_1, setCaseAccountNumber_1, ...args_1], void 0, function* (caseDispatch, apolloClient, caseNumber, setCaseAccountNumber, includeSecureSupport = false) {
|
|
385
|
+
var _a, _b;
|
|
386
|
+
caseDispatch({
|
|
387
|
+
type: CaseDetailsFetchActions.requestCaseDetails,
|
|
388
|
+
payload: { caseDetails: { caseNumber } },
|
|
389
|
+
});
|
|
390
|
+
try {
|
|
391
|
+
const graphqlCaseDetails = yield fetchCaseDetailsByCaseNumber(apolloClient, caseNumber, includeSecureSupport);
|
|
392
|
+
if (!graphqlCaseDetails) {
|
|
393
|
+
throw new Error('You don’t have permission to access this case. Please contact your administrator if you believe you should have access.');
|
|
394
|
+
}
|
|
395
|
+
if (isCssRestrictedAccess(graphqlCaseDetails.accessRestriction)) {
|
|
396
|
+
caseDispatch({
|
|
397
|
+
type: CaseDetailsFetchActions.receivedCaseDetailsError,
|
|
398
|
+
payload: {
|
|
399
|
+
caseDetailsError: {
|
|
400
|
+
status: 403,
|
|
401
|
+
detailMessage: CSS_ACCESS_RESTRICTION_ERROR_DETAIL,
|
|
402
|
+
message: CSS_ACCESS_RESTRICTION_ERROR_DETAIL,
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
});
|
|
406
|
+
return undefined;
|
|
407
|
+
}
|
|
408
|
+
const phoneToUse = graphqlCaseDetails.suppliedPhone || graphqlCaseDetails.contactPhone;
|
|
409
|
+
const caseDetails = Object.assign(Object.assign({}, mapGraphQLCaseDetailsToCasePayload(graphqlCaseDetails)), mapGraphQLContactPhoneToCasePhoneFields(phoneToUse, (phone) => {
|
|
410
|
+
const { countryCode, phoneLine } = getPhoneObj(phone);
|
|
411
|
+
return { countryCode, phoneLine: phoneLine || '' };
|
|
412
|
+
}));
|
|
413
|
+
const ownerFromGraphQL = mapGraphQLCaseContactToOwnerState(graphqlCaseDetails);
|
|
414
|
+
caseDispatch({
|
|
415
|
+
type: CaseDetailsFetchActions.receivedCaseDetails,
|
|
416
|
+
payload: Object.assign(Object.assign({ caseDetails }, (ownerFromGraphQL ? { selectedOwner: getApiResourceObject(ownerFromGraphQL) } : {})), { isClosed: (_a = graphqlCaseDetails.isClosed) !== null && _a !== void 0 ? _a : ((_b = graphqlCaseDetails.status) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'closed', caseNoOfCreatedCase: caseNumber }),
|
|
417
|
+
});
|
|
418
|
+
if (setCaseAccountNumber) {
|
|
419
|
+
yield setCaseAccountNumber(caseDispatch, graphqlCaseDetails.accountNumberRef, false, {}, apolloClient);
|
|
420
|
+
}
|
|
421
|
+
return caseDetails;
|
|
422
|
+
}
|
|
423
|
+
catch (error) {
|
|
424
|
+
caseDispatch({
|
|
425
|
+
type: CaseDetailsFetchActions.receivedCaseDetailsError,
|
|
426
|
+
payload: { caseDetailsError: error },
|
|
427
|
+
});
|
|
428
|
+
return undefined;
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
export const fetchAllStatuses = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
432
|
+
var _a;
|
|
321
433
|
dispatch({
|
|
322
434
|
type: GlobalMetadataReducerConstants.setCaseStatuses,
|
|
323
435
|
payload: { allCaseStatuses: getApiResourceObject([], true) },
|
|
324
436
|
});
|
|
325
437
|
try {
|
|
326
|
-
const
|
|
438
|
+
const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Status']));
|
|
439
|
+
const allCaseStatuses = (_a = picklists.Status) !== null && _a !== void 0 ? _a : [];
|
|
327
440
|
dispatch({
|
|
328
441
|
type: GlobalMetadataReducerConstants.setCaseStatuses,
|
|
329
|
-
payload: { allCaseStatuses: getApiResourceObject(
|
|
442
|
+
payload: { allCaseStatuses: getApiResourceObject(allCaseStatuses) },
|
|
330
443
|
});
|
|
331
444
|
}
|
|
332
445
|
catch (e) {
|
|
@@ -336,25 +449,26 @@ export const fetchAllStatuses = (dispatch, isSecureSupport) => __awaiter(void 0,
|
|
|
336
449
|
});
|
|
337
450
|
}
|
|
338
451
|
});
|
|
339
|
-
export const fetchProducts = (
|
|
452
|
+
export const fetchProducts = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
453
|
+
var _a, _b, _c, _d;
|
|
340
454
|
try {
|
|
341
455
|
dispatch({
|
|
342
456
|
type: GlobalMetadataReducerConstants.setAllProducts,
|
|
343
457
|
payload: { allProducts: getApiResourceObject(initialProductResponse, true) },
|
|
344
458
|
});
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
459
|
+
const { data } = yield apolloClient.query({
|
|
460
|
+
query: GET_PRODUCTS,
|
|
461
|
+
variables: {
|
|
462
|
+
where: {
|
|
463
|
+
ParentProduct__c: { eq: null },
|
|
464
|
+
IsActive: { eq: true },
|
|
465
|
+
},
|
|
466
|
+
first: 200,
|
|
467
|
+
orderBy: { Name: { order: 'ASC' } },
|
|
468
|
+
},
|
|
469
|
+
});
|
|
470
|
+
const edges = (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.redhat_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.RedHatSupportProduct2) === null || _c === void 0 ? void 0 : _c.edges) !== null && _d !== void 0 ? _d : [];
|
|
471
|
+
const allProducts = handleGraphQLProductsResponse(edges);
|
|
358
472
|
dispatch({
|
|
359
473
|
type: GlobalMetadataReducerConstants.setAllProducts,
|
|
360
474
|
payload: { allProducts: getApiResourceObject(allProducts) },
|
|
@@ -367,18 +481,63 @@ export const fetchProducts = (dispatch_1, ownerSSOUsername_1, ...args_1) => __aw
|
|
|
367
481
|
});
|
|
368
482
|
}
|
|
369
483
|
});
|
|
484
|
+
export const fetchCaseRecordTypes = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
485
|
+
if (getTechnicalSupportRecordTypeId()) {
|
|
486
|
+
const cached = getCaseRecordTypes();
|
|
487
|
+
dispatch({
|
|
488
|
+
type: GlobalMetadataReducerConstants.setCaseRecordTypes,
|
|
489
|
+
payload: { caseRecordTypes: getApiResourceObject(cached) },
|
|
490
|
+
});
|
|
491
|
+
return cached;
|
|
492
|
+
}
|
|
493
|
+
return beginCaseRecordTypesLoad(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
494
|
+
var _a, _b, _c, _d;
|
|
495
|
+
dispatch({
|
|
496
|
+
type: GlobalMetadataReducerConstants.setCaseRecordTypes,
|
|
497
|
+
payload: { caseRecordTypes: getApiResourceObject({}, true) },
|
|
498
|
+
});
|
|
499
|
+
try {
|
|
500
|
+
const { data } = yield apolloClient.query({
|
|
501
|
+
query: GET_CASE_RECORD_TYPES,
|
|
502
|
+
});
|
|
503
|
+
const recordTypeInfos = (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.redhat_support_uiapi) === null || _a === void 0 ? void 0 : _a.objectInfos) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.recordTypeInfos) !== null && _d !== void 0 ? _d : [];
|
|
504
|
+
const caseRecordTypes = {};
|
|
505
|
+
recordTypeInfos.forEach((info) => {
|
|
506
|
+
caseRecordTypes[info.name] = info.recordTypeId;
|
|
507
|
+
});
|
|
508
|
+
setCaseRecordTypes(caseRecordTypes);
|
|
509
|
+
dispatch({
|
|
510
|
+
type: GlobalMetadataReducerConstants.setCaseRecordTypes,
|
|
511
|
+
payload: { caseRecordTypes: getApiResourceObject(caseRecordTypes) },
|
|
512
|
+
});
|
|
513
|
+
return caseRecordTypes;
|
|
514
|
+
}
|
|
515
|
+
catch (e) {
|
|
516
|
+
dispatch({
|
|
517
|
+
type: GlobalMetadataReducerConstants.setCaseRecordTypes,
|
|
518
|
+
payload: { caseRecordTypes: getApiResourceObject({}, false, true, e.message) },
|
|
519
|
+
});
|
|
520
|
+
throw e;
|
|
521
|
+
}
|
|
522
|
+
}));
|
|
523
|
+
});
|
|
370
524
|
export const setAllProducts = (dispatch, allProducts) => {
|
|
371
525
|
dispatch({
|
|
372
526
|
type: GlobalMetadataReducerConstants.setAllProducts,
|
|
373
527
|
payload: { allProducts: getApiResourceObject(allProducts) },
|
|
374
528
|
});
|
|
375
529
|
};
|
|
376
|
-
export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __awaiter(void 0, [dispatch_1, token_1, ...args_1], void 0, function* (dispatch, token, silent = false) {
|
|
377
|
-
var _a;
|
|
530
|
+
export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __awaiter(void 0, [dispatch_1, token_1, ...args_1], void 0, function* (dispatch, token, silent = false, apolloClient) {
|
|
531
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
378
532
|
let accountNumber = token.account_number;
|
|
379
533
|
if (silent) {
|
|
380
534
|
try {
|
|
381
|
-
const
|
|
535
|
+
const { data } = yield apolloClient.query({
|
|
536
|
+
query: GET_ACCOUNT,
|
|
537
|
+
variables: getAccountQueryVariables(accountNumber),
|
|
538
|
+
});
|
|
539
|
+
const edges = (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.redhat_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.RedHatSupportAccount) === null || _c === void 0 ? void 0 : _c.edges) !== null && _d !== void 0 ? _d : [];
|
|
540
|
+
const loggedInUsersAccount = handleGraphQLAccountResponse(edges);
|
|
382
541
|
dispatch({
|
|
383
542
|
type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
|
|
384
543
|
payload: { loggedInUsersAccount: getApiResourceObject(loggedInUsersAccount) },
|
|
@@ -394,7 +553,13 @@ export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __a
|
|
|
394
553
|
type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
|
|
395
554
|
payload: { loggedInUsersAccount: getApiResourceObject({}, true) },
|
|
396
555
|
});
|
|
397
|
-
const
|
|
556
|
+
const { data } = yield apolloClient.query({
|
|
557
|
+
query: GET_ACCOUNT,
|
|
558
|
+
variables: getAccountQueryVariables(accountNumber),
|
|
559
|
+
fetchPolicy: 'network-only',
|
|
560
|
+
});
|
|
561
|
+
const edges = (_h = (_g = (_f = (_e = data === null || data === void 0 ? void 0 : data.redhat_support_uiapi) === null || _e === void 0 ? void 0 : _e.query) === null || _f === void 0 ? void 0 : _f.RedHatSupportAccount) === null || _g === void 0 ? void 0 : _g.edges) !== null && _h !== void 0 ? _h : [];
|
|
562
|
+
const loggedInUsersAccount = handleGraphQLAccountResponse(edges);
|
|
398
563
|
dispatch({
|
|
399
564
|
type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
|
|
400
565
|
payload: { loggedInUsersAccount: getApiResourceObject(loggedInUsersAccount) },
|
|
@@ -402,7 +567,7 @@ export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __a
|
|
|
402
567
|
return loggedInUsersAccount;
|
|
403
568
|
}
|
|
404
569
|
catch (e) {
|
|
405
|
-
(
|
|
570
|
+
(_j = window.sessionjs) === null || _j === void 0 ? void 0 : _j.reportProblem(e, {
|
|
406
571
|
tags: {
|
|
407
572
|
portal_app: window.app || 'Portal Case Management',
|
|
408
573
|
error_effect: 'PCM - App wide error',
|
|
@@ -412,27 +577,30 @@ export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __a
|
|
|
412
577
|
});
|
|
413
578
|
dispatch({
|
|
414
579
|
type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
|
|
415
|
-
payload: {
|
|
580
|
+
payload: {
|
|
581
|
+
loggedInUsersAccount: getApiResourceObject({}, false, true, e === null || e === void 0 ? void 0 : e.message, e),
|
|
582
|
+
},
|
|
416
583
|
});
|
|
417
584
|
}
|
|
418
585
|
}
|
|
419
586
|
});
|
|
420
|
-
export const fetchLoggedInUser = (dispatch, token, pcmConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
587
|
+
export const fetchLoggedInUser = (dispatch, token, pcmConfig, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
421
588
|
var _a;
|
|
422
589
|
try {
|
|
423
590
|
dispatch({
|
|
424
591
|
type: GlobalMetadataReducerConstants.setLoggedInUser,
|
|
425
592
|
payload: { loggedInUser: getApiResourceObject({}, true) },
|
|
426
593
|
});
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
594
|
+
if (!apolloClient) {
|
|
595
|
+
throw new Error('Apollo client is required to fetch logged-in user via GraphQL');
|
|
596
|
+
}
|
|
597
|
+
const ssoUsername = (token === null || token === void 0 ? void 0 : token.preferred_username) || (token === null || token === void 0 ? void 0 : token.username) || (token === null || token === void 0 ? void 0 : token.RHAT_LOGIN) || (token === null || token === void 0 ? void 0 : token.REDHAT_LOGIN) || '';
|
|
598
|
+
const loggedInUser = yield fetchLoggedInUserFromGraphQL(apolloClient, ssoUsername);
|
|
431
599
|
dispatch({
|
|
432
600
|
type: GlobalMetadataReducerConstants.setLoggedInUser,
|
|
433
601
|
payload: { loggedInUser: getApiResourceObject(loggedInUser) },
|
|
434
602
|
});
|
|
435
|
-
//
|
|
603
|
+
// TODO: migrate to GraphQL - bookmark accounts skipped for now
|
|
436
604
|
const canViewBookmarkAccounts = loggedInUser.isInternal;
|
|
437
605
|
if (canViewBookmarkAccounts) {
|
|
438
606
|
fetchBookmarkedGroupAccounts(dispatch, loggedInUser.ssoUsername);
|
|
@@ -455,16 +623,19 @@ export const fetchLoggedInUser = (dispatch, token, pcmConfig) => __awaiter(void
|
|
|
455
623
|
});
|
|
456
624
|
}
|
|
457
625
|
});
|
|
458
|
-
export const fetchLanguageMetadata = (dispatch) => __awaiter(void 0, void 0, void 0, function* () {
|
|
626
|
+
export const fetchLanguageMetadata = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
627
|
+
var _a;
|
|
628
|
+
dispatch({
|
|
629
|
+
type: GlobalMetadataReducerConstants.setCaseLanguages,
|
|
630
|
+
payload: { caseLanguages: getApiResourceObject([], true) },
|
|
631
|
+
});
|
|
459
632
|
try {
|
|
633
|
+
yield fetchCaseRecordTypes(dispatch, apolloClient);
|
|
634
|
+
const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Language']));
|
|
635
|
+
const caseLanguages = (_a = picklists.Language) !== null && _a !== void 0 ? _a : [];
|
|
460
636
|
dispatch({
|
|
461
637
|
type: GlobalMetadataReducerConstants.setCaseLanguages,
|
|
462
|
-
payload: { caseLanguages: getApiResourceObject(
|
|
463
|
-
});
|
|
464
|
-
const response = yield caseMetadata.getLanguagesMetadata();
|
|
465
|
-
dispatch({
|
|
466
|
-
type: GlobalMetadataReducerConstants.setCaseLanguages,
|
|
467
|
-
payload: { caseLanguages: getApiResourceObject(response.items) },
|
|
638
|
+
payload: { caseLanguages: getApiResourceObject(caseLanguages) },
|
|
468
639
|
});
|
|
469
640
|
}
|
|
470
641
|
catch (e) {
|
|
@@ -512,58 +683,59 @@ export const fetchCaseSbrsMetadata = (dispatch) => __awaiter(void 0, void 0, voi
|
|
|
512
683
|
});
|
|
513
684
|
}
|
|
514
685
|
});
|
|
515
|
-
export const fetchCaseGroupsForSSO = (dispatch,
|
|
516
|
-
|
|
517
|
-
dispatch({
|
|
518
|
-
type: GlobalMetadataReducerConstants.setCaseGroups,
|
|
519
|
-
payload: { caseGroups: getApiResourceObject([], true) },
|
|
520
|
-
});
|
|
521
|
-
const response = yield publicApi.caseGroups.getCaseGroupsForSSO(ssoUserName);
|
|
522
|
-
(response || []).sort((a, b) => a.name.localeCompare(b.name));
|
|
523
|
-
dispatch({
|
|
524
|
-
type: GlobalMetadataReducerConstants.setCaseGroups,
|
|
525
|
-
payload: { caseGroups: getApiResourceObject(response, false) },
|
|
526
|
-
});
|
|
527
|
-
return response;
|
|
528
|
-
}
|
|
529
|
-
catch (e) {
|
|
530
|
-
dispatch({
|
|
531
|
-
type: GlobalMetadataReducerConstants.setCaseGroups,
|
|
532
|
-
payload: { caseGroups: getApiResourceObject([], false, true, e.message) },
|
|
533
|
-
});
|
|
534
|
-
}
|
|
686
|
+
export const fetchCaseGroupsForSSO = (dispatch, apolloClient, accountId, defaultCaseGroupId, contactId, isOrgAdmin) => __awaiter(void 0, void 0, void 0, function* () {
|
|
687
|
+
return fetchCaseGroupsByAccountId(dispatch, apolloClient, accountId, defaultCaseGroupId, contactId, isOrgAdmin);
|
|
535
688
|
});
|
|
536
|
-
export const fetchCaseGroupsForAccount = (dispatch,
|
|
537
|
-
|
|
538
|
-
dispatch({
|
|
539
|
-
type: GlobalMetadataReducerConstants.setCaseGroups,
|
|
540
|
-
payload: { caseGroups: getApiResourceObject([], true) },
|
|
541
|
-
});
|
|
542
|
-
const response = yield publicApi.caseGroups.getCaseGroupsForInternalUser(accountNumber);
|
|
543
|
-
dispatch({
|
|
544
|
-
type: GlobalMetadataReducerConstants.setCaseGroups,
|
|
545
|
-
payload: { caseGroups: getApiResourceObject(response, false) },
|
|
546
|
-
});
|
|
547
|
-
return response;
|
|
548
|
-
}
|
|
549
|
-
catch (e) {
|
|
550
|
-
dispatch({
|
|
551
|
-
type: GlobalMetadataReducerConstants.setCaseGroups,
|
|
552
|
-
payload: { caseGroups: getApiResourceObject([], false, true, e.message) },
|
|
553
|
-
});
|
|
554
|
-
}
|
|
689
|
+
export const fetchCaseGroupsForAccount = (dispatch, apolloClient, accountId, defaultCaseGroupId, contactId, isOrgAdmin) => __awaiter(void 0, void 0, void 0, function* () {
|
|
690
|
+
return fetchCaseGroupsByAccountId(dispatch, apolloClient, accountId, defaultCaseGroupId, contactId, isOrgAdmin);
|
|
555
691
|
});
|
|
556
|
-
|
|
692
|
+
/** Shared implementation that fetches case groups via GraphQL by Salesforce Account ID. */
|
|
693
|
+
const fetchCaseGroupsByAccountId = (dispatch, apolloClient, accountId, defaultCaseGroupId, contactId, isOrgAdmin) => __awaiter(void 0, void 0, void 0, function* () {
|
|
694
|
+
var _a, _b, _c, _d, _e, _f;
|
|
557
695
|
try {
|
|
558
696
|
dispatch({
|
|
559
697
|
type: GlobalMetadataReducerConstants.setCaseGroups,
|
|
560
698
|
payload: { caseGroups: getApiResourceObject([], true) },
|
|
561
699
|
});
|
|
562
|
-
const
|
|
700
|
+
const PAGE_SIZE = 200;
|
|
701
|
+
let allEdges = [];
|
|
702
|
+
let hasNextPage = true;
|
|
703
|
+
let afterCursor;
|
|
704
|
+
while (hasNextPage) {
|
|
705
|
+
const { data } = yield apolloClient.query({
|
|
706
|
+
query: GET_CASE_GROUP,
|
|
707
|
+
variables: Object.assign({ where: { Account__c: { eq: accountId } }, first: PAGE_SIZE }, (afterCursor ? { after: afterCursor } : {})),
|
|
708
|
+
fetchPolicy: 'network-only',
|
|
709
|
+
});
|
|
710
|
+
const connection = (_b = (_a = data === null || data === void 0 ? void 0 : data.redhat_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.RedHatSupportCaseGroup__c;
|
|
711
|
+
const edges = (connection === null || connection === void 0 ? void 0 : connection.edges) || [];
|
|
712
|
+
allEdges = allEdges.concat(edges);
|
|
713
|
+
hasNextPage = (_d = (_c = connection === null || connection === void 0 ? void 0 : connection.pageInfo) === null || _c === void 0 ? void 0 : _c.hasNextPage) !== null && _d !== void 0 ? _d : false;
|
|
714
|
+
afterCursor = (_f = (_e = connection === null || connection === void 0 ? void 0 : connection.pageInfo) === null || _e === void 0 ? void 0 : _e.endCursor) !== null && _f !== void 0 ? _f : undefined;
|
|
715
|
+
}
|
|
716
|
+
const filteredEdges = contactId && isOrgAdmin === false
|
|
717
|
+
? allEdges.filter(({ node }) => {
|
|
718
|
+
var _a, _b;
|
|
719
|
+
return (_b = (_a = node.CaseGroupMembers__r) === null || _a === void 0 ? void 0 : _a.edges) === null || _b === void 0 ? void 0 : _b.some(({ node: member }) => { var _a; return ((_a = member.Contact__c) === null || _a === void 0 ? void 0 : _a.value) === contactId; });
|
|
720
|
+
})
|
|
721
|
+
: allEdges;
|
|
722
|
+
const groups = filteredEdges.map(({ node }) => {
|
|
723
|
+
var _a;
|
|
724
|
+
return ({
|
|
725
|
+
groupNum: node.Id,
|
|
726
|
+
name: unescape((_a = node.Name.displayValue) !== null && _a !== void 0 ? _a : node.Name.value),
|
|
727
|
+
isPrivate: false,
|
|
728
|
+
isDefault: defaultCaseGroupId ? node.Id === defaultCaseGroupId : false,
|
|
729
|
+
defaultMembers: [],
|
|
730
|
+
members: [],
|
|
731
|
+
});
|
|
732
|
+
});
|
|
733
|
+
groups.sort((a, b) => a.name.localeCompare(b.name));
|
|
563
734
|
dispatch({
|
|
564
735
|
type: GlobalMetadataReducerConstants.setCaseGroups,
|
|
565
|
-
payload: { caseGroups: getApiResourceObject(
|
|
736
|
+
payload: { caseGroups: getApiResourceObject(groups, false) },
|
|
566
737
|
});
|
|
738
|
+
return groups;
|
|
567
739
|
}
|
|
568
740
|
catch (e) {
|
|
569
741
|
dispatch({
|
|
@@ -893,10 +1065,14 @@ export const fetchNoClusterIdReasonsMetadata = (dispatch) => __awaiter(void 0, v
|
|
|
893
1065
|
});
|
|
894
1066
|
}
|
|
895
1067
|
});
|
|
896
|
-
|
|
1068
|
+
/** Sets both case-list and troubleshoot agreement flags together (agree once per session). */
|
|
1069
|
+
export const setTraditionalSupportSessionAgreed = (dispatch, value) => {
|
|
897
1070
|
dispatch({
|
|
898
|
-
type: GlobalMetadataReducerConstants.
|
|
899
|
-
payload: {
|
|
1071
|
+
type: GlobalMetadataReducerConstants.setTraditionalSupportSessionAgreed,
|
|
1072
|
+
payload: {
|
|
1073
|
+
caseListTraditionalSupportAgreed: value,
|
|
1074
|
+
troubleshootTraditionalSupportAgreed: value,
|
|
1075
|
+
},
|
|
900
1076
|
});
|
|
901
1077
|
};
|
|
902
1078
|
export const updateShareHostnameWithRHTState = (dispatch, loggedInUsersAccount, shareHostnameWithRHT) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/react-context",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.321",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"lib/**/*"
|
|
23
23
|
],
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@
|
|
25
|
+
"@apollo/client": "^4.1.6",
|
|
26
|
+
"@cee-eng/hydrajs": "^4.18.114",
|
|
26
27
|
"@patternfly/react-core": "6.2.1",
|
|
27
28
|
"@patternfly/react-icons": "6.2.1",
|
|
28
29
|
"i18next": "^23.15.0",
|
|
@@ -33,13 +34,13 @@
|
|
|
33
34
|
"react-test-renderer": "18.2.0"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@cee-eng/hydrajs": "4.18.
|
|
37
|
+
"@cee-eng/hydrajs": "^4.18.114",
|
|
37
38
|
"@patternfly/react-core": "6.2.1",
|
|
38
39
|
"@patternfly/react-icons": "6.2.1",
|
|
39
|
-
"@rh-support/components": "2.5.
|
|
40
|
+
"@rh-support/components": "2.5.225",
|
|
40
41
|
"@rh-support/types": "2.0.26",
|
|
41
|
-
"@rh-support/user-permissions": "2.5.
|
|
42
|
-
"@rh-support/utils": "2.5.
|
|
42
|
+
"@rh-support/user-permissions": "2.5.173",
|
|
43
|
+
"@rh-support/utils": "2.5.152",
|
|
43
44
|
"i18next": "^23.15.0",
|
|
44
45
|
"localforage": "^1.10.0",
|
|
45
46
|
"lodash": "^4.17.21",
|
|
@@ -50,6 +51,8 @@
|
|
|
50
51
|
"react-test-renderer": "18.2.0"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
54
|
+
"@patternfly/react-styles": "^6.2.1",
|
|
55
|
+
"@patternfly/react-tokens": "^6.2.1",
|
|
53
56
|
"@testing-library/jest-dom": "^6.2.0",
|
|
54
57
|
"@testing-library/react": "^14.1.2",
|
|
55
58
|
"@testing-library/react-hooks": "^5.1.2",
|
|
@@ -89,5 +92,5 @@
|
|
|
89
92
|
"defaults and supports es6-module",
|
|
90
93
|
"maintained node versions"
|
|
91
94
|
],
|
|
92
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "4cb198056cdf53141dcdf4d9b55d9cbb36940e05"
|
|
93
96
|
}
|
|
@@ -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,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":"AAKA,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,CA+CpE,CAAC"}
|