Skip to content

Commit 90fa332

Browse files
authored
Merge branch 'opensearch-project:main' into boarderTop
2 parents c722883 + 584a229 commit 90fa332

File tree

6 files changed

+64
-60
lines changed

6 files changed

+64
-60
lines changed

public/components/incontext_insight/generate_popover_body.test.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ describe('GeneratePopoverBody', () => {
143143
expect.stringMatching(/^generated/)
144144
);
145145

146-
// insight tip icon is visible
147-
const insightTipIcon = screen.getAllByLabelText('How was this generated?')[0];
148-
expect(insightTipIcon).toBeInTheDocument();
146+
// insight button is visible
147+
const insightButton = screen.getAllByText('View insight')[0];
148+
expect(insightButton).toBeInTheDocument();
149149

150-
// 2. Click insight tip icon to view insight
151-
fireEvent.click(insightTipIcon);
150+
// 2. Click insight button to view insight
151+
fireEvent.click(insightButton);
152152
// title is back button + 'Insight With RAG'
153153
let backButton = getByLabelText('back-to-summary');
154154
expect(backButton).toBeInTheDocument();
@@ -223,8 +223,8 @@ describe('GeneratePopoverBody', () => {
223223
expect.stringMatching(/^generated/)
224224
);
225225

226-
// insight tip icon is not visible
227-
expect(screen.queryAllByLabelText('How was this generated?')).toHaveLength(0);
226+
// insight button is not visible
227+
expect(screen.queryAllByLabelText('View insight')).toHaveLength(0);
228228
// Only call http post 1 time.
229229
expect(mockPost).toHaveBeenCalledTimes(1);
230230
});
@@ -285,8 +285,8 @@ describe('GeneratePopoverBody', () => {
285285
});
286286
// Show summary content although insight generation failed
287287
expect(getByText('Generated summary content')).toBeInTheDocument();
288-
// insight tip icon is not visible for this alert
289-
expect(screen.queryAllByLabelText('How was this generated?')).toHaveLength(0);
288+
// insight button is not visible for this alert
289+
expect(screen.queryAllByLabelText('View insight')).toHaveLength(0);
290290
});
291291

292292
it('should not display discover link if monitor type is not query_level_monitor or bucket_level_monitor', async () => {

public/components/incontext_insight/generate_popover_body.tsx

+24-31
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
EuiText,
1919
EuiTitle,
2020
EuiButton,
21+
EuiButtonEmpty,
2122
} from '@elastic/eui';
2223
import { useEffectOnce } from 'react-use';
2324
import { METRIC_TYPE } from '@osd/analytics';
@@ -263,12 +264,12 @@ export const GeneratePopoverBody: React.FC<{
263264
const content = showInsight && insightAvailable ? insight : summary;
264265
return content ? (
265266
<>
266-
<EuiPanel paddingSize="s" hasBorder hasShadow={false} color="subdued">
267+
<EuiPanel paddingSize="s" hasBorder hasShadow={false}>
267268
<EuiText className="incontextInsightGeneratePopoverContent" size="s">
268269
<EuiMarkdownFormat>{content}</EuiMarkdownFormat>
269270
</EuiText>
270271
<EuiSpacer size={'xs'} />
271-
{renderInnerFooter()}
272+
{renderInnerFooter(content)}
272273
</EuiPanel>
273274
</>
274275
) : (
@@ -289,7 +290,7 @@ export const GeneratePopoverBody: React.FC<{
289290
setShowInsight(false);
290291
}}
291292
type="arrowLeft"
292-
color={'text'}
293+
color="ghost"
293294
/>
294295
) : (
295296
<EuiIcon
@@ -320,7 +321,9 @@ export const GeneratePopoverBody: React.FC<{
320321
);
321322
};
322323

323-
const renderInnerFooter = () => {
324+
const TraceButton = showInsight ? EuiButtonEmpty : EuiButton;
325+
326+
const renderInnerFooter = (contentToCopy: string) => {
324327
return (
325328
<EuiPopoverFooter className="incontextInsightGeneratePopoverFooter" paddingSize="none">
326329
{displayDiscoverButton && (
@@ -330,38 +333,28 @@ export const GeneratePopoverBody: React.FC<{
330333
})}
331334
</EuiButton>
332335
)}
333-
{
334-
<div
335-
className="messageActionsWrapper"
336-
style={{ display: showInsight ? 'none' : 'block' }}
336+
{insightAvailable && (
337+
<TraceButton
338+
onClick={() => {
339+
setShowInsight(!showInsight);
340+
}}
341+
size="s"
337342
>
338-
<MessageActions
339-
contentToCopy={summary}
340-
showFeedback
341-
showTraceIcon={insightAvailable}
342-
onViewTrace={() => {
343-
setShowInsight(true);
344-
}}
345-
usageCollection={usageCollection}
346-
isOnTrace={showInsight}
347-
metricAppName={metricAppName}
348-
/>
349-
</div>
350-
}
343+
{showInsight
344+
? i18n.translate('assistantDashboards.incontextInsight.backToSummary', {
345+
defaultMessage: 'Back to summary',
346+
})
347+
: i18n.translate('assistantDashboards.incontextInsight.viewInsight', {
348+
defaultMessage: 'View insight',
349+
})}
350+
</TraceButton>
351+
)}
351352
{
352-
<div
353-
className="messageActionsWrapper"
354-
style={{ display: showInsight && insightAvailable ? 'block' : 'none' }}
355-
>
353+
<div className="messageActionsWrapper">
356354
<MessageActions
357-
contentToCopy={insight}
355+
contentToCopy={contentToCopy}
358356
showFeedback
359-
showTraceIcon={insightAvailable}
360-
onViewTrace={() => {
361-
setShowInsight(false);
362-
}}
363357
usageCollection={usageCollection}
364-
isOnTrace={showInsight}
365358
metricAppName={metricAppName}
366359
/>
367360
</div>

public/components/incontext_insight/index.scss

+18
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,19 @@
8282
}
8383
}
8484

85+
.incontextInsightPopover {
86+
// Color for $ouiColorDarkestShade that don't revert color for dark mode
87+
background-color: #343741 !important;
88+
89+
.euiPopover__panelArrow:after {
90+
border-right-color: #343741 !important;
91+
}
92+
93+
.euiLoadingContent__singleLineBackground {
94+
background: linear-gradient(137deg, #a1a5ae80 45%, #ffffff80 50%, #98a2b380 55%) !important;
95+
}
96+
}
97+
8598
.incontextInsightPopoverFooter {
8699
// TODO: Remove this one paddingSize is fixed
87100
padding: 4px 12px 8px !important;
@@ -92,6 +105,10 @@
92105
max-width: 486px;
93106
min-width: 486px;
94107
width: 100%;
108+
109+
.euiTitle {
110+
color: $euiColorGhost;
111+
}
95112
}
96113

97114
.incontextInsightGeneratePopoverTitle {
@@ -111,6 +128,7 @@
111128
display: flex;
112129
align-items: center;
113130
justify-content: space-between;
131+
gap: $euiSizeS;
114132

115133
.buttonGroupDivider {
116134
height: 24px;

public/components/incontext_insight/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ export const IncontextInsight = ({
339339
anchorPosition="rightUp"
340340
offset={6}
341341
panelPaddingSize="s"
342+
panelClassName="incontextInsightPopover"
342343
>
343344
{
344345
// For 'generate' type insights, we don't want to show this title but its own inner title

public/tabs/chat/messages/message_action.tsx

+11-20
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,7 @@
44
*/
55

66
import React, { useCallback } from 'react';
7-
import {
8-
EuiFlexGroup,
9-
EuiFlexItem,
10-
EuiSmallButtonIcon,
11-
EuiCopy,
12-
EuiToolTip,
13-
EuiButtonEmpty,
14-
} from '@elastic/eui';
7+
import { EuiFlexGroup, EuiFlexItem, EuiSmallButtonIcon, EuiCopy, EuiToolTip } from '@elastic/eui';
158
import { i18n } from '@osd/i18n';
169
import { IOutput, Interaction } from '../../../../common/types/chat_saved_object_attributes';
1710
import { useFeedback } from '../../../hooks/use_feed_back';
@@ -29,6 +22,7 @@ interface MessageActionsProps {
2922
showTraceIcon?: boolean;
3023
isOnTrace?: boolean;
3124
traceInteractionId?: string;
25+
traceTip?: string;
3226
onViewTrace?: () => void;
3327
shouldActionBarVisibleOnHover?: boolean;
3428
isFullWidth?: boolean;
@@ -51,6 +45,7 @@ export const MessageActions: React.FC<MessageActionsProps> = ({
5145
showTraceIcon = false,
5246
isOnTrace = false,
5347
traceInteractionId = null,
48+
traceTip = 'info',
5449
onViewTrace,
5550
shouldActionBarVisibleOnHover = false,
5651
isFullWidth = false,
@@ -111,6 +106,7 @@ export const MessageActions: React.FC<MessageActionsProps> = ({
111106
const feedbackTip = i18n.translate(`assistantDashboards.messageActions.feedbackTip`, {
112107
defaultMessage: 'We have successfully received your feedback. Thank you.',
113108
});
109+
114110
const buttonConfigs = {
115111
copy: {
116112
show: !isFullWidth,
@@ -171,23 +167,18 @@ export const MessageActions: React.FC<MessageActionsProps> = ({
171167
},
172168
trace: {
173169
show: showTraceIcon && onViewTrace,
174-
component: (
175-
<EuiButtonEmpty
170+
component: renderButtonWithTooltip(
171+
traceTip,
172+
<EuiSmallButtonIcon
176173
aria-label="How was this generated?"
177174
{...(traceInteractionId && {
178175
'data-test-subj': `trace-icon-${traceInteractionId}`,
179176
})}
180177
onClick={onViewTrace}
181-
color="primary"
182-
>
183-
{isOnTrace
184-
? i18n.translate('assistantDashboards.incontextInsight.backToSummary', {
185-
defaultMessage: 'Back to summary',
186-
})
187-
: i18n.translate('assistantDashboards.incontextInsight.viewInsightWithRAG', {
188-
defaultMessage: 'View insight with RAG',
189-
})}
190-
</EuiButtonEmpty>
178+
color={isOnTrace ? 'primary' : 'text'}
179+
iconType="iInCircle"
180+
/>,
181+
'trace'
191182
),
192183
},
193184
};

release-notes/dashboards-assistant.release-notes-3.0.0.0-alpha1.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Compatible with OpenSearch and OpenSearch Dashboards version 3.0.0-alpha1
2626
- Show error message if PPL query does not contain aggregation ([#499](https://github.com/opensearch-project/dashboards-assistant/pull/499))
2727
- Adjust the overall style of alert summary popover ([#501](https://github.com/opensearch-project/dashboards-assistant/pull/501))
2828
- Add http error instruction for t2ppl task ([#502](https://github.com/opensearch-project/dashboards-assistant/pull/502))
29+
- Change the background color, button position and text for alert summary popover ([#506](https://github.com/opensearch-project/dashboards-assistant/pull/506))
2930
- collect metrics for when t2viz triggered([#510](https://github.com/opensearch-project/dashboards-assistant/pull/510))
3031

3132
### Bug Fixes

0 commit comments

Comments
 (0)