Skip to content
Draft
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
21 changes: 20 additions & 1 deletion packages/app/src/DBSearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ import {
parseTimeQuery,
useNewTimeQuery,
} from '@/timeQuery';
import { QUERY_LOCAL_STORAGE, useLocalStorage, usePrevious } from '@/utils';
import {
QUERY_LOCAL_STORAGE,
useLocalStorage,
usePrevious,
useWindowSize,
} from '@/utils';

import { SQLPreview } from './components/ChartSQLPreview';
import DBSqlRowTableWithSideBar from './components/DBSqlRowTableWithSidebar';
Expand Down Expand Up @@ -841,6 +846,16 @@ function DBSearchPage() {
[setIsLive, _setDenoiseResults],
);

// Filters collapse state
const { width } = useWindowSize();
const isSmallScreen = (width ?? 1000) < 900;

// Default to collapsed on mobile, but allow user to override
const [isFiltersPreferCollapsed, setIsFiltersPreferCollapsed] =
useLocalStorage<boolean>('isSearchFiltersCollapsed', isSmallScreen);

const isFiltersCollapsed = isFiltersPreferCollapsed;

// Get default source
const defaultSourceId = useMemo(
() => getDefaultSourceId(sources, lastSelectedSourceId),
Expand Down Expand Up @@ -1809,6 +1824,10 @@ function DBSearchPage() {
chartConfig={filtersChartConfig}
sourceId={inputSourceObj?.id}
showDelta={!!searchedSource?.durationExpression}
isCollapsed={isFiltersCollapsed}
onToggleCollapse={() =>
setIsFiltersPreferCollapsed(!isFiltersPreferCollapsed)
}
{...searchFilters}
/>
</ErrorBoundary>
Expand Down
7 changes: 4 additions & 3 deletions packages/app/src/components/AppNav/AppNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,15 @@ export default function AppNav({ fixed = false }: { fixed?: boolean }) {
defaultValue: true,
});
const { width } = useWindowSize();
const isSmallScreen = (width ?? 1000) < 900;

// Default to collapsed on mobile, but allow user to override
const [isPreferCollapsed, setIsPreferCollapsed] = useLocalStorage<boolean>({
key: 'isNavCollapsed',
defaultValue: false,
defaultValue: isSmallScreen,
});

const isSmallScreen = (width ?? 1000) < 900;
const isCollapsed = isSmallScreen || isPreferCollapsed;
const isCollapsed = isPreferCollapsed;

const navWidth = isCollapsed ? 50 : 230;

Expand Down
108 changes: 94 additions & 14 deletions packages/app/src/components/DBSearchPageFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
Button,
Center,
Checkbox,
Collapse,
Flex,
Group,
Loader,
Expand All @@ -33,6 +34,7 @@ import {
IconChartBar,
IconChartBarOff,
IconChevronDown,
IconChevronLeft,
IconChevronRight,
IconChevronUp,
IconFilterOff,
Expand Down Expand Up @@ -841,6 +843,8 @@ const DBSearchPageFiltersComponent = ({
denoiseResults,
setDenoiseResults,
setFilterRange,
isCollapsed = false,
onToggleCollapse,
}: {
analysisMode: 'results' | 'delta' | 'pattern';
setAnalysisMode: (mode: 'results' | 'delta' | 'pattern') => void;
Expand All @@ -851,6 +855,8 @@ const DBSearchPageFiltersComponent = ({
denoiseResults: boolean;
setDenoiseResults: (denoiseResults: boolean) => void;
setFilterRange: (key: string, range: { min: number; max: number }) => void;
isCollapsed?: boolean;
onToggleCollapse?: () => void;
} & FilterStateHook) => {
const setFilterValue = useCallback(
(
Expand Down Expand Up @@ -1150,22 +1156,94 @@ const DBSearchPageFiltersComponent = ({
}, [filterState, source]);

return (
<Box className={classes.filtersPanel} style={{ width: `${size}%` }}>
<div className={resizeStyles.resizeHandle} onMouseDown={startResize} />
<ScrollArea
<Box
className={classes.filtersPanel}
data-collapsed={isCollapsed}
style={{
width: isCollapsed ? 'auto' : `${size}%`,
minWidth: isCollapsed ? 'auto' : undefined,
}}
>
{!isCollapsed && (
<div className={resizeStyles.resizeHandle} onMouseDown={startResize} />
)}
<Stack
gap={0}
h="100%"
scrollbarSize={4}
scrollbars="y"
style={{
display: 'block',
width: '100%',
overflow: 'hidden',
position: 'relative',
}}
>
<Stack gap="sm" p="xs">
<Text size="xxs" c="dimmed" fw="bold">
Analysis Mode
</Text>
{onToggleCollapse && isCollapsed && (
<Flex
justify="center"
p="xs"
h="100%"
>
<Stack gap={8} align="center" style={{ cursor: 'pointer' }} onClick={onToggleCollapse}>
<ActionIcon
variant="subtle"
size="xs"
title="Expand Filters"
data-testid="toggle-filters-button"
color="gray"
>
<IconChevronRight size={14} />
</ActionIcon>
<Text
size="10px"
c="dimmed"
fw={500}
style={{
writingMode: 'vertical-rl',
textOrientation: 'mixed',
letterSpacing: '1px',
userSelect: 'none',
transform: 'rotate(180deg)',
}}
>
FILTERS
</Text>
</Stack>
</Flex>
)}
<Collapse
in={!isCollapsed}
style={{
flex: 1,
overflow: 'hidden',
display: 'flex',
flexDirection: 'column',
}}
>
<ScrollArea
h="100%"
scrollbarSize={4}
scrollbars="y"
style={{
display: 'block',
width: '100%',
overflow: 'hidden',
}}
>
<Stack gap="sm" p="xs">
<Flex align="center" justify="space-between">
<Text size="xxs" c="dimmed" fw="bold">
Analysis Mode
</Text>
{onToggleCollapse && (
<ActionIcon
variant="subtle"
size="xs"
title="Collapse Filters"
onClick={onToggleCollapse}
data-testid="toggle-filters-button"
color="gray"
>
<IconChevronLeft size={14} />
</ActionIcon>
)}
</Flex>
<Tabs
value={analysisMode}
onChange={value =>
Expand Down Expand Up @@ -1432,8 +1510,10 @@ const DBSearchPageFiltersComponent = ({
</Text>
</div>
)}
</Stack>
</ScrollArea>
</Stack>
</ScrollArea>
</Collapse>
</Stack>
</Box>
);
};
Expand Down
6 changes: 6 additions & 0 deletions packages/app/styles/SearchPage.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
border-right: 1px solid var(--color-border);
overflow: hidden;
z-index: 3; // higher z-index to be above other elements
transition: min-width 0.2s ease;

&[data-collapsed='true'] {
min-width: 44px;
width: 44px !important;
}

:global {
.mantine-TextInput-wrapper {
Expand Down
Loading