@rh-support/react-context 2.1.45 → 2.1.46
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;AAOtC,OAAO,KAA0C,MAAM,OAAO,CAAC;AAO/D,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"HostnameAwarenessModal.d.ts","sourceRoot":"","sources":["../../../../src/components/HostnameAwarenessModal/HostnameAwarenessModal.tsx"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,CAAC;AAOtC,OAAO,KAA0C,MAAM,OAAO,CAAC;AAO/D,eAAO,MAAM,sBAAsB,yBAsKlC,CAAC"}
|
|
@@ -24,43 +24,50 @@ export const HostnameAwarenessModal = () => {
|
|
|
24
24
|
// Setting State for original data value which are used to open/finalize close modal
|
|
25
25
|
const [originalViewedCountValue, setViewedCountValue] = useState(999);
|
|
26
26
|
const [doNotShowModal, setDoNotShowModal] = useState(0);
|
|
27
|
-
const [
|
|
28
|
-
const [isModalOpen, setIsModalOpen] = useState(true);
|
|
27
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
29
28
|
const [isHostnamesChecked, setisHostnamesChecked] = useState(false);
|
|
30
|
-
const [isLoadingHostnamesVisibilityObj, setIsLoadingHostnamesVisibilityObj] = useState(true);
|
|
31
|
-
//preserving initial state to disable modal load
|
|
32
|
-
const [alreadyCheckedCloseModal, setAlreadyCheckedCloseModal] = useState(false);
|
|
33
29
|
const { globalMetadataState: { loggedInUsersAccount }, } = useGlobalStateContext();
|
|
34
30
|
const dispatchToGlobalMetadataReducer = useContext(GlobalMetadataDispatchContext);
|
|
35
31
|
const accountNumber = loggedInUsersAccount.data.accountNumber;
|
|
36
32
|
const { request: updateHostnameDefault, isFetching: isFetchingUpdateHostnameDefault } = useFetch(accounts.updateIsSharingHostname);
|
|
33
|
+
//Do not show modal if user cannot share hostnames.
|
|
34
|
+
const canUseHostName = ability.can(resourceActions.PATCH, resources.CASE_CREATE, CaseListFields.HOSTNAME);
|
|
37
35
|
useEffect(() => {
|
|
36
|
+
if (loggedInUsersAccount.isFetching)
|
|
37
|
+
return;
|
|
38
|
+
let localOriginalViewedCountValue;
|
|
39
|
+
let localDoNotShowModal;
|
|
38
40
|
const userOriginalHostnamesCount = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
41
|
try {
|
|
40
|
-
setIsLoadingHostnamesVisibilityObj(true);
|
|
41
42
|
const originalHostnameVisibilityObj = yield getHostnamesVisibilityObj();
|
|
42
43
|
if (!originalHostnameVisibilityObj)
|
|
43
44
|
return;
|
|
44
45
|
const parsedVisibilityObj = JSON.parse(originalHostnameVisibilityObj);
|
|
45
|
-
|
|
46
|
+
// updating space takes time, here we define a lcal variable to immidiatly use the value
|
|
47
|
+
localOriginalViewedCountValue = parsedVisibilityObj.shownCount;
|
|
48
|
+
localDoNotShowModal = parsedVisibilityObj.doNotShow;
|
|
46
49
|
setViewedCountValue(parsedVisibilityObj.shownCount);
|
|
47
50
|
setDoNotShowModal(parsedVisibilityObj.doNotShow);
|
|
48
51
|
}
|
|
49
52
|
catch (error) {
|
|
50
|
-
setIsLoadingHostnamesVisibilityObj(false);
|
|
51
53
|
console.log(error);
|
|
52
54
|
}
|
|
53
55
|
});
|
|
54
56
|
const userOriginalHostnameValue = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
-
var _a
|
|
57
|
+
var _a;
|
|
56
58
|
setisHostnamesChecked((_a = loggedInUsersAccount.data) === null || _a === void 0 ? void 0 : _a.shareHostnameWithRHT);
|
|
57
|
-
// This is needed so we preserve initial state we do not close modal upon updating names.
|
|
58
|
-
setAlreadyCheckedCloseModal((_b = loggedInUsersAccount.data) === null || _b === void 0 ? void 0 : _b.shareHostnameWithRHT);
|
|
59
59
|
});
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
const init = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
yield userOriginalHostnamesCount();
|
|
62
|
+
userOriginalHostnameValue();
|
|
63
|
+
//Do not show modal if user is already sharing hostnames, has seen the modal more than twice, or opted to not show it again
|
|
64
|
+
if (canUseHostName && localDoNotShowModal !== 1 && localOriginalViewedCountValue < 2) {
|
|
65
|
+
setIsModalOpen(true);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
init();
|
|
62
69
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
|
-
}, []);
|
|
70
|
+
}, [loggedInUsersAccount.isFetching]);
|
|
64
71
|
// To handle modal close
|
|
65
72
|
const onCloseModal = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
73
|
if (isFetchingUpdateHostnameDefault)
|
|
@@ -68,7 +75,7 @@ export const HostnameAwarenessModal = () => {
|
|
|
68
75
|
try {
|
|
69
76
|
const updatedCountValue = (originalViewedCountValue || 0) + 1;
|
|
70
77
|
updateShowHostnamesCount({ shownCount: updatedCountValue, doNotShow: doNotShowModal });
|
|
71
|
-
setIsModalOpen(
|
|
78
|
+
setIsModalOpen(false);
|
|
72
79
|
}
|
|
73
80
|
catch (error) {
|
|
74
81
|
console.log(error);
|
|
@@ -89,7 +96,6 @@ export const HostnameAwarenessModal = () => {
|
|
|
89
96
|
//for the checkbox
|
|
90
97
|
const onDoNotAskAgain = () => {
|
|
91
98
|
try {
|
|
92
|
-
setDoNotShowNotClicked(false);
|
|
93
99
|
setDoNotShowModal(1);
|
|
94
100
|
const updateObjValue = { shownCount: originalViewedCountValue, doNotShow: 1 };
|
|
95
101
|
updateShowHostnamesCount(updateObjValue);
|
|
@@ -109,24 +115,12 @@ export const HostnameAwarenessModal = () => {
|
|
|
109
115
|
React.createElement(InfoIcon, { className: "pf-v5-u-ml-sm hostnameInfoIcon" })),
|
|
110
116
|
isFetchingUpdateHostnameDefault && (React.createElement(Spinner, { size: "lg", className: "pf-v5-u-ml-sm hostnameSpinner", "aria-label": "Hostname loading" }))));
|
|
111
117
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
(doNotShowModal === 1 && doNotShowNotClicked)) {
|
|
121
|
-
return React.createElement(React.Fragment, null);
|
|
122
|
-
}
|
|
123
|
-
return (React.createElement(React.Fragment, null,
|
|
124
|
-
React.createElement(Modal, { variant: ModalVariant.medium, title: "Share hostnames with Red Hat?", isOpen: isModalOpen, onClose: onCloseModal, actions: [
|
|
125
|
-
React.createElement(Button, { "data-tracking-id": "close-hostname-modal", key: "close", variant: "primary", onClick: onCloseModal, isDisabled: isFetchingUpdateHostnameDefault }, "Close"),
|
|
126
|
-
React.createElement("div", { className: "dontAskCheckbox" },
|
|
127
|
-
React.createElement(Checkbox, { isChecked: !!doNotShowModal, label: "Don't ask me again", id: "dont-ask-again", "data-tracking-id": "dont-ask-again-hostname-modal", onChange: onDoNotAskAgain })),
|
|
128
|
-
] },
|
|
129
|
-
React.createElement("div", null,
|
|
130
|
-
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.")),
|
|
131
|
-
modalBody())));
|
|
118
|
+
return (React.createElement(Modal, { variant: ModalVariant.medium, title: "Share hostnames with Red Hat?", isOpen: isModalOpen, onClose: onCloseModal, actions: [
|
|
119
|
+
React.createElement(Button, { "data-tracking-id": "close-hostname-modal", key: "close", variant: "primary", onClick: onCloseModal, isDisabled: isFetchingUpdateHostnameDefault }, "Close"),
|
|
120
|
+
React.createElement("div", { className: "dontAskCheckbox" },
|
|
121
|
+
React.createElement(Checkbox, { isChecked: !!doNotShowModal, label: "Don't ask me again", id: "dont-ask-again", "data-tracking-id": "dont-ask-again-hostname-modal", onChange: onDoNotAskAgain })),
|
|
122
|
+
] },
|
|
123
|
+
React.createElement("div", null,
|
|
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.")),
|
|
125
|
+
modalBody()));
|
|
132
126
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/react-context",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.46",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"defaults and supports es6-module",
|
|
94
94
|
"maintained node versions"
|
|
95
95
|
],
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "0c9672e10ec1e2d97e7679a47cc9191f4b41d977"
|
|
97
97
|
}
|