Repository navigation
fix(app): keep saved search usable on a phone #3376
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
Changes from all commits
613ab3a
c21ab91
35494d3
c6a57c9
152f4e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@hyperdx/app': patch | ||
| --- | ||
|
|
||
| fix: saved search is usable on a phone. Below 900px the filters open in a | ||
| drawer, SELECT and ORDER BY stay behind "Columns", and the log table | ||
| keeps the remaining screen. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,6 +88,8 @@ import CodeMirror from '@uiw/react-codemirror'; | |
| import api, { useCompleteOnboardingTask } from '@/api'; | ||
| import { ActiveFilterPills } from '@/components/ActiveFilterPills'; | ||
| import { AlertStatusIcon } from '@/components/AlertStatusIcon'; | ||
| import { ResponsiveSidePanel } from '@/components/CompactViewport/ResponsiveSidePanel'; | ||
| import { useCompactViewport } from '@/components/CompactViewport/useCompactViewport'; | ||
| import { ContactSupportText } from '@/components/ContactSupportText'; | ||
| import { DBSearchPageFilters } from '@/components/DBSearchPageFilters'; | ||
| import { cleanClickHouseExpression } from '@/components/DBSearchPageFilters/utils'; | ||
|
|
@@ -1117,6 +1119,31 @@ function DBSearchPageContent() { | |
|
|
||
| const [isFilterSidebarCollapsed, setIsFilterSidebarCollapsed] = | ||
| useLocalStorage<boolean>('isFilterSidebarCollapsed', false); | ||
| // Compact open state stays out of `isFilterSidebarCollapsed`. Writing that | ||
|
elizabetdev marked this conversation as resolved.
Resolved
|
||
| // key from a phone would collapse the sidebar the next time the same | ||
| // browser opens the page on a desktop. | ||
| const [isCompactFiltersOpen, setIsCompactFiltersOpen] = useState(false); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 minor — The new compact search behaviour has no test The PR's main claims are that opening or closing the drawer never writes the Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond |
||
| // SELECT grows with its text. On a phone that pushes the logs off the | ||
| // screen, so the column editors stay closed until the user asks. | ||
| const [columnsOpen, setColumnsOpen] = useState(false); | ||
| const isCompact = useCompactViewport(); | ||
| const filtersCollapsed = isCompact | ||
| ? !isCompactFiltersOpen | ||
| : isFilterSidebarCollapsed; | ||
|
elizabetdev marked this conversation as resolved.
Resolved
|
||
| const collapseFilters = useCallback(() => { | ||
| if (isCompact) { | ||
| setIsCompactFiltersOpen(false); | ||
| return; | ||
| } | ||
| setIsFilterSidebarCollapsed(true); | ||
| }, [isCompact, setIsFilterSidebarCollapsed]); | ||
| const expandFilters = useCallback(() => { | ||
| if (isCompact) { | ||
| setIsCompactFiltersOpen(true); | ||
| return; | ||
| } | ||
| setIsFilterSidebarCollapsed(false); | ||
| }, [isCompact, setIsFilterSidebarCollapsed]); | ||
|
|
||
| const [denoiseResults, _setDenoiseResults] = useQueryState( | ||
| 'denoise', | ||
|
|
@@ -2209,6 +2236,52 @@ function DBSearchPageContent() { | |
| [setValue, setNewSourceModalClosed], | ||
| ); | ||
|
|
||
| const columnFields = (allowMultiline: boolean, stacked: boolean) => { | ||
| const select = ( | ||
| <SQLInlineEditorControlled | ||
| tableConnection={inputSourceTableConnection} | ||
| control={control} | ||
| name="select" | ||
| defaultValue={defaultSearchConfig.select} | ||
| placeholder={defaultSearchConfig.select || 'SELECT Columns'} | ||
| onSubmit={onSubmit} | ||
| label="SELECT" | ||
| size="xs" | ||
| allowMultiline={allowMultiline} | ||
| dateRange={searchedTimeRange} | ||
| sourceId={inputSource} | ||
| /> | ||
| ); | ||
| const orderBy = ( | ||
| <SQLInlineEditorControlled | ||
| tableConnection={inputSourceTableConnection} | ||
| control={control} | ||
| name="orderBy" | ||
| defaultValue={defaultSearchConfig.orderBy} | ||
| onSubmit={onSubmit} | ||
| label="ORDER BY" | ||
| size="xs" | ||
| allowMultiline={allowMultiline} | ||
| dateRange={searchedTimeRange} | ||
| sourceId={inputSource} | ||
| /> | ||
| ); | ||
| if (stacked) { | ||
| return ( | ||
| <> | ||
| {select} | ||
| {orderBy} | ||
| </> | ||
| ); | ||
| } | ||
| return ( | ||
| <> | ||
| <Box style={{ flex: '1 1 0%', minWidth: 100 }}>{select}</Box> | ||
| <Box style={{ maxWidth: 400, width: '20%' }}>{orderBy}</Box> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| return ( | ||
| <Flex | ||
| direction="column" | ||
|
|
@@ -2345,7 +2418,12 @@ function DBSearchPageContent() { | |
| className={searchPageStyles.searchForm} | ||
| > | ||
| {/* <DevTool control={control} /> */} | ||
| <Flex gap="sm" px="sm" pt="sm" wrap="nowrap"> | ||
| <Flex | ||
| gap={isCompact ? 'xs' : 'sm'} | ||
| px="sm" | ||
| pt={isCompact ? 4 : 'sm'} | ||
| wrap={isCompact ? 'wrap' : 'nowrap'} | ||
| > | ||
| <SourceSelectControlled | ||
| key={`${savedSearchId}`} | ||
| size="xs" | ||
|
|
@@ -2360,42 +2438,17 @@ function DBSearchPageContent() { | |
| )} | ||
| allowedSourceKinds={ALLOWED_SOURCE_KINDS} | ||
| data-testid="source-selector" | ||
| style={{ minWidth: 150 }} | ||
| style={ | ||
| isCompact ? { flex: '1 1 140px', minWidth: 0 } : { minWidth: 150 } | ||
| } | ||
| /> | ||
| <SourceSchemaPreview | ||
| source={inputSourceObj} | ||
| controlled | ||
| open={isSourceSchemaPreviewOpen} | ||
| onClose={() => setIsSourceSchemaPreviewOpen(false)} | ||
| /> | ||
| <Box style={{ flex: '1 1 0%', minWidth: 100 }}> | ||
| <SQLInlineEditorControlled | ||
| tableConnection={inputSourceTableConnection} | ||
| control={control} | ||
| name="select" | ||
| defaultValue={defaultSearchConfig.select} | ||
| placeholder={defaultSearchConfig.select || 'SELECT Columns'} | ||
| onSubmit={onSubmit} | ||
| label="SELECT" | ||
| size="xs" | ||
| allowMultiline | ||
| dateRange={searchedTimeRange} | ||
| sourceId={inputSource} | ||
| /> | ||
| </Box> | ||
| <Box style={{ maxWidth: 400, width: '20%' }}> | ||
| <SQLInlineEditorControlled | ||
| tableConnection={inputSourceTableConnection} | ||
| control={control} | ||
| name="orderBy" | ||
| defaultValue={defaultSearchConfig.orderBy} | ||
| onSubmit={onSubmit} | ||
| label="ORDER BY" | ||
| size="xs" | ||
| dateRange={searchedTimeRange} | ||
| sourceId={inputSource} | ||
| /> | ||
| </Box> | ||
| {!isCompact && columnFields(true, false)} | ||
| <> | ||
| {!savedSearchId ? ( | ||
| <Button | ||
|
|
@@ -2434,8 +2487,24 @@ function DBSearchPageContent() { | |
| </Group> | ||
| </Button> | ||
| )} | ||
| {isCompact && ( | ||
|
elizabetdev marked this conversation as resolved.
Resolved
|
||
| <Button | ||
| variant="subtle" | ||
| size="xs" | ||
| style={{ flexShrink: 0 }} | ||
| aria-expanded={columnsOpen} | ||
| onClick={() => setColumnsOpen(open => !open)} | ||
| > | ||
| {columnsOpen ? 'Hide columns' : 'Columns'} | ||
| </Button> | ||
| )} | ||
| </> | ||
| </Flex> | ||
| {isCompact && columnsOpen && ( | ||
| <Flex direction="column" gap={4} px="sm" pt={4}> | ||
| {columnFields(false, true)} | ||
| </Flex> | ||
| )} | ||
| <SourceEditModal | ||
| opened={modelFormExpanded} | ||
| onClose={onModelFormExpandClose} | ||
|
|
@@ -2446,7 +2515,12 @@ function DBSearchPageContent() { | |
| onClose={setNewSourceModalClosed} | ||
| onCreate={onNewSourceCreate} | ||
| /> | ||
| <Flex gap="sm" mt="sm" px="sm" wrap="wrap"> | ||
| <Flex | ||
| gap={isCompact ? 'xs' : 'sm'} | ||
| mt={isCompact ? 4 : 'sm'} | ||
| px="sm" | ||
| wrap="wrap" | ||
| > | ||
| <SearchWhereInput | ||
| tableConnection={inputSourceTableConnection} | ||
| control={control} | ||
|
|
@@ -2532,7 +2606,7 @@ function DBSearchPageContent() { | |
| /> | ||
| <Flex | ||
| direction="column" | ||
| style={{ overflow: 'hidden', height: '100%' }} | ||
| style={{ overflow: 'hidden', flex: 1, minHeight: 0 }} | ||
| className="bg-body" | ||
| > | ||
| {!queryReady ? ( | ||
|
|
@@ -2544,14 +2618,12 @@ function DBSearchPageContent() { | |
| /> | ||
| ) : ( | ||
| <> | ||
| <div | ||
| <ResponsiveSidePanel | ||
| className={searchPageStyles.searchPageContainer} | ||
| style={{ | ||
| minHeight: 0, | ||
| height: '100%', | ||
| }} | ||
| > | ||
| {!isFilterSidebarCollapsed && ( | ||
| opened={!filtersCollapsed} | ||
| onClose={collapseFilters} | ||
| title="Filters" | ||
| panel={ | ||
| <ErrorBoundary message="Unable to render search filters"> | ||
| <DBSearchPageFilters | ||
| denoiseResults={denoiseResults} | ||
|
|
@@ -2568,11 +2640,13 @@ function DBSearchPageContent() { | |
| } | ||
| onColumnToggle={toggleColumn} | ||
| displayedColumns={displayedColumns} | ||
| onCollapse={() => setIsFilterSidebarCollapsed(true)} | ||
| onCollapse={isCompact ? undefined : collapseFilters} | ||
| fill={isCompact} | ||
| {...searchFilters} | ||
| /> | ||
| </ErrorBoundary> | ||
| )} | ||
| } | ||
| > | ||
| {analysisMode === 'pattern' && | ||
| histogramTimeChartConfig != null && ( | ||
| <Flex direction="column" w="100%" gap="0px" mih="0" miw={0}> | ||
|
|
@@ -2583,10 +2657,8 @@ function DBSearchPageContent() { | |
| style={{ width: '100%' }} | ||
| > | ||
| <SearchResultsCountGroup | ||
| isFilterSidebarCollapsed={isFilterSidebarCollapsed} | ||
| onExpandFilters={() => | ||
| setIsFilterSidebarCollapsed(false) | ||
| } | ||
| isFilterSidebarCollapsed={filtersCollapsed} | ||
| onExpandFilters={expandFilters} | ||
| histogramTimeChartConfig={histogramTimeChartConfig} | ||
| /> | ||
| <SearchNumRows | ||
|
|
@@ -2604,7 +2676,11 @@ function DBSearchPageContent() { | |
| </Box> | ||
| {!hasQueryError && ( | ||
| <Box | ||
| className={searchPageStyles.timeChartContainer} | ||
| className={ | ||
| isCompact | ||
| ? `${searchPageStyles.timeChartContainer} ${searchPageStyles.timeChartContainerCompact}` | ||
| : searchPageStyles.timeChartContainer | ||
| } | ||
| mih="0" | ||
| > | ||
| <DBTimeChart | ||
|
|
@@ -2652,16 +2728,25 @@ function DBSearchPageContent() { | |
| {analysisMode === 'delta' && | ||
| searchedSource != null && | ||
| isTraceSource(searchedSource) && ( | ||
| <DBSearchHeatmapChart | ||
| chartConfig={{ | ||
| ...chartConfig, | ||
| dateRange: searchedTimeRange, | ||
| with: aliasWith, | ||
| }} | ||
| isReady={isReady} | ||
| source={searchedSource} | ||
| onAddFilter={searchFilters.setFilterValue} | ||
| /> | ||
| <Flex direction="column" mih="0" miw={0} flex="1"> | ||
| {filtersCollapsed && ( | ||
| <Box className={searchPageStyles.searchStatsContainer}> | ||
| <ExpandFiltersButton onExpand={expandFilters} /> | ||
| </Box> | ||
| )} | ||
| <Box flex="1" mih="0"> | ||
| <DBSearchHeatmapChart | ||
| chartConfig={{ | ||
| ...chartConfig, | ||
| dateRange: searchedTimeRange, | ||
| with: aliasWith, | ||
| }} | ||
| isReady={isReady} | ||
| source={searchedSource} | ||
| onAddFilter={searchFilters.setFilterValue} | ||
| /> | ||
| </Box> | ||
| </Flex> | ||
| )} | ||
| {analysisMode === 'results' && ( | ||
| <Flex direction="column" mih="0" miw={0}> | ||
|
|
@@ -2674,10 +2759,8 @@ function DBSearchPageContent() { | |
| style={{ width: '100%' }} | ||
| > | ||
| <SearchResultsCountGroup | ||
| isFilterSidebarCollapsed={isFilterSidebarCollapsed} | ||
| onExpandFilters={() => | ||
| setIsFilterSidebarCollapsed(false) | ||
| } | ||
| isFilterSidebarCollapsed={filtersCollapsed} | ||
| onExpandFilters={expandFilters} | ||
| histogramTimeChartConfig={histogramTimeChartConfig} | ||
| enableParallelQueries | ||
| /> | ||
|
|
@@ -2704,7 +2787,11 @@ function DBSearchPageContent() { | |
| </Box> | ||
| {!hasQueryError && ( | ||
| <Box | ||
| className={searchPageStyles.timeChartContainer} | ||
| className={ | ||
| isCompact | ||
| ? `${searchPageStyles.timeChartContainer} ${searchPageStyles.timeChartContainerCompact}` | ||
| : searchPageStyles.timeChartContainer | ||
| } | ||
| mih="0" | ||
| > | ||
| <DBTimeChart | ||
|
|
@@ -2884,7 +2971,7 @@ function DBSearchPageContent() { | |
| )} | ||
| </Flex> | ||
| )} | ||
| </div> | ||
| </ResponsiveSidePanel> | ||
| </> | ||
| )} | ||
| </Flex> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.