@rh-support/react-context 2.5.327 → 2.6.10
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/CSSUserModal.d.ts.map +1 -1
- package/lib/esm/components/SharedModals/CSSUserModal.js +2 -1
- package/lib/esm/components/SharedModals/CloseCaseModal.d.ts +2 -2
- package/lib/esm/components/SharedModals/CloseCaseModal.d.ts.map +1 -1
- package/lib/esm/components/SharedModals/CloseCaseModal.js +23 -7
- 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 +9 -2
- 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 +64 -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 +270 -89
- package/package.json +8 -5
- 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,76 @@ 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
|
+
const noAccessError = {
|
|
394
|
+
status: 403,
|
|
395
|
+
message: 'You do not have permission to view this case. Please contact your organization administrator if you believe you should have access.',
|
|
396
|
+
detailMessage: 'You do not have permission to view this case. Please contact your organization administrator if you believe you should have access.',
|
|
397
|
+
};
|
|
398
|
+
throw noAccessError;
|
|
399
|
+
}
|
|
400
|
+
if (isCssRestrictedAccess(graphqlCaseDetails.accessRestriction)) {
|
|
401
|
+
caseDispatch({
|
|
402
|
+
type: CaseDetailsFetchActions.receivedCaseDetailsError,
|
|
403
|
+
payload: {
|
|
404
|
+
caseDetailsError: {
|
|
405
|
+
status: 403,
|
|
406
|
+
detailMessage: CSS_ACCESS_RESTRICTION_ERROR_DETAIL,
|
|
407
|
+
message: CSS_ACCESS_RESTRICTION_ERROR_DETAIL,
|
|
408
|
+
},
|
|
409
|
+
},
|
|
410
|
+
});
|
|
411
|
+
return undefined;
|
|
412
|
+
}
|
|
413
|
+
const phoneToUse = graphqlCaseDetails.suppliedPhone || graphqlCaseDetails.contactPhone;
|
|
414
|
+
const caseDetails = Object.assign(Object.assign({}, mapGraphQLCaseDetailsToCasePayload(graphqlCaseDetails)), mapGraphQLContactPhoneToCasePhoneFields(phoneToUse, (phone) => {
|
|
415
|
+
const { countryCode, phoneLine } = getPhoneObj(phone);
|
|
416
|
+
return { countryCode, phoneLine: phoneLine || '' };
|
|
417
|
+
}));
|
|
418
|
+
const ownerFromGraphQL = mapGraphQLCaseContactToOwnerState(graphqlCaseDetails);
|
|
419
|
+
caseDispatch({
|
|
420
|
+
type: CaseDetailsFetchActions.receivedCaseDetails,
|
|
421
|
+
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 }),
|
|
422
|
+
});
|
|
423
|
+
if (setCaseAccountNumber) {
|
|
424
|
+
yield setCaseAccountNumber(caseDispatch, graphqlCaseDetails.accountNumberRef, false, {}, apolloClient);
|
|
425
|
+
}
|
|
426
|
+
return caseDetails;
|
|
427
|
+
}
|
|
428
|
+
catch (error) {
|
|
429
|
+
caseDispatch({
|
|
430
|
+
type: CaseDetailsFetchActions.receivedCaseDetailsError,
|
|
431
|
+
payload: { caseDetailsError: error },
|
|
432
|
+
});
|
|
433
|
+
return undefined;
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
export const fetchAllStatuses = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
437
|
+
var _a;
|
|
321
438
|
dispatch({
|
|
322
439
|
type: GlobalMetadataReducerConstants.setCaseStatuses,
|
|
323
440
|
payload: { allCaseStatuses: getApiResourceObject([], true) },
|
|
324
441
|
});
|
|
325
442
|
try {
|
|
326
|
-
const
|
|
443
|
+
const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Status']));
|
|
444
|
+
const allCaseStatuses = (_a = picklists.Status) !== null && _a !== void 0 ? _a : [];
|
|
327
445
|
dispatch({
|
|
328
446
|
type: GlobalMetadataReducerConstants.setCaseStatuses,
|
|
329
|
-
payload: { allCaseStatuses: getApiResourceObject(
|
|
447
|
+
payload: { allCaseStatuses: getApiResourceObject(allCaseStatuses) },
|
|
330
448
|
});
|
|
331
449
|
}
|
|
332
450
|
catch (e) {
|
|
@@ -336,25 +454,26 @@ export const fetchAllStatuses = (dispatch, isSecureSupport) => __awaiter(void 0,
|
|
|
336
454
|
});
|
|
337
455
|
}
|
|
338
456
|
});
|
|
339
|
-
export const fetchProducts = (
|
|
457
|
+
export const fetchProducts = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
458
|
+
var _a, _b, _c, _d;
|
|
340
459
|
try {
|
|
341
460
|
dispatch({
|
|
342
461
|
type: GlobalMetadataReducerConstants.setAllProducts,
|
|
343
462
|
payload: { allProducts: getApiResourceObject(initialProductResponse, true) },
|
|
344
463
|
});
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
464
|
+
const { data } = yield apolloClient.query({
|
|
465
|
+
query: GET_PRODUCTS,
|
|
466
|
+
variables: {
|
|
467
|
+
where: {
|
|
468
|
+
ParentProduct__c: { eq: null },
|
|
469
|
+
IsActive: { eq: true },
|
|
470
|
+
},
|
|
471
|
+
first: 200,
|
|
472
|
+
orderBy: { Name: { order: 'ASC' } },
|
|
473
|
+
},
|
|
474
|
+
});
|
|
475
|
+
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 : [];
|
|
476
|
+
const allProducts = handleGraphQLProductsResponse(edges);
|
|
358
477
|
dispatch({
|
|
359
478
|
type: GlobalMetadataReducerConstants.setAllProducts,
|
|
360
479
|
payload: { allProducts: getApiResourceObject(allProducts) },
|
|
@@ -367,18 +486,63 @@ export const fetchProducts = (dispatch_1, ownerSSOUsername_1, ...args_1) => __aw
|
|
|
367
486
|
});
|
|
368
487
|
}
|
|
369
488
|
});
|
|
489
|
+
export const fetchCaseRecordTypes = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
490
|
+
if (getTechnicalSupportRecordTypeId()) {
|
|
491
|
+
const cached = getCaseRecordTypes();
|
|
492
|
+
dispatch({
|
|
493
|
+
type: GlobalMetadataReducerConstants.setCaseRecordTypes,
|
|
494
|
+
payload: { caseRecordTypes: getApiResourceObject(cached) },
|
|
495
|
+
});
|
|
496
|
+
return cached;
|
|
497
|
+
}
|
|
498
|
+
return beginCaseRecordTypesLoad(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
499
|
+
var _a, _b, _c, _d;
|
|
500
|
+
dispatch({
|
|
501
|
+
type: GlobalMetadataReducerConstants.setCaseRecordTypes,
|
|
502
|
+
payload: { caseRecordTypes: getApiResourceObject({}, true) },
|
|
503
|
+
});
|
|
504
|
+
try {
|
|
505
|
+
const { data } = yield apolloClient.query({
|
|
506
|
+
query: GET_CASE_RECORD_TYPES,
|
|
507
|
+
});
|
|
508
|
+
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 : [];
|
|
509
|
+
const caseRecordTypes = {};
|
|
510
|
+
recordTypeInfos.forEach((info) => {
|
|
511
|
+
caseRecordTypes[info.name] = info.recordTypeId;
|
|
512
|
+
});
|
|
513
|
+
setCaseRecordTypes(caseRecordTypes);
|
|
514
|
+
dispatch({
|
|
515
|
+
type: GlobalMetadataReducerConstants.setCaseRecordTypes,
|
|
516
|
+
payload: { caseRecordTypes: getApiResourceObject(caseRecordTypes) },
|
|
517
|
+
});
|
|
518
|
+
return caseRecordTypes;
|
|
519
|
+
}
|
|
520
|
+
catch (e) {
|
|
521
|
+
dispatch({
|
|
522
|
+
type: GlobalMetadataReducerConstants.setCaseRecordTypes,
|
|
523
|
+
payload: { caseRecordTypes: getApiResourceObject({}, false, true, e.message) },
|
|
524
|
+
});
|
|
525
|
+
throw e;
|
|
526
|
+
}
|
|
527
|
+
}));
|
|
528
|
+
});
|
|
370
529
|
export const setAllProducts = (dispatch, allProducts) => {
|
|
371
530
|
dispatch({
|
|
372
531
|
type: GlobalMetadataReducerConstants.setAllProducts,
|
|
373
532
|
payload: { allProducts: getApiResourceObject(allProducts) },
|
|
374
533
|
});
|
|
375
534
|
};
|
|
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;
|
|
535
|
+
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) {
|
|
536
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
378
537
|
let accountNumber = token.account_number;
|
|
379
538
|
if (silent) {
|
|
380
539
|
try {
|
|
381
|
-
const
|
|
540
|
+
const { data } = yield apolloClient.query({
|
|
541
|
+
query: GET_ACCOUNT,
|
|
542
|
+
variables: getAccountQueryVariables(accountNumber),
|
|
543
|
+
});
|
|
544
|
+
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 : [];
|
|
545
|
+
const loggedInUsersAccount = handleGraphQLAccountResponse(edges);
|
|
382
546
|
dispatch({
|
|
383
547
|
type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
|
|
384
548
|
payload: { loggedInUsersAccount: getApiResourceObject(loggedInUsersAccount) },
|
|
@@ -394,7 +558,13 @@ export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __a
|
|
|
394
558
|
type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
|
|
395
559
|
payload: { loggedInUsersAccount: getApiResourceObject({}, true) },
|
|
396
560
|
});
|
|
397
|
-
const
|
|
561
|
+
const { data } = yield apolloClient.query({
|
|
562
|
+
query: GET_ACCOUNT,
|
|
563
|
+
variables: getAccountQueryVariables(accountNumber),
|
|
564
|
+
fetchPolicy: 'network-only',
|
|
565
|
+
});
|
|
566
|
+
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 : [];
|
|
567
|
+
const loggedInUsersAccount = handleGraphQLAccountResponse(edges);
|
|
398
568
|
dispatch({
|
|
399
569
|
type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
|
|
400
570
|
payload: { loggedInUsersAccount: getApiResourceObject(loggedInUsersAccount) },
|
|
@@ -402,7 +572,7 @@ export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __a
|
|
|
402
572
|
return loggedInUsersAccount;
|
|
403
573
|
}
|
|
404
574
|
catch (e) {
|
|
405
|
-
(
|
|
575
|
+
(_j = window.sessionjs) === null || _j === void 0 ? void 0 : _j.reportProblem(e, {
|
|
406
576
|
tags: {
|
|
407
577
|
portal_app: window.app || 'Portal Case Management',
|
|
408
578
|
error_effect: 'PCM - App wide error',
|
|
@@ -412,27 +582,30 @@ export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __a
|
|
|
412
582
|
});
|
|
413
583
|
dispatch({
|
|
414
584
|
type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
|
|
415
|
-
payload: {
|
|
585
|
+
payload: {
|
|
586
|
+
loggedInUsersAccount: getApiResourceObject({}, false, true, e === null || e === void 0 ? void 0 : e.message, e),
|
|
587
|
+
},
|
|
416
588
|
});
|
|
417
589
|
}
|
|
418
590
|
}
|
|
419
591
|
});
|
|
420
|
-
export const fetchLoggedInUser = (dispatch, token, pcmConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
592
|
+
export const fetchLoggedInUser = (dispatch, token, pcmConfig, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
421
593
|
var _a;
|
|
422
594
|
try {
|
|
423
595
|
dispatch({
|
|
424
596
|
type: GlobalMetadataReducerConstants.setLoggedInUser,
|
|
425
597
|
payload: { loggedInUser: getApiResourceObject({}, true) },
|
|
426
598
|
});
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
599
|
+
if (!apolloClient) {
|
|
600
|
+
throw new Error('Apollo client is required to fetch logged-in user via GraphQL');
|
|
601
|
+
}
|
|
602
|
+
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) || '';
|
|
603
|
+
const loggedInUser = yield fetchLoggedInUserFromGraphQL(apolloClient, ssoUsername);
|
|
431
604
|
dispatch({
|
|
432
605
|
type: GlobalMetadataReducerConstants.setLoggedInUser,
|
|
433
606
|
payload: { loggedInUser: getApiResourceObject(loggedInUser) },
|
|
434
607
|
});
|
|
435
|
-
//
|
|
608
|
+
// TODO: migrate to GraphQL - bookmark accounts skipped for now
|
|
436
609
|
const canViewBookmarkAccounts = loggedInUser.isInternal;
|
|
437
610
|
if (canViewBookmarkAccounts) {
|
|
438
611
|
fetchBookmarkedGroupAccounts(dispatch, loggedInUser.ssoUsername);
|
|
@@ -455,16 +628,19 @@ export const fetchLoggedInUser = (dispatch, token, pcmConfig) => __awaiter(void
|
|
|
455
628
|
});
|
|
456
629
|
}
|
|
457
630
|
});
|
|
458
|
-
export const fetchLanguageMetadata = (dispatch) => __awaiter(void 0, void 0, void 0, function* () {
|
|
631
|
+
export const fetchLanguageMetadata = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
632
|
+
var _a;
|
|
633
|
+
dispatch({
|
|
634
|
+
type: GlobalMetadataReducerConstants.setCaseLanguages,
|
|
635
|
+
payload: { caseLanguages: getApiResourceObject([], true) },
|
|
636
|
+
});
|
|
459
637
|
try {
|
|
638
|
+
yield fetchCaseRecordTypes(dispatch, apolloClient);
|
|
639
|
+
const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Language']));
|
|
640
|
+
const caseLanguages = (_a = picklists.Language) !== null && _a !== void 0 ? _a : [];
|
|
460
641
|
dispatch({
|
|
461
642
|
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) },
|
|
643
|
+
payload: { caseLanguages: getApiResourceObject(caseLanguages) },
|
|
468
644
|
});
|
|
469
645
|
}
|
|
470
646
|
catch (e) {
|
|
@@ -512,58 +688,59 @@ export const fetchCaseSbrsMetadata = (dispatch) => __awaiter(void 0, void 0, voi
|
|
|
512
688
|
});
|
|
513
689
|
}
|
|
514
690
|
});
|
|
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
|
-
}
|
|
691
|
+
export const fetchCaseGroupsForSSO = (dispatch, apolloClient, accountId, defaultCaseGroupId, contactId, isOrgAdmin) => __awaiter(void 0, void 0, void 0, function* () {
|
|
692
|
+
return fetchCaseGroupsByAccountId(dispatch, apolloClient, accountId, defaultCaseGroupId, contactId, isOrgAdmin);
|
|
535
693
|
});
|
|
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
|
-
}
|
|
694
|
+
export const fetchCaseGroupsForAccount = (dispatch, apolloClient, accountId, defaultCaseGroupId, contactId, isOrgAdmin) => __awaiter(void 0, void 0, void 0, function* () {
|
|
695
|
+
return fetchCaseGroupsByAccountId(dispatch, apolloClient, accountId, defaultCaseGroupId, contactId, isOrgAdmin);
|
|
555
696
|
});
|
|
556
|
-
|
|
697
|
+
/** Shared implementation that fetches case groups via GraphQL by Salesforce Account ID. */
|
|
698
|
+
const fetchCaseGroupsByAccountId = (dispatch, apolloClient, accountId, defaultCaseGroupId, contactId, isOrgAdmin) => __awaiter(void 0, void 0, void 0, function* () {
|
|
699
|
+
var _a, _b, _c, _d, _e, _f;
|
|
557
700
|
try {
|
|
558
701
|
dispatch({
|
|
559
702
|
type: GlobalMetadataReducerConstants.setCaseGroups,
|
|
560
703
|
payload: { caseGroups: getApiResourceObject([], true) },
|
|
561
704
|
});
|
|
562
|
-
const
|
|
705
|
+
const PAGE_SIZE = 200;
|
|
706
|
+
let allEdges = [];
|
|
707
|
+
let hasNextPage = true;
|
|
708
|
+
let afterCursor;
|
|
709
|
+
while (hasNextPage) {
|
|
710
|
+
const { data } = yield apolloClient.query({
|
|
711
|
+
query: GET_CASE_GROUP,
|
|
712
|
+
variables: Object.assign({ where: { Account__c: { eq: accountId } }, first: PAGE_SIZE }, (afterCursor ? { after: afterCursor } : {})),
|
|
713
|
+
fetchPolicy: 'network-only',
|
|
714
|
+
});
|
|
715
|
+
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;
|
|
716
|
+
const edges = (connection === null || connection === void 0 ? void 0 : connection.edges) || [];
|
|
717
|
+
allEdges = allEdges.concat(edges);
|
|
718
|
+
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;
|
|
719
|
+
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;
|
|
720
|
+
}
|
|
721
|
+
const filteredEdges = contactId && isOrgAdmin === false
|
|
722
|
+
? allEdges.filter(({ node }) => {
|
|
723
|
+
var _a, _b;
|
|
724
|
+
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; });
|
|
725
|
+
})
|
|
726
|
+
: allEdges;
|
|
727
|
+
const groups = filteredEdges.map(({ node }) => {
|
|
728
|
+
var _a;
|
|
729
|
+
return ({
|
|
730
|
+
groupNum: node.Id,
|
|
731
|
+
name: unescape((_a = node.Name.displayValue) !== null && _a !== void 0 ? _a : node.Name.value),
|
|
732
|
+
isPrivate: false,
|
|
733
|
+
isDefault: defaultCaseGroupId ? node.Id === defaultCaseGroupId : false,
|
|
734
|
+
defaultMembers: [],
|
|
735
|
+
members: [],
|
|
736
|
+
});
|
|
737
|
+
});
|
|
738
|
+
groups.sort((a, b) => a.name.localeCompare(b.name));
|
|
563
739
|
dispatch({
|
|
564
740
|
type: GlobalMetadataReducerConstants.setCaseGroups,
|
|
565
|
-
payload: { caseGroups: getApiResourceObject(
|
|
741
|
+
payload: { caseGroups: getApiResourceObject(groups, false) },
|
|
566
742
|
});
|
|
743
|
+
return groups;
|
|
567
744
|
}
|
|
568
745
|
catch (e) {
|
|
569
746
|
dispatch({
|
|
@@ -893,10 +1070,14 @@ export const fetchNoClusterIdReasonsMetadata = (dispatch) => __awaiter(void 0, v
|
|
|
893
1070
|
});
|
|
894
1071
|
}
|
|
895
1072
|
});
|
|
896
|
-
|
|
1073
|
+
/** Sets both case-list and troubleshoot agreement flags together (agree once per session). */
|
|
1074
|
+
export const setTraditionalSupportSessionAgreed = (dispatch, value) => {
|
|
897
1075
|
dispatch({
|
|
898
|
-
type: GlobalMetadataReducerConstants.
|
|
899
|
-
payload: {
|
|
1076
|
+
type: GlobalMetadataReducerConstants.setTraditionalSupportSessionAgreed,
|
|
1077
|
+
payload: {
|
|
1078
|
+
caseListTraditionalSupportAgreed: value,
|
|
1079
|
+
troubleshootTraditionalSupportAgreed: value,
|
|
1080
|
+
},
|
|
900
1081
|
});
|
|
901
1082
|
};
|
|
902
1083
|
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.
|
|
3
|
+
"version": "2.6.10",
|
|
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,10 +34,10 @@
|
|
|
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.
|
|
40
|
+
"@rh-support/components": "2.6.10",
|
|
40
41
|
"@rh-support/types": "2.0.26",
|
|
41
42
|
"@rh-support/user-permissions": "2.5.170",
|
|
42
43
|
"@rh-support/utils": "2.5.149",
|
|
@@ -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": "3f16770cee04217483b234f6d8dceaced57a0695"
|
|
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"}
|