@rh-support/react-context 1.0.12 → 1.0.13
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":"HostnameAwarenessModal.d.ts","sourceRoot":"","sources":["../../../../src/components/HostnameAwarenessModal/HostnameAwarenessModal.tsx"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,CAAC;AAatC,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"HostnameAwarenessModal.d.ts","sourceRoot":"","sources":["../../../../src/components/HostnameAwarenessModal/HostnameAwarenessModal.tsx"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,CAAC;AAatC,eAAO,MAAM,sBAAsB,mBAyKlC,CAAC"}
|
|
@@ -25,32 +25,36 @@ export const HostnameAwarenessModal = () => {
|
|
|
25
25
|
const [doNotShowModal, setDoNotShowModal] = useState(null);
|
|
26
26
|
const [isModalOpen, setIsModalOpen] = useState(true);
|
|
27
27
|
const [isHostnamesChecked, setisHostnamesChecked] = useState(false);
|
|
28
|
+
const [isLoadingHostnamesVisibilityObj, setIsLoadingHostnamesVisibilityObj] = useState(false);
|
|
28
29
|
//preserving initial state to disable modal load
|
|
29
30
|
const [alreadyCheckedCloseModal, setAlreadyCheckedCloseModal] = useState(false);
|
|
30
31
|
const [isHostnamesLoading, setIsHostnamesLoading] = useState(true);
|
|
31
|
-
const userOriginalHostnamesCount = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
-
try {
|
|
33
|
-
const originalHostnameVisibilityObj = yield getHostnamesVisibilityObj();
|
|
34
|
-
const parsedVisibilityObj = JSON.parse(originalHostnameVisibilityObj);
|
|
35
|
-
setViewedCountValue(parsedVisibilityObj.shownCount);
|
|
36
|
-
setDoNotShowModal(parsedVisibilityObj.doNotShow);
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
console.log(error);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
32
|
const { globalMetadataState: { loggedInUsersAccount }, } = useGlobalStateContext();
|
|
43
33
|
const accountNumber = loggedInUsersAccount.data.accountNumber;
|
|
44
|
-
const { request: fetchHostnameDefault } = useFetch(accounts.getIsSharingHostname);
|
|
45
|
-
const { request: updateHostnameDefault } = useFetch(accounts.updateIsSharingHostname);
|
|
46
|
-
const userOriginalHostnameValue = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
-
const fetchedHostnameStatus = yield fetchHostnameDefault(accountNumber);
|
|
48
|
-
setisHostnamesChecked(fetchedHostnameStatus.shareHostnameWithRHT);
|
|
49
|
-
// This is needed so we preserve initial state we do not close modal upon updating names.
|
|
50
|
-
setAlreadyCheckedCloseModal(fetchedHostnameStatus.shareHostnameWithRHT);
|
|
51
|
-
setIsHostnamesLoading(false);
|
|
52
|
-
});
|
|
34
|
+
const { request: fetchHostnameDefault, isFetching: isFetchingHostnameDefault } = useFetch(accounts.getIsSharingHostname);
|
|
35
|
+
const { request: updateHostnameDefault, isFetching: isFetchingUpdateHostnameDefault } = useFetch(accounts.updateIsSharingHostname);
|
|
53
36
|
useEffect(() => {
|
|
37
|
+
const userOriginalHostnamesCount = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
try {
|
|
39
|
+
setIsLoadingHostnamesVisibilityObj(true);
|
|
40
|
+
const originalHostnameVisibilityObj = yield getHostnamesVisibilityObj();
|
|
41
|
+
const parsedVisibilityObj = JSON.parse(originalHostnameVisibilityObj);
|
|
42
|
+
setIsLoadingHostnamesVisibilityObj(false);
|
|
43
|
+
setViewedCountValue(parsedVisibilityObj.shownCount);
|
|
44
|
+
setDoNotShowModal(parsedVisibilityObj.doNotShow);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
setIsLoadingHostnamesVisibilityObj(false);
|
|
48
|
+
console.log(error);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const userOriginalHostnameValue = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
const fetchedHostnameStatus = yield fetchHostnameDefault(accountNumber);
|
|
53
|
+
setisHostnamesChecked(fetchedHostnameStatus.shareHostnameWithRHT);
|
|
54
|
+
// This is needed so we preserve initial state we do not close modal upon updating names.
|
|
55
|
+
setAlreadyCheckedCloseModal(fetchedHostnameStatus.shareHostnameWithRHT);
|
|
56
|
+
setIsHostnamesLoading(false);
|
|
57
|
+
});
|
|
54
58
|
userOriginalHostnamesCount();
|
|
55
59
|
userOriginalHostnameValue();
|
|
56
60
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -100,18 +104,21 @@ export const HostnameAwarenessModal = () => {
|
|
|
100
104
|
};
|
|
101
105
|
//Do not show modal if user cannot share hostnames.
|
|
102
106
|
const canUseHostName = ability.can(resourceActions.PATCH, resources.CASE_CREATE, CaseListFields.HOSTNAME);
|
|
103
|
-
if (!canUseHostName) {
|
|
104
|
-
return React.createElement(React.Fragment, null);
|
|
105
|
-
}
|
|
106
107
|
//Do not show modal if user is already sharing hostnames, has seen the modal more than twice, or opted to not show it again
|
|
107
|
-
if (
|
|
108
|
+
if (isFetchingHostnameDefault ||
|
|
109
|
+
isFetchingUpdateHostnameDefault ||
|
|
110
|
+
isLoadingHostnamesVisibilityObj ||
|
|
111
|
+
!canUseHostName ||
|
|
112
|
+
alreadyCheckedCloseModal ||
|
|
113
|
+
originalViewedCountValue > 2 ||
|
|
114
|
+
doNotShowModal === 1) {
|
|
108
115
|
return React.createElement(React.Fragment, null);
|
|
109
116
|
}
|
|
110
117
|
return (React.createElement(React.Fragment, null,
|
|
111
118
|
React.createElement(Modal, { variant: ModalVariant.medium, title: "Share hostnames with Red Hat?", isOpen: isModalOpen, onClose: onCloseModal, actions: [
|
|
112
119
|
React.createElement(Button, { "data-tracking-id": "close-hostname-modal", key: "close", variant: "primary", onClick: onCloseModal }, "Close"),
|
|
113
120
|
React.createElement("div", { className: "dontAskCheckbox" },
|
|
114
|
-
React.createElement(Checkbox, { label: "Don't ask me again", id: "dont-ask-again", "data-tracking-id": "dont-ask-again-hostname-modal", onClick: onDoNotAskAgain })),
|
|
121
|
+
React.createElement(Checkbox, { isChecked: !!doNotShowModal, label: "Don't ask me again", id: "dont-ask-again", "data-tracking-id": "dont-ask-again-hostname-modal", onClick: onDoNotAskAgain })),
|
|
115
122
|
] },
|
|
116
123
|
React.createElement("div", null,
|
|
117
124
|
React.createElement(Trans, null, "Red Hat Support cannot currently access hostnames that have been entered on a case. You can share this information at any time to improve your support experience, or you can ignore this.")),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/react-context",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"not ie <= 11",
|
|
88
88
|
"not op_mini all"
|
|
89
89
|
],
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "e5eaffb494da11a1b2f33603dd6b369106033882"
|
|
91
91
|
}
|