Bump @grafana/assistant package (#110507)
* Bump @grafana/assistant package * Update origin * Update FlameGraphHeader.tsx Co-authored-by: Kevin Adam <16607163+kevelopment@users.noreply.github.com> * Update LogListContext.tsx Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com> * Fix lint * Update public/app/features/logs/components/panel/LogListContext.tsx Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com> --------- Co-authored-by: Kevin Adam <16607163+kevelopment@users.noreply.github.com> Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com>
This commit is contained in:
co-authored by
Kevin Adam
Sven Grossmann
parent
dc16562050
commit
4e28cba1c5
@@ -83,7 +83,7 @@
|
||||
"typescript": "5.9.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@grafana/assistant": "^0.0.12",
|
||||
"@grafana/assistant": "^0.0.17",
|
||||
"react": "^18.0.0",
|
||||
"react-dom": "^18.0.0"
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import { ChatContextItem, useAssistant } from '@grafana/assistant';
|
||||
import { Button } from '@grafana/ui';
|
||||
|
||||
type Props = {
|
||||
assistantContext: ChatContextItem[];
|
||||
className?: string;
|
||||
};
|
||||
|
||||
export function AnalyzeFlameGraphButton(props: Props) {
|
||||
const { assistantContext, className } = props;
|
||||
const [isAvailable, openAssistant] = useAssistant();
|
||||
|
||||
if (!isAvailable || !openAssistant || assistantContext.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Button
|
||||
className={className}
|
||||
onClick={() =>
|
||||
openAssistant({
|
||||
origin: 'analyze-flame-graph',
|
||||
prompt: 'Analyze Flame Graph',
|
||||
context: assistantContext,
|
||||
})
|
||||
}
|
||||
variant="secondary"
|
||||
fill="outline"
|
||||
icon="ai-sparkle"
|
||||
size="sm"
|
||||
>
|
||||
Analyze Flame Graph
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -11,7 +11,8 @@ import { MIN_WIDTH_TO_SHOW_BOTH_TOPTABLE_AND_FLAMEGRAPH } from './constants';
|
||||
|
||||
jest.mock('@grafana/assistant', () => ({
|
||||
useAssistant: jest.fn(() => [false, null]), // [isAvailable, openAssistant]
|
||||
createContext: jest.fn(),
|
||||
createAssistantContextItem: jest.fn(),
|
||||
OpenAssistantButton: () => <div>OpenAssistantButton</div>,
|
||||
}));
|
||||
|
||||
jest.mock('react-use', () => ({
|
||||
|
||||
@@ -9,7 +9,8 @@ import { ColorScheme, SelectedView } from './types';
|
||||
|
||||
jest.mock('@grafana/assistant', () => ({
|
||||
useAssistant: jest.fn(() => [false, null]), // [isAvailable, openAssistant]
|
||||
createContext: jest.fn(),
|
||||
createAssistantContextItem: jest.fn(),
|
||||
OpenAssistantButton: () => <div>OpenAssistantButton</div>,
|
||||
}));
|
||||
|
||||
describe('FlameGraphHeader', () => {
|
||||
|
||||
@@ -3,11 +3,10 @@ import { useEffect, useState } from 'react';
|
||||
import * as React from 'react';
|
||||
import { useDebounce, usePrevious } from 'react-use';
|
||||
|
||||
import { ChatContextItem } from '@grafana/assistant';
|
||||
import { ChatContextItem, OpenAssistantButton } from '@grafana/assistant';
|
||||
import { GrafanaTheme2, SelectableValue } from '@grafana/data';
|
||||
import { Button, ButtonGroup, Dropdown, Input, Menu, RadioButtonGroup, useStyles2 } from '@grafana/ui';
|
||||
|
||||
import { AnalyzeFlameGraphButton } from './AnalyzeFlameGraphButton';
|
||||
import { byPackageGradient, byValueGradient, diffColorBlindGradient, diffDefaultGradient } from './FlameGraph/colors';
|
||||
import { CollapsedMap } from './FlameGraph/dataTransform';
|
||||
import { MIN_WIDTH_TO_SHOW_BOTH_TOPTABLE_AND_FLAMEGRAPH } from './constants';
|
||||
@@ -89,8 +88,10 @@ const FlameGraphHeader = ({
|
||||
</div>
|
||||
|
||||
<div className={styles.rightContainer}>
|
||||
{assistantContext && (
|
||||
<AnalyzeFlameGraphButton className={styles.buttonSpacing} assistantContext={assistantContext} />
|
||||
{!!assistantContext?.length && (
|
||||
<div className={styles.buttonSpacing}>
|
||||
<OpenAssistantButton origin="grafana/flame-graph" prompt="Analyze Flame Graph" context={assistantContext} />
|
||||
</div>
|
||||
)}
|
||||
{showResetButton && (
|
||||
<Button
|
||||
|
||||
Reference in New Issue
Block a user