@rh-support/react-context 2.5.309 → 2.5.318

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.
Files changed (41) hide show
  1. package/lib/esm/GlobalContextWrapper.d.ts +3 -1
  2. package/lib/esm/GlobalContextWrapper.d.ts.map +1 -1
  3. package/lib/esm/GlobalContextWrapper.js +8 -26
  4. package/lib/esm/components/AccountSelector/AccountSelectorInternal.d.ts +2 -1
  5. package/lib/esm/components/AccountSelector/AccountSelectorInternal.d.ts.map +1 -1
  6. package/lib/esm/components/AccountSelector/AccountSelectorInternal.js +37 -93
  7. package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.d.ts +0 -6
  8. package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.d.ts.map +1 -1
  9. package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.js +51 -17
  10. package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.d.ts +12 -0
  11. package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.d.ts.map +1 -0
  12. package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.js +29 -0
  13. package/lib/esm/components/EmbeddedServiceChat/embeddedServiceChat.css +51 -1
  14. package/lib/esm/components/SharedModals/CloseCaseModal.js +1 -1
  15. package/lib/esm/hooks/index.d.ts +1 -0
  16. package/lib/esm/hooks/index.d.ts.map +1 -1
  17. package/lib/esm/hooks/index.js +1 -0
  18. package/lib/esm/hooks/useCanEditCase.d.ts +1 -2
  19. package/lib/esm/hooks/useCanEditCase.d.ts.map +1 -1
  20. package/lib/esm/hooks/useCanEditCase.js +3 -20
  21. package/lib/esm/hooks/useChatConfig.d.ts +17 -9
  22. package/lib/esm/hooks/useChatConfig.d.ts.map +1 -1
  23. package/lib/esm/hooks/useChatConfig.js +43 -11
  24. package/lib/esm/hooks/useChatInit.d.ts +13 -9
  25. package/lib/esm/hooks/useChatInit.d.ts.map +1 -1
  26. package/lib/esm/hooks/useChatInit.js +119 -63
  27. package/lib/esm/hooks/usePreChatFormDetails.d.ts +12 -0
  28. package/lib/esm/hooks/usePreChatFormDetails.d.ts.map +1 -0
  29. package/lib/esm/hooks/usePreChatFormDetails.js +61 -0
  30. package/lib/esm/index.d.ts +0 -1
  31. package/lib/esm/index.d.ts.map +1 -1
  32. package/lib/esm/index.js +0 -2
  33. package/lib/esm/reducers/GlobalMetadataHelpers.d.ts.map +1 -1
  34. package/lib/esm/reducers/GlobalMetadataHelpers.js +6 -2
  35. package/lib/esm/reducers/GlobalMetadataReducer.d.ts +15 -48
  36. package/lib/esm/reducers/GlobalMetadataReducer.d.ts.map +1 -1
  37. package/lib/esm/reducers/GlobalMetadataReducer.js +82 -253
  38. package/package.json +7 -10
  39. package/lib/esm/context/CaseStatusContext.d.ts +0 -9
  40. package/lib/esm/context/CaseStatusContext.d.ts.map +0 -1
  41. package/lib/esm/context/CaseStatusContext.js +0 -5
@@ -7,16 +7,14 @@ 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, 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';
10
+ import { accounts, caseMetadata, contacts, customEmail, maintenance, products, publicApi, userPreferences, } from '@cee-eng/hydrajs';
11
+ import { getApiResourceObject, handleEntitledProductResponse, handleProductSearchResponse, severitySort, } from '@rh-support/utils';
13
12
  import differenceBy from 'lodash/differenceBy';
14
13
  import filter from 'lodash/filter';
15
14
  import find from 'lodash/find';
16
15
  import isEmpty from 'lodash/isEmpty';
17
16
  import reduce from 'lodash/reduce';
18
17
  import sortBy from 'lodash/sortBy';
19
- import unescape from 'lodash/unescape';
20
18
  import unionBy from 'lodash/unionBy';
21
19
  import { getProcessedCaseTypes } from './GlobalMetadataHelpers';
22
20
  export var UserPreferencesKeys;
@@ -82,7 +80,6 @@ export var GlobalMetadataReducerConstants;
82
80
  GlobalMetadataReducerConstants["getNoclusteridreasons"] = "getNoclusteridreasons";
83
81
  GlobalMetadataReducerConstants["setIsSharingHostnameswithRHt"] = "setIsSharingHostnameswithRHt";
84
82
  GlobalMetadataReducerConstants["setCaseListTraditionalSupportAgreed"] = "setCaseListTraditionalSupportAgreed";
85
- GlobalMetadataReducerConstants["setCaseRecordTypes"] = "setCaseRecordTypes";
86
83
  })(GlobalMetadataReducerConstants || (GlobalMetadataReducerConstants = {}));
87
84
  const initialProductResponse = {
88
85
  topProducts: [],
@@ -121,7 +118,6 @@ export const initialGlobalMetadataState = {
121
118
  },
122
119
  referrerUrl: null,
123
120
  caseNoClusterIdReasons: getApiResourceObject([]),
124
- caseRecordTypes: getApiResourceObject({}),
125
121
  caseListTraditionalSupportAgreed: false,
126
122
  };
127
123
  // Resucers
@@ -222,9 +218,6 @@ export const globalMetadataReducer = (pState, action) => {
222
218
  case GlobalMetadataReducerConstants.setCaseListTraditionalSupportAgreed: {
223
219
  return Object.assign(Object.assign({}, pState), { caseListTraditionalSupportAgreed: (_a = action.payload) === null || _a === void 0 ? void 0 : _a.caseListTraditionalSupportAgreed });
224
220
  }
225
- case GlobalMetadataReducerConstants.setCaseRecordTypes: {
226
- return Object.assign(Object.assign({}, pState), { caseRecordTypes: action.payload.caseRecordTypes });
227
- }
228
221
  default: {
229
222
  return pState;
230
223
  }
@@ -285,35 +278,7 @@ export const addEditbookmarks = (dispatch, allBookmarks, updatedAccounts, select
285
278
  payload: { bookmarkedGroupAccounts: getApiResourceObject(allBookmarksCopy, false) },
286
279
  });
287
280
  };
288
- export const fetchCaseTypes = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
289
- var _a;
290
- dispatch({
291
- type: GlobalMetadataReducerConstants.setCaseTypes,
292
- payload: { allCaseTypes: getApiResourceObject([], true) },
293
- });
294
- try {
295
- // Picklists require Technical Support record type ID - await it to avoid race on first load
296
- yield fetchCaseRecordTypes(dispatch, apolloClient);
297
- const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Type']));
298
- const allCaseTypes = getProcessedCaseTypes((_a = picklists.Type) !== null && _a !== void 0 ? _a : []);
299
- dispatch({
300
- type: GlobalMetadataReducerConstants.setCaseTypes,
301
- payload: { allCaseTypes: getApiResourceObject(allCaseTypes) },
302
- });
303
- }
304
- catch (e) {
305
- dispatch({
306
- type: GlobalMetadataReducerConstants.setCaseTypes,
307
- payload: { allCaseTypes: getApiResourceObject([], false, true, e.message) },
308
- });
309
- }
310
- // const caseTypes = await caseMetadata.getTypes(isSecureSupport);
311
- // dispatch({
312
- // type: GlobalMetadataReducerConstants.setCaseTypes,
313
- // payload: { allCaseTypes: getApiResourceObject(getProcessedCaseTypes(caseTypes.items)) },
314
- // });
315
- });
316
- export const fetchCaseTypesHydra = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
281
+ export const fetchCaseTypes = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
317
282
  dispatch({
318
283
  type: GlobalMetadataReducerConstants.setCaseTypes,
319
284
  payload: { allCaseTypes: getApiResourceObject([], true) },
@@ -332,29 +297,7 @@ export const fetchCaseTypesHydra = (dispatch, isSecureSupport) => __awaiter(void
332
297
  });
333
298
  }
334
299
  });
335
- export const fetchCaseSeverities = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
336
- var _a;
337
- dispatch({
338
- type: GlobalMetadataReducerConstants.setCaseSeverities,
339
- payload: { allCaseSeverities: getApiResourceObject([], true) },
340
- });
341
- try {
342
- yield fetchCaseRecordTypes(dispatch, apolloClient);
343
- const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Priority']));
344
- const allCaseSeverities = [...((_a = picklists.Priority) !== null && _a !== void 0 ? _a : [])].sort((sevA, sevB) => severitySort(sevA, sevB));
345
- dispatch({
346
- type: GlobalMetadataReducerConstants.setCaseSeverities,
347
- payload: { allCaseSeverities: getApiResourceObject(allCaseSeverities) },
348
- });
349
- }
350
- catch (e) {
351
- dispatch({
352
- type: GlobalMetadataReducerConstants.setCaseSeverities,
353
- payload: { allCaseSeverities: getApiResourceObject([], false, true, e.message) },
354
- });
355
- }
356
- });
357
- export const fetchCaseSeveritiesHydra = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
300
+ export const fetchCaseSeverities = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
358
301
  dispatch({
359
302
  type: GlobalMetadataReducerConstants.setCaseSeverities,
360
303
  payload: { allCaseSeverities: getApiResourceObject([], true) },
@@ -374,71 +317,16 @@ export const fetchCaseSeveritiesHydra = (dispatch, isSecureSupport) => __awaiter
374
317
  });
375
318
  }
376
319
  });
377
- /** Case reducer action types kept in sync with CaseReducerConstants in troubleshoot */
378
- const CaseDetailsFetchActions = {
379
- requestCaseDetails: 'requestCaseDetails',
380
- receivedCaseDetails: 'receivedCaseDetails',
381
- receivedCaseDetailsError: 'receivedCaseDetailsError',
382
- };
383
- 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) {
384
- var _a, _b;
385
- caseDispatch({
386
- type: CaseDetailsFetchActions.requestCaseDetails,
387
- payload: { caseDetails: { caseNumber } },
388
- });
389
- try {
390
- const graphqlCaseDetails = yield fetchCaseDetailsByCaseNumber(apolloClient, caseNumber, includeSecureSupport);
391
- if (!graphqlCaseDetails) {
392
- throw new Error('You don’t have permission to access this case. Please contact your administrator if you believe you should have access.');
393
- }
394
- if (isCssRestrictedAccess(graphqlCaseDetails.accessRestriction)) {
395
- caseDispatch({
396
- type: CaseDetailsFetchActions.receivedCaseDetailsError,
397
- payload: {
398
- caseDetailsError: {
399
- status: 403,
400
- detailMessage: CSS_ACCESS_RESTRICTION_ERROR_DETAIL,
401
- message: CSS_ACCESS_RESTRICTION_ERROR_DETAIL,
402
- },
403
- },
404
- });
405
- return undefined;
406
- }
407
- const phoneToUse = graphqlCaseDetails.suppliedPhone || graphqlCaseDetails.contactPhone;
408
- const caseDetails = Object.assign(Object.assign({}, mapGraphQLCaseDetailsToCasePayload(graphqlCaseDetails)), mapGraphQLContactPhoneToCasePhoneFields(phoneToUse, (phone) => {
409
- const { countryCode, phoneLine } = getPhoneObj(phone);
410
- return { countryCode, phoneLine: phoneLine || '' };
411
- }));
412
- const ownerFromGraphQL = mapGraphQLCaseContactToOwnerState(graphqlCaseDetails);
413
- caseDispatch({
414
- type: CaseDetailsFetchActions.receivedCaseDetails,
415
- 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 }),
416
- });
417
- if (setCaseAccountNumber) {
418
- yield setCaseAccountNumber(caseDispatch, graphqlCaseDetails.accountNumberRef, false, {}, apolloClient);
419
- }
420
- return caseDetails;
421
- }
422
- catch (error) {
423
- caseDispatch({
424
- type: CaseDetailsFetchActions.receivedCaseDetailsError,
425
- payload: { caseDetailsError: error },
426
- });
427
- return undefined;
428
- }
429
- });
430
- export const fetchAllStatuses = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
431
- var _a;
320
+ export const fetchAllStatuses = (dispatch, isSecureSupport) => __awaiter(void 0, void 0, void 0, function* () {
432
321
  dispatch({
433
322
  type: GlobalMetadataReducerConstants.setCaseStatuses,
434
323
  payload: { allCaseStatuses: getApiResourceObject([], true) },
435
324
  });
436
325
  try {
437
- const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Status']));
438
- const allCaseStatuses = (_a = picklists.Status) !== null && _a !== void 0 ? _a : [];
326
+ const caseStatusesResponse = yield caseMetadata.getStatuses(isSecureSupport);
439
327
  dispatch({
440
328
  type: GlobalMetadataReducerConstants.setCaseStatuses,
441
- payload: { allCaseStatuses: getApiResourceObject(allCaseStatuses) },
329
+ payload: { allCaseStatuses: getApiResourceObject(caseStatusesResponse.items) },
442
330
  });
443
331
  }
444
332
  catch (e) {
@@ -448,26 +336,25 @@ export const fetchAllStatuses = (dispatch, apolloClient) => __awaiter(void 0, vo
448
336
  });
449
337
  }
450
338
  });
451
- export const fetchProducts = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
452
- var _a, _b, _c, _d;
339
+ export const fetchProducts = (dispatch_1, ownerSSOUsername_1, ...args_1) => __awaiter(void 0, [dispatch_1, ownerSSOUsername_1, ...args_1], void 0, function* (dispatch, ownerSSOUsername, params = {}) {
453
340
  try {
454
341
  dispatch({
455
342
  type: GlobalMetadataReducerConstants.setAllProducts,
456
343
  payload: { allProducts: getApiResourceObject(initialProductResponse, true) },
457
344
  });
458
- const { data } = yield apolloClient.query({
459
- query: GET_PRODUCTS,
460
- variables: {
461
- where: {
462
- ParentProduct__c: { eq: null },
463
- IsActive: { eq: true },
464
- },
465
- first: 200,
466
- orderBy: { Name: { order: 'ASC' } },
467
- },
468
- });
469
- 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 : [];
470
- const allProducts = handleGraphQLProductsResponse(edges);
345
+ /**
346
+ * Here we are trying to fetch products from two sources (getSEProductsList and getProducts) and if even first source (getSEProductsList) fail to deliver product information
347
+ * we still need to use second source (getProducts) to parse and list product
348
+ */
349
+ const response = yield Promise.allSettled([
350
+ products.getSEProductsList(params),
351
+ products.getProducts(ownerSSOUsername),
352
+ ]);
353
+ const productsResultAll = response[0].status === 'fulfilled' ? response[0].value : [];
354
+ const productsResultEntitled = response[1].status === 'fulfilled' ? response[1].value : [];
355
+ const allProducts = productsResultAll.length
356
+ ? handleProductSearchResponse(productsResultAll, productsResultEntitled)
357
+ : handleEntitledProductResponse(productsResultEntitled);
471
358
  dispatch({
472
359
  type: GlobalMetadataReducerConstants.setAllProducts,
473
360
  payload: { allProducts: getApiResourceObject(allProducts) },
@@ -480,63 +367,18 @@ export const fetchProducts = (dispatch, apolloClient) => __awaiter(void 0, void
480
367
  });
481
368
  }
482
369
  });
483
- export const fetchCaseRecordTypes = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
484
- if (getTechnicalSupportRecordTypeId()) {
485
- const cached = getCaseRecordTypes();
486
- dispatch({
487
- type: GlobalMetadataReducerConstants.setCaseRecordTypes,
488
- payload: { caseRecordTypes: getApiResourceObject(cached) },
489
- });
490
- return cached;
491
- }
492
- return beginCaseRecordTypesLoad(() => __awaiter(void 0, void 0, void 0, function* () {
493
- var _a, _b, _c, _d;
494
- dispatch({
495
- type: GlobalMetadataReducerConstants.setCaseRecordTypes,
496
- payload: { caseRecordTypes: getApiResourceObject({}, true) },
497
- });
498
- try {
499
- const { data } = yield apolloClient.query({
500
- query: GET_CASE_RECORD_TYPES,
501
- });
502
- 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 : [];
503
- const caseRecordTypes = {};
504
- recordTypeInfos.forEach((info) => {
505
- caseRecordTypes[info.name] = info.recordTypeId;
506
- });
507
- setCaseRecordTypes(caseRecordTypes);
508
- dispatch({
509
- type: GlobalMetadataReducerConstants.setCaseRecordTypes,
510
- payload: { caseRecordTypes: getApiResourceObject(caseRecordTypes) },
511
- });
512
- return caseRecordTypes;
513
- }
514
- catch (e) {
515
- dispatch({
516
- type: GlobalMetadataReducerConstants.setCaseRecordTypes,
517
- payload: { caseRecordTypes: getApiResourceObject({}, false, true, e.message) },
518
- });
519
- throw e;
520
- }
521
- }));
522
- });
523
370
  export const setAllProducts = (dispatch, allProducts) => {
524
371
  dispatch({
525
372
  type: GlobalMetadataReducerConstants.setAllProducts,
526
373
  payload: { allProducts: getApiResourceObject(allProducts) },
527
374
  });
528
375
  };
529
- 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) {
530
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
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;
531
378
  let accountNumber = token.account_number;
532
379
  if (silent) {
533
380
  try {
534
- const { data } = yield apolloClient.query({
535
- query: GET_ACCOUNT,
536
- variables: getAccountQueryVariables(accountNumber),
537
- });
538
- 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 : [];
539
- const loggedInUsersAccount = handleGraphQLAccountResponse(edges);
381
+ const loggedInUsersAccount = yield accounts.getAccount(accountNumber);
540
382
  dispatch({
541
383
  type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
542
384
  payload: { loggedInUsersAccount: getApiResourceObject(loggedInUsersAccount) },
@@ -552,13 +394,7 @@ export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __a
552
394
  type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
553
395
  payload: { loggedInUsersAccount: getApiResourceObject({}, true) },
554
396
  });
555
- const { data } = yield apolloClient.query({
556
- query: GET_ACCOUNT,
557
- variables: getAccountQueryVariables(accountNumber),
558
- fetchPolicy: 'network-only',
559
- });
560
- 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 : [];
561
- const loggedInUsersAccount = handleGraphQLAccountResponse(edges);
397
+ const loggedInUsersAccount = yield accounts.getAccount(accountNumber);
562
398
  dispatch({
563
399
  type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
564
400
  payload: { loggedInUsersAccount: getApiResourceObject(loggedInUsersAccount) },
@@ -566,7 +402,7 @@ export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __a
566
402
  return loggedInUsersAccount;
567
403
  }
568
404
  catch (e) {
569
- (_j = window.sessionjs) === null || _j === void 0 ? void 0 : _j.reportProblem(e, {
405
+ (_a = window.sessionjs) === null || _a === void 0 ? void 0 : _a.reportProblem(e, {
570
406
  tags: {
571
407
  portal_app: window.app || 'Portal Case Management',
572
408
  error_effect: 'PCM - App wide error',
@@ -576,30 +412,27 @@ export const fetchLoggedInUsersAccount = (dispatch_1, token_1, ...args_1) => __a
576
412
  });
577
413
  dispatch({
578
414
  type: GlobalMetadataReducerConstants.setLoggedInUsersAccount,
579
- payload: {
580
- loggedInUsersAccount: getApiResourceObject({}, false, true, e === null || e === void 0 ? void 0 : e.message, e),
581
- },
415
+ payload: { loggedInUsersAccount: getApiResourceObject({}, false, true, e === null || e === void 0 ? void 0 : e.message, e) },
582
416
  });
583
417
  }
584
418
  }
585
419
  });
586
- export const fetchLoggedInUser = (dispatch, token, pcmConfig, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
420
+ export const fetchLoggedInUser = (dispatch, token, pcmConfig) => __awaiter(void 0, void 0, void 0, function* () {
587
421
  var _a;
588
422
  try {
589
423
  dispatch({
590
424
  type: GlobalMetadataReducerConstants.setLoggedInUser,
591
425
  payload: { loggedInUser: getApiResourceObject({}, true) },
592
426
  });
593
- if (!apolloClient) {
594
- throw new Error('Apollo client is required to fetch logged-in user via GraphQL');
595
- }
596
- 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) || '';
597
- const loggedInUser = yield fetchLoggedInUserFromGraphQL(apolloClient, ssoUsername);
427
+ let loggedInUser = yield contacts.getCurrentContact({
428
+ userId: token.sub,
429
+ assumeEntitledIfSubscriptionServiceUnavailable: true,
430
+ });
598
431
  dispatch({
599
432
  type: GlobalMetadataReducerConstants.setLoggedInUser,
600
433
  payload: { loggedInUser: getApiResourceObject(loggedInUser) },
601
434
  });
602
- // TODO: migrate to GraphQL - bookmark accounts skipped for now
435
+ // Saving bookmarked accounts separately.
603
436
  const canViewBookmarkAccounts = loggedInUser.isInternal;
604
437
  if (canViewBookmarkAccounts) {
605
438
  fetchBookmarkedGroupAccounts(dispatch, loggedInUser.ssoUsername);
@@ -622,19 +455,16 @@ export const fetchLoggedInUser = (dispatch, token, pcmConfig, apolloClient) => _
622
455
  });
623
456
  }
624
457
  });
625
- export const fetchLanguageMetadata = (dispatch, apolloClient) => __awaiter(void 0, void 0, void 0, function* () {
626
- var _a;
627
- dispatch({
628
- type: GlobalMetadataReducerConstants.setCaseLanguages,
629
- payload: { caseLanguages: getApiResourceObject([], true) },
630
- });
458
+ export const fetchLanguageMetadata = (dispatch) => __awaiter(void 0, void 0, void 0, function* () {
631
459
  try {
632
- yield fetchCaseRecordTypes(dispatch, apolloClient);
633
- const picklists = yield fetchPicklistValues(apolloClient, buildPicklistInput(['Language']));
634
- const caseLanguages = (_a = picklists.Language) !== null && _a !== void 0 ? _a : [];
635
460
  dispatch({
636
461
  type: GlobalMetadataReducerConstants.setCaseLanguages,
637
- payload: { caseLanguages: getApiResourceObject(caseLanguages) },
462
+ payload: { caseLanguages: getApiResourceObject([], true) },
463
+ });
464
+ const response = yield caseMetadata.getLanguagesMetadata();
465
+ dispatch({
466
+ type: GlobalMetadataReducerConstants.setCaseLanguages,
467
+ payload: { caseLanguages: getApiResourceObject(response.items) },
638
468
  });
639
469
  }
640
470
  catch (e) {
@@ -682,59 +512,58 @@ export const fetchCaseSbrsMetadata = (dispatch) => __awaiter(void 0, void 0, voi
682
512
  });
683
513
  }
684
514
  });
685
- export const fetchCaseGroupsForSSO = (dispatch, apolloClient, accountId, defaultCaseGroupId, contactId, isOrgAdmin) => __awaiter(void 0, void 0, void 0, function* () {
686
- return fetchCaseGroupsByAccountId(dispatch, apolloClient, accountId, defaultCaseGroupId, contactId, isOrgAdmin);
687
- });
688
- export const fetchCaseGroupsForAccount = (dispatch, apolloClient, accountId, defaultCaseGroupId, contactId, isOrgAdmin) => __awaiter(void 0, void 0, void 0, function* () {
689
- return fetchCaseGroupsByAccountId(dispatch, apolloClient, accountId, defaultCaseGroupId, contactId, isOrgAdmin);
515
+ export const fetchCaseGroupsForSSO = (dispatch, ssoUserName) => __awaiter(void 0, void 0, void 0, function* () {
516
+ try {
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
+ }
690
535
  });
691
- /** Shared implementation that fetches case groups via GraphQL by Salesforce Account ID. */
692
- const fetchCaseGroupsByAccountId = (dispatch, apolloClient, accountId, defaultCaseGroupId, contactId, isOrgAdmin) => __awaiter(void 0, void 0, void 0, function* () {
693
- var _a, _b, _c, _d, _e, _f;
536
+ export const fetchCaseGroupsForAccount = (dispatch, accountNumber) => __awaiter(void 0, void 0, void 0, function* () {
694
537
  try {
695
538
  dispatch({
696
539
  type: GlobalMetadataReducerConstants.setCaseGroups,
697
540
  payload: { caseGroups: getApiResourceObject([], true) },
698
541
  });
699
- const PAGE_SIZE = 200;
700
- let allEdges = [];
701
- let hasNextPage = true;
702
- let afterCursor;
703
- while (hasNextPage) {
704
- const { data } = yield apolloClient.query({
705
- query: GET_CASE_GROUP,
706
- variables: Object.assign({ where: { Account__c: { eq: accountId } }, first: PAGE_SIZE }, (afterCursor ? { after: afterCursor } : {})),
707
- fetchPolicy: 'network-only',
708
- });
709
- 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;
710
- const edges = (connection === null || connection === void 0 ? void 0 : connection.edges) || [];
711
- allEdges = allEdges.concat(edges);
712
- 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;
713
- 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;
714
- }
715
- const filteredEdges = contactId && isOrgAdmin === false
716
- ? allEdges.filter(({ node }) => {
717
- var _a, _b;
718
- 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; });
719
- })
720
- : allEdges;
721
- const groups = filteredEdges.map(({ node }) => {
722
- var _a;
723
- return ({
724
- groupNum: node.Id,
725
- name: unescape((_a = node.Name.displayValue) !== null && _a !== void 0 ? _a : node.Name.value),
726
- isPrivate: false,
727
- isDefault: defaultCaseGroupId ? node.Id === defaultCaseGroupId : false,
728
- defaultMembers: [],
729
- members: [],
730
- });
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
+ }
555
+ });
556
+ export const fetchCaseGroups = (dispatch) => __awaiter(void 0, void 0, void 0, function* () {
557
+ try {
558
+ dispatch({
559
+ type: GlobalMetadataReducerConstants.setCaseGroups,
560
+ payload: { caseGroups: getApiResourceObject([], true) },
731
561
  });
732
- groups.sort((a, b) => a.name.localeCompare(b.name));
562
+ const response = yield publicApi.caseGroups.getCaseGroups();
733
563
  dispatch({
734
564
  type: GlobalMetadataReducerConstants.setCaseGroups,
735
- payload: { caseGroups: getApiResourceObject(groups, false) },
565
+ payload: { caseGroups: getApiResourceObject(response, false) },
736
566
  });
737
- return groups;
738
567
  }
739
568
  catch (e) {
740
569
  dispatch({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/react-context",
3
- "version": "2.5.309",
3
+ "version": "2.5.318",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -22,8 +22,7 @@
22
22
  "lib/**/*"
23
23
  ],
24
24
  "peerDependencies": {
25
- "@apollo/client": "^4.1.6",
26
- "@cee-eng/hydrajs": "^4.18.114",
25
+ "@cee-eng/hydrajs": "4.18.111",
27
26
  "@patternfly/react-core": "6.2.1",
28
27
  "@patternfly/react-icons": "6.2.1",
29
28
  "i18next": "^23.15.0",
@@ -34,13 +33,13 @@
34
33
  "react-test-renderer": "18.2.0"
35
34
  },
36
35
  "dependencies": {
37
- "@cee-eng/hydrajs": "^4.18.114",
36
+ "@cee-eng/hydrajs": "4.18.111",
38
37
  "@patternfly/react-core": "6.2.1",
39
38
  "@patternfly/react-icons": "6.2.1",
40
- "@rh-support/components": "2.5.214",
39
+ "@rh-support/components": "2.5.222",
41
40
  "@rh-support/types": "2.0.26",
42
- "@rh-support/user-permissions": "2.5.161",
43
- "@rh-support/utils": "2.5.142",
41
+ "@rh-support/user-permissions": "2.5.170",
42
+ "@rh-support/utils": "2.5.149",
44
43
  "i18next": "^23.15.0",
45
44
  "localforage": "^1.10.0",
46
45
  "lodash": "^4.17.21",
@@ -51,8 +50,6 @@
51
50
  "react-test-renderer": "18.2.0"
52
51
  },
53
52
  "devDependencies": {
54
- "@patternfly/react-styles": "^6.2.1",
55
- "@patternfly/react-tokens": "^6.2.1",
56
53
  "@testing-library/jest-dom": "^6.2.0",
57
54
  "@testing-library/react": "^14.1.2",
58
55
  "@testing-library/react-hooks": "^5.1.2",
@@ -92,5 +89,5 @@
92
89
  "defaults and supports es6-module",
93
90
  "maintained node versions"
94
91
  ],
95
- "gitHead": "db4ef21c103bd27b78fdbcbe38b84750e7886df4"
92
+ "gitHead": "cc1c26280084d477ee0abcec8d46963c8213b783"
96
93
  }
@@ -1,9 +0,0 @@
1
- import React, { ReactNode } from 'react';
2
- export declare const CaseStatusContext: React.Context<string>;
3
- interface CaseStatusProviderProps {
4
- caseStatus?: string;
5
- children: ReactNode;
6
- }
7
- export declare function CaseStatusProvider({ caseStatus, children }: CaseStatusProviderProps): React.JSX.Element;
8
- export {};
9
- //# sourceMappingURL=CaseStatusContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CaseStatusContext.d.ts","sourceRoot":"","sources":["../../../src/context/CaseStatusContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAExD,eAAO,MAAM,iBAAiB,uBAA+C,CAAC;AAE9E,UAAU,uBAAuB;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,uBAAuB,qBAEnF"}
@@ -1,5 +0,0 @@
1
- import React, { createContext } from 'react';
2
- export const CaseStatusContext = createContext(undefined);
3
- export function CaseStatusProvider({ caseStatus, children }) {
4
- return React.createElement(CaseStatusContext.Provider, { value: caseStatus }, children);
5
- }