@rh-support/troubleshoot 2.6.47 → 2.6.49
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.
- package/lib/esm/components/Recommendations/AsideResults.d.ts.map +1 -1
- package/lib/esm/components/Recommendations/AsideResults.js +1 -1
- package/lib/esm/components/Recommendations/Recommendations.js +2 -2
- package/lib/esm/components/TroubleshootSection/AskRedHat.d.ts +7 -0
- package/lib/esm/components/TroubleshootSection/AskRedHat.d.ts.map +1 -0
- package/lib/esm/components/TroubleshootSection/AskRedHat.js +184 -0
- package/lib/esm/components/TroubleshootSection/CloseButton.d.ts +9 -0
- package/lib/esm/components/TroubleshootSection/CloseButton.d.ts.map +1 -0
- package/lib/esm/components/TroubleshootSection/CloseButton.js +5 -0
- package/lib/esm/components/TroubleshootSection/QuickResponse.d.ts +15 -0
- package/lib/esm/components/TroubleshootSection/QuickResponse.d.ts.map +1 -0
- package/lib/esm/components/TroubleshootSection/QuickResponse.js +26 -0
- package/lib/esm/components/TroubleshootSection/ResponseActionButton.d.ts +18 -0
- package/lib/esm/components/TroubleshootSection/ResponseActionButton.d.ts.map +1 -0
- package/lib/esm/components/TroubleshootSection/ResponseActionButton.js +28 -0
- package/lib/esm/components/TroubleshootSection/ResponseActions.d.ts +20 -0
- package/lib/esm/components/TroubleshootSection/ResponseActions.d.ts.map +1 -0
- package/lib/esm/components/TroubleshootSection/ResponseActions.js +52 -0
- package/lib/esm/components/TroubleshootSection/TroubleshootSection.d.ts +7 -0
- package/lib/esm/components/TroubleshootSection/TroubleshootSection.d.ts.map +1 -1
- package/lib/esm/components/TroubleshootSection/TroubleshootSection.js +99 -13
- package/lib/esm/components/TroubleshootSection/UserFeedback.d.ts +13 -0
- package/lib/esm/components/TroubleshootSection/UserFeedback.d.ts.map +1 -0
- package/lib/esm/components/TroubleshootSection/UserFeedback.js +44 -0
- package/lib/esm/components/TroubleshootSection/UserFeedbackComplete.d.ts +10 -0
- package/lib/esm/components/TroubleshootSection/UserFeedbackComplete.d.ts.map +1 -0
- package/lib/esm/components/TroubleshootSection/UserFeedbackComplete.js +46 -0
- package/lib/esm/components/TroubleshootSection/icons/CollapseIcon.d.ts +9 -0
- package/lib/esm/components/TroubleshootSection/icons/CollapseIcon.d.ts.map +1 -0
- package/lib/esm/components/TroubleshootSection/icons/CollapseIcon.js +9 -0
- package/lib/esm/components/TroubleshootSection/icons/StarIcon.d.ts +9 -0
- package/lib/esm/components/TroubleshootSection/icons/StarIcon.d.ts.map +1 -0
- package/lib/esm/components/TroubleshootSection/icons/StarIcon.js +17 -0
- package/lib/esm/components/wizardLayout/WizardLayout.d.ts.map +1 -1
- package/lib/esm/components/wizardLayout/WizardLayout.js +9 -6
- package/lib/esm/components/wizardLayout/WizardMain.d.ts +7 -1
- package/lib/esm/components/wizardLayout/WizardMain.d.ts.map +1 -1
- package/lib/esm/components/wizardLayout/WizardMain.js +210 -11
- package/lib/esm/components/wizardLayout/WizardNavigation.d.ts +2 -0
- package/lib/esm/components/wizardLayout/WizardNavigation.d.ts.map +1 -1
- package/lib/esm/components/wizardLayout/WizardNavigation.js +4 -3
- package/lib/esm/components/wizardLayout/index.d.ts +1 -0
- package/lib/esm/components/wizardLayout/index.d.ts.map +1 -1
- package/lib/esm/components/wizardLayout/index.js +1 -0
- package/lib/esm/constants/askRedHatMessages.d.ts +35 -0
- package/lib/esm/constants/askRedHatMessages.d.ts.map +1 -0
- package/lib/esm/constants/askRedHatMessages.js +36 -0
- package/lib/esm/context/AIResponseContext.d.ts +10 -0
- package/lib/esm/context/AIResponseContext.d.ts.map +1 -0
- package/lib/esm/context/AIResponseContext.js +26 -0
- package/lib/esm/context/RootTroubleshootProvider.d.ts.map +1 -1
- package/lib/esm/context/RootTroubleshootProvider.js +8 -6
- package/lib/esm/css/AskRedHat.css +392 -0
- package/lib/esm/hooks/useWizard.d.ts +6 -0
- package/lib/esm/hooks/useWizard.d.ts.map +1 -1
- package/lib/esm/hooks/useWizard.js +1 -1
- package/lib/esm/reducers/AIResponseConstNTypes.d.ts +48 -0
- package/lib/esm/reducers/AIResponseConstNTypes.d.ts.map +1 -0
- package/lib/esm/reducers/AIResponseConstNTypes.js +18 -0
- package/lib/esm/reducers/AIResponseReducer.d.ts +9 -0
- package/lib/esm/reducers/AIResponseReducer.d.ts.map +1 -0
- package/lib/esm/reducers/AIResponseReducer.js +42 -0
- package/lib/esm/reducers/CaseConstNTypes.d.ts +2 -0
- package/lib/esm/reducers/CaseConstNTypes.d.ts.map +1 -1
- package/lib/esm/reducers/CaseConstNTypes.js +2 -0
- package/lib/esm/scss/_main.scss +15 -14
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AsideResults.d.ts","sourceRoot":"","sources":["../../../../src/components/Recommendations/AsideResults.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AASvD,OAAO,EAAE,eAAe,EAAsC,MAAM,iCAAiC,CAAC;AAUtG,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"AsideResults.d.ts","sourceRoot":"","sources":["../../../../src/components/Recommendations/AsideResults.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AASvD,OAAO,EAAE,eAAe,EAAsC,MAAM,iCAAiC,CAAC;AAUtG,UAAU,MAAM;IACZ,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,CAAC;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,qBAsMzC"}
|
|
@@ -133,7 +133,7 @@ export function AsideResults(props) {
|
|
|
133
133
|
return React.createElement(React.Fragment, null);
|
|
134
134
|
return (React.createElement(Card, { className: "pf-v6-u-mt-lg pf-v6-u-mb-0" },
|
|
135
135
|
React.createElement(CardHeader, null,
|
|
136
|
-
React.createElement("h3", null, isIdea ?
|
|
136
|
+
React.createElement("h3", null, isIdea ? React.createElement(Trans, null, "Search recommendations") : React.createElement(Trans, null, "Recommended search results"))),
|
|
137
137
|
React.createElement(CardBody, null,
|
|
138
138
|
React.createElement("ul", { className: "list-flat" }, recommendationState.sideRecommendation.map((doc, index) => {
|
|
139
139
|
var _a, _b;
|
|
@@ -184,7 +184,7 @@ export default function Recommendations(props) {
|
|
|
184
184
|
isATestvariation
|
|
185
185
|
? (recommendationState.visibleDocs.length !== 0 ||
|
|
186
186
|
recommendationState.isLoadingRecommendations) && (React.createElement("div", { className: `${recommendationState.isLoadingRecommendations ? 'gradient' : ''} label-container-icon` },
|
|
187
|
-
React.createElement(
|
|
187
|
+
React.createElement("div", { id: "DeepPurpleColorAILabel" },
|
|
188
188
|
recommendationState.isLoadingRecommendations ? (React.createElement(React.Fragment, null,
|
|
189
189
|
React.createElement("span", { className: "loading-text" },
|
|
190
190
|
React.createElement(Spinner, { size: "sm", className: "pf-v6-u-mr-xs" }),
|
|
@@ -200,7 +200,7 @@ export default function Recommendations(props) {
|
|
|
200
200
|
React.createElement(WatsonxAiIcon, { fillColor: "#FFFFFF", className: "pf-v6-u-mr-xs" }),
|
|
201
201
|
' ',
|
|
202
202
|
React.createElement("span", { className: "ai-label-text1" },
|
|
203
|
-
React.createElement(Trans, null, "
|
|
203
|
+
React.createElement(Trans, null, "Recommended search results"),
|
|
204
204
|
" ",
|
|
205
205
|
infoPopover)))),
|
|
206
206
|
' ')))
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AskRedHat.d.ts","sourceRoot":"","sources":["../../../../src/components/TroubleshootSection/AskRedHat.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAa5D,UAAU,MAAM;IACZ,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;CAClC;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAwTtC,CAAC"}
|
|
@@ -0,0 +1,184 @@
|
|
|
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 { Env } from '@cee-eng/hydrajs';
|
|
11
|
+
import { sendRHDirectMessageFeedback } from '@ifd-ui/ask-redhat-core';
|
|
12
|
+
import { Button, Card, CardBody, CardHeader, Modal, ModalVariant, Spinner } from '@patternfly/react-core';
|
|
13
|
+
import React, { useContext, useRef, useState } from 'react';
|
|
14
|
+
import { MODAL_MESSAGES, QUICK_RESPONSES, TOOLTIP_MESSAGES } from '../../constants/askRedHatMessages';
|
|
15
|
+
import { useAIResponseState } from '../../context/AIResponseContext';
|
|
16
|
+
import { RouteContext } from '../../context/RouteContext';
|
|
17
|
+
import { useParseRuleMarkdown } from '../../hooks/useParseRuleMarkdown';
|
|
18
|
+
import { appSourceId_ARH } from '../../reducers/CaseConstNTypes';
|
|
19
|
+
import { CollapseIcon } from './icons/CollapseIcon';
|
|
20
|
+
import { StarIcon } from './icons/StarIcon';
|
|
21
|
+
import ResponseActions from './ResponseActions';
|
|
22
|
+
import UserFeedback from './UserFeedback';
|
|
23
|
+
import UserFeedbackComplete from './UserFeedbackComplete';
|
|
24
|
+
export const AskRedHat = ({ onChatWithAIClick }) => {
|
|
25
|
+
var _a, _b, _c;
|
|
26
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
27
|
+
const [showFeedbackCard, setShowFeedbackCard] = useState(false);
|
|
28
|
+
const [showFeedbackComplete, setShowFeedbackComplete] = useState(false);
|
|
29
|
+
const [feedbackType, setFeedbackType] = useState('');
|
|
30
|
+
const [submittedFeedbackTypes, setSubmittedFeedbackTypes] = useState([]);
|
|
31
|
+
const [isSubmittingFeedback, setIsSubmittingFeedback] = useState(false);
|
|
32
|
+
const aiResponseState = useAIResponseState();
|
|
33
|
+
const contentRef = useRef(null);
|
|
34
|
+
const { routeState: { isCaseCreate }, } = useContext(RouteContext);
|
|
35
|
+
const onToggle = () => {
|
|
36
|
+
if (isExpanded && contentRef.current) {
|
|
37
|
+
contentRef.current.scrollTop = 0;
|
|
38
|
+
}
|
|
39
|
+
setIsExpanded((prev) => !prev);
|
|
40
|
+
};
|
|
41
|
+
const handleChatWithAIClick = () => onChatWithAIClick === null || onChatWithAIClick === void 0 ? void 0 : onChatWithAIClick();
|
|
42
|
+
const aiResponse = aiResponseState.aiResponse;
|
|
43
|
+
const messageId = aiResponse === null || aiResponse === void 0 ? void 0 : aiResponse.messageId;
|
|
44
|
+
const conversationId = aiResponse === null || aiResponse === void 0 ? void 0 : aiResponse.conversationId;
|
|
45
|
+
// Use accumulated response if streaming, otherwise use the final response
|
|
46
|
+
const answer = aiResponseState.isStreaming && aiResponseState.accumulatedResponse
|
|
47
|
+
? aiResponseState.accumulatedResponse
|
|
48
|
+
: (aiResponse === null || aiResponse === void 0 ? void 0 : aiResponse.answer) || (aiResponse === null || aiResponse === void 0 ? void 0 : aiResponse.content) || 'No AI response available yet.';
|
|
49
|
+
const sources = (aiResponse === null || aiResponse === void 0 ? void 0 : aiResponse.sources) || (aiResponse === null || aiResponse === void 0 ? void 0 : aiResponse.references) || [];
|
|
50
|
+
const sourcesCount = sources.length || 0;
|
|
51
|
+
// Show loading only when streaming has started but no content received yet
|
|
52
|
+
const isLoading = aiResponseState.isStreaming && aiResponseState.accumulatedResponse === '';
|
|
53
|
+
const isStreaming = aiResponseState.isStreaming;
|
|
54
|
+
const { parseMarkdown } = useParseRuleMarkdown();
|
|
55
|
+
const config = {
|
|
56
|
+
appSourceId: appSourceId_ARH,
|
|
57
|
+
packageVersion: (_a = window === null || window === void 0 ? void 0 : window.supportVersionInfo) === null || _a === void 0 ? void 0 : _a.packageVersion,
|
|
58
|
+
authToken: (_c = (_b = window === null || window === void 0 ? void 0 : window.sessionjs) === null || _b === void 0 ? void 0 : _b.getEncodedToken()) !== null && _c !== void 0 ? _c : '',
|
|
59
|
+
appEnv: Env.getEnvName(),
|
|
60
|
+
};
|
|
61
|
+
const handleFeedbackSubmit = (selectedResponse, additionalFeedback) => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
+
setIsSubmittingFeedback(true);
|
|
63
|
+
try {
|
|
64
|
+
const payload = {
|
|
65
|
+
rating: (feedbackType === 'positive' ? 'positive' : 'negative'),
|
|
66
|
+
freeform: additionalFeedback || undefined,
|
|
67
|
+
predefined_response: selectedResponse || '',
|
|
68
|
+
};
|
|
69
|
+
yield sendRHDirectMessageFeedback(conversationId, messageId, payload, config);
|
|
70
|
+
setShowFeedbackCard(false);
|
|
71
|
+
setShowFeedbackComplete(true);
|
|
72
|
+
setSubmittedFeedbackTypes((prev) => [...prev, feedbackType]);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
setShowFeedbackCard(false);
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
setIsSubmittingFeedback(false);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
const responseActions = {
|
|
82
|
+
positive: Object.assign({ onClick: () => {
|
|
83
|
+
setFeedbackType('positive');
|
|
84
|
+
setShowFeedbackCard(true);
|
|
85
|
+
} }, TOOLTIP_MESSAGES.positive),
|
|
86
|
+
negative: Object.assign({ onClick: () => {
|
|
87
|
+
setFeedbackType('negative');
|
|
88
|
+
setShowFeedbackCard(true);
|
|
89
|
+
} }, TOOLTIP_MESSAGES.negative),
|
|
90
|
+
copy: Object.assign({ onClick: () => {
|
|
91
|
+
navigator.clipboard.writeText(answer);
|
|
92
|
+
} }, TOOLTIP_MESSAGES.copy),
|
|
93
|
+
};
|
|
94
|
+
if (isLoading) {
|
|
95
|
+
return (React.createElement("div", { className: "ask-redhat" },
|
|
96
|
+
React.createElement("p", { className: "ask-redhat-title" },
|
|
97
|
+
React.createElement(StarIcon, { width: 20, height: 20 }),
|
|
98
|
+
isCaseCreate ? 'Resolve your issue now with AI insights' : 'Troubleshoot with AI insights'),
|
|
99
|
+
React.createElement("div", { className: "ask-redhat-content-wrapper" },
|
|
100
|
+
React.createElement("div", { className: "ask-redhat-content", style: { textAlign: 'center', padding: '2rem' } },
|
|
101
|
+
React.createElement(Spinner, { size: "lg" }),
|
|
102
|
+
React.createElement("p", { style: { marginTop: '1rem' } }, "Getting AI insights..."))),
|
|
103
|
+
!aiResponseState.isStreaming && (React.createElement("div", { className: "ask-redhat-toggle-button" },
|
|
104
|
+
React.createElement(Button, { variant: "link", onClick: handleChatWithAIClick, className: "ask-redhat-chat-button" }, "Chat with AI to get started")))));
|
|
105
|
+
}
|
|
106
|
+
// Show streaming content
|
|
107
|
+
if (isStreaming && aiResponseState.accumulatedResponse && aiResponseState.accumulatedResponse !== '') {
|
|
108
|
+
return (React.createElement("div", { className: "ask-redhat" },
|
|
109
|
+
React.createElement("p", { className: "ask-redhat-title" },
|
|
110
|
+
React.createElement(StarIcon, { width: 20, height: 20 }),
|
|
111
|
+
"Resolve your issue now with AI insights"),
|
|
112
|
+
React.createElement("div", { className: "ask-redhat-content-wrapper" },
|
|
113
|
+
React.createElement("div", { ref: contentRef, className: `ask-redhat-content ${isExpanded ? 'ask-redhat-content--expanded' : ''}` },
|
|
114
|
+
React.createElement("div", { className: `ask-redhat-content-scrollable ${isExpanded ? 'ask-redhat-content--expanded-scrollable' : ''}` },
|
|
115
|
+
React.createElement("div", null,
|
|
116
|
+
React.createElement("div", { dangerouslySetInnerHTML: { __html: parseMarkdown(answer) } }),
|
|
117
|
+
React.createElement("div", { style: { display: 'inline-block' } },
|
|
118
|
+
React.createElement(Spinner, { size: "sm" })))),
|
|
119
|
+
!isExpanded && React.createElement("div", { className: "ask-redhat-fade-overlay" }))),
|
|
120
|
+
React.createElement("div", { className: "ask-redhat-toggle-button-wrapper" },
|
|
121
|
+
React.createElement("div", { className: "ask-redhat-border-line" }),
|
|
122
|
+
React.createElement(Button, { onClick: onToggle, className: isExpanded ? 'ask-redhat-toggle-button-collapsed' : 'ask-redhat-toggle-button' },
|
|
123
|
+
isExpanded ? React.createElement(CollapseIcon, null) : React.createElement(StarIcon, { width: 20, height: 20 }),
|
|
124
|
+
isExpanded ? '' : 'Read more'))));
|
|
125
|
+
}
|
|
126
|
+
if (aiResponseState.error) {
|
|
127
|
+
return (React.createElement("div", { className: "ask-redhat" },
|
|
128
|
+
React.createElement("p", { className: "ask-redhat-title" },
|
|
129
|
+
React.createElement(StarIcon, { width: 20, height: 20 }),
|
|
130
|
+
"Resolve your issue now with AI insights"),
|
|
131
|
+
React.createElement("div", { className: "ask-redhat-content-wrapper" },
|
|
132
|
+
React.createElement("div", { className: "ask-redhat-content", style: { textAlign: 'center', padding: '2rem' } },
|
|
133
|
+
React.createElement("p", { style: { color: '#d73502', marginBottom: '1rem' } }, "Unable to get AI insights. Please try again later."),
|
|
134
|
+
React.createElement(Button, { variant: "link", onClick: handleChatWithAIClick, className: "ask-redhat-chat-button", icon: React.createElement(StarIcon, null) }, "Try again with AI Chat")))));
|
|
135
|
+
}
|
|
136
|
+
return (React.createElement("div", { className: "ask-redhat" },
|
|
137
|
+
React.createElement("p", { className: "ask-redhat-title" },
|
|
138
|
+
React.createElement(StarIcon, { width: 20, height: 20 }),
|
|
139
|
+
isCaseCreate ? 'Resolve your issue now with AI insights' : 'Troubleshoot with AI insights'),
|
|
140
|
+
React.createElement("div", { className: "ask-redhat-content-wrapper" },
|
|
141
|
+
React.createElement("div", { ref: contentRef, className: `ask-redhat-content ${isExpanded ? 'ask-redhat-content--expanded' : ''}` },
|
|
142
|
+
React.createElement("div", { className: `ask-redhat-content-scrollable ${isExpanded ? 'ask-redhat-content--expanded-scrollable' : ''}` },
|
|
143
|
+
React.createElement("div", null,
|
|
144
|
+
React.createElement("div", { dangerouslySetInnerHTML: { __html: parseMarkdown(answer) } }),
|
|
145
|
+
sourcesCount > 0 && (React.createElement(React.Fragment, null,
|
|
146
|
+
React.createElement("p", null, "2 sources"),
|
|
147
|
+
React.createElement("div", { className: "ask-redhat-cards" }, sources.map((source, index) => (React.createElement(Card, { className: "ask-redhat-card", key: index },
|
|
148
|
+
React.createElement(CardHeader, null,
|
|
149
|
+
React.createElement("h3", { className: "ask-redhat-card-title" },
|
|
150
|
+
React.createElement("a", { href: source.link, target: "_blank", rel: "noopener noreferrer" }, source.title))),
|
|
151
|
+
React.createElement(CardBody, null,
|
|
152
|
+
React.createElement("p", null, source.snippet)))))))),
|
|
153
|
+
React.createElement("div", { className: "response-actions-wrapper" },
|
|
154
|
+
React.createElement(ResponseActions, { actions: responseActions, submittedFeedbackTypes: submittedFeedbackTypes })))),
|
|
155
|
+
React.createElement("div", { className: "ask-redhat-footer-wrapper" },
|
|
156
|
+
React.createElement("div", { className: "ask-redhat-footer" },
|
|
157
|
+
React.createElement("p", { className: "ask-redhat-footer-text" }, "Want to continue the conversation? Dive deeper with our AI assistant"),
|
|
158
|
+
React.createElement(Button, { onClick: handleChatWithAIClick, className: 'ask-redhat-chat-button', icon: React.createElement(StarIcon, null) }, "Chat with AI"))),
|
|
159
|
+
!isExpanded && React.createElement("div", { className: "ask-redhat-fade-overlay" }))),
|
|
160
|
+
React.createElement("div", { className: "ask-redhat-toggle-button-wrapper" },
|
|
161
|
+
React.createElement("div", { className: "ask-redhat-border-line" }),
|
|
162
|
+
React.createElement(Button, { onClick: onToggle, className: isExpanded ? 'ask-redhat-toggle-button-collapsed' : 'ask-redhat-toggle-button' },
|
|
163
|
+
isExpanded ? React.createElement(CollapseIcon, null) : React.createElement(StarIcon, { width: 20, height: 20 }),
|
|
164
|
+
isExpanded ? '' : 'Read more')),
|
|
165
|
+
React.createElement(Modal, { variant: ModalVariant.small, isOpen: showFeedbackCard, onClose: () => {
|
|
166
|
+
setShowFeedbackCard(false);
|
|
167
|
+
setFeedbackType('');
|
|
168
|
+
setIsSubmittingFeedback(false);
|
|
169
|
+
} },
|
|
170
|
+
React.createElement(UserFeedback, { title: feedbackType === 'positive'
|
|
171
|
+
? MODAL_MESSAGES.feedback.positive
|
|
172
|
+
: MODAL_MESSAGES.feedback.negative, hasTextArea: true, quickResponses: feedbackType === 'positive' ? QUICK_RESPONSES.positive : QUICK_RESPONSES.negative, onSubmit: handleFeedbackSubmit, onClose: () => {
|
|
173
|
+
setShowFeedbackCard(false);
|
|
174
|
+
setFeedbackType('');
|
|
175
|
+
}, isSubmitting: isSubmittingFeedback })),
|
|
176
|
+
React.createElement(Modal, { variant: ModalVariant.small, isOpen: showFeedbackComplete, onClose: () => {
|
|
177
|
+
setShowFeedbackComplete(false);
|
|
178
|
+
setFeedbackType('');
|
|
179
|
+
} },
|
|
180
|
+
React.createElement(UserFeedbackComplete, { title: MODAL_MESSAGES.complete.title, body: MODAL_MESSAGES.complete.body, onClose: () => {
|
|
181
|
+
setShowFeedbackComplete(false);
|
|
182
|
+
setFeedbackType('');
|
|
183
|
+
} }))));
|
|
184
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ButtonProps } from '@patternfly/react-core';
|
|
2
|
+
import { type FunctionComponent } from 'react';
|
|
3
|
+
export interface CloseButtonProps extends ButtonProps {
|
|
4
|
+
onClose?: () => void;
|
|
5
|
+
ariaLabel?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const CloseButton: FunctionComponent<CloseButtonProps>;
|
|
8
|
+
export default CloseButton;
|
|
9
|
+
//# sourceMappingURL=CloseButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CloseButton.d.ts","sourceRoot":"","sources":["../../../../src/components/TroubleshootSection/CloseButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAU,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEtD,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACjD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,QAAA,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,CAEpD,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Button } from '@patternfly/react-core';
|
|
2
|
+
import CloseIcon from '@patternfly/react-icons/dist/esm/icons/close-icon';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
const CloseButton = ({ onClose, ariaLabel }) => (React.createElement(Button, { variant: "plain", onClick: onClose, icon: React.createElement(CloseIcon, null), "aria-label": ariaLabel }));
|
|
5
|
+
export default CloseButton;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LabelGroupProps, LabelProps } from '@patternfly/react-core';
|
|
2
|
+
import { type FunctionComponent } from 'react';
|
|
3
|
+
export interface QuickResponse extends Omit<LabelProps, 'children'> {
|
|
4
|
+
content: string;
|
|
5
|
+
id: string;
|
|
6
|
+
}
|
|
7
|
+
export interface QuickResponseProps {
|
|
8
|
+
quickResponses: QuickResponse[];
|
|
9
|
+
quickResponseContainerProps?: Omit<LabelGroupProps, 'ref'>;
|
|
10
|
+
onSelect?: (id: string) => void;
|
|
11
|
+
isCompact?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare const QuickResponse: FunctionComponent<QuickResponseProps>;
|
|
14
|
+
export default QuickResponse;
|
|
15
|
+
//# sourceMappingURL=QuickResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QuickResponse.d.ts","sourceRoot":"","sources":["../../../../src/components/TroubleshootSection/QuickResponse.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,eAAe,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAExF,OAAc,EAAE,KAAK,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAEhE,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IAC/B,cAAc,EAAE,aAAa,EAAE,CAAC;IAChC,2BAA2B,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IAC3D,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,eAAO,MAAM,aAAa,EAAE,iBAAiB,CAAC,kBAAkB,CAqC/D,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { Label, LabelGroup } from '@patternfly/react-core';
|
|
13
|
+
import CheckIcon from '@patternfly/react-icons/dist/esm/icons/check-icon';
|
|
14
|
+
import React, { useState } from 'react';
|
|
15
|
+
export const QuickResponse = ({ quickResponses, quickResponseContainerProps = { numLabels: 5 }, onSelect, isCompact, }) => {
|
|
16
|
+
const [selectedQuickResponse, setSelectedQuickResponse] = useState();
|
|
17
|
+
const handleQuickResponseClick = (id) => {
|
|
18
|
+
setSelectedQuickResponse(id);
|
|
19
|
+
onSelect && onSelect(id);
|
|
20
|
+
};
|
|
21
|
+
return (React.createElement(LabelGroup, Object.assign({ className: `pf-chatbot__message-quick-response ${(quickResponseContainerProps === null || quickResponseContainerProps === void 0 ? void 0 : quickResponseContainerProps.className) ? quickResponseContainerProps === null || quickResponseContainerProps === void 0 ? void 0 : quickResponseContainerProps.className : ''}` }, quickResponseContainerProps), quickResponses.map((_a) => {
|
|
22
|
+
var { id, content, className } = _a, props = __rest(_a, ["id", "content", "className"]);
|
|
23
|
+
return (React.createElement(Label, Object.assign({ variant: id === selectedQuickResponse ? undefined : 'outline', icon: id === selectedQuickResponse ? React.createElement(CheckIcon, null) : undefined, color: "blue", key: id, onClick: () => handleQuickResponseClick(id), className: `${id === selectedQuickResponse ? 'pf-chatbot__message-quick-response--selected' : ''} ${className ? className : ''}`, isCompact: isCompact }, props), content));
|
|
24
|
+
})));
|
|
25
|
+
};
|
|
26
|
+
export default QuickResponse;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ButtonProps } from '@patternfly/react-core';
|
|
2
|
+
import React, { type FunctionComponent, type MouseEvent } from 'react';
|
|
3
|
+
export interface ResponseActionButtonProps extends ButtonProps {
|
|
4
|
+
ariaLabel?: string;
|
|
5
|
+
clickedAriaLabel?: string;
|
|
6
|
+
icon: React.ReactNode;
|
|
7
|
+
onClick?: ((event: MouseEvent | React.MouseEvent<Element, MouseEvent> | KeyboardEvent) => void) | undefined;
|
|
8
|
+
tooltipContent?: string;
|
|
9
|
+
clickedTooltipContent?: string;
|
|
10
|
+
/** Props to control if the button should be disabled */
|
|
11
|
+
isDisabled?: boolean;
|
|
12
|
+
isClicked?: boolean;
|
|
13
|
+
innerRef?: React.Ref<HTMLButtonElement>;
|
|
14
|
+
}
|
|
15
|
+
export declare const ResponseActionButtonBase: FunctionComponent<ResponseActionButtonProps>;
|
|
16
|
+
declare const ResponseActionButton: React.ForwardRefExoticComponent<ResponseActionButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
17
|
+
export default ResponseActionButton;
|
|
18
|
+
//# sourceMappingURL=ResponseActionButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResponseActionButton.d.ts","sourceRoot":"","sources":["../../../../src/components/TroubleshootSection/ResponseActionButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAU,WAAW,EAAiB,MAAM,wBAAwB,CAAC;AAC5E,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,KAAK,UAAU,EAAwB,MAAM,OAAO,CAAC;AAE7F,MAAM,WAAW,yBAA0B,SAAQ,WAAW;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,aAAa,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC5G,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,wDAAwD;IACxD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;CAC3C;AAED,eAAO,MAAM,wBAAwB,EAAE,iBAAiB,CAAC,yBAAyB,CAmDjF,CAAC;AAEF,QAAA,MAAM,oBAAoB,qGAExB,CAAC;AAEH,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { Button, Icon, Tooltip } from '@patternfly/react-core';
|
|
13
|
+
import React, { forwardRef } from 'react';
|
|
14
|
+
export const ResponseActionButtonBase = (_a) => {
|
|
15
|
+
var { ariaLabel, clickedAriaLabel = ariaLabel, icon, onClick, tooltipContent, clickedTooltipContent = tooltipContent, isDisabled, isClicked = false, innerRef } = _a, props = __rest(_a, ["ariaLabel", "clickedAriaLabel", "icon", "onClick", "tooltipContent", "clickedTooltipContent", "isDisabled", "isClicked", "innerRef"]);
|
|
16
|
+
const generateAriaLabel = () => {
|
|
17
|
+
if (ariaLabel) {
|
|
18
|
+
return isClicked ? clickedAriaLabel : ariaLabel;
|
|
19
|
+
}
|
|
20
|
+
return isClicked ? clickedTooltipContent : tooltipContent;
|
|
21
|
+
};
|
|
22
|
+
return (React.createElement(Tooltip, { id: `pf-chatbot__tooltip-response-action-${tooltipContent}`, content: isClicked ? clickedTooltipContent : tooltipContent, "aria-live": "polite", position: "bottom", entryDelay: 0, exitDelay: 0, distance: 8, animationDuration: 0,
|
|
23
|
+
// prevents VO announcements of both aria label and tooltip
|
|
24
|
+
aria: "none" },
|
|
25
|
+
React.createElement(Button, Object.assign({ variant: "plain", className: `pf-chatbot__button--response-action ${isClicked ? 'pf-chatbot__button--response-action-clicked' : ''}`, "aria-label": generateAriaLabel(), icon: React.createElement(Icon, { isInline: true, size: "lg" }, icon), isDisabled: isDisabled, onClick: onClick, size: "sm", ref: innerRef }, props))));
|
|
26
|
+
};
|
|
27
|
+
const ResponseActionButton = forwardRef((props, ref) => (React.createElement(ResponseActionButtonBase, Object.assign({ innerRef: ref }, props))));
|
|
28
|
+
export default ResponseActionButton;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ButtonProps } from '@patternfly/react-core';
|
|
2
|
+
import React, { type FunctionComponent, type MouseEvent } from 'react';
|
|
3
|
+
export interface ActionProps extends Omit<ButtonProps, 'ref'> {
|
|
4
|
+
ariaLabel?: string;
|
|
5
|
+
clickedAriaLabel?: string;
|
|
6
|
+
onClick?: ((event: MouseEvent | React.MouseEvent<Element, MouseEvent> | KeyboardEvent) => void) | undefined;
|
|
7
|
+
tooltipContent?: string;
|
|
8
|
+
clickedTooltipContent?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ResponseActionProps {
|
|
11
|
+
actions: {
|
|
12
|
+
positive?: ActionProps;
|
|
13
|
+
negative?: ActionProps;
|
|
14
|
+
copy?: ActionProps;
|
|
15
|
+
};
|
|
16
|
+
submittedFeedbackTypes?: string[];
|
|
17
|
+
}
|
|
18
|
+
export declare const ResponseActions: FunctionComponent<ResponseActionProps>;
|
|
19
|
+
export default ResponseActions;
|
|
20
|
+
//# sourceMappingURL=ResponseActions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResponseActions.d.ts","sourceRoot":"","sources":["../../../../src/components/TroubleshootSection/ResponseActions.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIrD,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,KAAK,UAAU,EAA+B,MAAM,OAAO,CAAC;AAIpG,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,aAAa,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC5G,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE;QACL,QAAQ,CAAC,EAAE,WAAW,CAAC;QACvB,QAAQ,CAAC,EAAE,WAAW,CAAC;QACvB,IAAI,CAAC,EAAE,WAAW,CAAC;KACtB,CAAC;IACF,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;CACrC;AAED,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAC,mBAAmB,CAyFlE,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import OutlinedCopyIcon from '@patternfly/react-icons/dist/esm/icons/outlined-copy-icon';
|
|
2
|
+
import OutlinedThumbsDownIcon from '@patternfly/react-icons/dist/esm/icons/outlined-thumbs-down-icon';
|
|
3
|
+
import OutlinedThumbsUpIcon from '@patternfly/react-icons/dist/esm/icons/outlined-thumbs-up-icon';
|
|
4
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import ResponseActionButton from './ResponseActionButton';
|
|
6
|
+
export const ResponseActions = ({ actions, submittedFeedbackTypes = [] }) => {
|
|
7
|
+
var _a, _b, _c, _d, _e, _f;
|
|
8
|
+
const [activeButton, setActiveButton] = useState();
|
|
9
|
+
const [clickStatePersisted, setClickStatePersisted] = useState(false);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
// Define the order of precedence for checking initial `isClicked`
|
|
12
|
+
const actionPrecedence = ['positive', 'negative', 'copy'];
|
|
13
|
+
let initialActive;
|
|
14
|
+
// Check predefined actions first based on precedence
|
|
15
|
+
for (const actionName of actionPrecedence) {
|
|
16
|
+
const actionProp = actions[actionName];
|
|
17
|
+
if (actionProp === null || actionProp === void 0 ? void 0 : actionProp.isClicked) {
|
|
18
|
+
initialActive = actionName;
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (initialActive) {
|
|
23
|
+
// Click state is explicitly controlled by consumer.
|
|
24
|
+
setClickStatePersisted(true);
|
|
25
|
+
}
|
|
26
|
+
setActiveButton(initialActive);
|
|
27
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
|
+
}, [actions]);
|
|
29
|
+
const { positive, negative, copy } = actions;
|
|
30
|
+
const responseActions = useRef(null);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const handleClickOutside = (e) => {
|
|
33
|
+
if (responseActions.current && !responseActions.current.contains(e.target) && !clickStatePersisted) {
|
|
34
|
+
setActiveButton(undefined);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
window.addEventListener('click', handleClickOutside);
|
|
38
|
+
return () => {
|
|
39
|
+
window.removeEventListener('click', handleClickOutside);
|
|
40
|
+
};
|
|
41
|
+
}, [clickStatePersisted]);
|
|
42
|
+
const handleClick = (e, id, onClick) => {
|
|
43
|
+
setClickStatePersisted(false);
|
|
44
|
+
setActiveButton(id);
|
|
45
|
+
onClick && onClick(e);
|
|
46
|
+
};
|
|
47
|
+
return (React.createElement("div", { ref: responseActions, className: "pf-chatbot__response-actions" },
|
|
48
|
+
positive && (React.createElement(ResponseActionButton, { ariaLabel: "Good response", clickedAriaLabel: "Response recorded", onClick: (e) => handleClick(e, 'positive', positive.onClick), tooltipContent: (_a = positive.tooltipContent) !== null && _a !== void 0 ? _a : 'Good response', clickedTooltipContent: (_b = positive.clickedTooltipContent) !== null && _b !== void 0 ? _b : 'Response recorded', icon: React.createElement(OutlinedThumbsUpIcon, null), isClicked: activeButton === 'positive', isDisabled: submittedFeedbackTypes === null || submittedFeedbackTypes === void 0 ? void 0 : submittedFeedbackTypes.includes('positive') })),
|
|
49
|
+
negative && (React.createElement(ResponseActionButton, { ariaLabel: "Bad response", clickedAriaLabel: "Response recorded", onClick: (e) => handleClick(e, 'negative', negative.onClick), tooltipContent: (_c = negative.tooltipContent) !== null && _c !== void 0 ? _c : 'Bad response', clickedTooltipContent: (_d = negative.clickedTooltipContent) !== null && _d !== void 0 ? _d : 'Response recorded', icon: React.createElement(OutlinedThumbsDownIcon, null), isClicked: activeButton === 'negative', isDisabled: submittedFeedbackTypes === null || submittedFeedbackTypes === void 0 ? void 0 : submittedFeedbackTypes.includes('negative') })),
|
|
50
|
+
copy && (React.createElement(ResponseActionButton, { ariaLabel: "Copy", clickedAriaLabel: "Copied", onClick: (e) => handleClick(e, 'copy', copy.onClick), tooltipContent: (_e = copy.tooltipContent) !== null && _e !== void 0 ? _e : 'Copy', clickedTooltipContent: (_f = copy.clickedTooltipContent) !== null && _f !== void 0 ? _f : 'Copied', icon: React.createElement(OutlinedCopyIcon, null), isClicked: activeButton === 'copy' }))));
|
|
51
|
+
};
|
|
52
|
+
export default ResponseActions;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '@ifd-ui/ask-redhat-core/ask-redhat-core.css';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
interface IProps {
|
|
3
4
|
inlineEditable: boolean;
|
|
@@ -6,6 +7,12 @@ interface IProps {
|
|
|
6
7
|
collapseOnBlur?: boolean;
|
|
7
8
|
autoFocus?: boolean;
|
|
8
9
|
hideSaveCancel?: boolean;
|
|
10
|
+
isAIChatMode: boolean;
|
|
11
|
+
setIsAIChatMode: (value: boolean) => void;
|
|
12
|
+
onChatWithAIClick?: () => void;
|
|
13
|
+
aiServicesAvailable: boolean;
|
|
14
|
+
isSecureSupport?: boolean;
|
|
15
|
+
hasConfirmedStatesideSupport?: boolean;
|
|
9
16
|
}
|
|
10
17
|
declare function TroubleshootSection(props: IProps): React.JSX.Element;
|
|
11
18
|
declare namespace TroubleshootSection {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TroubleshootSection.d.ts","sourceRoot":"","sources":["../../../../src/components/TroubleshootSection/TroubleshootSection.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TroubleshootSection.d.ts","sourceRoot":"","sources":["../../../../src/components/TroubleshootSection/TroubleshootSection.tsx"],"names":[],"mappings":"AAAA,OAAO,6CAA6C,CAAC;AAUrD,OAAO,KAAqB,MAAM,OAAO,CAAC;AAc1C,UAAU,MAAM;IACZ,cAAc,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1C,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,4BAA4B,CAAC,EAAE,OAAO,CAAC;CAC1C;AAUD,iBAAS,mBAAmB,CAAC,KAAK,EAAE,MAAM,qBAgLzC;kBAhLQ,mBAAmB;;;AAmL5B,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
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 '@ifd-ui/ask-redhat-core/ask-redhat-core.css';
|
|
11
|
+
import { Env } from '@cee-eng/hydrajs';
|
|
12
|
+
import { AskRedHatChat, setAuthToken } from '@ifd-ui/ask-redhat-core';
|
|
13
|
+
import { Button, Card, CardBody, CardHeader, Tooltip } from '@patternfly/react-core';
|
|
2
14
|
import InfoCircleIcon from '@patternfly/react-icons/dist/js/icons/info-circle-icon';
|
|
3
15
|
import { ErrorBoundary, LoadingDots } from '@rh-support/components';
|
|
4
16
|
import { PreviousCaseTypes } from '@rh-support/utils';
|
|
@@ -6,23 +18,33 @@ import isEmpty from 'lodash/isEmpty';
|
|
|
6
18
|
import isEqual from 'lodash/isEqual';
|
|
7
19
|
import React, { useContext } from 'react';
|
|
8
20
|
import { Trans, useTranslation } from 'react-i18next';
|
|
21
|
+
import { useAIResponseState } from '../../context/AIResponseContext';
|
|
9
22
|
import { useCaseSelector } from '../../context/CaseContext';
|
|
23
|
+
import { RouteContext } from '../../context/RouteContext';
|
|
10
24
|
import { TCStateContext } from '../../context/TopContentContext';
|
|
25
|
+
import { appSourceId_ARH, excludedCaseTypesforARH } from '../../reducers/CaseConstNTypes';
|
|
11
26
|
import { OpenShiftClusterId } from '../CaseManagement/OpenShiftClusterId';
|
|
12
27
|
import ClusterRecommendations from '../Recommendations/ClusterRecommendations';
|
|
13
28
|
import InsightsResults from '../Recommendations/InsightsResults';
|
|
14
29
|
import Suggestions from '../Suggestions/Suggestions';
|
|
30
|
+
import { AskRedHat } from './AskRedHat';
|
|
15
31
|
const defaultProps = {
|
|
16
32
|
initialIsEditing: false,
|
|
17
33
|
required: false,
|
|
18
34
|
collapseOnBlur: false,
|
|
19
35
|
autoFocus: false,
|
|
20
36
|
hideSaveCancel: false,
|
|
37
|
+
aiServicesAvailable: false,
|
|
21
38
|
};
|
|
22
39
|
function TroubleshootSection(props) {
|
|
23
|
-
var _a;
|
|
40
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
24
41
|
const { t } = useTranslation();
|
|
42
|
+
const { aiServicesAvailable, isAIChatMode, setIsAIChatMode, onChatWithAIClick } = props;
|
|
25
43
|
const { topContentState: { topContent }, } = useContext(TCStateContext);
|
|
44
|
+
const { routeState: { isCaseCreate }, } = useContext(RouteContext);
|
|
45
|
+
const aiResponseState = useAIResponseState();
|
|
46
|
+
const session = window === null || window === void 0 ? void 0 : window.sessionjs;
|
|
47
|
+
const keycloakSession = (_b = (_a = session === null || session === void 0 ? void 0 : session._state) === null || _a === void 0 ? void 0 : _a.keycloak) !== null && _b !== void 0 ? _b : null;
|
|
26
48
|
const { product, version, isCreatingCase, caseType } = useCaseSelector((state) => ({
|
|
27
49
|
product: state.caseDetails.product,
|
|
28
50
|
version: state.caseDetails.version,
|
|
@@ -32,18 +54,82 @@ function TroubleshootSection(props) {
|
|
|
32
54
|
issue: state.caseDetails.issue,
|
|
33
55
|
}), isEqual);
|
|
34
56
|
const canShowTopProducts = isEmpty(product);
|
|
35
|
-
const canShowTopContent = !canShowTopProducts && ((
|
|
57
|
+
const canShowTopContent = !canShowTopProducts && ((_c = topContent === null || topContent === void 0 ? void 0 : topContent.data) === null || _c === void 0 ? void 0 : _c.length) > 0;
|
|
36
58
|
const isNotAnIdea = caseType !== PreviousCaseTypes.FEATURE_ENHANCEMENT;
|
|
37
|
-
|
|
59
|
+
const shouldShowARHUI = () => {
|
|
60
|
+
// Check if the case type is allowed (not in the excluded list)
|
|
61
|
+
// test
|
|
62
|
+
const isCaseTypeAllowed = !excludedCaseTypesforARH.includes(caseType !== null && caseType !== void 0 ? caseType : '');
|
|
63
|
+
// Check if user is not a secure support or confirmed stateside support user
|
|
64
|
+
const isNotSecureOrStatesideUser = !props.isSecureSupport && !props.hasConfirmedStatesideSupport;
|
|
65
|
+
// Check if AI services are available
|
|
66
|
+
const isAIServicesAvailable = aiServicesAvailable;
|
|
67
|
+
return isCaseTypeAllowed && isNotSecureOrStatesideUser && isAIServicesAvailable;
|
|
68
|
+
};
|
|
69
|
+
const handleInitialized = (success, error) => {
|
|
70
|
+
if (success) {
|
|
71
|
+
console.log('Chat initialized successfully');
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
console.error('Chat initialization failed:', error);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const preprocessRequest = () => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
var _a;
|
|
79
|
+
if (!keycloakSession) {
|
|
80
|
+
throw new Error('No Keycloak session available');
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
yield ((_a = session === null || session === void 0 ? void 0 : session.updateToken) === null || _a === void 0 ? void 0 : _a.call(session, 500));
|
|
84
|
+
const token = session === null || session === void 0 ? void 0 : session.getEncodedToken();
|
|
85
|
+
if (token) {
|
|
86
|
+
setAuthToken(token);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
throw new Error('No token available');
|
|
90
|
+
}
|
|
91
|
+
return Promise.resolve();
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
console.error('Failed to refresh token:', error);
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const initConfig = {
|
|
99
|
+
packageVersion: (_d = window === null || window === void 0 ? void 0 : window.supportVersionInfo) === null || _d === void 0 ? void 0 : _d.packageVersion,
|
|
100
|
+
appSourceId: appSourceId_ARH,
|
|
101
|
+
enableDebugLogging: false,
|
|
102
|
+
headerTitle: 'AI insights',
|
|
103
|
+
appEnv: Env.getEnvName(),
|
|
104
|
+
showWelcomeMessage: false,
|
|
105
|
+
conversationId: ((_e = aiResponseState.aiResponse) === null || _e === void 0 ? void 0 : _e.conversationId) || undefined,
|
|
106
|
+
enableHeaderMenu: false,
|
|
107
|
+
enableTheme: false,
|
|
108
|
+
tokenAuth: {
|
|
109
|
+
auth: {
|
|
110
|
+
userInfo: (_h = (_g = (_f = window === null || window === void 0 ? void 0 : window.sessionjs) === null || _f === void 0 ? void 0 : _f.getToken) === null || _g === void 0 ? void 0 : _g.call(_f)) !== null && _h !== void 0 ? _h : {},
|
|
111
|
+
authToken: (_k = (_j = window === null || window === void 0 ? void 0 : window.sessionjs) === null || _j === void 0 ? void 0 : _j.getEncodedToken()) !== null && _k !== void 0 ? _k : '',
|
|
112
|
+
},
|
|
113
|
+
events: {
|
|
114
|
+
preprocessRequest,
|
|
115
|
+
isAuthenticated: () => {
|
|
116
|
+
var _a, _b, _c;
|
|
117
|
+
return (_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.sessionjs) === null || _a === void 0 ? void 0 : _a.isAuthenticated) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : false;
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
onInitialized: handleInitialized,
|
|
122
|
+
};
|
|
123
|
+
const handleChatWithAIClick = () => {
|
|
124
|
+
setIsAIChatMode(true);
|
|
125
|
+
onChatWithAIClick === null || onChatWithAIClick === void 0 ? void 0 : onChatWithAIClick();
|
|
126
|
+
};
|
|
127
|
+
return (React.createElement(React.Fragment, null, isAIChatMode ? (React.createElement(React.Fragment, null,
|
|
128
|
+
React.createElement(AskRedHatChat, { initConfig: initConfig }),
|
|
129
|
+
React.createElement("div", { className: "fullscreen-chat-footer" },
|
|
130
|
+
React.createElement(Button, { onClick: () => props.setIsAIChatMode(false), variant: "link", className: "return-to-case-btn" }, isCaseCreate ? t('Return to case creation') : t('Back to resources'))))) : (React.createElement(React.Fragment, null,
|
|
38
131
|
React.createElement("section", null,
|
|
39
|
-
React.createElement(
|
|
40
|
-
React.createElement("p", { className: "pf-v6-u-pt-md" },
|
|
41
|
-
React.createElement("span", { className: "pf-v6-u-font-family-heading pf-v6-u-pr-xs" }, t('Product')),
|
|
42
|
-
" ",
|
|
43
|
-
product),
|
|
44
|
-
React.createElement("p", null,
|
|
45
|
-
React.createElement("span", { className: "pf-v6-u-font-family-heading pf-v6-u-pr-xs" }, t('Version')),
|
|
46
|
-
version)),
|
|
132
|
+
shouldShowARHUI() && React.createElement(AskRedHat, { onChatWithAIClick: handleChatWithAIClick }),
|
|
47
133
|
!isCreatingCase && (React.createElement(OpenShiftClusterId, { className: "push-bottom", "data-tracking-id": "troubleshoot-section-openshift-cluster-id" })),
|
|
48
134
|
React.createElement(LoadingDots, { show: topContent.isFetching }),
|
|
49
135
|
topContent.data.length === 0 && (React.createElement(Card, { id: "card", className: "pf-v6-u-mb-md" },
|
|
@@ -56,7 +142,7 @@ function TroubleshootSection(props) {
|
|
|
56
142
|
React.createElement(Trans, null, "No recommendations for this product")))),
|
|
57
143
|
React.createElement(ErrorBoundary, { errorMsgInfo: { message: t('There was an error loading suggestions') } }, canShowTopContent && !isEmpty(version) && React.createElement(Suggestions, null)),
|
|
58
144
|
!isCreatingCase && React.createElement(ClusterRecommendations, { className: "pf-v6-u-mt-lg" })),
|
|
59
|
-
React.createElement("section", { className: "pf-v6-u-mt-lg" }, isNotAnIdea && (React.createElement(InsightsResults, { isDisplayOnMain: true, "data-tracking-id": "troubleshoot-section-file-recs" })))));
|
|
145
|
+
React.createElement("section", { className: "pf-v6-u-mt-lg" }, isNotAnIdea && (React.createElement(InsightsResults, { isDisplayOnMain: true, "data-tracking-id": "troubleshoot-section-file-recs" })))))));
|
|
60
146
|
}
|
|
61
147
|
TroubleshootSection.defaultProps = defaultProps;
|
|
62
148
|
export default TroubleshootSection;
|