@rh-support/react-context 0.2.54 → 0.2.55
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":"CloseCaseModal.d.ts","sourceRoot":"","sources":["../../../../src/components/SharedModals/CloseCaseModal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CloseCaseModal.d.ts","sourceRoot":"","sources":["../../../../src/components/SharedModals/CloseCaseModal.tsx"],"names":[],"mappings":"AAgBA,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,eA4J3C"}
|
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { Button, ButtonVariant, Form, FormGroup, Modal, ModalVariant, Select, SelectOption, TextArea, } from '@patternfly/react-core';
|
|
11
11
|
import ExclamationCircleIcon from '@patternfly/react-icons/dist/js/icons/exclamation-circle-icon';
|
|
12
|
+
import { isEmpty } from 'lodash';
|
|
12
13
|
import React, { useState } from 'react';
|
|
13
14
|
import { Trans, useTranslation } from 'react-i18next';
|
|
14
15
|
const resolutionsWithDescription = ['Other'];
|
|
@@ -22,7 +23,7 @@ export function CloseCaseModal(props) {
|
|
|
22
23
|
const { t } = useTranslation();
|
|
23
24
|
const [showTextArea, setShowTextArea] = useState(false);
|
|
24
25
|
const [selectedResolution, setSelectedResolution] = useState('');
|
|
25
|
-
const [
|
|
26
|
+
const [resolutionDescription, setResolutionDescription] = useState('');
|
|
26
27
|
const [showDropdown, setShowDropdown] = useState(false);
|
|
27
28
|
const onDropdownToggle = (toggle) => setShowDropdown(toggle);
|
|
28
29
|
const [showValidationError, setShowValidationError] = useState(false);
|
|
@@ -34,13 +35,13 @@ export function CloseCaseModal(props) {
|
|
|
34
35
|
onDropdownToggle(false);
|
|
35
36
|
};
|
|
36
37
|
const getCommentBody = () => {
|
|
37
|
-
return `**Reason for closing case:** \n${selectedResolution}${resolutionsWithDescription.includes(selectedResolution) ? `. ${
|
|
38
|
+
return `**Reason for closing case:** \n${selectedResolution}${resolutionsWithDescription.includes(selectedResolution) ? `. ${resolutionDescription}` : ''}`;
|
|
38
39
|
};
|
|
39
40
|
const checkForRequiredFields = () => {
|
|
40
41
|
let isValid = false;
|
|
41
42
|
if (selectedResolution) {
|
|
42
43
|
isValid = resolutionsWithDescription.includes(selectedResolution)
|
|
43
|
-
?
|
|
44
|
+
? resolutionDescription
|
|
44
45
|
? true
|
|
45
46
|
: false
|
|
46
47
|
: true;
|
|
@@ -57,8 +58,9 @@ export function CloseCaseModal(props) {
|
|
|
57
58
|
setShowValidationError(false);
|
|
58
59
|
setResolutionDescription(description);
|
|
59
60
|
};
|
|
61
|
+
const isResolutionDescEmpty = showTextArea && isEmpty(resolutionDescription === null || resolutionDescription === void 0 ? void 0 : resolutionDescription.trim());
|
|
60
62
|
return (React.createElement(Modal, { id: "case-close-modal", title: t(isCaseListPage ? 'Do you want to close the selected cases?' : 'Do you want to close this case?'), "aria-describedby": "case-close-modal", isOpen: true, onClose: props.onClose, showClose: true, actions: [
|
|
61
|
-
React.createElement(Button, { key: "submit-description", variant: ButtonVariant.primary, onClick: onSubmit, isLoading: props.isUpdating, isDisabled: showValidationError || props.isUpdating, "data-tracking-id": "close-case-description-modal-submit" },
|
|
63
|
+
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" },
|
|
62
64
|
React.createElement(Trans, null, "Close case")),
|
|
63
65
|
React.createElement(Button, { key: "close-modal", variant: ButtonVariant.secondary, onClick: props.onClose, isDisabled: props.isUpdating, "data-tracking-id": "close-case-description-modal-cancel" },
|
|
64
66
|
React.createElement(Trans, null, "Cancel")),
|
|
@@ -80,5 +82,5 @@ export function CloseCaseModal(props) {
|
|
|
80
82
|
React.createElement(Select, { "aria-label": t('Select an option that best fits'), id: "case-resolution", selections: selectedResolution, onSelect: onResolutionChange, isOpen: showDropdown, isDisabled: props.isUpdating, menuAppendTo: document.body, validated: showValidationError && !selectedResolution ? 'error' : 'default', placeholderText: t('Select an option that best fits'), onToggle: onDropdownToggle }, resolutionOptions.map((option, index) => (React.createElement(SelectOption, { key: index, value: option },
|
|
81
83
|
React.createElement(Trans, null, option)))))),
|
|
82
84
|
showTextArea && (React.createElement(FormGroup, { label: t('Please describe your resolution'), type: "text", isRequired: true, fieldId: "close-case-description" },
|
|
83
|
-
React.createElement(TextArea, { validated: showValidationError && !
|
|
85
|
+
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: onDescriptionChange, isDisabled: props.isUpdating }))))));
|
|
84
86
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/react-context",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.55",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@patternfly/react-core": "4.194.0",
|
|
47
47
|
"@patternfly/react-icons": "4.45.0",
|
|
48
48
|
"@rh-support/api": "0.3.13",
|
|
49
|
-
"@rh-support/components": "1.1.
|
|
49
|
+
"@rh-support/components": "1.1.55",
|
|
50
50
|
"@rh-support/types": "0.2.0",
|
|
51
51
|
"@rh-support/user-permissions": "0.2.44",
|
|
52
52
|
"@rh-support/utils": "0.2.33",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"not ie <= 11",
|
|
90
90
|
"not op_mini all"
|
|
91
91
|
],
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "a3df00d1fcf2e999400a0b17f5ac00f2a32d878d"
|
|
93
93
|
}
|