@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.
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/AddNewCategoryDropDown.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentCategoryContent/AddNewCategoryDropDown.js +29 -10
- package/lib/esm/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.js +1 -1
- package/lib/esm/components/TopContentManagement/TopContentProductVersionSelector.d.ts.map +1 -1
- package/lib/esm/components/TopContentManagement/TopContentProductVersionSelector.js +31 -30
- package/lib/esm/scss/_main.scss +8 -0
- package/lib/esm/scss/_pf4-overrides.scss +4 -0
- package/package.json +4 -4
|
@@ -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;
|
|
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 {
|
|
2
|
-
import {
|
|
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(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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;
|
|
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 {
|
|
3
|
-
import {
|
|
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 [
|
|
44
|
-
const [
|
|
45
|
-
const
|
|
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
|
|
68
|
-
|
|
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
|
|
74
|
-
validateVersion(option);
|
|
72
|
+
props.onVersionChange(option);
|
|
75
73
|
};
|
|
76
74
|
const onProductClear = () => {
|
|
77
|
-
onProductChange(
|
|
75
|
+
onProductChange({ name: '', id: '' });
|
|
78
76
|
};
|
|
79
|
-
const
|
|
80
|
-
|
|
77
|
+
const getProductOptions = (options) => {
|
|
78
|
+
return options.map((product, id) => (React.createElement(SelectOption, { key: id, value: product }, product.name)));
|
|
81
79
|
};
|
|
82
|
-
const
|
|
83
|
-
|
|
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
|
|
86
|
-
|
|
87
|
+
const onProductToggle = (isExpanded) => {
|
|
88
|
+
setIsProductOpen(isExpanded);
|
|
87
89
|
};
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
+
const onProductSelect = (event, selection, isPlaceholder) => {
|
|
91
|
+
onProductChange(selection);
|
|
92
|
+
onProductToggle(false);
|
|
90
93
|
};
|
|
91
|
-
const
|
|
92
|
-
|
|
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(
|
|
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(
|
|
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 };
|
package/lib/esm/scss/_main.scss
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/manage",
|
|
3
|
-
"version": "1.0.
|
|
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.
|
|
97
|
+
"@rh-support/components": "1.2.25",
|
|
98
98
|
"@rh-support/configs": "1.0.3",
|
|
99
|
-
"@rh-support/react-context": "1.0.
|
|
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": "
|
|
112
|
+
"gitHead": "503c03f099f29076c7cbd553e53c6fe74bf2d749"
|
|
113
113
|
}
|