Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.
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
3 changes: 1 addition & 2 deletions src/pages/Stream/Views/Explore/StaticLogRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,10 @@ const LogRow: FC<LogRowProps> = (props) => {
<tr key={logIndex} className={logIndex % 2 ? trStyle : trEvenStyle} onClick={() => onClick(log)}>
{columnsToShow.map((header, logSchemaIndex) => {
const parsedData = parseLogData(log[header], header);

return (
<td
key={`${header}-${logSchemaIndex}`}
style={{ position: 'relative' }}
style={{ position: 'relative', whiteSpace: 'pre' }}
onMouseEnter={() => handleMouseEnter(logIndex, logSchemaIndex)}
onMouseLeave={handleMouseLeave}>
<Group wrap="nowrap">
Expand Down
4 changes: 1 addition & 3 deletions src/pages/Stream/components/Querier/QueryCodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { sanitiseSqlString } from '@/utils/sanitiseSqlString';
import { Field } from '@/@types/parseable/dataType';
import queryCodeStyles from '../../styles/QueryCode.module.css';
import { useAppStore } from '@/layouts/MainLayout/providers/AppProvider';
import { useFilterStore } from '../../providers/FilterProvider';
import { LOAD_LIMIT, useLogsStore } from '../../providers/LogsProvider';
import { useStreamStore } from '../../providers/StreamProvider';

Expand All @@ -30,7 +29,7 @@ const genColumnConfig = (fields: Field[]) => {
}, columnConfig);
};

const defaultCustSQLQuery = (streamName: string | null) => {
export const defaultCustSQLQuery = (streamName: string | null) => {
if (streamName && streamName.length > 0) {
return `SELECT * FROM ${streamName} LIMIT ${LOAD_LIMIT};`;
} else {
Expand All @@ -44,7 +43,6 @@ const QueryCodeEditor: FC<{
onClear: () => void;
}> = (props) => {
const [llmActive] = useAppStore((store) => store.instanceConfig?.llmActive);
const [] = useFilterStore((store) => store);
const [{ isQuerySearchActive, activeMode, savedFilterId, custSearchQuery }] = useLogsStore(
(store) => store.custQuerySearchState,
);
Expand Down
1 change: 0 additions & 1 deletion src/pages/Stream/components/Querier/SavedFiltersModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ const SavedFiltersModal = () => {
const onSqlSearchApply = useCallback(
(query: string, id: string, time_filter: null | { from: string; to: string }) => {
setFilterStore((store) => resetFilters(store));

setLogsStore((store) => applyCustomQuery(store, query, 'sql', id, time_filter));
},
[],
Expand Down
21 changes: 13 additions & 8 deletions src/pages/Stream/components/Querier/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import classes from '../../styles/Querier.module.css';
import { Text } from '@mantine/core';
import { FilterQueryBuilder, QueryPills } from './FilterQueryBuilder';
import { AppliedSQLQuery } from './QueryEditor';
import QueryCodeEditor from './QueryCodeEditor';
import QueryCodeEditor, { defaultCustSQLQuery } from './QueryCodeEditor';
import { useLogsStore, logsStoreReducers } from '../../providers/LogsProvider';
import { useCallback, useEffect, useRef } from 'react';
import { filterStoreReducers, noValueOperators, useFilterStore } from '../../providers/FilterProvider';
Expand Down Expand Up @@ -72,12 +72,17 @@ const QuerierModal = (props: {
onSqlSearchApply: (query: string) => void;
onFiltersApply: () => void;
}) => {
const [currentStream] = useAppStore(store => store.currentStream)
const [{ showQueryBuilder, viewMode }, setLogsStore] = useLogsStore((store) => store.custQuerySearchState);
const onClose = useCallback(() => {
setLogsStore((store) => toggleQueryBuilder(store, false));
}, []);
const queryCodeEditorRef = useRef<any>(''); // to store input value even after the editor unmounts

useEffect(() => {
queryCodeEditorRef.current = defaultCustSQLQuery(currentStream);
}, [currentStream]);

return (
<Modal
opened={showQueryBuilder}
Expand Down Expand Up @@ -123,7 +128,7 @@ const Querier = () => {

useEffect(() => {
return setFilterStore(resetFilters);
}, []);
}, [currentStream]);

const triggerRefetch = useCallback(
(query: string, mode: 'filters' | 'sql', id?: string) => {
Expand All @@ -136,8 +141,8 @@ const Querier = () => {
const onFiltersApply = useCallback(
(opts?: { isUncontrolled?: boolean }) => {
if (!currentStream) return;
const { isUncontrolled } = opts || {};

const { isUncontrolled } = opts || {};
const { parsedQuery } = parseQuery(query, currentStream);
setFilterStore((store) => storeAppliedQuery(store));
triggerRefetch(parsedQuery, 'filters', isUncontrolled && savedFilterId ? savedFilterId : undefined);
Expand Down Expand Up @@ -175,13 +180,13 @@ const Querier = () => {

// trigger query fetch if the rules were updated by the remove btn on pills
// -----------------------------------
if (!showQueryBuilder && (activeMode !== 'sql' || savedFilterId)) {
if ((!showQueryBuilder && activeMode === 'filters') || savedFilterId) {
if (!shouldSumbitDisabled) {
onFiltersApply({ isUncontrolled: true });
}

if (allValues.length === 0 && activeMode !== 'sql') {
onClear();
} else {
if (activeMode === 'filters') {
onClear();
}
}
}
// -----------------------------------
Expand Down
9 changes: 0 additions & 9 deletions src/pages/Stream/providers/LogsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ type LogsStoreReducers = {
streamChangeCleanup: (store: LogsStore) => ReducerOutput;
toggleQueryBuilder: (store: LogsStore, val?: boolean) => ReducerOutput;
resetCustQuerySearchState: (store: LogsStore) => ReducerOutput;
setCustQuerySearchState: (store: LogsStore, payload: Partial<CustQuerySearchState>) => ReducerOutput;
toggleCustQuerySearchViewMode: (store: LogsStore, targetMode: 'sql' | 'filters') => ReducerOutput;
toggleDeleteModal: (store: LogsStore, val?: boolean) => ReducerOutput;
toggleAlertsModal: (store: LogsStore, val?: boolean) => ReducerOutput;
Expand Down Expand Up @@ -445,13 +444,6 @@ const resetCustQuerySearchState = (store: LogsStore) => {
};
};

const setCustQuerySearchState = (store: LogsStore, payload: Partial<CustQuerySearchState>) => {
const { custQuerySearchState } = store;
return {
custQuerySearchState: { ...custQuerySearchState, ...payload, isQuerySearchActive: true, showQueryBuilder: false },
};
};

const toggleCustQuerySearchViewMode = (store: LogsStore, targetMode: 'filters' | 'sql') => {
const { custQuerySearchState } = store;

Expand Down Expand Up @@ -914,7 +906,6 @@ const logsStoreReducers: LogsStoreReducers = {
streamChangeCleanup,
toggleQueryBuilder,
resetCustQuerySearchState,
setCustQuerySearchState,
toggleCustQuerySearchViewMode,
toggleAlertsModal,
toggleRetentionModal,
Expand Down