@rh-support/troubleshoot 2.6.295 → 2.6.299

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.
Files changed (98) hide show
  1. package/lib/esm/components/CaseEditView/ActiveCustomerEscalation/RequestEscalationModal.d.ts.map +1 -1
  2. package/lib/esm/components/CaseEditView/ActiveCustomerEscalation/RequestEscalationModal.js +4 -7
  3. package/lib/esm/components/CaseEditView/Case.d.ts.map +1 -1
  4. package/lib/esm/components/CaseEditView/Case.js +42 -12
  5. package/lib/esm/components/CaseEditView/CaseDetailsTabs.d.ts.map +1 -1
  6. package/lib/esm/components/CaseEditView/CaseDetailsTabs.js +17 -7
  7. package/lib/esm/components/CaseEditView/CaseOverview/CaseStatus.d.ts +1 -2
  8. package/lib/esm/components/CaseEditView/CaseOverview/CaseStatus.d.ts.map +1 -1
  9. package/lib/esm/components/CaseEditView/CaseOverview/CaseStatus.js +8 -6
  10. package/lib/esm/components/CaseEditView/CaseOverview/index.d.ts.map +1 -1
  11. package/lib/esm/components/CaseEditView/CaseOverview/index.js +17 -12
  12. package/lib/esm/components/CaseEditView/ConfirmationModals/ReopenCaseModal.d.ts +1 -3
  13. package/lib/esm/components/CaseEditView/ConfirmationModals/ReopenCaseModal.d.ts.map +1 -1
  14. package/lib/esm/components/CaseEditView/ConfirmationModals/ReopenCaseModal.js +3 -4
  15. package/lib/esm/components/CaseEditView/RequestRemoteSession/ESSRemoteSessionModal.d.ts.map +1 -1
  16. package/lib/esm/components/CaseEditView/RequestRemoteSession/ESSRemoteSessionModal.js +4 -7
  17. package/lib/esm/components/CaseEditView/RequestRemoteSession/NewEssTermsModal.d.ts.map +1 -1
  18. package/lib/esm/components/CaseEditView/RequestRemoteSession/NewEssTermsModal.js +4 -30
  19. package/lib/esm/components/CaseEditView/RequestRemoteSession/RemoteSessionAgreementModal.d.ts.map +1 -1
  20. package/lib/esm/components/CaseEditView/RequestRemoteSession/RemoteSessionAgreementModal.js +4 -30
  21. package/lib/esm/components/CaseEditView/RequestRemoteSession/remoteSessionUtils.d.ts +3 -0
  22. package/lib/esm/components/CaseEditView/RequestRemoteSession/remoteSessionUtils.d.ts.map +1 -0
  23. package/lib/esm/components/CaseEditView/RequestRemoteSession/remoteSessionUtils.js +22 -0
  24. package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/CaseDiscussion.d.ts +4 -2
  25. package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/CaseDiscussion.d.ts.map +1 -1
  26. package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/CaseDiscussion.js +110 -148
  27. package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/PostComment/useAttachmentUploadCompletion.d.ts +15 -0
  28. package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/PostComment/useAttachmentUploadCompletion.d.ts.map +1 -0
  29. package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/PostComment/useAttachmentUploadCompletion.js +19 -0
  30. package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/PostComment/useCommentDrafts.d.ts +17 -0
  31. package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/PostComment/useCommentDrafts.d.ts.map +1 -0
  32. package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/PostComment/useCommentDrafts.js +49 -0
  33. package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/PostComment.d.ts +6 -2
  34. package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/PostComment.d.ts.map +1 -1
  35. package/lib/esm/components/CaseEditView/Tabs/CaseDiscussion/PostComment.js +147 -241
  36. package/lib/esm/components/CaseEditView/Tabs/CaseHistory/CaseHistory.d.ts.map +1 -1
  37. package/lib/esm/components/CaseEditView/Tabs/CaseHistory/CaseHistory.js +3 -1
  38. package/lib/esm/components/CaseEditView/Tabs/CaseHistory/Timeline.css +4 -4
  39. package/lib/esm/components/CaseEditView/Tabs/CaseHistory/Timeline.d.ts +35 -3
  40. package/lib/esm/components/CaseEditView/Tabs/CaseHistory/Timeline.d.ts.map +1 -1
  41. package/lib/esm/components/CaseEditView/Tabs/CaseHistory/Timeline.js +63 -224
  42. package/lib/esm/components/CaseEditView/Tabs/CaseSummary/CaseSummary.d.ts.map +1 -1
  43. package/lib/esm/components/CaseEditView/Tabs/CaseSummary/CaseSummary.js +7 -2
  44. package/lib/esm/components/CaseEditView/Tabs/RMEEscalations/RMEEscalationList.d.ts.map +1 -1
  45. package/lib/esm/components/CaseEditView/Tabs/RMEEscalations/RMEEscalationList.js +4 -7
  46. package/lib/esm/components/CaseManagement/Cep.d.ts.map +1 -1
  47. package/lib/esm/components/CaseManagement/Cep.js +4 -7
  48. package/lib/esm/components/ProductSelector/NewProductVersionSelector.d.ts.map +1 -1
  49. package/lib/esm/components/ProductSelector/NewProductVersionSelector.js +18 -4
  50. package/lib/esm/components/UpdateSeverityModal/UpdateSeverityModal.d.ts.map +1 -1
  51. package/lib/esm/components/UpdateSeverityModal/UpdateSeverityModal.js +4 -7
  52. package/lib/esm/components/shared/usePostComment.d.ts.map +1 -1
  53. package/lib/esm/components/shared/usePostComment.js +6 -10
  54. package/lib/esm/components/wizardLayout/GlobalTroubleshootEffects.d.ts.map +1 -1
  55. package/lib/esm/components/wizardLayout/GlobalTroubleshootEffects.js +0 -2
  56. package/lib/esm/context/CaseContext.d.ts.map +1 -1
  57. package/lib/esm/hooks/useCaseComments/caseCommentMutation.d.ts +4 -0
  58. package/lib/esm/hooks/useCaseComments/caseCommentMutation.d.ts.map +1 -0
  59. package/lib/esm/hooks/useCaseComments/caseCommentMutation.js +12 -0
  60. package/lib/esm/hooks/useCaseComments/caseCommentsQuery.d.ts +4 -0
  61. package/lib/esm/hooks/useCaseComments/caseCommentsQuery.d.ts.map +1 -0
  62. package/lib/esm/hooks/useCaseComments/caseCommentsQuery.js +55 -0
  63. package/lib/esm/hooks/useCaseComments/index.d.ts +7 -0
  64. package/lib/esm/hooks/useCaseComments/index.d.ts.map +1 -0
  65. package/lib/esm/hooks/useCaseComments/index.js +5 -0
  66. package/lib/esm/hooks/useCaseComments/mapCaseComment.d.ts +25 -0
  67. package/lib/esm/hooks/useCaseComments/mapCaseComment.d.ts.map +1 -0
  68. package/lib/esm/hooks/useCaseComments/mapCaseComment.js +66 -0
  69. package/lib/esm/hooks/useCaseComments/types.d.ts +80 -0
  70. package/lib/esm/hooks/useCaseComments/types.d.ts.map +1 -0
  71. package/lib/esm/hooks/useCaseComments/types.js +1 -0
  72. package/lib/esm/hooks/useCaseComments/useCaseComments.d.ts +16 -0
  73. package/lib/esm/hooks/useCaseComments/useCaseComments.d.ts.map +1 -0
  74. package/lib/esm/hooks/useCaseComments/useCaseComments.js +25 -0
  75. package/lib/esm/hooks/useCaseComments/useCreateCaseComment.d.ts +19 -0
  76. package/lib/esm/hooks/useCaseComments/useCreateCaseComment.d.ts.map +1 -0
  77. package/lib/esm/hooks/useCaseComments/useCreateCaseComment.js +33 -0
  78. package/lib/esm/hooks/useCaseHistory.d.ts +26 -0
  79. package/lib/esm/hooks/useCaseHistory.d.ts.map +1 -0
  80. package/lib/esm/hooks/useCaseHistory.js +98 -0
  81. package/lib/esm/models/caseHistory.d.ts +80 -0
  82. package/lib/esm/models/caseHistory.d.ts.map +1 -0
  83. package/lib/esm/models/caseHistory.js +1 -0
  84. package/lib/esm/reducers/CaseConstNTypes.d.ts +0 -1
  85. package/lib/esm/reducers/CaseConstNTypes.d.ts.map +1 -1
  86. package/lib/esm/reducers/CaseConstNTypes.js +0 -1
  87. package/lib/esm/reducers/CaseDiscussionTabReducer.d.ts +0 -2
  88. package/lib/esm/reducers/CaseDiscussionTabReducer.d.ts.map +1 -1
  89. package/lib/esm/reducers/CaseDiscussionTabReducer.js +1 -28
  90. package/lib/esm/reducers/CaseReducer.d.ts.map +1 -1
  91. package/lib/esm/reducers/CaseReducer.js +14 -4
  92. package/lib/esm/utils/TimelineUtils.d.ts +41 -0
  93. package/lib/esm/utils/TimelineUtils.d.ts.map +1 -0
  94. package/lib/esm/utils/TimelineUtils.js +134 -0
  95. package/lib/esm/utils/caseHistoryUtils.d.ts +66 -0
  96. package/lib/esm/utils/caseHistoryUtils.d.ts.map +1 -0
  97. package/lib/esm/utils/caseHistoryUtils.js +165 -0
  98. package/package.json +5 -5
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Maps Salesforce field identifiers to human-readable display names.
3
+ *
4
+ * Contains two distinct key categories:
5
+ * - Real SF API field names (e.g. `ContactId`, `RH_Product__c`, `FolderId__c`)
6
+ * - Synthetic lifecycle pseudo-fields produced by the SF History API (e.g. `created`,
7
+ * `closed`, `ownerAssignment`). These are not custom Salesforce fields — they represent
8
+ * case lifecycle events that appear as history entries with no OldValue/NewValue.
9
+ */
10
+ export const FIELD_NAME_DISPLAY_MAP = {
11
+ created: 'Case Created',
12
+ closed: 'Case Closed',
13
+ ownerAssignment: 'Owner',
14
+ ownerAccepted: 'Owner',
15
+ ownerEscalated: 'Owner',
16
+ external: 'Visibility',
17
+ ContactId: 'Contact',
18
+ RH_Product__c: 'Product',
19
+ RH_Version__c: 'Version',
20
+ EntitlementId: 'Entitlement',
21
+ AccountId: 'Account',
22
+ OwnerId: 'Owner',
23
+ BusinessHoursId: 'Business Hours',
24
+ FolderId__c: 'Case Group',
25
+ Status: 'Status',
26
+ Customer_Escalation__c: 'Customer Escalation',
27
+ SlaStartDate: 'SLA Start Date',
28
+ Case_Language__c: 'Case Language',
29
+ SBR_Group__c: 'SBR Group',
30
+ };
31
+ export function getFieldDisplayName(fieldName) {
32
+ if (fieldName in FIELD_NAME_DISPLAY_MAP) {
33
+ return FIELD_NAME_DISPLAY_MAP[fieldName];
34
+ }
35
+ return undefined;
36
+ }
37
+ // Salesforce object IDs are strictly 15 (case-sensitive) or 18 (case-insensitive)
38
+ // alphanumeric characters. Strings of 16–17 chars are intentionally excluded.
39
+ const SFDC_ID_REGEX = /^[a-zA-Z0-9]{15}$|^[a-zA-Z0-9]{18}$/;
40
+ export function isSfdcId(value) {
41
+ return SFDC_ID_REGEX.test(value);
42
+ }
43
+ /**
44
+ * Extracts a string representation from a polymorphic SF value union.
45
+ *
46
+ * Property names (`stringValue`, `booleanValue`, etc.) correspond to GraphQL
47
+ * inline-fragment aliases defined in the `GET_CASE_HISTORY` query. Changing those
48
+ * aliases without updating this function will silently break value extraction.
49
+ *
50
+ * The check order is safe because the union discriminants are mutually exclusive.
51
+ * Note: empty string `''` is a valid return value (distinct from `null`).
52
+ */
53
+ export function extractStringValue(val) {
54
+ if (!val)
55
+ return null;
56
+ if ('stringValue' in val)
57
+ return val.stringValue;
58
+ if ('booleanValue' in val)
59
+ return String(val.booleanValue);
60
+ if ('doubleValue' in val)
61
+ return String(val.doubleValue);
62
+ if ('dateTimeValue' in val)
63
+ return val.dateTimeValue;
64
+ return null;
65
+ }
66
+ /**
67
+ * Lifecycle pseudo-field names from the SF History API mapped to human-readable action
68
+ * sentences. Fields not listed here fall back to using the raw `fieldName` as output text
69
+ * in {@link normalizeNodeToHistoryItem}.
70
+ */
71
+ export const SPECIAL_FIELD_ACTIONS = {
72
+ created: 'created the case',
73
+ closed: 'closed the case',
74
+ ownerAssignment: 'changed the case owner',
75
+ ownerAccepted: 'accepted ownership of the case',
76
+ ownerEscalated: 'escalated the case owner',
77
+ external: 'made the case visible to customers',
78
+ };
79
+ export const DEFAULT_AVATAR_SRC = 'https://www.patternfly.org/images/668560cd.svg';
80
+ const INTERNAL_USER_TYPE = 'Standard';
81
+ /**
82
+ * Only SF `UserType === 'Standard'` is treated as an internal (Red Hat) user.
83
+ * All other types — including `null`, `undefined`, and unknown portal types — default
84
+ * to customer. This conservative default ensures external users are never accidentally
85
+ * styled as internal.
86
+ */
87
+ export function deriveIsCustomer(userType) {
88
+ if (userType === INTERNAL_USER_TYPE)
89
+ return false;
90
+ return true;
91
+ }
92
+ /**
93
+ * Filters out history entries whose values are raw Salesforce IDs that cannot be
94
+ * decoded into human-readable display strings.
95
+ *
96
+ * Filtering rules:
97
+ * - Both values null → **keep** (lifecycle action events carry no values)
98
+ * - `newValue` is an SFDC ID and `oldValue` is null or also an ID → **drop**
99
+ * (unresolvable reference change with no readable side)
100
+ * - `oldValue` is an SFDC ID and `newValue` is null → **drop**
101
+ * (ID removal with no display name)
102
+ * - At least one side is a human-readable string → **keep**
103
+ */
104
+ export function filterSfdcIdEntries(edges) {
105
+ return edges
106
+ .map((edge) => edge.node)
107
+ .filter((node) => {
108
+ const newVal = extractStringValue(node.NewValue);
109
+ const oldVal = extractStringValue(node.OldValue);
110
+ if (!newVal && !oldVal)
111
+ return true;
112
+ const hasIdNewVal = newVal && isSfdcId(newVal);
113
+ const hasIdOldVal = oldVal && isSfdcId(oldVal);
114
+ if (hasIdNewVal && (!oldVal || hasIdOldVal))
115
+ return false;
116
+ if (hasIdOldVal && !newVal)
117
+ return false;
118
+ return true;
119
+ });
120
+ }
121
+ /**
122
+ * Converts a raw SF history node into a normalized `ICaseHistoryItem`.
123
+ *
124
+ * Classifies each entry as either:
125
+ * - **Action** (`!oldValue && !newValue`): lifecycle events like "created", "closed".
126
+ * `outputText` is set here from {@link SPECIAL_FIELD_ACTIONS}, or falls back to the
127
+ * raw `fieldName` for unknown actions.
128
+ * - **Change**: field-value mutations. `outputText` is left empty because the Timeline
129
+ * layer formats change text via `applyReplacements` / `handleFieldChange`.
130
+ *
131
+ * Display name fallback chain: `FIELD_NAME_DISPLAY_MAP` → SF `label` → SF
132
+ * `displayValue` → raw `fieldName`.
133
+ */
134
+ export function normalizeNodeToHistoryItem(node) {
135
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
136
+ const fieldName = node.SalesforceSupportField.value;
137
+ const oldValue = extractStringValue(node.OldValue);
138
+ const newValue = extractStringValue(node.NewValue);
139
+ const isAction = !oldValue && !newValue;
140
+ let outputText = '';
141
+ if (isAction) {
142
+ if (fieldName in SPECIAL_FIELD_ACTIONS) {
143
+ outputText = SPECIAL_FIELD_ACTIONS[fieldName];
144
+ }
145
+ else {
146
+ outputText = fieldName;
147
+ }
148
+ }
149
+ return {
150
+ id: node.Id,
151
+ fieldName,
152
+ displayName: (_c = (_b = (_a = getFieldDisplayName(fieldName)) !== null && _a !== void 0 ? _a : node.SalesforceSupportField.label) !== null && _b !== void 0 ? _b : node.SalesforceSupportField.displayValue) !== null && _c !== void 0 ? _c : fieldName,
153
+ label: (_f = (_e = (_d = getFieldDisplayName(fieldName)) !== null && _d !== void 0 ? _d : node.SalesforceSupportField.label) !== null && _e !== void 0 ? _e : node.SalesforceSupportField.displayValue) !== null && _f !== void 0 ? _f : fieldName,
154
+ oldValue,
155
+ newValue,
156
+ createdDate: node.CreatedDate.value,
157
+ createdByUserName: (_j = (_h = (_g = node.CreatedBy) === null || _g === void 0 ? void 0 : _g.Name) === null || _h === void 0 ? void 0 : _h.value) !== null && _j !== void 0 ? _j : '',
158
+ createdByCustomer: deriveIsCustomer((_l = (_k = node.CreatedBy) === null || _k === void 0 ? void 0 : _k.UserType) === null || _l === void 0 ? void 0 : _l.value),
159
+ // TODO: SmallPhotoUrl points to an internal Salesforce domain that external portal
160
+ // users can't authenticate against. If images break, Hydra will need to proxy them.
161
+ photoUrl: (_p = (_o = (_m = node.CreatedBy) === null || _m === void 0 ? void 0 : _m.SmallPhotoUrl) === null || _o === void 0 ? void 0 : _o.value) !== null && _p !== void 0 ? _p : null,
162
+ type: isAction ? 'Action' : 'Change',
163
+ outputText,
164
+ };
165
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/troubleshoot",
3
- "version": "2.6.295",
3
+ "version": "2.6.299",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -54,10 +54,10 @@
54
54
  "@progress/kendo-react-pdf": "^5.16.0",
55
55
  "@redux-devtools/extension": "^3.3.0",
56
56
  "@rh-support/components": "2.5.165",
57
- "@rh-support/react-context": "2.5.271",
57
+ "@rh-support/react-context": "2.5.275",
58
58
  "@rh-support/types": "2.0.26",
59
- "@rh-support/user-permissions": "2.5.123",
60
- "@rh-support/utils": "2.5.106",
59
+ "@rh-support/user-permissions": "2.5.127",
60
+ "@rh-support/utils": "2.5.110",
61
61
  "@types/react-redux": "^7.1.33",
62
62
  "@types/redux": "^3.6.0",
63
63
  "date-fns": "3.6.0",
@@ -127,5 +127,5 @@
127
127
  "defaults and supports es6-module",
128
128
  "maintained node versions"
129
129
  ],
130
- "gitHead": "7b1306d35722c768378d97b4c6f9895c6a66bce8"
130
+ "gitHead": "d1a226af32eb5997a31c34001b6146be141c8911"
131
131
  }