@rh-support/react-context 0.3.3 → 0.3.4

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,mBAkJlC,CAAC"}
1
+ {"version":3,"file":"HostnameAwarenessModal.d.ts","sourceRoot":"","sources":["../../../../src/components/HostnameAwarenessModal/HostnameAwarenessModal.tsx"],"names":[],"mappings":"AAAA,OAAO,8BAA8B,CAAC;AAatC,eAAO,MAAM,sBAAsB,mBA0JlC,CAAC"}
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import './hostnameAwarenessModal.css';
11
11
  import { accounts } from '@cee-eng/hydrajs';
12
- import { Button, Checkbox, Modal, ModalVariant, Switch, Tooltip } from '@patternfly/react-core';
12
+ import { Button, Checkbox, Modal, ModalVariant, Spinner, Switch, Tooltip } from '@patternfly/react-core';
13
13
  import InfoIcon from '@patternfly/react-icons/dist/js/icons/info-circle-icon';
14
14
  import { useFetch } from '@rh-support/components';
15
15
  import { ability, CaseListFields, resourceActions, resources } from '@rh-support/user-permissions';
@@ -27,6 +27,7 @@ export const HostnameAwarenessModal = () => {
27
27
  const [isHostnamesChecked, setisHostnamesChecked] = useState(false);
28
28
  //preserving initial state to disable modal load
29
29
  const [alreadyCheckedCloseModal, setAlreadyCheckedCloseModal] = useState(false);
30
+ const [isHostnamesLoading, setIsHostnamesLoading] = useState(true);
30
31
  const userOriginalHostnamesCount = () => __awaiter(void 0, void 0, void 0, function* () {
31
32
  try {
32
33
  const originalHostnameVisibilityObj = yield getHostnamesVisibilityObj();
@@ -47,6 +48,7 @@ export const HostnameAwarenessModal = () => {
47
48
  setisHostnamesChecked(fetchedHostnameStatus.shareHostnameWithRHT);
48
49
  // This is needed so we preserve initial state we do not close modal upon updating names.
49
50
  setAlreadyCheckedCloseModal(fetchedHostnameStatus.shareHostnameWithRHT);
51
+ setIsHostnamesLoading(false);
50
52
  });
51
53
  useEffect(() => {
52
54
  userOriginalHostnamesCount();
@@ -66,12 +68,14 @@ export const HostnameAwarenessModal = () => {
66
68
  // for hostnames swich
67
69
  const onHostnameSwitchChange = () => __awaiter(void 0, void 0, void 0, function* () {
68
70
  try {
71
+ setIsHostnamesLoading(true);
69
72
  yield updateHostnameDefault(!isHostnamesChecked, accountNumber);
70
73
  setisHostnamesChecked(!isHostnamesChecked);
71
74
  }
72
75
  catch (error) {
73
76
  console.log(error);
74
77
  }
78
+ setIsHostnamesLoading(false);
75
79
  });
76
80
  //for the checkbox
77
81
  const onDoNotAskAgain = () => {
@@ -91,7 +95,8 @@ export const HostnameAwarenessModal = () => {
91
95
  return (React.createElement(React.Fragment, null,
92
96
  React.createElement(Switch, { label: "Share hostnames", isChecked: isHostnamesChecked, onChange: onHostnameSwitchChange, className: "push-top-narrow" }),
93
97
  React.createElement(Tooltip, { content: shareHostnamesClarificationCopy, position: "right" },
94
- React.createElement(InfoIcon, { className: "pf-u-ml-sm hostnameInfoIcon" }))));
98
+ React.createElement(InfoIcon, { className: "pf-u-ml-sm hostnameInfoIcon" })),
99
+ isHostnamesLoading && (React.createElement(Spinner, { isSVG: true, size: "lg", className: "pf-u-ml-sm hostnameSpinner", "aria-label": "Hostname loading" }))));
95
100
  };
96
101
  //Do not show modal if user cannot share hostnames.
97
102
  const canUseHostName = ability.can(resourceActions.PATCH, resources.CASE_CREATE, CaseListFields.HOSTNAME);
@@ -6,3 +6,7 @@ svg.hostnameInfoIcon {
6
6
  vertical-align: -0.65rem !important;
7
7
  margin-left: -0.1rem !important;
8
8
  }
9
+
10
+ svg.hostnameSpinner {
11
+ vertical-align: -0.65rem !important;
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/react-context",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
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": "8ad6dda321ad690b179be7346240345a57f1749b"
90
+ "gitHead": "cd70b3e8d05162414bc78e541020c3de692d892b"
91
91
  }