@rh-support/react-context 2.5.325 → 2.6.10

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,10 +1,10 @@
1
1
  import './CloseCaseModal.scss';
2
2
  import React from 'react';
3
3
  interface IProps {
4
- onConfirm: (commentBody: string) => void;
4
+ onConfirm: (commentBody: string) => Promise<boolean> | boolean;
5
5
  onClose: () => void;
6
6
  caseNumber?: string;
7
- isUpdating: boolean;
7
+ isUpdating?: boolean;
8
8
  }
9
9
  export declare function CloseCaseModal(props: IProps): React.JSX.Element;
10
10
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"CloseCaseModal.d.ts","sourceRoot":"","sources":["../../../../src/components/SharedModals/CloseCaseModal.tsx"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAoB/B,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,UAAU,MAAM;IACZ,SAAS,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;CACvB;AAUD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,qBAkL3C"}
1
+ {"version":3,"file":"CloseCaseModal.d.ts","sourceRoot":"","sources":["../../../../src/components/SharedModals/CloseCaseModal.tsx"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAoB/B,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,UAAU,MAAM;IACZ,SAAS,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAC/D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAUD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,qBAkM3C"}
@@ -24,10 +24,17 @@ const resolutionOptions = [...resolutionWithoutDescription, ...resolutionsWithDe
24
24
  export function CloseCaseModal(props) {
25
25
  const { t } = useTranslation();
26
26
  const [showTextArea, setShowTextArea] = useState(false);
27
+ const [isSubmitting, setIsSubmitting] = useState(false);
27
28
  const [selectedResolution, setSelectedResolution] = useState('');
28
29
  const [resolutionDescription, setResolutionDescription] = useState('');
29
30
  const [showValidationError, setShowValidationError] = useState(false);
30
31
  const isCaseListPage = !props.caseNumber;
32
+ const isBusy = isSubmitting || !!props.isUpdating;
33
+ const handleClose = () => {
34
+ if (!isBusy) {
35
+ props.onClose();
36
+ }
37
+ };
31
38
  const onResolutionChange = (option) => {
32
39
  setSelectedResolution(option.value);
33
40
  setShowValidationError(false);
@@ -52,7 +59,16 @@ export function CloseCaseModal(props) {
52
59
  const onSubmit = () => __awaiter(this, void 0, void 0, function* () {
53
60
  if (!checkForRequiredFields())
54
61
  return;
55
- props.onConfirm(getCommentBody());
62
+ setIsSubmitting(true);
63
+ try {
64
+ const result = yield props.onConfirm(getCommentBody());
65
+ if (result) {
66
+ props.onClose();
67
+ }
68
+ }
69
+ finally {
70
+ setIsSubmitting(false);
71
+ }
56
72
  });
57
73
  const onDescriptionChange = (description) => {
58
74
  setShowValidationError(false);
@@ -67,7 +83,7 @@ export function CloseCaseModal(props) {
67
83
  label: t(selectedResolution),
68
84
  value: t(selectedResolution),
69
85
  };
70
- return (React.createElement(Modal, { id: "case-close-modal", "aria-describedby": "case-close-modal", isOpen: true, onClose: props.onClose, variant: ModalVariant.medium },
86
+ return (React.createElement(Modal, { id: "case-close-modal", "aria-describedby": "case-close-modal", isOpen: true, onClose: handleClose, variant: ModalVariant.medium },
71
87
  React.createElement(ModalHeader, null,
72
88
  React.createElement("h2", null,
73
89
  isCaseListPage && React.createElement(Trans, null, "Do you want to close the selected cases?"),
@@ -93,12 +109,12 @@ export function CloseCaseModal(props) {
93
109
  React.createElement(Trans, null, "All of the selected cases will have the same resolution in bulk edit."))),
94
110
  showValidationError && !selectedResolution && (React.createElement(HelperTextItem, { variant: "error" },
95
111
  React.createElement(Trans, null, "Required field"))))),
96
- React.createElement(SingleSelectDropdown, { placeholder: t('Select an option that best fits'), dataTrackingId: "case-resolution", options: getDropdownOptions, selected: getSelectedDropdownOption, isDisabled: props.isUpdating, isInvalid: showValidationError && !selectedResolution, onSelect: onResolutionChange })),
112
+ React.createElement(SingleSelectDropdown, { placeholder: t('Select an option that best fits'), dataTrackingId: "case-resolution", options: getDropdownOptions, selected: getSelectedDropdownOption, isDisabled: isBusy, isInvalid: showValidationError && !selectedResolution, onSelect: onResolutionChange })),
97
113
  showTextArea && (React.createElement(FormGroup, { label: t('Please describe your resolution'), type: "text", isRequired: true, fieldId: "close-case-description" },
98
- React.createElement(TextArea, { validated: showValidationError && !resolutionDescription ? 'error' : 'default', isRequired: true, id: "close-case-description", name: "close-case-description", "aria-describedby": "close-case-description", value: resolutionDescription, placeholder: t('Please describe your resolution to help us better understand.'), onChange: (_event, description) => onDescriptionChange(description), isDisabled: props.isUpdating, resizeOrientation: "vertical" }))))),
114
+ React.createElement(TextArea, { validated: showValidationError && !resolutionDescription ? 'error' : 'default', isRequired: true, id: "close-case-description", name: "close-case-description", "aria-describedby": "close-case-description", value: resolutionDescription, placeholder: t('Please describe your resolution to help us better understand.'), onChange: (_event, description) => onDescriptionChange(description), isDisabled: isBusy, resizeOrientation: "vertical" }))))),
99
115
  React.createElement(ModalFooter, null,
100
- React.createElement(Button, { key: "submit-description", variant: ButtonVariant.primary, onClick: onSubmit, isLoading: props.isUpdating, isDisabled: isResolutionDescEmpty || showValidationError || props.isUpdating, "data-tracking-id": "close-case-description-modal-submit" },
116
+ React.createElement(Button, { key: "submit-description", variant: ButtonVariant.primary, onClick: onSubmit, isLoading: isBusy, isDisabled: isResolutionDescEmpty || showValidationError || isBusy, "data-tracking-id": "close-case-description-modal-submit" },
101
117
  React.createElement(Trans, null, "Close case")),
102
- React.createElement(Button, { key: "close-modal", variant: ButtonVariant.secondary, onClick: props.onClose, isDisabled: props.isUpdating, "data-tracking-id": "close-case-description-modal-cancel" },
118
+ React.createElement(Button, { key: "close-modal", variant: ButtonVariant.secondary, onClick: handleClose, isDisabled: isBusy, "data-tracking-id": "close-case-description-modal-cancel" },
103
119
  React.createElement(Trans, null, "Cancel")))));
104
120
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useCanEditCase.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCanEditCase.ts"],"names":[],"mappings":"AAQA,wBAAgB,cAAc,CAAC,kBAAkB,CAAC,EAAE,MAAM;;;;EA0BzD"}
1
+ {"version":3,"file":"useCanEditCase.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCanEditCase.ts"],"names":[],"mappings":"AAMA,wBAAgB,cAAc,CAAC,kBAAkB,CAAC,EAAE,MAAM;;;;EAYzD"}
@@ -1,24 +1,14 @@
1
- import { ToastNotification } from '@rh-support/components';
2
1
  import { isCaseArchivedStatus } from '@rh-support/utils';
3
2
  import { useContext } from 'react';
4
- import { useTranslation } from 'react-i18next';
5
3
  import { CaseStatusContext } from '../context/CaseStatusContext';
6
4
  import { useSubscriptionAbused } from './useSubscriptionAbused';
7
5
  export function useCanEditCase(caseStatusOverride) {
8
- const { t } = useTranslation();
9
6
  const contextCaseStatus = useContext(CaseStatusContext);
10
7
  const caseStatus = caseStatusOverride !== null && caseStatusOverride !== void 0 ? caseStatusOverride : contextCaseStatus;
11
8
  const { checkAndShowSubscriptionAbused, isAccountFreezed } = useSubscriptionAbused();
12
9
  const isCaseArchived = isCaseArchivedStatus(caseStatus);
13
- const alert = () => {
14
- if (isCaseArchived) {
15
- ToastNotification.addInfoMessage(t('This case has been archived and can no longer be updated. Contact us or open a new case if you need further assistance.'));
16
- return true;
17
- }
18
- return checkAndShowSubscriptionAbused();
19
- };
20
10
  return {
21
- alert,
11
+ alert: checkAndShowSubscriptionAbused,
22
12
  isCaseNotEditable: isAccountFreezed || isCaseArchived,
23
13
  isCaseArchived,
24
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useChatInit.d.ts","sourceRoot":"","sources":["../../../src/hooks/useChatInit.ts"],"names":[],"mappings":"AAMA,UAAU,YAAY;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,uBAAuB,EAAE,OAAO,CAAC;IACjC,kBAAkB,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,QAAO,YAsE9B,CAAC"}
1
+ {"version":3,"file":"useChatInit.d.ts","sourceRoot":"","sources":["../../../src/hooks/useChatInit.ts"],"names":[],"mappings":"AAMA,UAAU,YAAY;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,uBAAuB,EAAE,OAAO,CAAC;IACjC,kBAAkB,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,QAAO,YAuE9B,CAAC"}
@@ -33,6 +33,7 @@ export const useChatInit = () => {
33
33
  return;
34
34
  }
35
35
  const onMessagingReady = () => {
36
+ window.embeddedservice_bootstrap.userVerificationAPI.clearSession(true);
36
37
  window.embeddedservice_bootstrap.prechatAPI.setHiddenPrechatFields({
37
38
  username: ssoNameRef.current,
38
39
  fullName: fullNameRef.current,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/react-context",
3
- "version": "2.5.325",
3
+ "version": "2.6.10",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -37,10 +37,10 @@
37
37
  "@cee-eng/hydrajs": "^4.18.114",
38
38
  "@patternfly/react-core": "6.2.1",
39
39
  "@patternfly/react-icons": "6.2.1",
40
- "@rh-support/components": "2.5.230",
40
+ "@rh-support/components": "2.6.10",
41
41
  "@rh-support/types": "2.0.26",
42
- "@rh-support/user-permissions": "2.5.178",
43
- "@rh-support/utils": "2.5.157",
42
+ "@rh-support/user-permissions": "2.5.170",
43
+ "@rh-support/utils": "2.5.149",
44
44
  "i18next": "^23.15.0",
45
45
  "localforage": "^1.10.0",
46
46
  "lodash": "^4.17.21",
@@ -92,5 +92,5 @@
92
92
  "defaults and supports es6-module",
93
93
  "maintained node versions"
94
94
  ],
95
- "gitHead": "78790ed8b35b8acbc7a3a4a182d212499a0cd181"
95
+ "gitHead": "3f16770cee04217483b234f6d8dceaced57a0695"
96
96
  }