@rh-support/troubleshoot 1.0.2 → 1.0.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":"CaseDetailsAside.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseEditView/CaseDetailsAside.tsx"],"names":[],"mappings":"AAwBA,UAAU,MAAM;IACZ,UAAU,EAAE,MAAM,CAAC;CACtB;AAMD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,eAsL7C"}
1
+ {"version":3,"file":"CaseDetailsAside.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseEditView/CaseDetailsAside.tsx"],"names":[],"mappings":"AA0BA,UAAU,MAAM;IACZ,UAAU,EAAE,MAAM,CAAC;CACtB;AAMD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,eAgQ7C"}
@@ -1,15 +1,25 @@
1
- import { Button, Switch, Tooltip } from '@patternfly/react-core';
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 { Button, Checkbox, Switch, Tooltip } from '@patternfly/react-core';
2
11
  import AngleDoubleLeftIcon from '@patternfly/react-icons/dist/js/icons/angle-double-left-icon';
3
12
  import AngleDoubleRightIcon from '@patternfly/react-icons/dist/js/icons/angle-double-right-icon';
4
13
  import ListIcon from '@patternfly/react-icons/dist/js/icons/list-icon';
5
14
  import LockIcon from '@patternfly/react-icons/dist/js/icons/lock-icon';
6
15
  import TrendUpIcon from '@patternfly/react-icons/dist/js/icons/trend-up-icon';
7
- import { ErrorBoundary, useBreakpoint, useForceUpdate } from '@rh-support/components';
8
- import { GlobalMetadataDispatchContext, toggleViewAsCustomerFlag, useGlobalStateContext, } from '@rh-support/react-context';
16
+ import { ErrorBoundary, ToastNotification, useBreakpoint, useForceUpdate } from '@rh-support/components';
17
+ import { GlobalMetadataDispatchContext, toggleViewAsCustomerFlag, useGlobalStateContext, useUserPreferences, } from '@rh-support/react-context';
9
18
  import { ability, CaseDetailsFields, resourceActions, resources } from '@rh-support/user-permissions';
10
19
  import { scrollIntoView } from '@rh-support/utils';
20
+ import { isEmpty } from 'lodash';
11
21
  import isEqual from 'lodash/isEqual';
12
- import React, { useContext, useEffect, useRef } from 'react';
22
+ import React, { useContext, useEffect, useRef, useState } from 'react';
13
23
  import { Trans, useTranslation } from 'react-i18next';
14
24
  import { useCaseSelector } from '../../context/CaseContext';
15
25
  import { useCaseDetailsPageStateContext } from '../../context/CaseDetailsPageContext';
@@ -53,6 +63,30 @@ export function CaseDetailsAside(props) {
53
63
  sectionToScrollRef.current = null;
54
64
  }
55
65
  };
66
+ const { getOriginalCaseView, updateOriginalCaseView } = useUserPreferences();
67
+ const [viewAsInternalPref, setViewAsInternalPref] = useState();
68
+ const [isDefaultBoxChecked, setIsDefaultBoxChecked] = useState(false);
69
+ useEffect(() => {
70
+ const userPreferredCaseView = () => __awaiter(this, void 0, void 0, function* () {
71
+ try {
72
+ const isRetrievedInternal = yield getOriginalCaseView(); // retrieving as string.
73
+ const finalIsRetrievedInternal = !!+isRetrievedInternal; // converting backend string -> num -> bool
74
+ if (finalIsRetrievedInternal != null) {
75
+ setViewAsInternalPref(finalIsRetrievedInternal);
76
+ !finalIsRetrievedInternal && setIsDefaultBoxChecked(true);
77
+ }
78
+ if (finalIsRetrievedInternal === false) {
79
+ !preferredOrDefaultCaseView() && toggleViewAsCustomerFlag(globalMetadataDispatchContext);
80
+ }
81
+ }
82
+ catch (_a) {
83
+ ToastNotification.addWarningMessage(t('Failed to fetch original preference'));
84
+ setIsDefaultBoxChecked(false);
85
+ }
86
+ });
87
+ userPreferredCaseView();
88
+ // eslint-disable-next-line react-hooks/exhaustive-deps
89
+ }, []);
56
90
  const setSectionToScollRef = (sectionRef) => {
57
91
  sectionToScrollRef.current = sectionRef;
58
92
  };
@@ -62,6 +96,14 @@ export function CaseDetailsAside(props) {
62
96
  caseDetailsAsidePanelRef.current.expanded = isExpanded;
63
97
  forceUpdate();
64
98
  };
99
+ const preferredOrDefaultCaseView = () => {
100
+ if (isEmpty(viewAsInternalPref)) {
101
+ return viewAsCustomer; // This is the default var used by the component we only want this if value is null meaning user made no preference.
102
+ }
103
+ else if (!isEmpty(viewAsInternalPref)) {
104
+ return !viewAsInternalPref;
105
+ }
106
+ };
65
107
  useEffect(() => {
66
108
  if (isFetchingCaseDetails || !isFirstMountRef.current || isFetchingCaseDetailsError)
67
109
  return;
@@ -73,6 +115,25 @@ export function CaseDetailsAside(props) {
73
115
  !isXLScreen && toggleAside(false);
74
116
  // eslint-disable-next-line react-hooks/exhaustive-deps
75
117
  }, [breakPoint]);
118
+ const onDefaultCheckboxChange = (e) => {
119
+ try {
120
+ //if user is unchecking the box we look for it being checked
121
+ if (isDefaultBoxChecked) {
122
+ updateOriginalCaseView(+viewAsCustomer);
123
+ setIsDefaultBoxChecked(!isDefaultBoxChecked);
124
+ }
125
+ else if (isDefaultBoxChecked === false) {
126
+ updateOriginalCaseView(0);
127
+ setIsDefaultBoxChecked(true);
128
+ }
129
+ }
130
+ catch (error) {
131
+ setIsDefaultBoxChecked(isDefaultBoxChecked);
132
+ }
133
+ };
134
+ const onCaseSwitchChange = (e) => {
135
+ toggleViewAsCustomerFlag(globalMetadataDispatchContext);
136
+ };
76
137
  const isSideBarExpanded = (_a = caseDetailsAsidePanelRef.current) === null || _a === void 0 ? void 0 : _a.expanded;
77
138
  if (isFetchingCaseDetails || isFetchingCaseDetailsError)
78
139
  return null;
@@ -96,9 +157,16 @@ export function CaseDetailsAside(props) {
96
157
  React.createElement(TrendUpIcon, { size: "md" }))))))),
97
158
  React.createElement("pfe-collapse-panel", { className: "sidebar-content", "pfe-animation": "false", id: "case-details-aside-content", ref: caseDetailsAsidePanelRef },
98
159
  React.createElement("div", { className: "grid-aside-content" },
99
- canSeeToggleCustomerView && (React.createElement("div", { className: "pf-u-display-flex customer-view-toggle", ref: toggleCustomerViewRef },
100
- React.createElement("span", { className: "customer-view-switch-label" }, viewAsCustomer ? t('Customer view') : t('Internal view')),
101
- React.createElement(Switch, { title: viewAsCustomer ? t('Customer view') : t('Internal view'), "data-tracking-id": viewAsCustomer ? 'disable-view-as-customer' : 'enable-view-as-customer', "aria-label": viewAsCustomer ? 'disable view as customer' : 'enable view as customer', id: "customer-view-switch", className: "pf-u-ml-auto", isChecked: viewAsCustomer, onChange: () => toggleViewAsCustomerFlag(globalMetadataDispatchContext) }))),
160
+ React.createElement("div", null,
161
+ canSeeToggleCustomerView && (React.createElement("div", { className: "pf-u-display-flex customer-view-toggle", ref: toggleCustomerViewRef },
162
+ React.createElement("span", { className: "customer-view-switch-label" }, preferredOrDefaultCaseView() ? t('Customer view') : t('Internal view')),
163
+ React.createElement(Switch, { title: preferredOrDefaultCaseView() ? t('Customer view') : t('Internal view'), "data-tracking-id": preferredOrDefaultCaseView()
164
+ ? 'disable-view-as-customer'
165
+ : 'enable-view-as-customer', "aria-label": preferredOrDefaultCaseView()
166
+ ? 'disable view as customer'
167
+ : 'enable view as customer', id: "customer-view-switch", className: "pf-u-ml-auto", isChecked: preferredOrDefaultCaseView(), onChange: onCaseSwitchChange }))),
168
+ React.createElement("div", null,
169
+ React.createElement(Checkbox, { label: t('Set to default'), isChecked: isDefaultBoxChecked, onChange: onDefaultCheckboxChange, id: "set-default-view-checkbox", name: "default-view-checkbox", isDisabled: !viewAsCustomer, className: 'defaultViewCheckbox' }))),
102
170
  React.createElement(ErrorBoundary, { errorMsgInfo: { message: t('There was an error loading top solutions') } },
103
171
  React.createElement(CaseSolutions, { caseNumber: caseNumber, ref: topSolutionsRef, isSecureSupportAccount: isSecureSupportAccount })),
104
172
  !caseEscalations.isFetching && canViewACESection && (React.createElement(ErrorBoundary, null,
@@ -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,eAgfjD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/CaseEditView/CaseOverview/index.tsx"],"names":[],"mappings":"AAwCA,UAAU,MAAM;IACZ,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,MAAM,eAmejD"}
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { Alert, AlertVariant, Button, ButtonVariant, ExpandableSection, Label } from '@patternfly/react-core';
11
11
  import { ToastNotification, useConfirmation } from '@rh-support/components';
12
- import { AddRemoveBookmarkWrapper, CloseCaseModal, fetchCaseSeverities, fetchCaseTypes, GlobalMetadataDispatchContext, GlobalMetadataStateContext, useCanEditCase, } from '@rh-support/react-context';
12
+ import { CloseCaseModal, fetchCaseSeverities, fetchCaseTypes, GlobalMetadataDispatchContext, GlobalMetadataStateContext, useCanEditCase, } from '@rh-support/react-context';
13
13
  import { AbilityContext, CaseDetailsFields, resourceActions, resources } from '@rh-support/user-permissions';
14
14
  import { haventLoadedMetadata, isOpenShiftOnlineProduct } from '@rh-support/utils';
15
15
  import isEqual from 'lodash/isEqual';
@@ -35,7 +35,6 @@ export default function CaseOverview(props) {
35
35
  const { t } = useTranslation();
36
36
  const canManageCase = ability.can(resourceActions.UPDATE, resources.CASE_DETAILS);
37
37
  const canSeeCaseOwnerInfo = ability.can(resourceActions.PATCH, resources.CASE_DETAILS, CaseDetailsFields.CASE_DETAILS_OWNER);
38
- const canAccessBookmark = ability.can(resourceActions.READ, resources.BOOKMARK_ACCOUNTS);
39
38
  const canSeeInactivityWarning = ability.can(resourceActions.PATCH, resources.CASE_DETAILS, CaseDetailsFields.CASE_DETAILS_ACTIVITY_WARNING);
40
39
  const [caseOverviewState, caseOverviewDispatch] = useReducer(caseOverviewReducer, initialCaseViewState);
41
40
  const [isDetailsExpanded, setIsDetailsExpanded] = useState(true);
@@ -261,12 +260,7 @@ export default function CaseOverview(props) {
261
260
  React.createElement("div", { className: "account" },
262
261
  React.createElement("h3", { className: "subheading subheading-sm" },
263
262
  React.createElement(Trans, null, "Account")),
264
- React.createElement("div", null,
265
- accountNumber,
266
- canAccessBookmark && accountNumber && (React.createElement(AddRemoveBookmarkWrapper, { selectedAccount: {
267
- accountNumber: accountNumber,
268
- name: selectedAccountDetails.data.name,
269
- }, removeBookmarkTitle: t('Remove bookmark'), addBookmarkTitle: t('Bookmark account') }))),
263
+ React.createElement("div", null, accountNumber),
270
264
  React.createElement("div", null, selectedAccountDetails.data.name)),
271
265
  React.createElement("div", { className: "created-by" },
272
266
  React.createElement("h3", { className: "subheading subheading-sm" },
@@ -1,4 +1,5 @@
1
1
  interface IProps {
2
+ init?: boolean;
2
3
  }
3
4
  declare function CaseGroup(props: IProps): JSX.Element;
4
5
  export default CaseGroup;
@@ -1 +1 @@
1
- {"version":3,"file":"CaseGroup.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseInformation/CaseGroup.tsx"],"names":[],"mappings":"AAiBA,UAAU,MAAM;CAAG;AAInB,iBAAS,SAAS,CAAC,KAAK,EAAE,MAAM,eA0N/B;AAED,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"CaseGroup.d.ts","sourceRoot":"","sources":["../../../../src/components/CaseInformation/CaseGroup.tsx"],"names":[],"mappings":"AAiBA,UAAU,MAAM;IACZ,IAAI,CAAC,EAAE,OAAO,CAAC;CAClB;AAID,iBAAS,SAAS,CAAC,KAAK,EAAE,MAAM,eA2N/B;AAED,eAAe,SAAS,CAAC"}
@@ -56,7 +56,9 @@ function CaseGroup(props) {
56
56
  defaultMembers: [],
57
57
  members: [],
58
58
  };
59
- onCaseGroupChange(toOption(parsedFetchedDefaultGroup, { labelKey: 'name' }));
59
+ groupNumber === '-1' &&
60
+ props.init &&
61
+ onCaseGroupChange(toOption(parsedFetchedDefaultGroup, { labelKey: 'name' }));
60
62
  }
61
63
  }
62
64
  });
@@ -58,7 +58,7 @@ export default function CaseManagement(props) {
58
58
  React.createElement(SupportLevel, null),
59
59
  React.createElement(Severity, { showSeverityInfoIcon: true, onSeverityChange: onSeverityChange }),
60
60
  React.createElement(Fts, { inlineEditable: false }),
61
- React.createElement(CaseGroup, null),
61
+ React.createElement(CaseGroup, { init: true }),
62
62
  React.createElement(CaseLanguageSelector, null),
63
63
  canSeeEmailNotifications && React.createElement(CaseContactSelector, null),
64
64
  React.createElement(RHAssociatesSelector, null),
@@ -1 +1 @@
1
- {"version":3,"file":"ClusterRecommendationItems.d.ts","sourceRoot":"","sources":["../../../../src/components/Recommendations/ClusterRecommendationItems.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oDAAoD,CAAC;AAe5F,UAAU,MAAM;IACZ,sBAAsB,EAAE,sBAAsB,EAAE,CAAC;CACpD;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,eAiGvD"}
1
+ {"version":3,"file":"ClusterRecommendationItems.d.ts","sourceRoot":"","sources":["../../../../src/components/Recommendations/ClusterRecommendationItems.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oDAAoD,CAAC;AAe5F,UAAU,MAAM;IACZ,sBAAsB,EAAE,sBAAsB,EAAE,CAAC;CACpD;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,eA0EvD"}
@@ -1,11 +1,11 @@
1
1
  import { pcm } from '@cee-eng/hydrajs';
2
2
  import { Label } from '@patternfly/react-core';
3
+ import ArrowRightIcon from '@patternfly/react-icons/dist/js/icons/arrow-right-icon';
3
4
  import isEqual from 'lodash/isEqual';
4
5
  import React, { useContext, useEffect } from 'react';
5
6
  import { Trans } from 'react-i18next';
6
7
  import { useCaseSelector } from '../../context/CaseContext';
7
8
  import { SessionRestoreDispatchContext, SessionRestoreStateContext } from '../../context/SessionRestoreContext';
8
- import { useParseRuleMarkdown } from '../../hooks/useParseRuleMarkdown';
9
9
  import { createOrUpdateSessionResources, getRulesToSave, getSessResFromRules, } from '../../reducers/SessionRestoreReducer';
10
10
  import { riskLabels } from '../shared/Constants';
11
11
  export function ClusterRecommendationItems(props) {
@@ -17,12 +17,8 @@ export function ClusterRecommendationItems(props) {
17
17
  product: state.caseDetails.product,
18
18
  openshiftClusterID: state.caseDetails.openshiftClusterID,
19
19
  }), isEqual);
20
- const { parseDotMarkdownWithTracking } = useParseRuleMarkdown();
21
20
  const onResourceClick = (e, rule) => {
22
- if (e.target.tagName.toLowerCase() === 'a') {
23
- const visitedUrl = e.target.href.split('?')[0];
24
- createOrUpdateSessionResources(sessionRestoreDispatch, activeSessionId, sessionResourceTracking, SessionResourceSource.CLUSTER_RECOMMENDATION, [getSessResFromRules(visitedUrl, SessionResourceVisibility.VISITED, rule.rule_id)], JSON.stringify({ product, version, openshiftClusterID }));
25
- }
21
+ createOrUpdateSessionResources(sessionRestoreDispatch, activeSessionId, sessionResourceTracking, SessionResourceSource.CLUSTER_RECOMMENDATION, [getSessResFromRules('', SessionResourceVisibility.VISITED, rule.rule_id)], JSON.stringify({ product, version, openshiftClusterID }));
26
22
  };
27
23
  useEffect(() => {
28
24
  createOrUpdateSessionResources(sessionRestoreDispatch, activeSessionId, sessionResourceTracking, SessionResourceSource.CLUSTER_RECOMMENDATION, getRulesToSave('', '', props.clusterRecommendations), JSON.stringify({ product, version, openshiftClusterID }));
@@ -36,10 +32,8 @@ export function ClusterRecommendationItems(props) {
36
32
  React.createElement(Label, { icon: riskLabels[rule.total_risk].icon, className: riskLabels[rule.total_risk].className },
37
33
  React.createElement(Trans, null, riskLabels[rule.total_risk].label))),
38
34
  React.createElement("p", null, rule.details || ''),
39
- rule.reason && (React.createElement(React.Fragment, null,
40
- React.createElement("h3", { className: "subheading subheading-sm" }, "Reason: "),
41
- React.createElement("p", { onClick: (e) => onResourceClick(e, rule), dangerouslySetInnerHTML: parseDotMarkdownWithTracking(rule.reason, rule.extra_data, SessionResourceSource.CLUSTER_RECOMMENDATION, 'ts-cluster-recommendation', 'se-cluster-recommendation-rule') }))),
42
- rule.resolution && (React.createElement(React.Fragment, null,
43
- React.createElement("h3", { className: "subheading subheading-sm" }, "Resolution: "),
44
- React.createElement("p", { onClick: (e) => onResourceClick(e, rule), dangerouslySetInnerHTML: parseDotMarkdownWithTracking(rule.resolution, rule.extra_data, SessionResourceSource.CLUSTER_RECOMMENDATION, 'ts-cluster-recommendation', 'se-cluster-recommendation-rule') })))))))));
35
+ React.createElement("a", { onClick: (e) => onResourceClick(e, rule), className: "pf-u-font-weight-bold", "data-tracking-id": "cluster-recommendations", href: `https://console.redhat.com/openshift/insights/advisor/clusters/${openshiftClusterID}`, target: "_blank", rel: "noopener noreferrer" },
36
+ React.createElement(Trans, null,
37
+ "View details and remediation steps ",
38
+ React.createElement(ArrowRightIcon, { "aria-hidden": "true" })))))))));
45
39
  }
@@ -945,3 +945,7 @@ div.pf-c-alert.ea-rule-alert > div.pf-c-alert__description > p {
945
945
  }
946
946
  }
947
947
  }
948
+
949
+ div.defaultViewCheckbox {
950
+ grid-gap: 0px;
951
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/troubleshoot",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -73,11 +73,11 @@
73
73
  "@patternfly/react-core": "4.202.16",
74
74
  "@progress/kendo-drawing": "^1.6.0",
75
75
  "@progress/kendo-react-pdf": "^3.12.0",
76
- "@rh-support/components": "1.2.0",
77
- "@rh-support/react-context": "1.0.1",
76
+ "@rh-support/components": "1.2.2",
77
+ "@rh-support/react-context": "1.0.3",
78
78
  "@rh-support/types": "0.2.0",
79
- "@rh-support/user-permissions": "1.0.0",
80
- "@rh-support/utils": "1.0.0",
79
+ "@rh-support/user-permissions": "1.0.2",
80
+ "@rh-support/utils": "1.0.1",
81
81
  "@types/react-redux": "^7.1.12",
82
82
  "@types/redux": "^3.6.0",
83
83
  "@webcomponents/webcomponentsjs": "^2.2.10",
@@ -142,5 +142,5 @@
142
142
  "not ie <= 11",
143
143
  "not op_mini all"
144
144
  ],
145
- "gitHead": "455d21baf7d383cdd9a58ba9ff6483dd4a9b60a9"
145
+ "gitHead": "727b155d872dbee66440d6fb874eef95d119bc3a"
146
146
  }