@rh-support/troubleshoot 0.2.71 → 0.2.72

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":"OpenShiftClusterId.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseManagement/OpenShiftClusterId.tsx"],"names":[],"mappings":"AAqBA,eAAO,MAAM,oBAAoB,mBAShC,CAAC;AAqBF,wBAAgB,kBAAkB,gBAgRjC"}
1
+ {"version":3,"file":"OpenShiftClusterId.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseManagement/OpenShiftClusterId.tsx"],"names":[],"mappings":"AAwBA,eAAO,MAAM,oBAAoB,mBAShC,CAAC;AAqBF,wBAAgB,kBAAkB,gBAsRjC"}
@@ -16,7 +16,7 @@ import React, { useContext, useEffect, useState } from 'react';
16
16
  import { Trans } from 'react-i18next';
17
17
  import { useLocation } from 'react-router';
18
18
  import { useCaseDispatch, useCaseSelector } from '../../context/CaseContext';
19
- import { ClusterRecommendationsDispatchContext } from '../../context/ClusterRecommendationsContext';
19
+ import { ClusterRecommendationsContext, ClusterRecommendationsDispatchContext, } from '../../context/ClusterRecommendationsContext';
20
20
  import { RouteContext } from '../../context/RouteContext';
21
21
  import { getUpdatedDescription } from '../../reducers/CaseHelpers';
22
22
  import { setCaseDetails, setCaseState } from '../../reducers/CaseReducer';
@@ -58,6 +58,7 @@ export function OpenShiftClusterId() {
58
58
  const { globalMetadataState: { pcmConfig, allProducts, loggedInUserRights }, } = useContext(GlobalMetadataStateContext);
59
59
  const { routeState: { showValidationErrorAlert }, } = useContext(RouteContext);
60
60
  const clusterRecommendationsDispatch = useContext(ClusterRecommendationsDispatchContext);
61
+ const { clusterRecommendationsState: { clusterRecommendations }, } = useContext(ClusterRecommendationsContext);
61
62
  const majorVersion = (version && getVersion(version).major) || '';
62
63
  const isOpenShiftV3 = majorVersion === '3';
63
64
  const isCustomer = loggedInUserRights.data.isAccountSameAsLoggedInAccount(selectedAccountDetails.data.accountNumber);
@@ -154,7 +155,9 @@ export function OpenShiftClusterId() {
154
155
  setSelectedReason('dont-have-id');
155
156
  }
156
157
  const canFetchClusterRecommendation = isClusterRecommendationEnabled && !isClusterIdInvalid && !isEmpty(openshiftClusterID);
158
+ // To prevent refetching clusterRecommendations checking for clusterRecommendations data length
157
159
  canFetchClusterRecommendation &&
160
+ !clusterRecommendations.data.length &&
158
161
  fetchClusterRecommendations(clusterRecommendationsDispatch, openshiftClusterID);
159
162
  // eslint-disable-next-line react-hooks/exhaustive-deps
160
163
  }, [v3ClusterName, noClusterIdReason]);
@@ -1 +1 @@
1
- {"version":3,"file":"ClusterRecommendationToast.d.ts","sourceRoot":"","sources":["../../../../src/components/Recommendations/ClusterRecommendationToast.tsx"],"names":[],"mappings":"AAIA,OAAc,EAAE,EAAE,EAAmC,MAAM,OAAO,CAAC;AAUnE,UAAU,MAAM;CAAG;AAEnB,QAAA,MAAM,0BAA0B,EAAE,EAAE,CAAC,MAAM,CAwD1C,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
1
+ {"version":3,"file":"ClusterRecommendationToast.d.ts","sourceRoot":"","sources":["../../../../src/components/Recommendations/ClusterRecommendationToast.tsx"],"names":[],"mappings":"AAGA,OAAc,EAAE,EAAE,EAAmC,MAAM,OAAO,CAAC;AAUnE,UAAU,MAAM;CAAG;AAEnB,QAAA,MAAM,0BAA0B,EAAE,EAAE,CAAC,MAAM,CAqD1C,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
@@ -1,5 +1,4 @@
1
1
  import { Alert, AlertActionCloseButton, Button } from '@patternfly/react-core';
2
- import { usePrevious } from '@rh-support/components';
3
2
  import { GlobalMetadataStateContext } from '@rh-support/react-context';
4
3
  import { isEmpty, isEqual } from 'lodash';
5
4
  import React, { useContext, useEffect, useState } from 'react';
@@ -7,7 +6,7 @@ import { Trans, useTranslation } from 'react-i18next';
7
6
  import { useCaseSelector } from '../../context/CaseContext';
8
7
  import { ClusterRecommendationsContext, ClusterRecommendationsDispatchContext, } from '../../context/ClusterRecommendationsContext';
9
8
  import { toggleClusterRecommendationModal } from '../../reducers/ClusterRecommendationsReducer';
10
- import { isClusterIdEnabledForProduct } from '../../utils/caseOpenshiftClusterIdUtils';
9
+ import { getIsClusterIdInvalid, isClusterIdEnabledForProduct } from '../../utils/caseOpenshiftClusterIdUtils';
11
10
  const ClusterRecommendationToast = () => {
12
11
  var _a;
13
12
  const { t } = useTranslation();
@@ -19,21 +18,21 @@ const ClusterRecommendationToast = () => {
19
18
  product: state.caseDetails.product,
20
19
  }), isEqual);
21
20
  const { globalMetadataState: { allProducts }, } = useContext(GlobalMetadataStateContext);
22
- const previousOpenShiftClusterId = usePrevious(openshiftClusterID);
23
21
  const onViewRecommendations = () => {
24
22
  setToastVisibility(false);
25
23
  toggleClusterRecommendationModal(clusterRecommendationsDispatch, !isClusterRecommendationsModalOpen);
26
24
  };
27
- // To prevent toast to reopen even after user close it we need to check cluster id
25
+ // To open popover we check for cluster id and clusterRecommendations array length
28
26
  useEffect(() => {
29
- if (!isEmpty(openshiftClusterID) &&
30
- previousOpenShiftClusterId !== openshiftClusterID &&
31
- clusterRecommendations.data.length)
27
+ if (!isEmpty(openshiftClusterID) && clusterRecommendations.data.length)
32
28
  setToastVisibility(true);
33
29
  // eslint-disable-next-line react-hooks/exhaustive-deps
34
30
  }, [clusterRecommendations.data]);
31
+ /**
32
+ * Hide Popover on cluster id change
33
+ */
35
34
  useEffect(() => {
36
- if (!openshiftClusterID)
35
+ if (!openshiftClusterID || getIsClusterIdInvalid(openshiftClusterID))
37
36
  setToastVisibility(false);
38
37
  }, [openshiftClusterID]);
39
38
  const hasCluster = isClusterIdEnabledForProduct(product, (_a = allProducts.data) === null || _a === void 0 ? void 0 : _a.productsResult);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/troubleshoot",
3
- "version": "0.2.71",
3
+ "version": "0.2.72",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -143,5 +143,5 @@
143
143
  "not ie <= 11",
144
144
  "not op_mini all"
145
145
  ],
146
- "gitHead": "1cdbdc6728ef3ea47afa61a60407e82cd81da6af"
146
+ "gitHead": "4c011d810dfd20f1da1b9aa172636543263db426"
147
147
  }