@rh-support/react-context 2.1.44 → 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":"AccountSelectorInternal.d.ts","sourceRoot":"","sources":["../../../../src/components/AccountSelector/AccountSelectorInternal.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAgBhF,OAAO,EAAE,kBAAkB,EAA8B,MAAM,wBAAwB,CAAC;AAKxF,OAAO,KAA+C,MAAM,OAAO,CAAC;AAGpE,UAAU,MAAO,SAAQ,kBAAkB,CAAC,QAAQ,CAAC;IACjD,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC9B,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC7B,kBAAkB,CAAC,EAAE,QAAQ,EAAE,CAAC;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,GAAG,CAAC;IACzC,iBAAiB,CAAC,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6BAA6B,CAAC,EAAE,OAAO,CAAC;CAC3C;AAkCD,iBAAS,uBAAuB,CAAC,KAAK,EAAE,MAAM,qBAmS7C;kBAnSQ,uBAAuB;;;AAsShC,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
1
+ {"version":3,"file":"AccountSelectorInternal.d.ts","sourceRoot":"","sources":["../../../../src/components/AccountSelector/AccountSelectorInternal.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAgBhF,OAAO,EAAE,kBAAkB,EAA8B,MAAM,wBAAwB,CAAC;AAKxF,OAAO,KAA+C,MAAM,OAAO,CAAC;AAGpE,UAAU,MAAO,SAAQ,kBAAkB,CAAC,QAAQ,CAAC;IACjD,gBAAgB,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC9B,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC7B,kBAAkB,CAAC,EAAE,QAAQ,EAAE,CAAC;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,GAAG,CAAC;IACzC,iBAAiB,CAAC,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6BAA6B,CAAC,EAAE,OAAO,CAAC;CAC3C;AAkCD,iBAAS,uBAAuB,CAAC,KAAK,EAAE,MAAM,qBAqS7C;kBArSQ,uBAAuB;;;AAwShC,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -243,7 +243,7 @@ function AccountSelectorInternal(props) {
243
243
  };
244
244
  const toggle = (toggleRef) => (React.createElement(MenuToggle, { innerRef: toggleRef, variant: "typeahead", onClick: onToggleClick, isExpanded: isOpen, isFullWidth: true, isDisabled: props.disabled },
245
245
  React.createElement(TextInputGroup, { isPlain: true, innerRef: inputGroupRef },
246
- React.createElement(TextInputGroupMain, { value: query, onClick: onToggleClick, onKeyDown: onInputKeyDown, onChange: onFilter, placeholder: t(props.placeholder || ''), isExpanded: isOpen, innerRef: textInputRef, "aria-controls": `select${props.multiple ? '-multi' : ''}-typeahead-listbox` }),
246
+ React.createElement(TextInputGroupMain, { value: query, role: "combobox", onClick: onToggleClick, onKeyDown: onInputKeyDown, onChange: onFilter, placeholder: t(props.placeholder || ''), isExpanded: isOpen, innerRef: textInputRef, "aria-label": `select${props.multiple ? ' multi' : ''} typeahead listbox`, "aria-controls": "account-selector-dropdown" }),
247
247
  React.createElement(TextInputGroupUtilities, null, !isEmpty(query) && (React.createElement(Button, { variant: "plain", onClick: onClearSelection, isDisabled: isFetching, "aria-label": t('Clear') }, isFetching ? React.createElement(LoadingIndicator, { show: true, size: "sm" }) : React.createElement(TimesCircleIcon, { "aria-hidden": true })))))));
248
248
  return (React.createElement(Select, { "data-tracking-id": "account-selector-dropdown", isOpen: isOpen, onOpenChange: () => setIsOpen(false), id: props.id, toggle: toggle, popperProps: { direction: 'down', enableFlip: false }, onSelect: (_e, v) => onSelect(v), selected: selectedItems, isScrollable: true },
249
249
  React.createElement(SelectList, null, dropdownOptions)));
@@ -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,yBA2KlC,CAAC"}
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 [doNotShowNotClicked, setDoNotShowNotClicked] = useState(true);
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
- setIsLoadingHostnamesVisibilityObj(false);
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, _b;
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
- userOriginalHostnamesCount();
61
- userOriginalHostnameValue();
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(!isModalOpen);
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
- //Do not show modal if user cannot share hostnames.
113
- const canUseHostName = ability.can(resourceActions.PATCH, resources.CASE_CREATE, CaseListFields.HOSTNAME);
114
- //Do not show modal if user is already sharing hostnames, has seen the modal more than twice, or opted to not show it again
115
- if (loggedInUsersAccount.isFetching ||
116
- isLoadingHostnamesVisibilityObj ||
117
- !canUseHostName ||
118
- alreadyCheckedCloseModal ||
119
- originalViewedCountValue > 2 ||
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.44",
3
+ "version": "2.1.46",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -40,7 +40,7 @@
40
40
  "@cee-eng/hydrajs": "4.17.3",
41
41
  "@patternfly/react-core": "5.1.1",
42
42
  "@patternfly/react-icons": "5.1.1",
43
- "@rh-support/components": "2.1.41",
43
+ "@rh-support/components": "2.1.42",
44
44
  "@rh-support/types": "2.0.3",
45
45
  "@rh-support/user-permissions": "2.1.30",
46
46
  "@rh-support/utils": "2.1.22",
@@ -93,5 +93,5 @@
93
93
  "defaults and supports es6-module",
94
94
  "maintained node versions"
95
95
  ],
96
- "gitHead": "1507b066b04853fb74cbd1fcac022dbcc94c0ec3"
96
+ "gitHead": "0c9672e10ec1e2d97e7679a47cc9191f4b41d977"
97
97
  }