Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: only support visual editor alerts to navigate to discover #368

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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(
<GeneratePopoverBody
incontextInsight={incontextInsightMock}
httpSetup={mockHttpSetup}
closePopover={closePopoverMock}
getStartServices={getStartServices}
/>
);

await waitFor(() => {
expect(queryByText('Discover details')).not.toBeInTheDocument();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Loading