@rh-support/troubleshoot 2.5.1 → 2.5.2
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":"OwnerSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/AccountInfo/OwnerSelector.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OwnerSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/AccountInfo/OwnerSelector.tsx"],"names":[],"mappings":"AAmBA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAiBxE,UAAU,MAAM;CAAG;AAMnB,iBAAS,aAAa,CAAC,KAAK,EAAE,MAAM,qBAiRnC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -7,15 +7,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { CaseContactsSelectorExternal, getHydraContactLabel,
|
|
10
|
+
import { CaseContactsSelectorExternal, getHydraContactLabel, OwnerTypeaheadDropdown, ToastNotification, usePrevious, ValueChangedIcon, } from '@rh-support/components';
|
|
11
11
|
import { GlobalMetadataStateContext, useCanEditCase } from '@rh-support/react-context';
|
|
12
12
|
import { sortHydraContacts } from '@rh-support/utils';
|
|
13
13
|
import filter from 'lodash/filter';
|
|
14
14
|
import isEmpty from 'lodash/isEmpty';
|
|
15
15
|
import isEqual from 'lodash/isEqual';
|
|
16
|
+
import map from 'lodash/map';
|
|
16
17
|
import uniqBy from 'lodash/uniqBy';
|
|
17
|
-
import React, { useContext, useEffect, useState } from 'react';
|
|
18
|
-
import { Typeahead } from 'react-bootstrap-typeahead';
|
|
18
|
+
import React, { useContext, useEffect, useMemo, useState } from 'react';
|
|
19
19
|
import { Trans, useTranslation } from 'react-i18next';
|
|
20
20
|
import { useCaseDispatch, useCaseSelector } from '../../context/CaseContext';
|
|
21
21
|
import { RouteContext } from '../../context/RouteContext';
|
|
@@ -24,6 +24,9 @@ import { setCaseDetails, setCaseOwner, setCaseState, setNotifiedUser, updateCase
|
|
|
24
24
|
import { PDFContext } from '../CaseEditView/PDFContainer';
|
|
25
25
|
import { CaseValuesToWatch } from '../shared/Constants';
|
|
26
26
|
import { getChangedValueTooltip } from '../shared/utils';
|
|
27
|
+
function getOwnerDropdownOptions(contacts) {
|
|
28
|
+
return map(contacts, (contact) => ({ contact }));
|
|
29
|
+
}
|
|
27
30
|
function OwnerSelector(props) {
|
|
28
31
|
const { t } = useTranslation();
|
|
29
32
|
const caseUpdateError = useCaseUpdateErrorMessage();
|
|
@@ -42,6 +45,9 @@ function OwnerSelector(props) {
|
|
|
42
45
|
const previousAccountNumber = usePrevious(accountNumber);
|
|
43
46
|
const { isExportingPDF } = useContext(PDFContext);
|
|
44
47
|
const [usersWithGroupAccess, setUsersWithGroupAccess] = useState([]);
|
|
48
|
+
const [filteredContacts, setFilteredContacts] = useState([]);
|
|
49
|
+
const [ownerQuery, setOwnerQuery] = useState('');
|
|
50
|
+
const ownerDropdownOptions = useMemo(() => getOwnerDropdownOptions(filteredContacts), [filteredContacts]);
|
|
45
51
|
const [localOwnerChange, setLocalOwnerChange] = useState(false);
|
|
46
52
|
const afterLocalChange = () => setLocalOwnerChange(false);
|
|
47
53
|
const ownerComparator = (value, pvalue) => value &&
|
|
@@ -158,11 +164,35 @@ function OwnerSelector(props) {
|
|
|
158
164
|
const showUsersWithSelectedGroupAccess = caseNumber &&
|
|
159
165
|
(selectedCaseGroupUsers.isFetching ||
|
|
160
166
|
(!selectedCaseGroupUsers.isFetching && (selectedCaseGroupUsers.data || []).length > 0));
|
|
167
|
+
const onQueryUpdated = (query) => {
|
|
168
|
+
if (ownerQuery !== query) {
|
|
169
|
+
setOwnerQuery(query);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
const onClearQuery = () => {
|
|
173
|
+
if (ownerQuery !== '') {
|
|
174
|
+
setOwnerQuery('');
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
setOwnerQuery(getHydraContactLabel(selectedOwner.data));
|
|
179
|
+
}, [selectedOwner.data]);
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
if (getHydraContactLabel(selectedOwner.data) === ownerQuery) {
|
|
182
|
+
setFilteredContacts(usersWithGroupAccess);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
const newContacts = filter(usersWithGroupAccess, (contact) => getHydraContactLabel(contact).toLowerCase().includes(ownerQuery.toLowerCase()));
|
|
186
|
+
setFilteredContacts(newContacts);
|
|
187
|
+
}
|
|
188
|
+
}, [usersWithGroupAccess, selectedOwner.data, ownerQuery]);
|
|
161
189
|
return (React.createElement("div", { className: "form-group get-support-owner-wapper", "data-tracking-id": "get-support-owner" },
|
|
162
190
|
React.createElement("label", { htmlFor: "get-support-owner" },
|
|
163
191
|
React.createElement(Trans, null, "Owner"),
|
|
164
192
|
React.createElement(ValueChangedIcon, { afterLocalChange: afterLocalChange, comparator: ownerComparator, isLocalChange: localOwnerChange, value: selectedOwner.data, getTooltipContent: getChangedValueTooltip(() => CaseValuesToWatch.owner, (v) => v.fullNameCustom) }),
|
|
165
193
|
React.createElement("span", { className: `form-required ${isExportingPDF ? 'hide-in-pdf' : ''}`, "aria-hidden": true }, "*")),
|
|
166
|
-
showUsersWithSelectedGroupAccess ? (React.createElement(
|
|
194
|
+
showUsersWithSelectedGroupAccess ? (React.createElement(React.Fragment, null,
|
|
195
|
+
React.createElement(OwnerTypeaheadDropdown, { id: "get-support-owner", hasClearButton: true, selected: !isEmpty(selectedOwner.data) ? [selectedOwner.data] : [], isDisabled: selectedCaseGroupUsers.isFetching || isCaseOwnerUpdating || isCasePhoneUpdating, onSelect: onCustomerContactSelect, onClearQuery: onClearQuery, onQueryUpdated: onQueryUpdated, options: ownerDropdownOptions }))) : (React.createElement(React.Fragment, null,
|
|
196
|
+
React.createElement(CaseContactsSelectorExternal, { loggedInUserRights: loggedInUserRights.data, selectedAccountNumber: accountNumber, selected: !isEmpty(selectedOwner.data) ? [selectedOwner.data] : [], onChange: onCustomerContactSelect, placeholder: t(`Search by name or username`), clearButton: true, id: "get-support-owner", name: "get-support-owner", className: "react-select-custom", isUpdating: isCaseOwnerUpdating, isInvalid: isNextBtnClickedToShowValidationError && isEmpty(selectedOwner.data), isDisabled: isCasePhoneUpdating || isCaseOwnerUpdating })))));
|
|
167
197
|
}
|
|
168
198
|
export { OwnerSelector };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/troubleshoot",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"lib/**/*"
|
|
26
26
|
],
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@cee-eng/hydrajs": "4.
|
|
28
|
+
"@cee-eng/hydrajs": "4.18.0",
|
|
29
29
|
"@cee-eng/ui-toolkit": "1.1.8",
|
|
30
30
|
"@patternfly/patternfly": "5.4.0",
|
|
31
31
|
"@patternfly/react-core": "5.4.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"react-virtualized": "^9.22.5"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@cee-eng/hydrajs": "4.
|
|
54
|
+
"@cee-eng/hydrajs": "4.18.0",
|
|
55
55
|
"@cee-eng/ui-toolkit": "1.1.8",
|
|
56
56
|
"@patternfly/patternfly": "5.4.0",
|
|
57
57
|
"@patternfly/react-core": "5.4.0",
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
"@progress/kendo-licensing": "1.3.5",
|
|
61
61
|
"@progress/kendo-react-pdf": "^5.16.0",
|
|
62
62
|
"@redux-devtools/extension": "^3.3.0",
|
|
63
|
-
"@rh-support/components": "2.5.
|
|
64
|
-
"@rh-support/react-context": "2.5.
|
|
63
|
+
"@rh-support/components": "2.5.2",
|
|
64
|
+
"@rh-support/react-context": "2.5.2",
|
|
65
65
|
"@rh-support/types": "2.0.5",
|
|
66
|
-
"@rh-support/user-permissions": "2.5.
|
|
67
|
-
"@rh-support/utils": "2.5.
|
|
66
|
+
"@rh-support/user-permissions": "2.5.1",
|
|
67
|
+
"@rh-support/utils": "2.5.1",
|
|
68
68
|
"@types/react-redux": "^7.1.33",
|
|
69
69
|
"@types/redux": "^3.6.0",
|
|
70
70
|
"date-fns": "3.6.0",
|
|
@@ -137,5 +137,5 @@
|
|
|
137
137
|
"defaults and supports es6-module",
|
|
138
138
|
"maintained node versions"
|
|
139
139
|
],
|
|
140
|
-
"gitHead": "
|
|
140
|
+
"gitHead": "c4edba0ff68de868d7de31a8afcca922b218476a"
|
|
141
141
|
}
|