diff --git a/CHANGELOG.md b/CHANGELOG.md index 084f2089..c99766b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - feat: edit visualization with natural language in a dialog([#351](https://github.com/opensearch-project/dashboards-assistant/pull/351)) - fix: Update alerting DSL verify mechanism([#359](https://github.com/opensearch-project/dashboards-assistant/pull/359)) - fix: Refactor contextProvider get to reduce re-fetch([#365](https://github.com/opensearch-project/dashboards-assistant/pull/365)) +- feat: Hide navigate to discover button if alert is not from visual editor monitor([#368](https://github.com/opensearch-project/dashboards-assistant/pull/368)) ### 📈 Features/Enhancements diff --git a/public/components/incontext_insight/generate_popover_body.test.tsx b/public/components/incontext_insight/generate_popover_body.test.tsx index 7c61d7f6..c6c83319 100644 --- a/public/components/incontext_insight/generate_popover_body.test.tsx +++ b/public/components/incontext_insight/generate_popover_body.test.tsx @@ -338,6 +338,7 @@ describe('GeneratePopoverBody', () => { index: 'mock_index', dataSourceId: `test-data-source-id`, monitorType: 'query_level_monitor', + isVisualEditorMonitor: true, }, }); mockPost.mockImplementation((path: string, body) => { @@ -384,4 +385,56 @@ describe('GeneratePopoverBody', () => { }); expect(window.open).toHaveBeenCalledWith('formattedUrl', '_blank'); }); + + it('should hide navigate to discover if not from visual editor monitor', async () => { + incontextInsightMock.contextProvider = jest.fn().mockResolvedValue({ + additionalInfo: { + dsl: mockDSL, + index: 'mock_index', + dataSourceId: `test-data-source-id`, + monitorType: 'query_level_monitor', + isVisualEditorMonitor: false, + }, + }); + mockPost.mockImplementation((path: string, body) => { + let value; + switch (path) { + case SUMMARY_ASSISTANT_API.SUMMARIZE: + value = { + summary: 'Generated summary content', + insightAgentIdExists: true, + }; + break; + + case SUMMARY_ASSISTANT_API.INSIGHT: + value = 'Generated insight content'; + break; + + default: + return null; + } + return Promise.resolve(value); + }); + + const coreStart = coreMock.createStart(); + const dataStart = dataPluginMock.createStartContract(); + const getStartServices = jest.fn().mockResolvedValue([ + coreStart, + { + data: dataStart, + }, + ]); + const { queryByText } = render( + + ); + + await waitFor(() => { + expect(queryByText('Discover details')).not.toBeInTheDocument(); + }); + }); }); diff --git a/public/components/incontext_insight/generate_popover_body.tsx b/public/components/incontext_insight/generate_popover_body.tsx index a161e4a8..ede3a119 100644 --- a/public/components/incontext_insight/generate_popover_body.tsx +++ b/public/components/incontext_insight/generate_popover_body.tsx @@ -58,6 +58,11 @@ export const GeneratePopoverBody: React.FC<{ if (!contextObject) return; const monitorType = contextObject?.additionalInfo?.monitorType; const dsl = contextObject?.additionalInfo?.dsl; + const isVisualEditorMonitor = contextObject?.additionalInfo?.isVisualEditorMonitor; + // Only alerts from visual editor monitor support to navigate to discover. + if (!isVisualEditorMonitor) { + return; + } // Only this two types from alerting contain DSL and index. const isSupportedMonitorType = monitorType === 'query_level_monitor' || monitorType === 'bucket_level_monitor';