@rh-support/manage 1.0.42 → 1.0.43

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":"AddNewCategoryDropDown.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/AddNewCategoryDropDown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAUhG,UAAU,MAAM;IACZ,gBAAgB,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACxD;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,eAmDnD"}
1
+ {"version":3,"file":"AddNewCategoryDropDown.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/AddNewCategoryDropDown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAShG,UAAU,MAAM;IACZ,gBAAgB,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACxD;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,eA4EnD"}
@@ -1,6 +1,6 @@
1
- import { Dropdown, ToastNotification } from '@rh-support/components';
2
- import { toOptions } from '@rh-support/utils';
3
- import React, { useEffect } from 'react';
1
+ import { Select, SelectOption, SelectVariant } from '@patternfly/react-core';
2
+ import { ToastNotification } from '@rh-support/components';
3
+ import React, { useEffect, useState } from 'react';
4
4
  import { Trans, useTranslation } from 'react-i18next';
5
5
  import { useTopContentContext, useTopContentDispatchContext } from '../../../../context/TopContentProvider';
6
6
  import { fetchCategories } from '../../../../reducers/TopContentReducer';
@@ -10,11 +10,29 @@ export function AddNewCategoryDropDown(props) {
10
10
  const topContentDispatch = useTopContentDispatchContext();
11
11
  const allAddedCategories = topContentEditState.map((cat) => cat.categoryName);
12
12
  const availableCategories = categories.data.filter((category) => !(allAddedCategories || []).includes(category.categoryName));
13
+ const [isOpen, setIsOpen] = useState(false);
14
+ const [selected, setSelected] = useState();
15
+ const getCategoryOptions = (options) => {
16
+ return options.map((category, id) => (React.createElement(SelectOption, { key: id, value: category }, category.categoryName)));
17
+ };
18
+ const onFilter = (_, value) => {
19
+ if (!value)
20
+ return getCategoryOptions(availableCategories);
21
+ const input = new RegExp(value, 'i');
22
+ const newOptions = availableCategories.filter((c) => input.test(c.categoryName));
23
+ return getCategoryOptions(newOptions);
24
+ };
25
+ const onToggle = (isExpanded) => {
26
+ setIsOpen(isExpanded);
27
+ };
28
+ const onSelect = (event, selection, isPlaceholder) => {
29
+ setSelected(selection);
30
+ props.onCategoryChange(selection);
31
+ onToggle(false);
32
+ };
13
33
  const onClearCategory = () => {
14
34
  props.onCategoryChange(undefined);
15
- };
16
- const onCategoryChange = (selectedItem) => {
17
- props.onCategoryChange(selectedItem.value);
35
+ setSelected(undefined);
18
36
  };
19
37
  useEffect(() => {
20
38
  try {
@@ -25,8 +43,9 @@ export function AddNewCategoryDropDown(props) {
25
43
  }
26
44
  }, [topContentDispatch, t]);
27
45
  return (React.createElement("div", { className: "form-group add-new-category" },
28
- React.createElement(Dropdown, { id: "new-category", name: "new-category", isLoadingList: categories.isFetching, disabled: categories.isFetching || categories.isFetching, required: true, title: t('Select an option or enter a new category'), placeholder: t('Select an option or enter a new category'), list: toOptions(availableCategories, { labelKey: 'categoryName' }), onChange: onCategoryChange, onClearSelection: onClearCategory, searchable: true, label: React.createElement("label", { htmlFor: "new-category" },
29
- React.createElement(Trans, null, "Category"),
30
- ' ',
31
- React.createElement("span", { className: "form-required", "aria-hidden": true }, "*")) })));
46
+ React.createElement("label", { htmlFor: "new-category" },
47
+ React.createElement(Trans, null, "Category"),
48
+ ' ',
49
+ React.createElement("span", { className: "form-required", "aria-hidden": true }, "*")),
50
+ React.createElement(Select, Object.assign({ variant: SelectVariant.typeahead, onToggle: onToggle, isOpen: isOpen, onClear: onClearCategory, onSelect: onSelect, onFilter: onFilter, selections: selected === null || selected === void 0 ? void 0 : selected.categoryName, placeholderText: t('Select an option or enter a new category') }, (categories.isFetching && { loadingVariant: 'spinner' }), { id: "new-category", "data-tracking-id": "new-category" }), getCategoryOptions(availableCategories))));
32
51
  }
@@ -18,7 +18,7 @@ export const TopContentSuggestion = () => {
18
18
  }, [topContentDispatch, selectedProduct, selectedVersion]);
19
19
  if (isEmpty(suggestion.linkedResources))
20
20
  return React.createElement(React.Fragment, null);
21
- return (React.createElement(Panel, { variant: "raised", className: "pf-u-mx-md pf-u-p-md" },
21
+ return (React.createElement(Panel, { variant: "raised", className: "pf-u-mx-md pf-u-p-md top-content-panel" },
22
22
  React.createElement(PanelMain, null,
23
23
  React.createElement(PanelMainBody, null,
24
24
  React.createElement(ExpandableSection, { onToggle: onToggle, isExpanded: isExpanded, toggleContent: React.createElement(Title, { headingLevel: "h6", className: "accordion_title" },
@@ -1 +1 @@
1
- {"version":3,"file":"TopContentProductVersionSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/TopContentManagement/TopContentProductVersionSelector.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAW,MAAM,0BAA0B,CAAC;AASrE,UAAU,MAAO,SAAQ,gBAAgB;IACrC,eAAe,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACxC,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IAC3D,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;CACrB;AAQD,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,aAAa,CAAC,MAAM,EAAE,CAAC,2BAG1E;AAqBD,iBAAS,gCAAgC,CAAC,KAAK,EAAE,MAAM,eA4HtD;kBA5HQ,gCAAgC;;;AA+HzC,OAAO,EAAE,gCAAgC,EAAE,CAAC"}
1
+ {"version":3,"file":"TopContentProductVersionSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/TopContentManagement/TopContentProductVersionSelector.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAGnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAS5D,UAAU,MAAO,SAAQ,gBAAgB;IACrC,eAAe,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACxC,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IAC3D,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC;CACrB;AAQD,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,aAAa,CAAC,MAAM,EAAE,CAAC,2BAG1E;AAqBD,iBAAS,gCAAgC,CAAC,KAAK,EAAE,MAAM,eAsItD;kBAtIQ,gCAAgC;;;AAyIzC,OAAO,EAAE,gCAAgC,EAAE,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import { products as productsApi } from '@cee-eng/hydrajs';
2
- import { Dropdown, useFetch } from '@rh-support/components';
3
- import { getUniqueSortedVersions, getVersion, toOption, toOptions } from '@rh-support/utils';
2
+ import { Select, SelectOption, SelectVariant } from '@patternfly/react-core';
3
+ import { useFetch } from '@rh-support/components';
4
+ import { getUniqueSortedVersions, getVersion } from '@rh-support/utils';
4
5
  import isEmpty from 'lodash/isEmpty';
5
6
  import React, { useEffect, useState } from 'react';
6
7
  import { Trans, useTranslation } from 'react-i18next';
@@ -40,10 +41,9 @@ function TopContentProductVersionSelector(props) {
40
41
  initialData: [],
41
42
  });
42
43
  const { request: getProductVersions, isFetching: isLoadingVersions, data: versions, } = useFetch(productsApi.getProductVersions, { initialData: [], postProcessor: postVersionsProcessor });
43
- const [isProductInValid, setIsProductInValid] = useState(false);
44
- const [isVersionInValid, setIsVersionInValid] = useState(false);
45
- const [isProductBlured, setIsProductBlured] = useState(false);
46
- const [isVersionBlured, setIsVersionBlured] = useState(false);
44
+ const [isProductOpen, setIsProductOpen] = useState(false);
45
+ const [isVersionOpen, setIsVersionOpen] = useState(false);
46
+ const { selectedProduct, selectedVersion } = props;
47
47
  const topContentDispatch = useTopContentDispatchContext();
48
48
  /**
49
49
  * Fetch products on load
@@ -64,48 +64,49 @@ function TopContentProductVersionSelector(props) {
64
64
  }, [versions]);
65
65
  const onProductChange = (option) => {
66
66
  setIsAddingCategory(topContentDispatch, false);
67
- props.onProductChange(option.value);
68
- validateProduct(option);
69
- isProductValid(option) && getProductVersions(option.value.name);
67
+ props.onProductChange(option);
68
+ getProductVersions(option.name);
70
69
  };
71
70
  const onVersionChange = (option) => {
72
71
  setIsAddingCategory(topContentDispatch, false);
73
- props.onVersionChange(option.value);
74
- validateVersion(option);
72
+ props.onVersionChange(option);
75
73
  };
76
74
  const onProductClear = () => {
77
- onProductChange(toOption({ name: '', id: '' }, { labelKey: 'name' }));
75
+ onProductChange({ name: '', id: '' });
78
76
  };
79
- const onProductOuterClick = (selectedItem) => {
80
- setIsProductBlured(true);
77
+ const getProductOptions = (options) => {
78
+ return options.map((product, id) => (React.createElement(SelectOption, { key: id, value: product }, product.name)));
81
79
  };
82
- const onVersionOuterClick = (selectedItem) => {
83
- setIsVersionBlured(true);
80
+ const onProductFilter = (_, value) => {
81
+ if (!value)
82
+ return getProductOptions(products);
83
+ const input = new RegExp(value, 'i');
84
+ const newOptions = products === null || products === void 0 ? void 0 : products.filter((p) => input.test(p.name));
85
+ return getProductOptions(newOptions);
84
86
  };
85
- const validateProduct = (selectedItem) => {
86
- setIsProductInValid(!selectedItem);
87
+ const onProductToggle = (isExpanded) => {
88
+ setIsProductOpen(isExpanded);
87
89
  };
88
- const isProductValid = (selectedItem) => {
89
- return !isEmpty(selectedItem) && !isEmpty(selectedItem.label);
90
+ const onProductSelect = (event, selection, isPlaceholder) => {
91
+ onProductChange(selection);
92
+ onProductToggle(false);
90
93
  };
91
- const validateVersion = (selectedItem) => {
92
- setIsVersionInValid(isEmpty(selectedItem) || isEmpty(selectedItem.label));
94
+ const onVersionToggle = (isExpanded) => {
95
+ setIsVersionOpen(isExpanded);
96
+ };
97
+ const onVersionSelect = (e, selection, isPlaceholder) => {
98
+ onVersionChange(selection);
99
+ onVersionToggle(false);
93
100
  };
94
- useEffect(() => {
95
- setIsProductInValid(false);
96
- setIsVersionInValid(false);
97
- isProductBlured && setIsProductInValid(isEmpty(props.selectedProduct.name));
98
- isVersionBlured && setIsVersionInValid(isEmpty(props.selectedVersion));
99
- }, [isProductBlured, isVersionBlured, props.selectedProduct.name, props.selectedVersion]);
100
101
  return (React.createElement("div", { className: "toolbar" },
101
102
  React.createElement("div", { className: "toolbar-left" },
102
103
  React.createElement("label", { htmlFor: 'tc-product-dropdown-downshift-search' },
103
104
  React.createElement(Trans, null, "Product")),
104
- React.createElement(Dropdown, { className: `tc-product-dropdown`, placeholder: t('Select a product'), list: products ? toOptions(products, { labelKey: 'name' }) : [], title: `Select a product`, selectedItem: toOption(props.selectedProduct, { labelKey: 'name' }), isInValid: isProductInValid, onChange: onProductChange, onOuterClick: onProductOuterClick, searchable: true, isLoadingList: isLoadingProducts, onClearSelection: onProductClear, id: "tc-product-dropdown-selector", "data-tracking-id": "tc-product-dropdown-selector" })),
105
+ React.createElement(Select, Object.assign({ variant: SelectVariant.typeahead, onToggle: onProductToggle, selections: selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.name, isOpen: isProductOpen, onSelect: onProductSelect, onClear: onProductClear, placeholderText: t('Select a product') }, (isLoadingProducts && { loadingVariant: 'spinner' }), { id: "tc-product-dropdown-selector", "data-tracking-id": "tc-product-dropdown-selector", onFilter: onProductFilter, isDisabled: isLoadingProducts }), getProductOptions(products))),
105
106
  React.createElement("div", { className: "toolbar-right" },
106
107
  React.createElement("label", { htmlFor: "version-selector-dropdown-toggle" },
107
108
  React.createElement(Trans, null, "Version")),
108
- React.createElement(Dropdown, { selectedItem: toOption(props.selectedVersion), list: props.selectedProduct ? toOptions(versions === null || versions === void 0 ? void 0 : versions.items) : [], id: "version-selector-dropdown", placeholder: t('Select a version'), isLoadingList: isLoadingVersions, title: `Versions for ${props.selectedProduct.name}`, disabled: isEmpty(versions === null || versions === void 0 ? void 0 : versions.items), isInValid: isVersionInValid, onChange: onVersionChange, onOuterClick: onVersionOuterClick, "data-tracking-id": "version-dropdown-selector" }))));
109
+ React.createElement(Select, Object.assign({ variant: SelectVariant.single, onToggle: onVersionToggle, onSelect: onVersionSelect, selections: selectedVersion, isOpen: isVersionOpen, placeholderText: t('Select a version'), isDisabled: isEmpty(versions === null || versions === void 0 ? void 0 : versions.items) }, (isLoadingVersions && { loadingVariant: 'spinner' }), { id: "version-dropdown-selector", "data-tracking-id": "version-dropdown-selector" }), ((versions === null || versions === void 0 ? void 0 : versions.items) || []).map((version, id) => (React.createElement(SelectOption, { key: id, value: version }, version)))))));
109
110
  }
110
111
  TopContentProductVersionSelector.defaultProps = defaultProps;
111
112
  export { TopContentProductVersionSelector };
@@ -307,3 +307,11 @@ div.prefhostnameTooltip {
307
307
  svg.hostnameSpinner {
308
308
  vertical-align: -0.65rem !important;
309
309
  }
310
+
311
+ #version-dropdown-selector {
312
+ z-index: 9999;
313
+ }
314
+
315
+ #tc-product-dropdown-selector {
316
+ z-index: 9999;
317
+ }
@@ -126,3 +126,7 @@ div.performance-metrics-modal {
126
126
  color: var(--pf-global--Color--100);
127
127
  }
128
128
  }
129
+
130
+ .top-content-panel {
131
+ z-index: 100;
132
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/manage",
3
- "version": "1.0.42",
3
+ "version": "1.0.43",
4
4
  "description": "Customer Support Manage App",
5
5
  "author": "Jordan Eudy <jeudy100@gmail.com>",
6
6
  "homepage": "",
@@ -94,9 +94,9 @@
94
94
  "@patternfly/pfe-tabs": "1.12.3",
95
95
  "@patternfly/react-core": "4.264.0",
96
96
  "@patternfly/react-table": "4.111.33",
97
- "@rh-support/components": "1.2.24",
97
+ "@rh-support/components": "1.2.25",
98
98
  "@rh-support/configs": "1.0.3",
99
- "@rh-support/react-context": "1.0.32",
99
+ "@rh-support/react-context": "1.0.33",
100
100
  "@rh-support/types": "0.2.0",
101
101
  "@rh-support/user-permissions": "1.0.14",
102
102
  "@rh-support/utils": "1.0.12",
@@ -109,5 +109,5 @@
109
109
  "react-i18next": ">=10.11.0",
110
110
  "react-router-dom": ">=5.1.2"
111
111
  },
112
- "gitHead": "415d159b0afb5dddc9247a314d138571433625a2"
112
+ "gitHead": "503c03f099f29076c7cbd553e53c6fe74bf2d749"
113
113
  }