@rh-support/troubleshoot 0.2.125 → 0.2.126

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":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/CaseEditView/CaseOverview/index.tsx"],"names":[],"mappings":"AAyCA,UAAU,MAAM;IACZ,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,MAAM,eA+ejD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/CaseEditView/CaseOverview/index.tsx"],"names":[],"mappings":"AAyCA,UAAU,MAAM;IACZ,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,MAAM,eAgfjD"}
@@ -281,7 +281,7 @@ export default function CaseOverview(props) {
281
281
  React.createElement("div", { className: "form-wrapper" },
282
282
  React.createElement(CaseType, { selectedType: caseType, onTypeChange: onTypeChange, isDisabled: !canManageCase || allCaseTypes.isFetching, allTypes: allCaseTypes.data, isFetching: caseOverviewState.caseTypeUpdating && isCaseUpdating, hasError: allCaseTypes.isError })),
283
283
  React.createElement("div", { className: "form-wrapper" },
284
- React.createElement(Severity, { onSeverityChange: onSeverityChange, isDisabled: !canManageCase, isFetching: caseOverviewState.caseSeverityUpdating && isCaseUpdating })))),
284
+ React.createElement(Severity, { onCaseDetailsPage: true, onSeverityChange: onSeverityChange, isDisabled: !canManageCase, isFetching: caseOverviewState.caseSeverityUpdating && isCaseUpdating })))),
285
285
  React.createElement(ExpandableSection, { className: "case-details-main", toggleText: t('Case information'), isExpanded: isDetailsExpanded, onToggle: onToggleDetails },
286
286
  React.createElement(CaseInformation, null))),
287
287
  showCloseCaseModal && (React.createElement(CloseCaseModal, { onConfirm: (commentBody) => __awaiter(this, void 0, void 0, function* () {
@@ -5,6 +5,7 @@ interface IProps extends IDClassNameProps {
5
5
  isFetching?: boolean;
6
6
  onSeverityChange: (casePayload: Partial<ICasePayload>) => void;
7
7
  showSeverityInfoIcon: boolean;
8
+ onCaseDetailsPage?: boolean;
8
9
  }
9
10
  export interface ISeverityOptions {
10
11
  disabled: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"Severity.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseInformation/Severity.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAKvE,OAAO,EAAE,gBAAgB,EAAW,MAAM,0BAA0B,CAAC;AAsBrE,UAAU,MAAO,SAAQ,gBAAgB;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IAC/D,oBAAoB,EAAE,OAAO,CAAC;CACjC;AASD,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,GAAG,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;CACxD;AAED,iBAAS,QAAQ,CAAC,KAAK,EAAE,MAAM,eA4N9B;kBA5NQ,QAAQ;;;AA8NjB,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"Severity.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseInformation/Severity.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAKvE,OAAO,EAAE,gBAAgB,EAAW,MAAM,0BAA0B,CAAC;AAuBrE,UAAU,MAAO,SAAQ,gBAAgB;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IAC/D,oBAAoB,EAAE,OAAO,CAAC;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AASD,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,GAAG,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;CACxD;AAED,iBAAS,QAAQ,CAAC,KAAK,EAAE,MAAM,eAyQ9B;kBAzQQ,QAAQ;;;AA2QjB,eAAe,QAAQ,CAAC"}
@@ -15,6 +15,7 @@ import { useCaseSelector } from '../../context/CaseContext';
15
15
  import { getIrtForSLAAndSeverity, getOrtForSLAAndSeverity, getSeverityDescription } from '../../reducers/CaseHelpers';
16
16
  import { CaseValuesToWatch } from '../shared/Constants';
17
17
  import { getChangedValueTooltip } from '../shared/utils';
18
+ import UpdateSeverityModal from '../UpdateSeverityModal/UpdateSeverityModal';
18
19
  const defaultProps = {
19
20
  id: '',
20
21
  className: '',
@@ -36,6 +37,7 @@ function Severity(props) {
36
37
  const [isSeverityInValid, setIsSeverityInValid] = useState(false);
37
38
  const [seviritiesOptions, setSeveritiesOptions] = useState([]);
38
39
  const [doNotShowIRT, setDoNotShowIRT] = useState(false);
40
+ const [openUpdateSeverityModal, setOpenUpdateSeverityModal] = useState(false);
39
41
  const updateState = (value) => {
40
42
  const casePayload = { severity: value };
41
43
  // .. change fts on sev change only while creating case or wchen we change to sev1
@@ -104,6 +106,9 @@ function Severity(props) {
104
106
  label: `${severity} - ${getSeverityDescription(severity)}`,
105
107
  additionalInfo: getAdditionalInfo(slaLocal, severity),
106
108
  };
109
+ const toggleModal = () => {
110
+ setOpenUpdateSeverityModal((openUpdateSeverityModal) => !openUpdateSeverityModal);
111
+ };
107
112
  useEffect(() => {
108
113
  var _a, _b, _c;
109
114
  if (!product ||
@@ -149,7 +154,24 @@ function Severity(props) {
149
154
  "\u00A0",
150
155
  filteredSeverities.filter((s) => s.disabled).length !== 0 && (React.createElement(Tooltip, { position: TooltipPosition.top, content: React.createElement(Trans, null, "Only the enabled severity levels are supported for selected product and version.") },
151
156
  React.createElement(WarningTriangleIcon, { color: "#ec7a08", size: "sm", title: "Support Severity Level warning" })))),
152
- React.createElement(Dropdown, { name: "open-case-severity", placeholder: t(`Select a severity`), title: t(`Select a severity`), list: allCaseSeverities.data
157
+ props.onCaseDetailsPage === true ? (React.createElement(React.Fragment, null,
158
+ React.createElement("div", { onClick: toggleModal },
159
+ React.createElement(Dropdown, { name: "open-case-severity", placeholder: t(`Select a severity`), title: t(`Select a severity`), list: allCaseSeverities.data
160
+ ? toOptions(filteredSeverities, {
161
+ labelKey: 'label',
162
+ additionalInfoKey: 'additionalInfo',
163
+ disabledKey: 'disabled',
164
+ })
165
+ : [], selectedItem: toOption(selectedSeverity, {
166
+ labelKey: 'label',
167
+ additionalInfoKey: 'additionalInfo',
168
+ disabledKey: 'disabled',
169
+ }), disabled: allCaseSeverities.isError ||
170
+ props.isDisabled ||
171
+ allCaseSeverities.isFetching ||
172
+ ownersEntitlements.isFetching ||
173
+ versionsDetails.isFetching, isLoadingList: props.isFetching || versionsDetails.isFetching, isInValid: allCaseSeverities.isError || isSeverityInValid, required: true, onChange: onSeverityChange, onOuterClick: setIsSeverityInValidLocal, "data-tracking-id": "open-case-severity" })),
174
+ React.createElement(UpdateSeverityModal, { show: openUpdateSeverityModal, onClose: toggleModal }))) : (React.createElement(Dropdown, { name: "open-case-severity", placeholder: t(`Select a severity`), title: t(`Select a severity`), list: allCaseSeverities.data
153
175
  ? toOptions(filteredSeverities, {
154
176
  labelKey: 'label',
155
177
  additionalInfoKey: 'additionalInfo',
@@ -163,7 +185,7 @@ function Severity(props) {
163
185
  props.isDisabled ||
164
186
  allCaseSeverities.isFetching ||
165
187
  ownersEntitlements.isFetching ||
166
- versionsDetails.isFetching, isLoadingList: props.isFetching || versionsDetails.isFetching, isInValid: allCaseSeverities.isError || isSeverityInValid, required: true, onChange: onSeverityChange, onOuterClick: setIsSeverityInValidLocal, "data-tracking-id": "open-case-severity" })));
188
+ versionsDetails.isFetching, isLoadingList: props.isFetching || versionsDetails.isFetching, isInValid: allCaseSeverities.isError || isSeverityInValid, required: true, onChange: onSeverityChange, onOuterClick: setIsSeverityInValidLocal, "data-tracking-id": "open-case-severity" }))));
167
189
  }
168
190
  Severity.defaultProps = defaultProps;
169
191
  export default Severity;
@@ -0,0 +1,7 @@
1
+ interface IProps {
2
+ show: boolean;
3
+ onClose: () => void;
4
+ }
5
+ export default function UpdateSeverityModal(props: IProps): JSX.Element;
6
+ export {};
7
+ //# sourceMappingURL=UpdateSeverityModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UpdateSeverityModal.d.ts","sourceRoot":"","sources":["../../../../src/components/UpdateSeverityModal/UpdateSeverityModal.tsx"],"names":[],"mappings":"AA0BA,UAAU,MAAM;IACZ,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,KAAK,EAAE,MAAM,eA8NxD"}
@@ -0,0 +1,170 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { publicApi } from '@cee-eng/hydrajs';
11
+ import { Button, Modal, TextArea } from '@patternfly/react-core';
12
+ import { ToastNotification, useFetch } from '@rh-support/components';
13
+ import { GlobalMetadataStateContext, useCanEditCase } from '@rh-support/react-context';
14
+ import { ability, resourceActions, resources } from '@rh-support/user-permissions';
15
+ import isEmpty from 'lodash/isEmpty';
16
+ import isEqual from 'lodash/isEqual';
17
+ import React, { useContext, useReducer, useState } from 'react';
18
+ import { Trans, useTranslation } from 'react-i18next';
19
+ import { useCaseDispatch, useCaseSelector } from '../../context/CaseContext';
20
+ import { useCaseDetailsPageStateContext } from '../../context/CaseDetailsPageContext';
21
+ import { useCaseDiscussionTabDispatchContext, useCaseDiscussionTabStateContext, } from '../../context/CaseDiscussionTabContext';
22
+ import { updateDiscussionStateComments } from '../../reducers/CaseDiscussionTabReducer';
23
+ import { caseOverviewReducer, initialCaseViewState, setSeverityUpdating } from '../../reducers/CaseOverviewReducer';
24
+ import { checkForCaseStatusToggleOnAttachOrComment, setCaseDetails, updateCaseDetails, } from '../../reducers/CaseReducer';
25
+ import Severity from '../CaseInformation/Severity';
26
+ export default function UpdateSeverityModal(props) {
27
+ const { show, onClose } = props;
28
+ const { t } = useTranslation();
29
+ const [descriptionValue, setDescriptionValue] = useState('');
30
+ const [caseOverviewState, caseOverviewDispatch] = useReducer(caseOverviewReducer, initialCaseViewState);
31
+ const canManageCase = ability.can(resourceActions.UPDATE, resources.CASE_DETAILS);
32
+ const caseDispatch = useCaseDispatch();
33
+ const canEditCase = useCanEditCase();
34
+ const [updatedSeverity, setUpdatedSeverity] = useState();
35
+ const [newSeverityValue, setNewSeverityValue] = useState([]);
36
+ const { request: postCommentRequest, isFetching: isPostingComment } = useFetch(publicApi.kase.postComment, {
37
+ propgateErrors: true,
38
+ });
39
+ const { caseDetailsPageState: { caseFeedbacksHydra }, } = useCaseDetailsPageStateContext();
40
+ const dispatchDiscussion = useCaseDiscussionTabDispatchContext();
41
+ const { sort, allDiscussions, discussionFiltersListState } = useCaseDiscussionTabStateContext();
42
+ const { globalMetadataState: { loggedInUserRights }, } = useContext(GlobalMetadataStateContext);
43
+ const caseState = useCaseSelector((state) => ({
44
+ caseDetails: {
45
+ caseNumber: state.caseDetails.caseNumber,
46
+ caseSeverity: state.caseDetails.severity,
47
+ },
48
+ isCaseUpdating: state.isCaseUpdating,
49
+ }), isEqual);
50
+ const { caseDetails, isCaseUpdating } = caseState;
51
+ const [currentSeverity, setCurrentSeverity] = useState(caseDetails.caseSeverity);
52
+ // Modal cancel function which resets the field
53
+ const onCancel = () => {
54
+ onClose();
55
+ setSeverityUpdating(caseOverviewDispatch, false);
56
+ setCaseDetails(caseDispatch, { severity: currentSeverity });
57
+ setDescriptionValue('');
58
+ };
59
+ // To handle description change
60
+ const handleTextAreaChange = (value) => {
61
+ setDescriptionValue(value);
62
+ };
63
+ const onSubmit = () => __awaiter(this, void 0, void 0, function* () {
64
+ // Severity update successful comment body
65
+ const severityUpdateComment = t('#### Severity update \n Severity changed from {{oldSeverity}} to {{newSeverity}}\n\n #### Description \n{{description}}', {
66
+ oldSeverity: currentSeverity,
67
+ newSeverity: newSeverityValue,
68
+ description: descriptionValue === null || descriptionValue === void 0 ? void 0 : descriptionValue.trim(),
69
+ });
70
+ // Severity update failed comment body
71
+ const severityUpdateFailedComment = t('#### Severity update \n Failed to change severity from {{oldSeverity}} to {{newSeverity}}\n\n #### Description \n{{description}}', {
72
+ oldSeverity: currentSeverity,
73
+ newSeverity: newSeverityValue,
74
+ description: descriptionValue === null || descriptionValue === void 0 ? void 0 : descriptionValue.trim(),
75
+ });
76
+ try {
77
+ setSeverityUpdating(caseOverviewDispatch, true);
78
+ yield updateCaseDetails(caseDispatch, caseDetails.caseNumber, updatedSeverity);
79
+ try {
80
+ yield postCommentRequest({
81
+ caseNumber: caseDetails.caseNumber,
82
+ commentBody: severityUpdateComment === null || severityUpdateComment === void 0 ? void 0 : severityUpdateComment.trim(),
83
+ contentType: 'markdown',
84
+ });
85
+ try {
86
+ yield checkForCaseStatusToggleOnAttachOrComment(caseDispatch, loggedInUserRights.data.isInternal(), caseDetails.caseSeverity);
87
+ ToastNotification.addSuccessMessage(t('Severity has been successfully updated'));
88
+ setCurrentSeverity(newSeverityValue);
89
+ onCancel();
90
+ }
91
+ catch (e) {
92
+ yield updateCaseDetails(caseDispatch, caseDetails.caseNumber, {
93
+ severity: currentSeverity,
94
+ });
95
+ yield postCommentRequest({
96
+ caseNumber: caseDetails.caseNumber,
97
+ commentBody: severityUpdateFailedComment === null || severityUpdateFailedComment === void 0 ? void 0 : severityUpdateFailedComment.trim(),
98
+ contentType: 'markdown',
99
+ });
100
+ ToastNotification.addDangerMessage(t(`Failed to check case status. Please try again.`));
101
+ }
102
+ }
103
+ catch (e) {
104
+ yield updateCaseDetails(caseDispatch, caseDetails.caseNumber, {
105
+ severity: currentSeverity,
106
+ });
107
+ ToastNotification.addDangerMessage(t(`Couldn't post severity update comment. Please try again.`));
108
+ }
109
+ }
110
+ catch (e) {
111
+ setSeverityUpdating(caseOverviewDispatch, false);
112
+ ToastNotification.addDangerMessage(t('Severity failed to update'));
113
+ onCancel();
114
+ }
115
+ finally {
116
+ yield updateDiscussionStateComments(dispatchDiscussion, caseDetails.caseNumber, allDiscussions, sort, caseFeedbacksHydra.data, discussionFiltersListState);
117
+ }
118
+ });
119
+ // To check if description is valid
120
+ const isTextAreaValid = () => {
121
+ if (isEmpty(descriptionValue === null || descriptionValue === void 0 ? void 0 : descriptionValue.trim())) {
122
+ return true;
123
+ }
124
+ else
125
+ return false;
126
+ };
127
+ // To compare previous and current severity values
128
+ const checkSeverity = () => {
129
+ const checkForUndefined = newSeverityValue['severity'] === undefined;
130
+ if (isEqual(currentSeverity, newSeverityValue['severity'])) {
131
+ return false;
132
+ }
133
+ else if (checkForUndefined) {
134
+ return false;
135
+ }
136
+ else {
137
+ return true;
138
+ }
139
+ };
140
+ // To disable submit button wrt above conditions
141
+ const isSubmitButtonDisabled = isTextAreaValid() || checkSeverity() ? true : false;
142
+ // Update severity modal buttons
143
+ const modalActions = [
144
+ React.createElement(Button, { key: "submit", variant: "primary", onClick: onSubmit, isLoading: isCaseUpdating || isPostingComment, "data-tracking-id": "update-severity-submit", isDisabled: isSubmitButtonDisabled }, t('Submit')),
145
+ React.createElement(Button, { key: "back", variant: "link", onClick: onCancel, "data-tracking-id": "update-severity-cancel" }, t('Cancel')),
146
+ ];
147
+ // To handle severity change in the modal
148
+ const onSeverityChange = (payload) => __awaiter(this, void 0, void 0, function* () {
149
+ if (canEditCase.alert())
150
+ return;
151
+ yield setUpdatedSeverity(payload);
152
+ yield setNewSeverityValue(payload['severity']);
153
+ setCaseDetails(caseDispatch, payload);
154
+ });
155
+ // Returns the modal body with its contents
156
+ const modalBody = () => {
157
+ return (React.createElement(React.Fragment, null,
158
+ React.createElement("form", { "aria-label": t('form') },
159
+ React.createElement("div", { className: "form-group pf-u-mt-xs" },
160
+ React.createElement("div", null,
161
+ React.createElement(Severity, { onCaseDetailsPage: false, onSeverityChange: onSeverityChange, isDisabled: !canManageCase && isCaseUpdating, isFetching: (caseOverviewState.caseSeverityUpdating && isCaseUpdating) || isPostingComment })),
162
+ React.createElement("div", null,
163
+ React.createElement("label", { htmlFor: "date-input", className: "pf-u-mt-md" },
164
+ React.createElement(Trans, null, "Describe update"),
165
+ React.createElement("span", { className: "form-required", "aria-hidden": "true" }, "*")),
166
+ React.createElement(TextArea, { placeholder: "Please identify any changes in the case's business impact", isDisabled: (caseOverviewState.caseSeverityUpdating && isCaseUpdating) || isPostingComment, value: descriptionValue, onChange: handleTextAreaChange, resizeOrientation: "vertical", "aria-label": "summary", isRequired: true }))))));
167
+ };
168
+ // Main modal and its headings
169
+ return (React.createElement(Modal, { title: t('Update severity'), description: t('Describing your update helps us better assist you.'), isOpen: show, onClose: onCancel, actions: modalActions }, modalBody()));
170
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/troubleshoot",
3
- "version": "0.2.125",
3
+ "version": "0.2.126",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -143,5 +143,5 @@
143
143
  "not ie <= 11",
144
144
  "not op_mini all"
145
145
  ],
146
- "gitHead": "69133e548c91349a60a4f9805216e60c98207b69"
146
+ "gitHead": "16100828f404296b3dfb26fbb9fde4c5920ab94e"
147
147
  }