@rh-support/troubleshoot 2.2.73 → 2.2.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"CaseSolutions.d.ts","sourceRoot":"","sources":["../../../../../src/components/CaseEditView/CaseSolutions/CaseSolutions.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAA8D,MAAM,OAAO,CAAC;AAuEnF,UAAU,MAAM;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB,EAAE,OAAO,CAAC;CACnC;AAUD,eAAO,MAAM,aAAa,+EAqhBxB,CAAC"}
1
+ {"version":3,"file":"CaseSolutions.d.ts","sourceRoot":"","sources":["../../../../../src/components/CaseEditView/CaseSolutions/CaseSolutions.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAsD,MAAM,OAAO,CAAC;AAqE3E,UAAU,MAAM;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB,EAAE,OAAO,CAAC;CACnC;AAUD,eAAO,MAAM,aAAa,+EA4fxB,CAAC"}
@@ -27,17 +27,17 @@ import { getSolrParams } from '@rh-support/utils';
27
27
  import find from 'lodash/find';
28
28
  import isEqual from 'lodash/isEqual';
29
29
  import some from 'lodash/some';
30
- import React, { forwardRef, useContext, useEffect, useRef, useState } from 'react';
30
+ import React, { forwardRef, useContext, useEffect, useState } from 'react';
31
31
  import { Trans, useTranslation } from 'react-i18next';
32
32
  import { CaseStatusEnum } from '../../../constants/caseDetailsConstants';
33
33
  import { useCaseDispatch, useCaseSelector } from '../../../context/CaseContext';
34
34
  import { CaseOverviewDispatchContext } from '../../../context/CaseOverviewContext';
35
- import { RecommendationDispatchContext, RecommendationStateContext, useRecommendationDispatchContext, useRecommendationStateContext, } from '../../../context/RecommendationContext';
35
+ import { useRecommendationDispatchContext, useRecommendationStateContext, } from '../../../context/RecommendationContext';
36
36
  import { useCaseUpdateErrorMessage } from '../../../hooks/useCaseUpdateErrorMessage';
37
37
  import { setStatusUpdating } from '../../../reducers/CaseOverviewReducer';
38
38
  import { updateCaseDetails } from '../../../reducers/CaseReducer';
39
39
  import { fetchRecommendations, fetchWatsonXRecommendations } from '../../../reducers/RecommendationsReducer';
40
- import { removeKTQuestions } from '../../../utils/caseUtils';
40
+ import { extractKTQuestion1FromDescription } from '../../../utils/caseUtils';
41
41
  import { usePostComment } from '../../shared/usePostComment';
42
42
  import { CaseSolutionsItem } from './CaseSolutionsItem';
43
43
  import { HandpickedItem } from './HandpicketItem';
@@ -101,9 +101,7 @@ export const CaseSolutions = forwardRef((props, ref) => {
101
101
  const caseOverviewDispatch = useContext(CaseOverviewDispatchContext);
102
102
  const { recommendationState: { isLoadingRecommendations, allDocs }, } = useRecommendationStateContext();
103
103
  const { globalMetadataState: { loggedInUsersAccount }, } = useGlobalStateContext();
104
- const { recommendationState } = useContext(RecommendationStateContext);
105
104
  const recommendationsDispatch = useRecommendationDispatchContext();
106
- const watsonXRecommendationDispatch = useContext(RecommendationDispatchContext);
107
105
  const { postComment } = usePostComment({ caseNumber: props.caseNumber });
108
106
  const { caseNumber, isSecureSupportAccount } = props;
109
107
  const [isPinLoading, setIsPinLoading] = useState({});
@@ -117,7 +115,6 @@ export const CaseSolutions = forwardRef((props, ref) => {
117
115
  const { t } = useTranslation();
118
116
  const hasPin = some(recommendations, (p) => p.isPinned);
119
117
  const hasLink = some(recommendations, (p) => p.isLinked);
120
- const abortControllerRef = useRef(undefined);
121
118
  const getCommentBody = () => {
122
119
  return `**Reason for closing case:** \nOther. Found a pinned article that perfectly resolved the issue. Closing this case now.`;
123
120
  };
@@ -217,20 +214,15 @@ export const CaseSolutions = forwardRef((props, ref) => {
217
214
  useEffect(() => {
218
215
  function fetchRecs() {
219
216
  if (product && version && summary && description) {
220
- const payload = { product, version, summary, description: removeKTQuestions(description) };
221
- const queryFilters = {
222
- id: { values: recommendationState.insightsKcsIds, exclude: true },
217
+ const payload = {
218
+ product,
219
+ version,
220
+ summary,
221
+ description: extractKTQuestion1FromDescription(description),
223
222
  };
224
- if (abortControllerRef.current !== undefined) {
225
- // Cancel the previous request
226
- abortControllerRef.current.abort();
227
- }
228
- // recreate a new AbortController for each call
229
- let controller = new AbortController();
230
- abortControllerRef.current = controller;
231
223
  !loggedInUsersAccount.data.secureSupport
232
- ? fetchWatsonXRecommendations(watsonXRecommendationDispatch, payload, 50, 5, 300, true, queryFilters, controller.signal)
233
- : fetchRecommendations(recommendationsDispatch, payload, 50, 5, 300, false, caseNumber, isSecureSupportAccount, queryFilters, controller.signal);
224
+ ? fetchWatsonXRecommendations(recommendationsDispatch, payload, 50, 5, 300, true)
225
+ : fetchRecommendations(recommendationsDispatch, payload, 50, 5, 300, false, caseNumber, isSecureSupportAccount);
234
226
  }
235
227
  }
236
228
  fetchRecs();
@@ -242,9 +234,7 @@ export const CaseSolutions = forwardRef((props, ref) => {
242
234
  recommendationsDispatch,
243
235
  caseNumber,
244
236
  isSecureSupportAccount,
245
- recommendationState.insightsKcsIds,
246
237
  loggedInUsersAccount.data.secureSupport,
247
- watsonXRecommendationDispatch,
248
238
  ]);
249
239
  // populate solutions when result is ready
250
240
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"AsideResults.d.ts","sourceRoot":"","sources":["../../../../src/components/Recommendations/AsideResults.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAUvD,OAAO,EAAE,eAAe,EAAsC,MAAM,iCAAiC,CAAC;AAUtG,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;CACpD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,qBA6NzC"}
1
+ {"version":3,"file":"AsideResults.d.ts","sourceRoot":"","sources":["../../../../src/components/Recommendations/AsideResults.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AASvD,OAAO,EAAE,eAAe,EAAsC,MAAM,iCAAiC,CAAC;AAUtG,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;CACpD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,qBAwMzC"}
@@ -20,7 +20,6 @@ import { RecommendationDispatchContext, RecommendationStateContext } from '../..
20
20
  import { RouteContext } from '../../context/RouteContext';
21
21
  import { SessionRestoreDispatchContext, SessionRestoreStateContext } from '../../context/SessionRestoreContext';
22
22
  import { WATSONX_DESCRIPTION_LIMIT, WATSONX_SUMMARY_LIMIT } from '../../reducers/CaseConstNTypes';
23
- import { getDescriptionWOQues } from '../../reducers/CaseHelpers';
24
23
  import { setCaseRecommendations } from '../../reducers/CaseReducer';
25
24
  import { RecommendationsConstants } from '../../reducers/RecommendationsReducer';
26
25
  import { showSidebarRecommendationsSections } from '../../reducers/RouteConstNTypes';
@@ -33,16 +32,13 @@ export function AsideResults(props) {
33
32
  */
34
33
  const { globalMetadataState: { loggedInUsersAccount, pcmConfig }, } = useContext(GlobalMetadataStateContext);
35
34
  const isRerankEnabled = getConfigField(pcmConfig.data, 'isRerankEnabled', PCM_CONFIG_FIELD_TYPE.FEATURE_FLAG);
36
- const { isSelectedAccounntSecureSupport, product, version, caseResourceLinks, summary, issue, environment, periodicityOfIssue, timeFramesAndUrgency, caseType, } = useCaseSelector((state) => ({
35
+ const { isSelectedAccounntSecureSupport, product, version, caseResourceLinks, summary, issue, caseType } = useCaseSelector((state) => ({
37
36
  isSelectedAccounntSecureSupport: state.selectedAccountDetails.data.secureSupport,
38
37
  product: state.caseDetails.product,
39
38
  version: state.caseDetails.version,
40
39
  caseResourceLinks: state.caseDetails.caseResourceLinks,
41
40
  summary: state.caseDetails.summary,
42
41
  issue: state.caseDetails.issue,
43
- environment: state.caseDetails.environment,
44
- periodicityOfIssue: state.caseDetails.periodicityOfIssue,
45
- timeFramesAndUrgency: state.caseDetails.timeFramesAndUrgency,
46
42
  caseType: state.caseDetails.caseType,
47
43
  }), isEqual);
48
44
  const caseDispatch = useCaseDispatch();
@@ -57,7 +53,7 @@ export function AsideResults(props) {
57
53
  product: product,
58
54
  version: version,
59
55
  summary: summary,
60
- description: getDescriptionWOQues(issue, environment, periodicityOfIssue, timeFramesAndUrgency),
56
+ description: issue, // on recommendation API we only pass issue and skip other KTQs
61
57
  });
62
58
  // abort controller ref
63
59
  const controllerRef = useRef(new AbortController());
@@ -74,7 +70,7 @@ export function AsideResults(props) {
74
70
  product: product,
75
71
  version: version,
76
72
  summary: summary,
77
- description: getDescriptionWOQues(issue, environment, periodicityOfIssue, timeFramesAndUrgency),
73
+ description: issue, // on recommendation API we only pass issue and skip other KTQs
78
74
  };
79
75
  const queryFilters = {
80
76
  id: { values: recommendationState.insightsKcsIds, exclude: true },
@@ -115,10 +111,7 @@ export function AsideResults(props) {
115
111
  version,
116
112
  summary,
117
113
  issue,
118
- environment,
119
114
  activeSection,
120
- timeFramesAndUrgency,
121
- periodicityOfIssue,
122
115
  recommendationState.insightsKcsIds,
123
116
  ], 2000);
124
117
  const canShowSideRecommendations = () => showSidebarRecommendationsSections.includes(activeSection) &&
@@ -113,7 +113,7 @@ export const fetchWatsonXRecommendations = (dispatch, query, max_rows, page_size
113
113
  summary: getTrimmedCharacters(query.summary, WATSONX_SUMMARY_LIMIT),
114
114
  })), ((query === null || query === void 0 ? void 0 : query.description) && {
115
115
  description: getTrimmedCharacters(query.description, WATSONX_DESCRIPTION_LIMIT),
116
- })), { rerank: isRerankEnabled });
116
+ })), { rerank: isRerankEnabled || false });
117
117
  const paramsObj = Object.assign(Object.assign({}, watsonXQuery), getSolrParams(max_rows, highlighted_fragment_size, additionalFilters, seQueryFields));
118
118
  const response = yield search.getWatsonXRecommendationsForCase2(
119
119
  //@ts-ignore
@@ -1,2 +1,2 @@
1
- export declare const removeKTQuestions: (description: string) => string;
1
+ export declare const extractKTQuestion1FromDescription: (description: any) => any;
2
2
  //# sourceMappingURL=caseUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"caseUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/caseUtils.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,gBAAiB,MAAM,WAWpD,CAAC"}
1
+ {"version":3,"file":"caseUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/caseUtils.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iCAAiC,2BAa7C,CAAC"}
@@ -1,14 +1,16 @@
1
1
  import { KtQuestionConstant } from '../reducers/CaseConstNTypes';
2
- // removes QT Questions from description to have only answers.
3
- // when description is sent to solr only answers are required.
4
- export const removeKTQuestions = (description) => {
5
- // escape the KtQuestionConstant enum and convert it to a regex
6
- const KtQuestionsJoined = Object.values(KtQuestionConstant)
7
- .map((item) => item.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'))
8
- .join('|');
9
- const pattern = new RegExp(KtQuestionsJoined, 'gi');
10
- return description
11
- .replace(pattern, '')
12
- .replace(/(\r|\n)/g, ' ')
13
- .trim();
2
+ // extract issue form description and remove other KT questions
3
+ export const extractKTQuestion1FromDescription = (description) => {
4
+ if (description.startsWith(KtQuestionConstant.issue)) {
5
+ // escape the KtQuestionConstant enum and convert it to a regex
6
+ const re = /[-\/\\^$*+?.()|[\]{}]/g;
7
+ const kt1 = KtQuestionConstant.issue.replace(re, '\\$&');
8
+ const kt2 = KtQuestionConstant.timeFramesAndUrgency.replace(re, '\\$&');
9
+ const regex = new RegExp(`${kt1}\n(.*?)\n${kt2}`, 'sm');
10
+ const match = description.match(regex);
11
+ return match ? match[1].trim() : null;
12
+ }
13
+ else {
14
+ return description;
15
+ }
14
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/troubleshoot",
3
- "version": "2.2.73",
3
+ "version": "2.2.74",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -61,11 +61,11 @@
61
61
  "@progress/kendo-licensing": "1.3.5",
62
62
  "@progress/kendo-react-pdf": "^5.16.0",
63
63
  "@redux-devtools/extension": "^3.3.0",
64
- "@rh-support/components": "2.1.40",
65
- "@rh-support/react-context": "2.1.43",
64
+ "@rh-support/components": "2.1.41",
65
+ "@rh-support/react-context": "2.1.44",
66
66
  "@rh-support/types": "2.0.3",
67
- "@rh-support/user-permissions": "2.1.29",
68
- "@rh-support/utils": "2.1.21",
67
+ "@rh-support/user-permissions": "2.1.30",
68
+ "@rh-support/utils": "2.1.22",
69
69
  "@types/react-redux": "^7.1.33",
70
70
  "@types/redux": "^3.6.0",
71
71
  "dompurify": "^2.2.6",
@@ -132,5 +132,5 @@
132
132
  "defaults and supports es6-module",
133
133
  "maintained node versions"
134
134
  ],
135
- "gitHead": "28f1b355dad14ac8fd818ab6c152c9c985ca1351"
135
+ "gitHead": "1507b066b04853fb74cbd1fcac022dbcc94c0ec3"
136
136
  }