@rh-support/troubleshoot 2.2.23 → 2.2.24

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":"ProductVersion.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CaseEditView/Tabs/CaseDetails/ProductVersion.tsx"],"names":[],"mappings":"AA6BA,UAAU,MAAM;IACZ,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACvC;AAYD,iBAAS,eAAe,CAAC,KAAK,EAAE,MAAM,eAoRrC;AAED,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"ProductVersion.d.ts","sourceRoot":"","sources":["../../../../../../src/components/CaseEditView/Tabs/CaseDetails/ProductVersion.tsx"],"names":[],"mappings":"AA6BA,UAAU,MAAM;IACZ,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACvC;AAED,iBAAS,eAAe,CAAC,KAAK,EAAE,MAAM,eAwOrC;AAED,eAAe,eAAe,CAAC"}
@@ -8,27 +8,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { Alert, AlertVariant } from '@patternfly/react-core';
11
- import { AlertMessage, AlertType, Dropdown, ToastNotification, usePrevious } from '@rh-support/components';
11
+ import { AlertMessage, AlertType, Dropdown, ToastNotification } from '@rh-support/components';
12
12
  import { fetchProducts, GlobalMetadataDispatchContext, GlobalMetadataStateContext, useCanEditCase, } from '@rh-support/react-context';
13
13
  import { getUniqueSortedVersions, haventLoadedMetadata, toOption, toOptions, } from '@rh-support/utils';
14
14
  import filter from 'lodash/filter';
15
- import findIndex from 'lodash/findIndex';
16
15
  import isEmpty from 'lodash/isEmpty';
17
16
  import isEqual from 'lodash/isEqual';
18
- import React, { useContext, useEffect, useMemo, useState } from 'react';
17
+ import React, { useContext, useEffect, useState } from 'react';
19
18
  import { Trans, useTranslation } from 'react-i18next';
20
19
  import { useCaseDispatch, useCaseSelector } from '../../../../context/CaseContext';
21
20
  import { useCaseUpdateErrorMessage } from '../../../../hooks/useCaseUpdateErrorMessage';
22
21
  import { getVersionsDetails, updateCaseDetails } from '../../../../reducers/CaseReducer';
22
+ import { getProductObj } from '../../../shared/utils';
23
23
  import { PDFContext } from '../../PDFContainer';
24
- const getVersions = (products, product) => {
25
- const allProductsIndex = findIndex(products, (p) => p.product === product);
26
- return allProductsIndex !== -1 ? products[allProductsIndex].versions || [] : [];
27
- };
28
- const checkIsTopProduct = (products, product) => {
29
- const allProductsIndex = findIndex(products, (p) => p.product === product);
30
- return allProductsIndex !== -1 ? products[allProductsIndex].isTopProduct : false;
31
- };
32
24
  function ProductNVersion(props) {
33
25
  const { t } = useTranslation();
34
26
  const caseUpdateError = useCaseUpdateErrorMessage();
@@ -42,16 +34,9 @@ function ProductNVersion(props) {
42
34
  caseNumber: state.caseDetails.caseNumber,
43
35
  versionsDetails: state.versionsDetails,
44
36
  }), isEqual);
45
- const productVersions = useMemo(() => versionsDetails.data
46
- .map(({ name }) => name)
47
- .sort()
48
- .reverse(),
49
- // eslint-disable-next-line react-hooks/exhaustive-deps
50
- [product, versionsDetails.data]);
51
37
  const caseDispatch = useCaseDispatch();
52
38
  const dispatchToGlobalMetadataReducer = useContext(GlobalMetadataDispatchContext);
53
39
  const { globalMetadataState: { allProducts }, } = useContext(GlobalMetadataStateContext);
54
- const productSEVersions = useMemo(() => getVersions(allProducts.data.productsResult, product), [allProducts.data.productsResult, product]);
55
40
  const [isProductInvalid, setIsProductInvalid] = useState(false);
56
41
  const [isVersionInvalid, setIsVersionInvalid] = useState(false);
57
42
  const [selectedProductLocal, setSelectedProductLocal] = useState(product);
@@ -59,33 +44,12 @@ function ProductNVersion(props) {
59
44
  const canEditCase = useCanEditCase();
60
45
  const { isExportingPDF } = useContext(PDFContext);
61
46
  useEffect(() => {
62
- setVersions(productVersions);
63
- if ((productVersions === null || productVersions === void 0 ? void 0 : productVersions.length) && !selectedVersionLocal && (productVersions === null || productVersions === void 0 ? void 0 : productVersions.length) < 2)
64
- setSelectedVersionLocal(productVersions[0]);
65
- }, [productVersions, selectedVersionLocal]);
66
- /**
67
- * Sync local version from global state if they change from someplace else
68
- */
69
- useEffect(() => {
70
- setSelectedVersionLocal(version);
71
- }, [version]);
72
- useEffect(() => {
73
- var _a;
74
47
  if (haventLoadedMetadata(allProducts, (data) => isEmpty(data.productsResult))) {
75
48
  fetchProducts(dispatchToGlobalMetadataReducer, contactSSOName);
76
49
  }
77
- if (allProducts.data && ((_a = allProducts.data.productsResult) === null || _a === void 0 ? void 0 : _a.length) !== 0) {
78
- const productSEVersions = getVersions(allProducts.data.productsResult, product);
79
- const versions = (productSEVersions === null || productSEVersions === void 0 ? void 0 : productSEVersions.length) ? productSEVersions : productVersions;
80
- setVersions(versions);
81
- }
82
- setSelectedProductLocal(product);
83
50
  // eslint-disable-next-line react-hooks/exhaustive-deps
84
- }, [allProducts, product, dispatchToGlobalMetadataReducer, contactSSOName]);
85
- let previousProduct = usePrevious(selectedProductLocal);
86
- let previousVersion = usePrevious(selectedVersionLocal);
51
+ }, [allProducts, dispatchToGlobalMetadataReducer, contactSSOName]);
87
52
  const onProductChange = (option) => __awaiter(this, void 0, void 0, function* () {
88
- var _a, _b, _c;
89
53
  if (canEditCase.alert())
90
54
  return;
91
55
  validateProduct(option);
@@ -94,60 +58,44 @@ function ProductNVersion(props) {
94
58
  if (!option.value.product) {
95
59
  return;
96
60
  }
97
- const hasSingleVersion = ((_b = (_a = option === null || option === void 0 ? void 0 : option.value) === null || _a === void 0 ? void 0 : _a.versions) === null || _b === void 0 ? void 0 : _b.length) < 2;
98
- setVersions((_c = option === null || option === void 0 ? void 0 : option.value) === null || _c === void 0 ? void 0 : _c.versions);
99
- if (hasSingleVersion) {
100
- setIsProductUpdating(true);
101
- setIsVersionUpdating(true);
102
- setSelectedVersionLocal(option.value.featuredVersion);
103
- try {
104
- const caseDetails = { product: option.value.product, version: option.value.featuredVersion };
105
- yield updateCaseDetails(caseDispatch, caseNumber, caseDetails);
106
- setIsProductUpdating(false);
107
- setIsVersionUpdating(false);
108
- setIsProductInvalid(false);
109
- ToastNotification.addSuccessMessage(t(`Product and Version have been successfully updated`));
110
- }
111
- catch (e) {
112
- setSelectedProductLocal(product);
113
- setSelectedVersionLocal(version);
114
- setIsProductUpdating(false);
115
- setIsVersionUpdating(false);
116
- setIsProductInvalid(false);
117
- caseUpdateError.showError(e, t('Product and Version failed to update'));
118
- }
119
- }
120
- else {
121
- setIsVersionUpdating(true);
122
- try {
123
- yield getVersionsDetails(caseDispatch, option.value.product);
124
- }
125
- catch (e) {
126
- setSelectedProductLocal(previousProduct);
127
- setSelectedVersionLocal(previousVersion);
128
- }
129
- setIsVersionUpdating(false);
130
- }
131
61
  });
132
62
  const onVersionChange = (option) => __awaiter(this, void 0, void 0, function* () {
133
63
  if (canEditCase.alert())
134
64
  return;
135
- let onlyVersionChanged = false;
136
- if (isEmpty(selectedVersionLocal)) {
137
- setIsProductUpdating(true);
138
- }
139
- setIsVersionUpdating(true);
140
65
  setSelectedVersionLocal(option.value);
66
+ updateProductVerstion(selectedProductLocal, option.value);
67
+ });
68
+ const validateProduct = (selectedItem) => {
69
+ const isValid = !isProductUpdating && (isEmpty(selectedItem) || isEmpty(selectedItem.label));
70
+ setIsProductInvalid(isValid);
71
+ };
72
+ const onOuterClick = () => {
73
+ setSelectedProductLocal(product);
74
+ setSelectedVersionLocal(version);
75
+ setIsProductInvalid(false);
76
+ };
77
+ const onProductClear = () => {
78
+ const defaultSelectedProduct = {
79
+ featuredVersion: '',
80
+ product: '',
81
+ versions: [],
82
+ isEntitledProduct: true,
83
+ };
84
+ setIsProductInvalid(true);
85
+ setIsVersionInvalid(true);
86
+ onProductChange(toOption(defaultSelectedProduct, { labelKey: 'product' }));
87
+ };
88
+ const updateProductVerstion = (selectedProduct, selectedVersion) => __awaiter(this, void 0, void 0, function* () {
89
+ let onlyVersionChanged = false;
141
90
  try {
142
- const caseDetails = { product: selectedProductLocal, version: option.value };
143
- if (caseDetails.product === previousProduct) {
91
+ if (product === selectedProduct) {
144
92
  onlyVersionChanged = true;
145
93
  }
146
- yield updateCaseDetails(caseDispatch, caseNumber, caseDetails);
94
+ setIsProductUpdating(true);
95
+ setIsVersionUpdating(true);
96
+ yield updateCaseDetails(caseDispatch, caseNumber, { product: selectedProduct, version: selectedVersion });
147
97
  setIsProductUpdating(false);
148
98
  setIsVersionUpdating(false);
149
- setIsProductInvalid(false);
150
- setIsVersionInvalid(false);
151
99
  if (onlyVersionChanged) {
152
100
  ToastNotification.addSuccessMessage(t(`Version has been successfully updated`));
153
101
  }
@@ -156,11 +104,10 @@ function ProductNVersion(props) {
156
104
  }
157
105
  }
158
106
  catch (e) {
159
- setSelectedProductLocal(product);
160
107
  setSelectedVersionLocal(version);
108
+ setSelectedProductLocal(product);
161
109
  setIsProductUpdating(false);
162
110
  setIsVersionUpdating(false);
163
- setIsProductInvalid(false);
164
111
  if (onlyVersionChanged) {
165
112
  caseUpdateError.showError(e, t('Version failed to update'));
166
113
  }
@@ -169,39 +116,46 @@ function ProductNVersion(props) {
169
116
  }
170
117
  }
171
118
  });
172
- const validateProduct = (selectedItem) => {
173
- const isValid = !isProductUpdating && (isEmpty(selectedItem) || isEmpty(selectedItem.label));
174
- setIsProductInvalid(isValid);
175
- };
176
- const onOuterClick = () => {
177
- setSelectedProductLocal(product);
178
- setSelectedVersionLocal(version);
179
- setIsProductInvalid(true);
180
- };
181
- const onProductClear = () => {
182
- const defaultSelectedProduct = {
183
- featuredVersion: '',
184
- product: '',
185
- versions: [],
186
- isTopProduct: false,
187
- isEntitledProduct: true,
188
- };
189
- setIsProductInvalid(true);
190
- setIsVersionInvalid(true);
191
- onProductChange(toOption(defaultSelectedProduct, { labelKey: 'product' }));
192
- };
193
- useEffect(() => {
194
- if (!isEmpty(product)) {
195
- getVersionsDetails(caseDispatch, product);
196
- }
197
- }, [caseDispatch, product]);
198
119
  // To check if version in invalid
199
120
  const checkIfVersionIsInvalid = isVersionInvalid && isEmpty(selectedVersionLocal);
200
- const versionsListMemo = useMemo(() => {
201
- return getUniqueSortedVersions(versions);
202
- }, [versions]);
203
- // Versions List
204
- const versionsList = toOptions(versionsListMemo);
121
+ // when user changes selected product, we need to fetch versions
122
+ useEffect(() => {
123
+ const getVersions = () => __awaiter(this, void 0, void 0, function* () {
124
+ if (!isEmpty(selectedProductLocal)) {
125
+ try {
126
+ setIsVersionUpdating(true);
127
+ yield getVersionsDetails(caseDispatch, selectedProductLocal);
128
+ setIsVersionUpdating(false);
129
+ }
130
+ catch (e) {
131
+ console.log(e);
132
+ setIsVersionUpdating(false);
133
+ // if sfdc api was downd and verssions were not available then populate versions with SE versions
134
+ const productObj = getProductObj(allProducts.data.productsResult, selectedProductLocal);
135
+ setVersions((productObj === null || productObj === void 0 ? void 0 : productObj.versions) || []);
136
+ }
137
+ }
138
+ else {
139
+ setVersions([]);
140
+ }
141
+ });
142
+ getVersions();
143
+ }, [selectedProductLocal, caseDispatch, allProducts.data]);
144
+ // observe when fetched versions are available
145
+ useEffect(() => {
146
+ const fetchedVersions = versionsDetails.data.map(({ name }) => name);
147
+ if (fetchedVersions.length === 1 && !selectedVersionLocal) {
148
+ setVersions(fetchedVersions);
149
+ setSelectedVersionLocal(fetchedVersions[0]);
150
+ updateProductVerstion(selectedProductLocal, fetchedVersions[0]);
151
+ return;
152
+ }
153
+ const productObj = getProductObj(allProducts.data.productsResult, selectedProductLocal);
154
+ const sfdcVersions = getUniqueSortedVersions(fetchedVersions);
155
+ const productVersions = (productObj === null || productObj === void 0 ? void 0 : productObj.hasComponentsInsteadOfVersions) ? sfdcVersions.reverse() : sfdcVersions;
156
+ setVersions(productVersions);
157
+ // eslint-disable-next-line react-hooks/exhaustive-deps
158
+ }, [versionsDetails.data]);
205
159
  return (React.createElement(React.Fragment, null,
206
160
  React.createElement(AlertMessage, { show: !allProducts.isFetching && allProducts.isError, title: t('There was an error loading products.'), variant: AlertType.DANGER }),
207
161
  isEmpty(selectedVersionLocal) && (selectedVersionLocal === null || selectedVersionLocal === void 0 ? void 0 : selectedVersionLocal.length) < 2 && (React.createElement(Alert, { isInline: true, className: "pf-u-mb-md", variant: AlertVariant.danger, title: React.createElement(Trans, null, "Please clear the errors to change the product on your case") })),
@@ -212,15 +166,14 @@ function ProductNVersion(props) {
212
166
  React.createElement(Trans, null, "Product")),
213
167
  React.createElement(Dropdown, { className: "open-case-product", placeholder: t('Select a product'), id: "case-details-product-selector", selectedItem: toOption({
214
168
  product: selectedProductLocal,
215
- versions: (productSEVersions === null || productSEVersions === void 0 ? void 0 : productSEVersions.length) ? productSEVersions : productVersions,
169
+ versions: versions,
216
170
  featuredVersion: '',
217
171
  selectedVersion: selectedVersionLocal,
218
- isTopProduct: checkIsTopProduct(allProducts.data.productsResult, product),
219
172
  isEntitledProduct: true,
220
173
  }, { labelKey: 'product' }), list: toOptions(filter(allProducts.data.productsResult, (p) => p.isEntitledProduct), { labelKey: 'product' }), title: t(`Select a product`), disabled: isProductUpdating || (allProducts.isFetching && !allProducts.isError), isInValid: isProductInvalid, onChange: onProductChange, isLoadingList: isProductUpdating, "data-tracking-id": "case-details-product-selector", onOuterClick: onOuterClick, searchable: true, onClearSelection: onProductClear, isExportingPDF: isExportingPDF })),
221
174
  React.createElement("div", { className: "version-selector-wrapper" },
222
175
  React.createElement("label", { htmlFor: "version-dropdown" },
223
176
  React.createElement(Trans, null, "Version")),
224
- React.createElement(Dropdown, { className: "open-case-version", id: "version-dropdown", placeholder: t(`Select a version`), selectedItem: toOption(selectedVersionLocal), list: versionsList, title: t(`Select a version`), isInValid: checkIfVersionIsInvalid, disabled: isVersionUpdating || (allProducts.isFetching && !allProducts.isError), onChange: onVersionChange, isLoadingList: isVersionUpdating, "data-tracking-id": "case-details-version-selector" }))))));
177
+ React.createElement(Dropdown, { className: "open-case-version", id: "version-dropdown", placeholder: t(`Select a version`), selectedItem: toOption(selectedVersionLocal), list: toOptions(versions), title: t(`Select a version`), isInValid: checkIfVersionIsInvalid, disabled: isVersionUpdating || (allProducts.isFetching && !allProducts.isError), onChange: onVersionChange, isLoadingList: isVersionUpdating, "data-tracking-id": "case-details-version-selector" }))))));
225
178
  }
226
179
  export default ProductNVersion;
@@ -181,7 +181,7 @@ function Severity(props) {
181
181
  props.isDisabled ||
182
182
  allCaseSeverities.isFetching ||
183
183
  ownersEntitlements.isFetching ||
184
- versionsDetails.isFetching, isLoadingList: props.isFetching || versionsDetails.isFetching, isInValid: allCaseSeverities.isError || isSeverityInValid, required: true, onChange: onSeverityChange, onOuterClick: setIsSeverityInValidLocal, "data-tracking-id": "get-support-severity" })),
184
+ versionsDetails.isFetching, isLoadingList: props.isFetching, isInValid: allCaseSeverities.isError || isSeverityInValid, required: true, onChange: onSeverityChange, onOuterClick: setIsSeverityInValidLocal, "data-tracking-id": "get-support-severity" })),
185
185
  React.createElement(UpdateSeverityModal, { isDisabled: props.isFetching, isFetching: props.isFetching, show: openUpdateSeverityModal, onClose: toggleModal }))) : (React.createElement(Dropdown, { name: "get-support-severity", placeholder: t(`Select a severity`), title: t(`Select a severity`), list: allCaseSeverities.data
186
186
  ? toOptions(filteredSeverities, {
187
187
  labelKey: 'label',
@@ -196,7 +196,7 @@ function Severity(props) {
196
196
  props.isDisabled ||
197
197
  allCaseSeverities.isFetching ||
198
198
  ownersEntitlements.isFetching ||
199
- versionsDetails.isFetching, isLoadingList: props.isFetching || versionsDetails.isFetching, isInValid: allCaseSeverities.isError || isSeverityInValid, required: true, onChange: onSeverityChange, onOuterClick: setIsSeverityInValidLocal, "data-tracking-id": "get-support-severity" }))));
199
+ versionsDetails.isFetching, isLoadingList: props.isFetching, isInValid: allCaseSeverities.isError || isSeverityInValid, required: true, onChange: onSeverityChange, onOuterClick: setIsSeverityInValidLocal, "data-tracking-id": "get-support-severity" }))));
200
200
  }
201
201
  Severity.defaultProps = defaultProps;
202
202
  export default Severity;
@@ -1 +1 @@
1
- {"version":3,"file":"NewProductVersionSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/ProductSelector/NewProductVersionSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAMpE,UAAU,MAAM;IACZ,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,qCAAqC,EAAE,OAAO,CAAC;CAClD;AAED,eAAO,MAAM,yBAAyB,UAAW,MAAM,gBA+EtD,CAAC"}
1
+ {"version":3,"file":"NewProductVersionSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/ProductSelector/NewProductVersionSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAYpE,UAAU,MAAM;IACZ,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,qCAAqC,EAAE,OAAO,CAAC;CAClD;AAED,eAAO,MAAM,yBAAyB,UAAW,MAAM,gBA+HtD,CAAC"}
@@ -1,13 +1,33 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import { Select, SelectGroup, SelectOption, SelectVariant } from '@patternfly/react-core';
11
+ import { GlobalMetadataStateContext } from '@rh-support/react-context';
12
+ import { getUniqueSortedVersions } from '@rh-support/utils';
2
13
  import isEmpty from 'lodash/isEmpty';
3
- import React, { useEffect, useState } from 'react';
14
+ import isEqual from 'lodash/isEqual';
15
+ import React, { useContext, useEffect, useState } from 'react';
4
16
  import { useTranslation } from 'react-i18next';
17
+ import { useCaseDispatch, useCaseSelector } from '../../context/CaseContext';
18
+ import { getVersionsDetails } from '../../reducers/CaseReducer';
19
+ import { getProductObj } from '../shared/utils';
5
20
  export const NewProductVersionSelector = (props) => {
6
21
  const { t } = useTranslation();
7
22
  const [isOpen, setIsOpen] = useState(false);
8
23
  const [selected, setSelected] = useState('');
9
24
  const [selectVersionOptions, setSelectVersionOptions] = React.useState([]);
10
25
  const [showValidationLocal, setShowValidationLocal] = useState(props.isNextBtnClickedToShowValidationError);
26
+ const caseDispatch = useCaseDispatch();
27
+ const { versionsDetails } = useCaseSelector((state) => ({
28
+ versionsDetails: state.versionsDetails,
29
+ }), isEqual);
30
+ const { globalMetadataState: { allProducts }, } = useContext(GlobalMetadataStateContext);
11
31
  useEffect(() => {
12
32
  setShowValidationLocal(props.isNextBtnClickedToShowValidationError);
13
33
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -21,18 +41,43 @@ export const NewProductVersionSelector = (props) => {
21
41
  }
22
42
  // eslint-disable-next-line react-hooks/exhaustive-deps
23
43
  }, [props.selectedProduct]);
44
+ // when user selects a product, we need to fetch versions
24
45
  useEffect(() => {
25
- const renderVersions = () => {
26
- let versionArray = [];
27
- props.selectedProduct.versions.forEach((version, index) => {
28
- let selectVersionItem = React.createElement(SelectOption, { key: index, value: version });
29
- versionArray.push(selectVersionItem);
30
- });
31
- setSelectVersionOptions(versionArray);
32
- };
33
- renderVersions();
46
+ const getVersions = () => __awaiter(void 0, void 0, void 0, function* () {
47
+ if (!isEmpty(props.selectedProduct.name)) {
48
+ try {
49
+ yield getVersionsDetails(caseDispatch, props.selectedProduct.name);
50
+ }
51
+ catch (e) {
52
+ console.log(e);
53
+ // if sfdc api was downd and verssions were not available then populate versions with SE versions
54
+ const productObj = getProductObj(allProducts.data.productsResult, props.selectedProduct.name);
55
+ const versionArray = productObj.versions.map((version, index) => (React.createElement(SelectOption, { key: index, value: version })));
56
+ setSelectVersionOptions(versionArray);
57
+ }
58
+ }
59
+ else {
60
+ setSelectVersionOptions([]);
61
+ }
62
+ });
63
+ getVersions();
34
64
  // eslint-disable-next-line react-hooks/exhaustive-deps
35
65
  }, [props.selectedProduct]);
66
+ // observe when fetched versions are available
67
+ useEffect(() => {
68
+ const fetchedVersions = versionsDetails.data.map(({ name }) => name);
69
+ // if versions array has one value set that value as selected
70
+ if (fetchedVersions.length === 1) {
71
+ props.onVersionChange(fetchedVersions[0]);
72
+ setSelected(fetchedVersions[0]);
73
+ }
74
+ const productObj = getProductObj(allProducts.data.productsResult, props.selectedProduct.name);
75
+ const sfdcVersions = getUniqueSortedVersions(fetchedVersions);
76
+ const productVersions = (productObj === null || productObj === void 0 ? void 0 : productObj.hasComponentsInsteadOfVersions) ? sfdcVersions.reverse() : sfdcVersions;
77
+ const versionArray = productVersions.map((version, index) => (React.createElement(SelectOption, { key: index, value: version })));
78
+ setSelectVersionOptions(versionArray);
79
+ // eslint-disable-next-line react-hooks/exhaustive-deps
80
+ }, [versionsDetails.data]);
36
81
  let options = [React.createElement(SelectGroup, { key: "productVersions" }), ...selectVersionOptions];
37
82
  const onToggle = (isOpen) => {
38
83
  setIsOpen(isOpen);
@@ -53,5 +98,5 @@ export const NewProductVersionSelector = (props) => {
53
98
  // eslint-disable-next-line react-hooks/exhaustive-deps
54
99
  }, [props.versionState]);
55
100
  const titleId = 'version-selector';
56
- return (React.createElement(Select, { variant: SelectVariant.single, onToggle: onToggle, onSelect: onSelect, isOpen: isOpen, placeholderText: t('Select a version'), "aria-labelledby": titleId, selections: selected, validated: isEmpty(selected) && showValidationLocal ? 'error' : 'default', isDisabled: isEmpty(props.selectedProduct.product), "data-tracking-id": "get-support-version-dropdown-selector" }, options));
101
+ return (React.createElement(Select, Object.assign({ variant: SelectVariant.single, onToggle: onToggle, onSelect: onSelect, isOpen: isOpen, placeholderText: t('Select a version'), "aria-labelledby": titleId, selections: selected, validated: isEmpty(selected) && showValidationLocal ? 'error' : 'default', isDisabled: isEmpty(props.selectedProduct.product), "data-tracking-id": "get-support-version-dropdown-selector" }, (versionsDetails.isFetching && { loadingVariant: 'spinner' })), options));
57
102
  };
@@ -1 +1 @@
1
- {"version":3,"file":"TroubleshootSection.d.ts","sourceRoot":"","sources":["../../../../src/components/TroubleshootSection/TroubleshootSection.tsx"],"names":[],"mappings":"AAmBA,UAAU,MAAM;IACZ,cAAc,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B;AASD,iBAAS,mBAAmB,CAAC,KAAK,EAAE,MAAM,eA0HzC;kBA1HQ,mBAAmB;;;AA6H5B,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"TroubleshootSection.d.ts","sourceRoot":"","sources":["../../../../src/components/TroubleshootSection/TroubleshootSection.tsx"],"names":[],"mappings":"AAmBA,UAAU,MAAM;IACZ,cAAc,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B;AASD,iBAAS,mBAAmB,CAAC,KAAK,EAAE,MAAM,eA4GzC;kBA5GQ,mBAAmB;;;AA+G5B,eAAe,mBAAmB,CAAC"}
@@ -37,15 +37,8 @@ function TroubleshootSection(props) {
37
37
  const canShowTopContent = !canShowTopProducts && ((_a = topContent === null || topContent === void 0 ? void 0 : topContent.data) === null || _a === void 0 ? void 0 : _a.length) > 0;
38
38
  const canAddAttachments = ability.can(resourceActions.PATCH, resources.CASE_CREATE, CaseListFields.ATTACHMENTS);
39
39
  const isNotAnIdea = caseType !== PreviousCaseTypes.FEATURE_ENHANCEMENT;
40
- const ParentSection = ({ children }) => {
41
- if (!children) {
42
- return null;
43
- }
44
- return React.createElement("section", { className: "parent-section" }, children);
45
- };
46
40
  return (React.createElement(React.Fragment, null,
47
- !isCreatingCase && (React.createElement(ParentSection, null,
48
- React.createElement(OpenShiftClusterId, { className: "push-bottom", "data-tracking-id": "troubleshoot-section-openshift-cluster-id" }))),
41
+ !isCreatingCase && (React.createElement(OpenShiftClusterId, { className: "push-bottom", "data-tracking-id": "troubleshoot-section-openshift-cluster-id" })),
49
42
  React.createElement("section", null,
50
43
  React.createElement("header", null,
51
44
  React.createElement("h3", null,
@@ -1,3 +1,4 @@
1
+ import { ISEProduct } from '@cee-eng/hydrajs/@types/models/product';
1
2
  import { CaseValuesToWatch } from './Constants';
2
3
  /**
3
4
  *
@@ -11,4 +12,5 @@ import { CaseValuesToWatch } from './Constants';
11
12
  export declare function getChangedValueTooltip<T>(valueNameCb: (current: T, previous: T) => CaseValuesToWatch, accessor?: (value: T, otherValue: T) => any): (currentValue: T, previousValue: T) => JSX.Element;
12
13
  export declare const isPhoneValid: (countryCode: string, phoneLine: string) => boolean;
13
14
  export declare const trimAndReplacePlus: (value: string) => string;
15
+ export declare const getProductObj: (products: Partial<ISEProduct>[], product: string) => Partial<ISEProduct>;
14
16
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/components/shared/utils.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EACpC,WAAW,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,iBAAiB,EAC3D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,KAAK,GAAG,kBAErB,CAAC,iBAAiB,CAAC,iBAQ5C;AAED,eAAO,MAAM,YAAY,gBAAiB,MAAM,aAAa,MAAM,KAAG,OAarE,CAAC;AAEF,eAAO,MAAM,kBAAkB,UAAW,MAAM,WAG/C,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/components/shared/utils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAOpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EACpC,WAAW,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,iBAAiB,EAC3D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,KAAK,GAAG,kBAErB,CAAC,iBAAiB,CAAC,iBAQ5C;AAED,eAAO,MAAM,YAAY,gBAAiB,MAAM,aAAa,MAAM,KAAG,OAarE,CAAC;AAEF,eAAO,MAAM,kBAAkB,UAAW,MAAM,WAG/C,CAAC;AAEF,eAAO,MAAM,aAAa,aAAc,QAAQ,UAAU,CAAC,EAAE,WAAW,MAAM,wBAG7E,CAAC"}
@@ -1,3 +1,4 @@
1
+ import findIndex from 'lodash/findIndex';
1
2
  import isEmpty from 'lodash/isEmpty';
2
3
  import React from 'react';
3
4
  import { Trans } from 'react-i18next';
@@ -42,3 +43,7 @@ export const trimAndReplacePlus = (value) => {
42
43
  return '';
43
44
  return (_a = value.trim()) === null || _a === void 0 ? void 0 : _a.replace('+', '');
44
45
  };
46
+ export const getProductObj = (products, product) => {
47
+ const productIndex = findIndex(products, (p) => p.product === product);
48
+ return productIndex === -1 ? {} : products[productIndex];
49
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalTroubleshootEffects.d.ts","sourceRoot":"","sources":["../../../../src/components/wizardLayout/GlobalTroubleshootEffects.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAWvD,OAAO,EAAqB,eAAe,EAAE,MAAM,iCAAiC,CAAC;AASrF,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;CACpD;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,eAmWtD"}
1
+ {"version":3,"file":"GlobalTroubleshootEffects.d.ts","sourceRoot":"","sources":["../../../../src/components/wizardLayout/GlobalTroubleshootEffects.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAUvD,OAAO,EAAqB,eAAe,EAAE,MAAM,iCAAiC,CAAC;AASrF,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;CACpD;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,eAgVtD"}
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { useDebounce, usePrevious } from '@rh-support/components';
11
11
  import { GlobalMetadataStateContext, useUserPreferences } from '@rh-support/react-context';
12
12
  import { ability, CaseListFields, resourceActions, resources } from '@rh-support/user-permissions';
13
- import { getUrlParsedParams, getVersion, getVersionIfOnlyVersion, isOnlyVersion } from '@rh-support/utils';
13
+ import { getVersion } from '@rh-support/utils';
14
14
  import findIndex from 'lodash/findIndex';
15
15
  import includes from 'lodash/includes';
16
16
  import isEmpty from 'lodash/isEmpty';
@@ -22,7 +22,6 @@ import { RulesDispatchContext } from '../../context/RulesContext';
22
22
  import { SessionRestoreStateContext } from '../../context/SessionRestoreContext';
23
23
  import { TCDispatchContext, TCStateContext } from '../../context/TopContentContext';
24
24
  import { useResetCaseCreate } from '../../hooks/useResetCaseCreate';
25
- import { initialCaseState } from '../../reducers/CaseConstNTypes';
26
25
  import { getDescriptionWOQues } from '../../reducers/CaseHelpers';
27
26
  import { setCaseAccountNumber, setCaseDetails, setCaseOwner, setCaseState } from '../../reducers/CaseReducer';
28
27
  import { setRouteFlags } from '../../reducers/RouteReducer';
@@ -51,11 +50,6 @@ export function GlobalTroubleshootEffects(props) {
51
50
  language: state.caseDetails.caseLanguage,
52
51
  selectedAccountDetails: state.selectedAccountDetails,
53
52
  }), isEqual);
54
- const versionsDetails = useCaseSelector((state) => {
55
- if (isEmpty(state.versionsDetails.data))
56
- return [];
57
- return state.versionsDetails.data.map(({ name }) => name);
58
- }, isEqual);
59
53
  const caseDispatch = useCaseDispatch();
60
54
  const isCaseCreate = RouteUtils.getQueryParams(props.routeProps).caseCreate === 'true';
61
55
  const urlQueryParams = RouteUtils.getQueryParams(props.routeProps);
@@ -74,19 +68,13 @@ export function GlobalTroubleshootEffects(props) {
74
68
  * Setting product version on case details from url.
75
69
  */
76
70
  useEffect(() => {
77
- if (allProducts.isFetching || allProducts.isError || isEmpty(allProducts.data.productsResult))
71
+ const productFromUrl = urlQueryParams.product;
72
+ const versionFromUrl = urlQueryParams.version;
73
+ if (!productFromUrl ||
74
+ allProducts.isFetching ||
75
+ allProducts.isError ||
76
+ isEmpty(allProducts.data.productsResult))
78
77
  return;
79
- const parsedUrlParams = getUrlParsedParams(props.routeProps.location.search);
80
- const productFromUrl = parsedUrlParams.product || initialCaseState.caseDetails.product;
81
- if (isEmpty(productFromUrl)) {
82
- // Reset case state
83
- setCaseDetails(caseDispatch, {
84
- product: productFromUrl,
85
- version: undefined,
86
- });
87
- return;
88
- }
89
- const versionFromUrl = parsedUrlParams.version || initialCaseState.caseDetails.version;
90
78
  const index = findIndex(allProducts.data.productsResult, (p) => p.product === productFromUrl);
91
79
  if (index === -1) {
92
80
  // invalid product, reset url
@@ -95,37 +83,20 @@ export function GlobalTroubleshootEffects(props) {
95
83
  version: undefined,
96
84
  };
97
85
  RouteUtils.updateQueryParams(props.routeProps, newParams);
86
+ return;
98
87
  }
99
- else {
100
- // Check if product information it self is having version list or fallback to version list from different source.
101
- const productVersions = isEmpty(allProducts.data.productsResult[index].versions)
102
- ? versionsDetails
103
- : allProducts.data.productsResult[index].versions;
104
- // product in url is valid
105
- const isVersionFromURLValid = !isEmpty(versionFromUrl) && includes(productVersions, versionFromUrl);
106
- const isMultiVersionProduct = !isOnlyVersion(productVersions);
107
- if (isVersionFromURLValid || isMultiVersionProduct) {
108
- // version is also valid
109
- const versionToSet = isVersionFromURLValid ? versionFromUrl : undefined;
110
- if (product !== productFromUrl || version !== versionToSet) {
111
- setCaseDetails(caseDispatch, {
112
- product: productFromUrl,
113
- version: versionToSet,
114
- });
115
- }
116
- }
117
- else if (!isMultiVersionProduct) {
118
- // no version or invalid version and there is only 1 version we set default version in url that will trigger the flow with valid version this time
119
- const defaultVersion = getVersionIfOnlyVersion(productVersions);
120
- const newParams = {
121
- product: productFromUrl,
122
- version: defaultVersion,
123
- };
124
- RouteUtils.updateQueryParams(props.routeProps, newParams);
125
- }
88
+ // product in url is valid check to see if version is valid
89
+ const productVersions = allProducts.data.productsResult[index].versions;
90
+ const isVersionFromURLValid = !isEmpty(versionFromUrl) && includes(productVersions, versionFromUrl);
91
+ const versionToSet = isVersionFromURLValid ? versionFromUrl : undefined;
92
+ if (product !== productFromUrl || version !== versionToSet) {
93
+ setCaseDetails(caseDispatch, {
94
+ product: productFromUrl,
95
+ version: versionToSet,
96
+ });
126
97
  }
127
98
  // eslint-disable-next-line react-hooks/exhaustive-deps
128
- }, [allProducts, allProducts.data.productsResult, caseDispatch, props.routeProps]);
99
+ }, [allProducts.data.productsResult, caseDispatch, props.routeProps]);
129
100
  // if you want to hide any section on page load then the logic will go here..
130
101
  useEffect(() => {
131
102
  if (!isFirstMount.current && loggedInUser.data && managedAccounts.data)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/troubleshoot",
3
- "version": "2.2.23",
3
+ "version": "2.2.24",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -26,7 +26,7 @@
26
26
  "lib/**/*"
27
27
  ],
28
28
  "peerDependencies": {
29
- "@cee-eng/hydrajs": "4.15.87",
29
+ "@cee-eng/hydrajs": "4.16.11",
30
30
  "@cee-eng/ui-toolkit": "1.1.6",
31
31
  "@patternfly/patternfly": "4.196.7",
32
32
  "@patternfly/pfe-accordion": "1.12.3",
@@ -56,7 +56,7 @@
56
56
  "react-virtualized": "^9.21.2"
57
57
  },
58
58
  "dependencies": {
59
- "@cee-eng/hydrajs": "4.15.87",
59
+ "@cee-eng/hydrajs": "4.16.11",
60
60
  "@cee-eng/ui-toolkit": "1.1.6",
61
61
  "@patternfly/patternfly": "4.196.7",
62
62
  "@patternfly/pfe-accordion": "1.12.3",
@@ -66,11 +66,11 @@
66
66
  "@patternfly/react-core": "4.264.0",
67
67
  "@progress/kendo-drawing": "^1.6.0",
68
68
  "@progress/kendo-react-pdf": "^3.12.0",
69
- "@rh-support/components": "2.1.12",
70
- "@rh-support/react-context": "2.1.12",
69
+ "@rh-support/components": "2.1.13",
70
+ "@rh-support/react-context": "2.1.13",
71
71
  "@rh-support/types": "2.0.2",
72
- "@rh-support/user-permissions": "2.1.6",
73
- "@rh-support/utils": "2.1.3",
72
+ "@rh-support/user-permissions": "2.1.7",
73
+ "@rh-support/utils": "2.1.4",
74
74
  "@types/react-redux": "^7.1.12",
75
75
  "@types/redux": "^3.6.0",
76
76
  "dompurify": "^2.4.1",
@@ -133,5 +133,5 @@
133
133
  "defaults and supports es6-module",
134
134
  "maintained node versions"
135
135
  ],
136
- "gitHead": "37be192367e7927f47125f2452142bbb8ccf9215"
136
+ "gitHead": "3cb1c9deeb0f55a0df73b0f0845194a72cbac688"
137
137
  }
@@ -1,12 +0,0 @@
1
- import { RouteComponentProps } from 'react-router';
2
- import { IRouteUrlParams } from '../../reducers/RouteConstNTypes';
3
- interface IProps {
4
- isDropdownSelected?: boolean;
5
- setIsDropdownSelected?: (flag: boolean) => void;
6
- routeProps: RouteComponentProps<IRouteUrlParams>;
7
- showOnlyEntitledProducts: boolean;
8
- productSelectorRef: HTMLDivElement;
9
- }
10
- export declare function TopProductsSelector(props: IProps): JSX.Element;
11
- export {};
12
- //# sourceMappingURL=TopProductsSelector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TopProductsSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/ProductSelector/TopProductsSelector.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGnD,OAAO,EAAqB,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAGrF,UAAU,MAAM;IACZ,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;IACjD,wBAAwB,EAAE,OAAO,CAAC;IAClC,kBAAkB,EAAE,cAAc,CAAC;CACtC;AAYD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,eAgHhD"}
@@ -1,107 +0,0 @@
1
- import { GlobalMetadataStateContext } from '@rh-support/react-context';
2
- import { getVersionIfOnlyVersion } from '@rh-support/utils';
3
- import filter from 'lodash/filter';
4
- import find from 'lodash/find';
5
- import findIndex from 'lodash/findIndex';
6
- import includes from 'lodash/includes';
7
- import isArray from 'lodash/isArray';
8
- import isEmpty from 'lodash/isEmpty';
9
- import isEqual from 'lodash/isEqual';
10
- import map from 'lodash/map';
11
- import noop from 'lodash/noop';
12
- import React, { useContext, useEffect, useState } from 'react';
13
- import { Trans } from 'react-i18next';
14
- import { useCaseSelector } from '../../context/CaseContext';
15
- import RouteUtils from '../../utils/routeUtils';
16
- /**
17
- * Renders a radio list to select top products.
18
- * Manages selected product internally.
19
- * Uses product version from case details and isDropdownSelected from props to determine its state.
20
- * Change URL on changing selection
21
- *
22
- * @param props
23
- */
24
- const SPACE = 32;
25
- const ENTER = 13;
26
- export function TopProductsSelector(props) {
27
- const defaultSelectedProduct = {
28
- featuredVersion: '',
29
- product: '',
30
- versions: [],
31
- isTopProduct: false,
32
- isEntitledProduct: true,
33
- };
34
- const { globalMetadataState: { allProducts, loggedInUserRights }, } = useContext(GlobalMetadataStateContext);
35
- const { product, version } = useCaseSelector((state) => ({
36
- product: state.caseDetails.product,
37
- version: state.caseDetails.version,
38
- }), isEqual);
39
- const [selectedProductForRadioList, setSelectedProductForRadioList] = useState(defaultSelectedProduct);
40
- const entitledTopProducts = filter(allProducts.data.topProducts, (p) => p.isEntitledProduct);
41
- const topProducts = props.showOnlyEntitledProducts ? entitledTopProducts : allProducts.data.topProducts;
42
- /**
43
- * Update value in radio list based on product & version from case details and if Dropdown is not Selected
44
- */
45
- useEffect(() => {
46
- if (allProducts.isFetching || allProducts.isError)
47
- return;
48
- if (props.isDropdownSelected) {
49
- if (isEmpty(selectedProductForRadioList.product))
50
- return;
51
- else
52
- setSelectedProductForRadioList(defaultSelectedProduct);
53
- }
54
- else {
55
- const caseDetailsProduct = find(topProducts, (p) => p.product === product);
56
- // When the selectedProductForRadioList is not in sync
57
- if (!isEmpty(caseDetailsProduct) && !isEmpty(version) && includes(caseDetailsProduct.versions, version)) {
58
- setSelectedProductForRadioList(caseDetailsProduct);
59
- }
60
- else if (isEmpty(caseDetailsProduct) && !isEmpty(selectedProductForRadioList.product)) {
61
- setSelectedProductForRadioList(defaultSelectedProduct);
62
- }
63
- }
64
- // eslint-disable-next-line react-hooks/exhaustive-deps
65
- }, [allProducts, defaultSelectedProduct, product, props, selectedProductForRadioList.product, version]);
66
- function onProductChange(selectedProduct) {
67
- var _a;
68
- setTimeout(() => {
69
- props.productSelectorRef.focus();
70
- }, 200); // Will make sure product is selected before we focus
71
- if (props.isDropdownSelected) {
72
- (_a = props.setIsDropdownSelected) === null || _a === void 0 ? void 0 : _a.call(props, false);
73
- }
74
- const newParams = {
75
- product: selectedProduct.product,
76
- version: getVersionIfOnlyVersion(selectedProduct.versions),
77
- };
78
- RouteUtils.updateQueryParams(props.routeProps, newParams);
79
- }
80
- const onHandleKey = (item) => (e) => {
81
- if (e.keyCode === SPACE || e.keyCode === ENTER) {
82
- onProductChange(item);
83
- }
84
- };
85
- const onHandleInputClick = (item) => (event) => {
86
- if (event.detail > 0 || loggedInUserRights.data.isOnIE11()) {
87
- onProductChange(item);
88
- }
89
- };
90
- const onHandleLabelClick = (item) => (event) => {
91
- onProductChange(item);
92
- };
93
- if (isEmpty(topProducts) || !isArray(topProducts))
94
- return React.createElement(React.Fragment, null);
95
- const selectedRadioIndex = findIndex(topProducts, (p) => p.product === selectedProductForRadioList.product || p.product === product);
96
- return (React.createElement("div", { className: "top-products" },
97
- React.createElement("p", { id: "productSelectRadioGroup" },
98
- React.createElement(Trans, null, "You can also select a top product:")),
99
- React.createElement("ul", { className: `product-selector-list unstyled-list`, role: "radiogroup", "aria-labelledby": "productSelectRadioGroup" }, map(topProducts, (item, i) => {
100
- if (Array.isArray(item) && item.length === 0) {
101
- return null;
102
- }
103
- return (React.createElement("li", { key: i, className: "form-group" },
104
- React.createElement("input", { type: "radio", id: `product-selector-${i}`, checked: selectedRadioIndex === i, onClick: onHandleInputClick(item), onKeyDown: onHandleKey(item), onChange: noop }),
105
- React.createElement("label", { htmlFor: `product-selector-${i}`, onClick: onHandleLabelClick(item) }, item.product)));
106
- }))));
107
- }