@rh-support/troubleshoot 1.1.8 → 2.0.1

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.
@@ -29,7 +29,7 @@ function AccountSelector(props) {
29
29
  const canAccessManagedAccounts = ability.can(resourceActions.PATCH, resources.CASE_CREATE, CaseListFields.MANAGED_ACCOUNTS);
30
30
  const canBookmarkAccounts = ability.can(resourceActions.PATCH, resources.CASE_CREATE, CaseListFields.BOOKMARK_ACCOUNTS);
31
31
  const canUseFindMyAccount = loggedInUserRights.data.isAccountDifferentFromLoggedInAccount(accountNumber);
32
- //
32
+ // Account Change Handler
33
33
  const onAccountChange = (account) => {
34
34
  if (selectedAccountDetails.data.accountNumber === account.accountNumber)
35
35
  return;
@@ -1,9 +1,6 @@
1
1
  import { ISEProduct } from '@cee-eng/hydrajs/@types/models/product';
2
- import { IApiResponseDetails } from '@rh-support/types/shared';
3
- import { ITroubleshootProductResponse } from '@rh-support/utils';
4
2
  interface IProps {
5
3
  products: Partial<ISEProduct>[];
6
- allProducts: IApiResponseDetails<ITroubleshootProductResponse>;
7
4
  onProductChange: (product: Partial<ISEProduct>) => any;
8
5
  selectedProduct: Partial<ISEProduct>;
9
6
  onVersionChange: (version: string) => any;
@@ -1 +1 @@
1
- {"version":3,"file":"NewProductDropdownSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/ProductSelector/NewProductDropdownSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AAMjE,UAAU,MAAM;IACZ,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;IAChC,WAAW,EAAE,mBAAmB,CAAC,4BAA4B,CAAC,CAAC;IAC/D,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,GAAG,CAAC;IACvD,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,GAAG,CAAC;IAC1C,wBAAwB,EAAE,OAAO,CAAC;IAClC,YAAY,EAAE,OAAO,CAAC;CACzB;AAED,eAAO,MAAM,0BAA0B,UAAW,MAAM,gBAsHvD,CAAC"}
1
+ {"version":3,"file":"NewProductDropdownSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/ProductSelector/NewProductDropdownSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAOpE,UAAU,MAAM;IACZ,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;IAChC,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,GAAG,CAAC;IACvD,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,GAAG,CAAC;IAC1C,wBAAwB,EAAE,OAAO,CAAC;IAClC,YAAY,EAAE,OAAO,CAAC;CACzB;AAED,eAAO,MAAM,0BAA0B,UAAW,MAAM,gBA0GvD,CAAC"}
@@ -1,13 +1,14 @@
1
1
  import { Divider, Select, SelectGroup, SelectOption, SelectVariant } from '@patternfly/react-core';
2
- import filter from 'lodash/filter';
2
+ import { GlobalMetadataStateContext } from '@rh-support/react-context';
3
3
  import isEmpty from 'lodash/isEmpty';
4
- import React, { useEffect, useState } from 'react';
4
+ import React, { useContext, useEffect, useState } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  export const NewProductDropdownSelector = (props) => {
7
7
  const { t } = useTranslation();
8
8
  const [isOpen, setIsOpen] = useState(false);
9
- const [selected, setSelected] = useState('');
9
+ const [selected, setSelected] = useState(undefined);
10
10
  const [showValidationLocal, setShowValidationLocal] = useState(props.showValidationErrorAlert);
11
+ const { globalMetadataState: { allProducts }, } = useContext(GlobalMetadataStateContext);
11
12
  useEffect(() => {
12
13
  if (props.selectedProduct) {
13
14
  setSelected(props.selectedProduct.name);
@@ -18,39 +19,9 @@ export const NewProductDropdownSelector = (props) => {
18
19
  setShowValidationLocal(props.showValidationErrorAlert);
19
20
  // eslint-disable-next-line react-hooks/exhaustive-deps
20
21
  }, [props.showValidationErrorAlert]);
21
- const renderTopProducts = () => {
22
- let topProductArray = [];
23
- const entitledTopProducts = filter(props.allProducts.data.topProducts, (p) => p.isEntitledProduct);
24
- entitledTopProducts.forEach((topProduct, index) => {
25
- let menuItemTopProduct = React.createElement(SelectOption, { key: index, value: topProduct.name });
26
- topProductArray.push(menuItemTopProduct);
27
- });
28
- const slicedTopProductArray = topProductArray.slice(0, 3);
29
- return slicedTopProductArray;
22
+ const createOption = (product, id, type) => {
23
+ return React.createElement(SelectOption, { key: `${type}-${id}`, value: product.name, className: "pf-c-select__menu-wrapper" });
30
24
  };
31
- const renderProducts = () => {
32
- let productArray = [];
33
- props.products.forEach((product, index) => {
34
- let selectProductItem = React.createElement(SelectOption, { key: index, value: product.name });
35
- productArray.push(selectProductItem);
36
- });
37
- return productArray;
38
- };
39
- const renderAllProductsTroubleshoot = () => {
40
- let troubleshootProductArray = [];
41
- props.allProducts.data.productsResult.forEach((product, index) => {
42
- let selectProductItem = React.createElement(SelectOption, { key: index, value: product.name });
43
- troubleshootProductArray.push(selectProductItem);
44
- });
45
- return troubleshootProductArray;
46
- };
47
- let options = [
48
- //Top Products
49
- React.createElement(SelectGroup, { label: "Top products", key: "topProducts" }, renderTopProducts()),
50
- React.createElement(Divider, { key: "all-product-divider" }),
51
- // All Products
52
- React.createElement(SelectGroup, { label: "All products", key: "AllProducts" }, props.isCaseCreate ? renderProducts() : renderAllProductsTroubleshoot()),
53
- ];
54
25
  const onToggle = (isOpen) => {
55
26
  setIsOpen(isOpen);
56
27
  };
@@ -63,26 +34,41 @@ export const NewProductDropdownSelector = (props) => {
63
34
  return foundISEProduct;
64
35
  }
65
36
  };
66
- const onSelect = (event, selection) => {
67
- setSelected(selection);
68
- let ISESelection = findISEProductObj(selection);
69
- props.onProductChange(ISESelection);
70
- setIsOpen(false);
37
+ const getOptions = () => {
38
+ const topProductOptions = allProducts.data.topProducts
39
+ .filter((p) => p.isEntitledProduct)
40
+ .map((p, id) => createOption(p, id, 'topProduct'))
41
+ .slice(0, 3);
42
+ const productOptions = props.products.map((p, id) => createOption(p, id, 'product'));
43
+ const allProductsTroubleshootOptions = allProducts.data.productsResult.map((p, id) => createOption(p, id, 'product'));
44
+ return [
45
+ React.createElement(SelectGroup, { label: t('Top products'), key: "topProducts" }),
46
+ ...topProductOptions,
47
+ React.createElement(Divider, { key: "all-product-divider" }),
48
+ React.createElement(SelectGroup, { label: t('All products'), key: "AllProducts" }),
49
+ ...(props.isCaseCreate ? productOptions : allProductsTroubleshootOptions),
50
+ ];
71
51
  };
72
52
  const onFilter = (e, textInput) => {
73
53
  if (textInput === '') {
74
- return options;
54
+ return getOptions();
75
55
  }
76
56
  else {
77
57
  let finalFilteredProducts = [];
78
58
  let filteredProducts = props.products.filter((product) => { var _a; return (_a = product.name) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(textInput.toLowerCase()); });
79
59
  filteredProducts.forEach((product, index) => {
80
- let selectProductItem = React.createElement(SelectOption, { key: index, value: product.name });
60
+ let selectProductItem = createOption(product, index, 'product');
81
61
  finalFilteredProducts.push(selectProductItem);
82
62
  });
83
63
  return finalFilteredProducts;
84
64
  }
85
65
  };
66
+ const onSelect = (event, selection) => {
67
+ setSelected(selection);
68
+ let ISESelection = findISEProductObj(selection);
69
+ props.onProductChange(ISESelection);
70
+ setIsOpen(false);
71
+ };
86
72
  return (React.createElement("div", null,
87
- React.createElement(Select, { variant: SelectVariant.typeahead, typeAheadAriaLabel: t('Search for or select a product'), onToggle: onToggle, onSelect: onSelect, isOpen: isOpen, placeholderText: t('Search for or select a product'), "aria-labelledby": t('Product-selector'), onFilter: onFilter, selections: selected, validated: isEmpty(selected) && showValidationLocal ? 'error' : 'default', "data-tracking-id": "get-support-product-dropdown-selector" }, options)));
73
+ React.createElement(Select, { variant: SelectVariant.typeahead, typeAheadAriaLabel: t('Search for or select a product'), onToggle: onToggle, onSelect: onSelect, isOpen: isOpen, placeholderText: t('Search for or select a product'), "aria-labelledby": t('Product-selector'), onFilter: onFilter, selections: selected, validated: isEmpty(selected) && showValidationLocal ? 'error' : 'default', "data-tracking-id": "get-support-product-dropdown-selector" }, getOptions())));
88
74
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ProductVersionDropdownSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/ProductSelector/ProductVersionDropdownSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAiC,MAAM,OAAO,CAAC;AAOtD,UAAU,MAAO,SAAQ,gBAAgB;IACrC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;IAChC,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,GAAG,CAAC;IACvD,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,GAAG,CAAC;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACnB;AAOD,QAAA,MAAM,8BAA8B,wEAgDlC,CAAC;AAEH,OAAO,EAAE,8BAA8B,EAAE,CAAC"}
1
+ {"version":3,"file":"ProductVersionDropdownSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/ProductSelector/ProductVersionDropdownSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAiC,MAAM,OAAO,CAAC;AAOtD,UAAU,MAAO,SAAQ,gBAAgB;IACrC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;IAChC,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,GAAG,CAAC;IACvD,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,GAAG,CAAC;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACnB;AAOD,QAAA,MAAM,8BAA8B,wEA2ClC,CAAC;AAEH,OAAO,EAAE,8BAA8B,EAAE,CAAC"}
@@ -1,4 +1,3 @@
1
- import { GlobalMetadataStateContext } from '@rh-support/react-context';
2
1
  import React, { forwardRef, useContext } from 'react';
3
2
  import { Trans } from 'react-i18next';
4
3
  import { RouteContext } from '../../context/RouteContext';
@@ -10,7 +9,6 @@ const defaultProps = {
10
9
  };
11
10
  const ProductVersionDropdownSelector = forwardRef((props, ref) => {
12
11
  const { routeState: { isCaseCreate, showValidationErrorAlert }, } = useContext(RouteContext);
13
- const { globalMetadataState: { allProducts }, } = useContext(GlobalMetadataStateContext);
14
12
  return (React.createElement(React.Fragment, null,
15
13
  React.createElement("div", { className: "product-selector-wrapper" },
16
14
  React.createElement("label", { htmlFor: "product-selector-dropdown-downshift-search", ref: ref },
@@ -18,7 +16,7 @@ const ProductVersionDropdownSelector = forwardRef((props, ref) => {
18
16
  React.createElement(Trans, null, "Product"),
19
17
  ' ',
20
18
  React.createElement("span", { className: "form-required", "aria-hidden": true }, "*"))),
21
- React.createElement(NewProductDropdownSelector, { products: props.products, allProducts: allProducts, onProductChange: props.onProductChange, selectedProduct: props.selectedProduct, onVersionChange: props.onVersionChange, showValidationErrorAlert: showValidationErrorAlert, isCaseCreate: isCaseCreate })),
19
+ React.createElement(NewProductDropdownSelector, { products: props.products, onProductChange: props.onProductChange, selectedProduct: props.selectedProduct, onVersionChange: props.onVersionChange, showValidationErrorAlert: showValidationErrorAlert, isCaseCreate: isCaseCreate })),
22
20
  React.createElement("div", { className: "version-selector-wrapper" },
23
21
  React.createElement("label", { htmlFor: "version-selector-dropdown-toggle" },
24
22
  React.createElement("h3", { className: "subheading subheading-sm" },
@@ -1 +1 @@
1
- {"version":3,"file":"ClusterRecommendationToast.d.ts","sourceRoot":"","sources":["../../../../src/components/Recommendations/ClusterRecommendationToast.tsx"],"names":[],"mappings":"AAGA,OAAc,EAAE,EAAE,EAAmC,MAAM,OAAO,CAAC;AAMnE,UAAU,MAAM;CAAG;AAEnB,QAAA,MAAM,0BAA0B,EAAE,EAAE,CAAC,MAAM,CAgD1C,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,CAsD1C,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
@@ -1,14 +1,16 @@
1
- import { Alert, AlertActionCloseButton } from '@patternfly/react-core';
1
+ import { Alert, AlertActionCloseButton, Button } from '@patternfly/react-core';
2
2
  import { GlobalMetadataStateContext } from '@rh-support/react-context';
3
3
  import { isEmpty, isEqual } from 'lodash';
4
4
  import React, { useContext, useEffect, useState } from 'react';
5
5
  import { Trans } from 'react-i18next';
6
6
  import { useCaseSelector } from '../../context/CaseContext';
7
- import { ClusterRecommendationsContext } from '../../context/ClusterRecommendationsContext';
7
+ import { ClusterRecommendationsContext, ClusterRecommendationsDispatchContext, } from '../../context/ClusterRecommendationsContext';
8
+ import { toggleClusterRecommendationModal } from '../../reducers/ClusterRecommendationsReducer';
8
9
  import { getIsClusterIdInvalid, isClusterIdEnabledForProduct } from '../../utils/caseOpenshiftClusterIdUtils';
9
10
  const ClusterRecommendationToast = () => {
10
11
  var _a;
11
- const { clusterRecommendationsState: { clusterRecommendations }, } = useContext(ClusterRecommendationsContext);
12
+ const { clusterRecommendationsState: { clusterRecommendations, isClusterRecommendationsModalOpen }, } = useContext(ClusterRecommendationsContext);
13
+ const clusterRecommendationsDispatch = useContext(ClusterRecommendationsDispatchContext);
12
14
  const [isToastVisible, setToastVisibility] = useState(false);
13
15
  const { openshiftClusterID, product } = useCaseSelector((state) => ({
14
16
  openshiftClusterID: state.caseDetails.openshiftClusterID,
@@ -31,7 +33,11 @@ const ClusterRecommendationToast = () => {
31
33
  const hasCluster = isClusterIdEnabledForProduct(product, (_a = allProducts.data) === null || _a === void 0 ? void 0 : _a.productsResult);
32
34
  if (!isToastVisible || !hasCluster)
33
35
  return null;
34
- return (React.createElement(Alert, { isLiveRegion: true, variant: "success", title: React.createElement(Trans, null, "Cluster recommendations are ready to view"), "data-tracking-id": "toast-view-cluster-sol", children: React.createElement("p", null,
36
+ const onViewRecommendations = () => {
37
+ setToastVisibility(false);
38
+ toggleClusterRecommendationModal(clusterRecommendationsDispatch, !isClusterRecommendationsModalOpen);
39
+ };
40
+ return (React.createElement(Alert, { isLiveRegion: true, variant: "success", title: React.createElement(Trans, null, "Cluster recommendations are ready to view"), "data-tracking-id": "toast-view-cluster-sol", children: React.createElement(Button, { isInline: true, variant: "link", onClick: onViewRecommendations },
35
41
  React.createElement(Trans, null, "Troubleshooting specific for your selected cluster.")), actionClose: React.createElement(AlertActionCloseButton, { variantLabel: "success alert", onClose: () => setToastVisibility(false) }) }));
36
42
  };
37
43
  export default ClusterRecommendationToast;
@@ -1418,8 +1418,8 @@ div.support-grid-case-details.support-case {
1418
1418
  -ms-grid-rows: 1fr auto;
1419
1419
  grid-template-rows: 1fr auto;
1420
1420
  grid-template-areas:
1421
- 'main'
1422
- 'nav';
1421
+ 'main main'
1422
+ 'nav nav';
1423
1423
 
1424
1424
  .grid-main {
1425
1425
  -ms-grid-row: 1;
@@ -405,3 +405,7 @@ div#case-reopen-modal.pf-c-modal-box__body {
405
405
  }
406
406
  }
407
407
  }
408
+
409
+ pfe-accordion {
410
+ box-shadow: inset 1px 1px 0px #d2d2d2, inset -1px -1px 0px #d2d2d2;
411
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/troubleshoot",
3
- "version": "1.1.8",
3
+ "version": "2.0.1",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -73,11 +73,11 @@
73
73
  "@patternfly/react-core": "4.264.0",
74
74
  "@progress/kendo-drawing": "^1.6.0",
75
75
  "@progress/kendo-react-pdf": "^3.12.0",
76
- "@rh-support/components": "1.3.1",
77
- "@rh-support/react-context": "1.1.3",
78
- "@rh-support/types": "0.2.1-beta.58",
79
- "@rh-support/user-permissions": "1.1.0",
80
- "@rh-support/utils": "1.0.10-beta.58",
76
+ "@rh-support/components": "2.0.1",
77
+ "@rh-support/react-context": "2.0.1",
78
+ "@rh-support/types": "2.0.1",
79
+ "@rh-support/user-permissions": "2.0.1",
80
+ "@rh-support/utils": "2.0.1",
81
81
  "@types/react-redux": "^7.1.12",
82
82
  "@types/redux": "^3.6.0",
83
83
  "@webcomponents/webcomponentsjs": "^2.2.10",
@@ -145,5 +145,5 @@
145
145
  "not ie <= 11",
146
146
  "not op_mini all"
147
147
  ],
148
- "gitHead": "f0ba37c79bcb3c80d8da82267ceadd5691b5a809"
148
+ "gitHead": "98c698c7f5ca8e1ec943598ef96a6fb816babc1e"
149
149
  }