@rh-support/manage 0.2.97 → 0.2.98
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/ManagePreferences/sections/PreferencesCaseCreate.d.ts.map +1 -1
- package/lib/esm/components/ManagePreferences/sections/PreferencesCaseCreate.js +42 -34
- package/lib/esm/components/ManagePreferences/sections/PreferencesCaseView.d.ts.map +1 -1
- package/lib/esm/components/ManagePreferences/sections/PreferencesCaseView.js +4 -3
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreferencesCaseCreate.d.ts","sourceRoot":"","sources":["../../../../../src/components/ManagePreferences/sections/PreferencesCaseCreate.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PreferencesCaseCreate.d.ts","sourceRoot":"","sources":["../../../../../src/components/ManagePreferences/sections/PreferencesCaseCreate.tsx"],"names":[],"mappings":"AAkBA,UAAU,MAAM;CAAG;AACnB,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,eAgIlD"}
|
|
@@ -9,7 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { Card, CardBody, CardHeader, SelectOption } from '@patternfly/react-core';
|
|
11
11
|
import { languageConst, ToastNotification } from '@rh-support/components';
|
|
12
|
-
import { GlobalMetadataStateContext } from '@rh-support/react-context';
|
|
12
|
+
import { fetchCaseGroupsForSSO, GlobalMetadataDispatchContext, GlobalMetadataStateContext, } from '@rh-support/react-context';
|
|
13
|
+
import { haventLoadedMetadata } from '@rh-support/utils';
|
|
13
14
|
import { invert } from 'lodash';
|
|
14
15
|
import isEmpty from 'lodash/isEmpty';
|
|
15
16
|
import React, { useContext, useEffect, useState } from 'react';
|
|
@@ -18,7 +19,8 @@ import { useUserPreferences } from '../../../hooks/useUserPreferences';
|
|
|
18
19
|
import { PreferenceSelect } from '../components/PreferenceSelect';
|
|
19
20
|
export function PreferencesCaseCreate(props) {
|
|
20
21
|
const { t } = useTranslation();
|
|
21
|
-
const { globalMetadataState: { caseGroups }, } = useContext(GlobalMetadataStateContext);
|
|
22
|
+
const { globalMetadataState: { caseGroups, loggedInUserJwtToken }, } = useContext(GlobalMetadataStateContext);
|
|
23
|
+
const dispatchToGlobalMetadataReducer = useContext(GlobalMetadataDispatchContext);
|
|
22
24
|
const [originalPreferredLanguage, setOriginalPreferredLanguage] = useState('');
|
|
23
25
|
const [originalDefaultGroup, setOriginalDefaultGroup] = useState('');
|
|
24
26
|
const [groupDictionary, setGroupDictionary] = useState({});
|
|
@@ -37,24 +39,6 @@ export function PreferencesCaseCreate(props) {
|
|
|
37
39
|
const selectionKey = invert(groupDictionary)[selection];
|
|
38
40
|
yield updateDefaultGroup(selectionKey);
|
|
39
41
|
});
|
|
40
|
-
const userOriginalPreferredLanguage = () => __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
try {
|
|
42
|
-
const retrievedLanguage = yield getPreferredLanguage();
|
|
43
|
-
setOriginalPreferredLanguage(languageConst[retrievedLanguage]);
|
|
44
|
-
}
|
|
45
|
-
catch (_a) {
|
|
46
|
-
ToastNotification.addWarningMessage(t('Failed to fetch original preference'));
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
const userOriginalDefaultGroup = () => __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
try {
|
|
51
|
-
const retrievedGroupId = yield getDefaultGroup();
|
|
52
|
-
setOriginalDefaultGroup(groupDictionary[retrievedGroupId]);
|
|
53
|
-
}
|
|
54
|
-
catch (_b) {
|
|
55
|
-
ToastNotification.addWarningMessage(t('Failed to fetch original preference'));
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
42
|
const createCaseGroupStruct = (caseGroups) => {
|
|
59
43
|
const defaultGroupDictionary = {};
|
|
60
44
|
for (let i = 0; i < caseGroups.data.length; i++) {
|
|
@@ -62,26 +46,50 @@ export function PreferencesCaseCreate(props) {
|
|
|
62
46
|
}
|
|
63
47
|
return defaultGroupDictionary;
|
|
64
48
|
};
|
|
65
|
-
|
|
66
|
-
var _a;
|
|
67
|
-
if (!isEmpty(caseGroups) && ((_a = caseGroups === null || caseGroups === void 0 ? void 0 : caseGroups.data) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
68
|
-
let updatedDictionary = createCaseGroupStruct(caseGroups);
|
|
69
|
-
setGroupDictionary(updatedDictionary);
|
|
70
|
-
const parsedDefaultGroupNames = [];
|
|
71
|
-
for (let groupId in updatedDictionary) {
|
|
72
|
-
parsedDefaultGroupNames.push(updatedDictionary[groupId]);
|
|
73
|
-
}
|
|
74
|
-
setUserDefaultGroupList(parsedDefaultGroupNames);
|
|
75
|
-
}
|
|
76
|
-
};
|
|
49
|
+
//use effect to retrieve original pref values.
|
|
77
50
|
useEffect(() => {
|
|
51
|
+
const userOriginalPreferredLanguage = () => __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
try {
|
|
53
|
+
const retrievedLanguage = yield getPreferredLanguage();
|
|
54
|
+
setOriginalPreferredLanguage(languageConst[retrievedLanguage]);
|
|
55
|
+
}
|
|
56
|
+
catch (_a) {
|
|
57
|
+
ToastNotification.addWarningMessage(t('Failed to fetch original preference'));
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const userOriginalDefaultGroup = () => __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
try {
|
|
62
|
+
const retrievedGroupId = yield getDefaultGroup();
|
|
63
|
+
setOriginalDefaultGroup(groupDictionary[retrievedGroupId]);
|
|
64
|
+
}
|
|
65
|
+
catch (_b) {
|
|
66
|
+
ToastNotification.addWarningMessage(t('Failed to fetch original preference'));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
78
69
|
userOriginalPreferredLanguage();
|
|
79
70
|
userOriginalDefaultGroup();
|
|
80
|
-
|
|
71
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
|
+
}, []);
|
|
73
|
+
// used to build the groups object
|
|
81
74
|
useEffect(() => {
|
|
75
|
+
const refreshParsedGroups = () => __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
var _a;
|
|
77
|
+
if (haventLoadedMetadata(caseGroups, (data) => data === undefined)) {
|
|
78
|
+
yield fetchCaseGroupsForSSO(dispatchToGlobalMetadataReducer, loggedInUserJwtToken.username);
|
|
79
|
+
}
|
|
80
|
+
if (!isEmpty(caseGroups) && ((_a = caseGroups === null || caseGroups === void 0 ? void 0 : caseGroups.data) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
81
|
+
let updatedDictionary = createCaseGroupStruct(caseGroups);
|
|
82
|
+
setGroupDictionary(updatedDictionary);
|
|
83
|
+
const parsedDefaultGroupNames = [];
|
|
84
|
+
for (let groupId in updatedDictionary) {
|
|
85
|
+
parsedDefaultGroupNames.push(updatedDictionary[groupId]);
|
|
86
|
+
}
|
|
87
|
+
setUserDefaultGroupList(parsedDefaultGroupNames);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
82
90
|
refreshParsedGroups();
|
|
83
91
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
84
|
-
}, [caseGroups]);
|
|
92
|
+
}, [caseGroups, dispatchToGlobalMetadataReducer, loggedInUserJwtToken]);
|
|
85
93
|
return (React.createElement(Card, { className: "preference-card" },
|
|
86
94
|
React.createElement(CardHeader, null,
|
|
87
95
|
React.createElement("h3", null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreferencesCaseView.d.ts","sourceRoot":"","sources":["../../../../../src/components/ManagePreferences/sections/PreferencesCaseView.tsx"],"names":[],"mappings":"AAcA,UAAU,MAAM;CAAG;AAEnB,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"PreferencesCaseView.d.ts","sourceRoot":"","sources":["../../../../../src/components/ManagePreferences/sections/PreferencesCaseView.tsx"],"names":[],"mappings":"AAcA,UAAU,MAAM;CAAG;AAEnB,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,eAiKhD"}
|
|
@@ -83,7 +83,7 @@ export function PreferencesCaseView(props) {
|
|
|
83
83
|
});
|
|
84
84
|
const titleId = 'default-comment-preference-select';
|
|
85
85
|
const canUseHostName = ability.can(resourceActions.PATCH, resources.CASE_CREATE, CaseListFields.HOSTNAME);
|
|
86
|
-
const { globalMetadataState: { loggedInUsersAccount }, } = useContext(GlobalMetadataStateContext);
|
|
86
|
+
const { globalMetadataState: { loggedInUsersAccount, loggedInUserRights }, } = useContext(GlobalMetadataStateContext);
|
|
87
87
|
const { request: fetchHostnameDefault } = useFetch(accounts.getIsSharingHostname);
|
|
88
88
|
const accountNumber = loggedInUsersAccount.data.accountNumber;
|
|
89
89
|
const { request: updateShareHostnames } = useFetch(accounts.updateIsSharingHostname);
|
|
@@ -92,14 +92,15 @@ export function PreferencesCaseView(props) {
|
|
|
92
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
93
|
try {
|
|
94
94
|
const fetchedHostnameStatus = yield fetchHostnameDefault(accountNumber);
|
|
95
|
-
|
|
95
|
+
(fetchedHostnameStatus === null || fetchedHostnameStatus === void 0 ? void 0 : fetchedHostnameStatus.shareHostnameWithRHT) &&
|
|
96
|
+
setIsSharingHostNames(fetchedHostnameStatus.shareHostnameWithRHT);
|
|
96
97
|
}
|
|
97
98
|
catch (error) {
|
|
98
99
|
console.log(error);
|
|
99
100
|
}
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
|
-
userOriginalHostnameValue();
|
|
103
|
+
!loggedInUserRights.data.isInternal && userOriginalHostnameValue();
|
|
103
104
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
104
105
|
}, []);
|
|
105
106
|
const onShareHostNamesSwitch = () => __awaiter(this, void 0, void 0, function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/manage",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.98",
|
|
4
4
|
"description": "Customer Support Manage App",
|
|
5
5
|
"author": "Jordan Eudy <jeudy100@gmail.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -96,9 +96,9 @@
|
|
|
96
96
|
"@patternfly/react-core": "4.202.16",
|
|
97
97
|
"@patternfly/react-table": "4.71.16",
|
|
98
98
|
"@rh-support/api": "0.3.24",
|
|
99
|
-
"@rh-support/components": "1.1.
|
|
99
|
+
"@rh-support/components": "1.1.79",
|
|
100
100
|
"@rh-support/configs": "0.2.5",
|
|
101
|
-
"@rh-support/react-context": "0.2.
|
|
101
|
+
"@rh-support/react-context": "0.2.85",
|
|
102
102
|
"@rh-support/types": "0.2.0",
|
|
103
103
|
"@rh-support/user-permissions": "0.2.63",
|
|
104
104
|
"@rh-support/utils": "0.2.46",
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"react-i18next": ">=10.11.0",
|
|
112
112
|
"react-router-dom": ">=5.1.2"
|
|
113
113
|
},
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "acb137236b62e31aba70cda91755b3b94f0cb7da"
|
|
115
115
|
}
|