Skip to content
Draft
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
37 changes: 37 additions & 0 deletions packages/app/src/DBSearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import {
import { notifications } from '@mantine/notifications';
import {
IconBolt,
IconChartDots,
IconPlayerPlay,
IconPlus,
IconTags,
Expand All @@ -74,6 +75,7 @@ import { useIsFetching } from '@tanstack/react-query';
import { SortingState } from '@tanstack/react-table';
import CodeMirror from '@uiw/react-codemirror';

import { DEFAULT_CHART_CONFIG } from '@/ChartUtils';
import { ContactSupportText } from '@/components/ContactSupportText';
import { DBSearchPageFilters } from '@/components/DBSearchPageFilters';
import { DBTimeChart } from '@/components/DBTimeChart';
Expand Down Expand Up @@ -1313,6 +1315,27 @@ function DBSearchPage() {
],
);

const chartExplorerUrl = useMemo(() => {
if (!searchedSource) return null;
const config = {
...DEFAULT_CHART_CONFIG,
source: searchedSource.id,
where: searchedConfig.where || '',
whereLanguage: searchedConfig.whereLanguage || 'lucene',
};
const qParams = new URLSearchParams({
config: JSON.stringify(config),
from: searchedTimeRange[0].getTime().toString(),
to: searchedTimeRange[1].getTime().toString(),
});
return `/chart?${qParams.toString()}`;
}, [
searchedSource,
searchedConfig.where,
searchedConfig.whereLanguage,
searchedTimeRange,
]);

const handleTableError = useCallback(
(error: Error | ClickHouseQueryError) => {
setIsLive(false);
Expand Down Expand Up @@ -1631,6 +1654,20 @@ function DBSearchPage() {
Alerts
</Button>
)}
{chartExplorerUrl && (
<Tooltip label="Open in Chart Explorer" withinPortal>
<ActionIcon
component="a"
href={chartExplorerUrl}
data-testid="open-in-chart-explorer-button"
variant="secondary"
size="input-xs"
style={{ flexShrink: 0 }}
>
<IconChartDots size={14} />
</ActionIcon>
</Tooltip>
)}
{!!savedSearch && (
<>
<Tags
Expand Down
Loading