Repository navigation
Mount Columns and Sort on the search page #3432
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
b5442e5
887b229
c02c1b6
3f6bae3
5a781ad
7c2c3de
db862a0
dd169d2
4cca3d7
977658f
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,5 @@ | ||
| --- | ||
| '@hyperdx/app': minor | ||
| --- | ||
|
|
||
| feat: Edit search SELECT and ORDER BY from Columns and Sort popovers on the results table, and tidy the table controls row |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,10 +112,12 @@ import SearchWhereInput, { | |
| getStoredLanguage, | ||
| } from '@/components/SearchInput/SearchWhereInput'; | ||
| import SearchPageActionBar from '@/components/SearchPageActionBar'; | ||
| import { ColumnsPopover } from '@/components/SearchResultsToolbar/ColumnsPopover'; | ||
| import { SortPopover } from '@/components/SearchResultsToolbar/SortPopover'; | ||
| import { useClauseFieldOptions } from '@/components/SearchResultsToolbar/useClauseFieldOptions'; | ||
| import SearchTotalCountChart from '@/components/SearchTotalCountChart'; | ||
| import { TableSourceForm } from '@/components/Sources/SourceForm'; | ||
| import { SourceSelectControlled } from '@/components/SourceSelect'; | ||
| import { SQLInlineEditorControlled } from '@/components/SQLEditor/SQLInlineEditor'; | ||
| import { Tags } from '@/components/Tags'; | ||
| import { TimePicker } from '@/components/TimePicker'; | ||
| import { IS_LOCAL_MODE } from '@/config'; | ||
|
|
@@ -1144,9 +1146,6 @@ function DBSearchPageContent() { | |
| // 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); | ||
| // 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 | ||
|
|
@@ -2176,6 +2175,15 @@ function DBSearchPageContent() { | |
| [inputSourceObj], | ||
| ); | ||
|
|
||
| const inputSelect = useWatch({ name: 'select', control }); | ||
| const inputOrderBy = useWatch({ name: 'orderBy', control }); | ||
| const clauseFieldOptions = useClauseFieldOptions({ | ||
| tableConnection: inputSourceTableConnection, | ||
| columns: inputSourceColumns, | ||
| dateRange: searchedTimeRange, | ||
| timestampValueExpression: inputSourceObj?.timestampValueExpression, | ||
| }); | ||
|
|
||
| const [isSourceSchemaPreviewOpen, setIsSourceSchemaPreviewOpen] = | ||
| useState(false); | ||
|
|
||
|
|
@@ -2313,51 +2321,73 @@ 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> | ||
| </> | ||
| ); | ||
| }; | ||
| const applySelect = useCallback( | ||
|
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 —
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
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 — No test covers the Columns and Sort apply logic on the search page The PR says a removed column is also dropped from ORDER BY, but no test checks this. The DBSearchPage unit test mocks 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
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 —
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
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 —
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: string, removedItems: string[]) => { | ||
|
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 — Lines 2307-2316 copy 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
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 — applySelect duplicates toggleColumn's logic for pruning the sort and resubmitting
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
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 —
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
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 — No test covers the new Columns-apply wiring that drops removed columns from the sort The PR description says removing a column drops it from the sort, but nothing tests 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 |
||
| setValue('select', select); | ||
| let orderBy = getValues('orderBy') ?? ''; | ||
| for (const item of removedItems) { | ||
| orderBy = orderByAfterRemovingSelectItem( | ||
| item, | ||
| orderBy, | ||
| defaultSearchConfig.orderBy ?? '', | ||
| ); | ||
|
Comment on lines
+2329
to
+2333
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.
Select |
||
| } | ||
| setValue('orderBy', orderBy); | ||
| onSubmit(); | ||
| }, | ||
| [setValue, getValues, defaultSearchConfig.orderBy, onSubmit], | ||
| ); | ||
|
|
||
| const applyOrderBy = useCallback( | ||
| (orderBy: string) => { | ||
| setValue('orderBy', orderBy); | ||
| onSubmit(); | ||
| }, | ||
| [setValue, onSubmit], | ||
| ); | ||
|
|
||
| // The dropdown source can move before the URL source does. An empty SELECT | ||
| // is shown as this default, so it has to follow the dropdown, the same way | ||
| // the sort default follows useDefaultOrderBy(inputSource). | ||
| const savedSelect = | ||
|
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 —
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
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 — Default SELECT is now computed in two places that have to be kept in sync by hand
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
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 — Second default-SELECT derivation duplicates
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
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 — defaultSelect re-implements defaultSearchConfig.select with a different source object
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 |
||
| savedSearchId && | ||
| savedSearch?.id === savedSearchId && | ||
| inputSource === savedSearch.source | ||
| ? savedSearch.select | ||
| : undefined; | ||
| const sourceDefaultSelect = | ||
| inputSourceObj?.kind === SourceKind.Log || | ||
| inputSourceObj?.kind === SourceKind.Trace | ||
| ? inputSourceObj.defaultTableSelectExpression | ||
| : undefined; | ||
| const defaultSelect = savedSelect ?? sourceDefaultSelect ?? ''; | ||
|
|
||
| // SELECT and ORDER BY shape the results table, so they sit on that table | ||
| // and stay hidden on Event Deltas and Event Patterns. | ||
| const resultsClauseEditors = | ||
|
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 — New toolbar element on every render defeats the memo on DBSqlRowTable and RawLogTable
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
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 —
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 |
||
| analysisMode === 'results' ? ( | ||
|
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. 🟠 major —
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond
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 — A new toolbarLeading element on every render cancels the memo on DBSqlRowTable and RawLogTable Every other prop passed to 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 |
||
| <Group gap="xs" wrap="wrap"> | ||
| <ColumnsPopover | ||
| value={inputSelect ?? ''} | ||
| defaultValue={defaultSelect} | ||
| fieldOptions={clauseFieldOptions} | ||
| knownColumns={knownColumns} | ||
| onApply={applySelect} | ||
| tableConnection={inputSourceTableConnection} | ||
| sourceId={inputSource} | ||
| dateRange={searchedTimeRange} | ||
| /> | ||
| <SortPopover | ||
| value={inputOrderBy ?? ''} | ||
| defaultValue={defaultSearchConfig.orderBy ?? ''} | ||
| fieldOptions={clauseFieldOptions} | ||
| onApply={applyOrderBy} | ||
| tableConnection={inputSourceTableConnection} | ||
| sourceId={inputSource} | ||
| dateRange={searchedTimeRange} | ||
| /> | ||
| </Group> | ||
| ) : null; | ||
|
|
||
| return ( | ||
| <Flex | ||
|
|
@@ -2500,6 +2530,8 @@ function DBSearchPageContent() { | |
| px="sm" | ||
| pt={isCompact ? 4 : 'sm'} | ||
| wrap={isCompact ? 'wrap' : 'nowrap'} | ||
| justify="space-between" | ||
| align="center" | ||
| > | ||
| <SourceSelectControlled | ||
| key={`${savedSearchId}`} | ||
|
|
@@ -2519,21 +2551,13 @@ function DBSearchPageContent() { | |
| isCompact ? { flex: '1 1 140px', minWidth: 0 } : { minWidth: 150 } | ||
| } | ||
| /> | ||
| <SourceSchemaPreview | ||
| source={inputSourceObj} | ||
| controlled | ||
| open={isSourceSchemaPreviewOpen} | ||
| onClose={() => setIsSourceSchemaPreviewOpen(false)} | ||
| /> | ||
| {!isCompact && columnFields(true, false)} | ||
| <> | ||
| <Group gap="sm" wrap="nowrap" style={{ flexShrink: 0 }}> | ||
| {!savedSearchId ? ( | ||
| <Button | ||
| data-testid="save-search-button" | ||
| variant="secondary" | ||
| size="xs" | ||
| onClick={onSaveSearch} | ||
| style={{ flexShrink: 0 }} | ||
| > | ||
| Save | ||
| </Button> | ||
|
|
@@ -2545,7 +2569,6 @@ function DBSearchPageContent() { | |
| onClick={() => { | ||
| setSaveSearchModalState('update'); | ||
| }} | ||
| style={{ flexShrink: 0 }} | ||
| > | ||
| Update | ||
| </Button> | ||
|
|
@@ -2556,82 +2579,60 @@ function DBSearchPageContent() { | |
| variant="secondary" | ||
| size="xs" | ||
| onClick={openAlertModal} | ||
| style={{ flexShrink: 0 }} | ||
| > | ||
| <Group gap={4}> | ||
| Alerts | ||
| <AlertStatusIcon alerts={savedSearch?.alerts} /> | ||
| </Group> | ||
| </Button> | ||
| )} | ||
| {isCompact && ( | ||
| <Button | ||
| variant="subtle" | ||
| size="xs" | ||
| style={{ flexShrink: 0 }} | ||
| aria-expanded={columnsOpen} | ||
| onClick={() => setColumnsOpen(open => !open)} | ||
| > | ||
| {columnsOpen ? 'Hide columns' : 'Columns'} | ||
| </Button> | ||
| )} | ||
| </> | ||
| </Group> | ||
| </Flex> | ||
| {isCompact && columnsOpen && ( | ||
| <Flex direction="column" gap={4} px="sm" pt={4}> | ||
| {columnFields(false, true)} | ||
| </Flex> | ||
| )} | ||
| <SourceEditModal | ||
| opened={modelFormExpanded} | ||
| onClose={onModelFormExpandClose} | ||
| inputSource={inputSource} | ||
| /> | ||
| <NewSourceModal | ||
| opened={newSourceModalOpened} | ||
| onClose={setNewSourceModalClosed} | ||
| onCreate={onNewSourceCreate} | ||
| /> | ||
| <Flex | ||
| className={searchPageStyles.whereRow} | ||
| gap={isCompact ? 'xs' : 'sm'} | ||
| mt={isCompact ? 4 : 'sm'} | ||
| px="sm" | ||
| wrap="wrap" | ||
| > | ||
| <SearchWhereInput | ||
| tableConnection={inputSourceTableConnection} | ||
| control={control} | ||
| name="where" | ||
| onSubmit={onSubmit} | ||
| sqlQueryHistoryType={QUERY_LOCAL_STORAGE.SEARCH_SQL} | ||
| luceneQueryHistoryType={QUERY_LOCAL_STORAGE.SEARCH_LUCENE} | ||
| enableHotkey | ||
| data-testid="search-input" | ||
| minWidth="min(600px, 100%)" | ||
| dateRange={searchedTimeRange} | ||
| sourceId={inputSource} | ||
| size="xs" | ||
| /> | ||
| <Box className={searchPageStyles.whereField}> | ||
| <SearchWhereInput | ||
| tableConnection={inputSourceTableConnection} | ||
| control={control} | ||
| name="where" | ||
| onSubmit={onSubmit} | ||
| sqlQueryHistoryType={QUERY_LOCAL_STORAGE.SEARCH_SQL} | ||
| luceneQueryHistoryType={QUERY_LOCAL_STORAGE.SEARCH_LUCENE} | ||
| enableHotkey | ||
| data-testid="search-input" | ||
| minWidth="100%" | ||
| dateRange={searchedTimeRange} | ||
| sourceId={inputSource} | ||
| size="xs" | ||
| /> | ||
| </Box> | ||
| <Flex | ||
| className={searchPageStyles.timeControls} | ||
| gap="sm" | ||
| style={{ flex: '0 1 500px', minWidth: 0 }} | ||
| wrap="wrap" | ||
| align="flex-start" | ||
| > | ||
| <TimePicker | ||
| data-testid="time-picker" | ||
| inputValue={displayedTimeInputValue} | ||
| setInputValue={setDisplayedTimeInputValue} | ||
| onSearch={onTimePickerSearch} | ||
| onRelativeSearch={onTimePickerRelativeSearch} | ||
| showLive={analysisMode === 'results'} | ||
| isLiveMode={isLive} | ||
| // Default to relative time mode if the user has made changes to interval and reloaded. | ||
| defaultRelativeTimeMode={ | ||
| isLive && interval !== LIVE_TAIL_DURATION_MS | ||
| } | ||
| width="100%" | ||
| size="xs" | ||
| /> | ||
| <Box className={searchPageStyles.timePicker}> | ||
| <TimePicker | ||
| data-testid="time-picker" | ||
| width="100%" | ||
| inputValue={displayedTimeInputValue} | ||
| setInputValue={setDisplayedTimeInputValue} | ||
| onSearch={onTimePickerSearch} | ||
| onRelativeSearch={onTimePickerRelativeSearch} | ||
| showLive={analysisMode === 'results'} | ||
| isLiveMode={isLive} | ||
| // Default to relative time mode if the user has made changes to interval and reloaded. | ||
|
Member
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.
My only major feedback is this works, but the page has 5 rows of elements before the search results appear. We should in the future consider how we can save vertical space. it looks very off with the amount of empty space is in the source/save column.. i feel like we could compact/rearrange further.
Member
Author
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. I think once we add Saved Views to the first row, along with Favorite and Share, the row will grow a little. Also in some scenarios we can have alerts. |
||
| defaultRelativeTimeMode={ | ||
| isLive && interval !== LIVE_TAIL_DURATION_MS | ||
| } | ||
| size="xs" | ||
| /> | ||
| </Box> | ||
| {isLive && ( | ||
| <Tooltip label="Live tail refresh interval"> | ||
| <Box style={{ width: 80, minWidth: 80, flexShrink: 0 }}> | ||
|
|
@@ -2655,6 +2656,22 @@ function DBSearchPageContent() { | |
| <SearchSubmitButton isFormStateDirty={formState.isDirty} /> | ||
| </Flex> | ||
| </Flex> | ||
| <SourceSchemaPreview | ||
| source={inputSourceObj} | ||
| controlled | ||
| open={isSourceSchemaPreviewOpen} | ||
| onClose={() => setIsSourceSchemaPreviewOpen(false)} | ||
| /> | ||
| <SourceEditModal | ||
| opened={modelFormExpanded} | ||
| onClose={onModelFormExpandClose} | ||
| inputSource={inputSource} | ||
| /> | ||
| <NewSourceModal | ||
| opened={newSourceModalOpened} | ||
| onClose={setNewSourceModalClosed} | ||
| onCreate={onNewSourceCreate} | ||
| /> | ||
| <ActiveFilterPills | ||
| searchFilters={searchFilters} | ||
| chartConfig={filtersChartConfig} | ||
|
|
@@ -2688,12 +2705,19 @@ function DBSearchPageContent() { | |
| className="bg-body" | ||
| > | ||
| {!queryReady ? ( | ||
| <EmptyState | ||
| h="100%" | ||
| icon={<IconStack2 size={32} />} | ||
| title="No data to display" | ||
| description="Select a source and click the play button to query data." | ||
| /> | ||
| <Flex direction="column" h="100%"> | ||
| {resultsClauseEditors != null && ( | ||
| <Box px="sm" pt="sm"> | ||
| {resultsClauseEditors} | ||
| </Box> | ||
| )} | ||
| <EmptyState | ||
|
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 — Empty state keeps In 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 |
||
| h="100%" | ||
| icon={<IconStack2 size={32} />} | ||
| title="No data to display" | ||
| description="Select a source and click the play button to query data." | ||
| /> | ||
| </Flex> | ||
| ) : ( | ||
| <> | ||
| <ResponsiveSidePanel | ||
|
|
@@ -2900,6 +2924,11 @@ function DBSearchPageContent() { | |
| )} | ||
| {hasQueryError && queryError ? ( | ||
| <> | ||
| {resultsClauseEditors != null && ( | ||
| <Box px="sm" pt="xs"> | ||
| {resultsClauseEditors} | ||
| </Box> | ||
| )} | ||
| <div className="h-100 w-100 px-4 mt-4 align-items-center justify-content-center text-muted overflow-auto"> | ||
| {whereSuggestions && whereSuggestions.length > 0 && ( | ||
| <Box mb="xl"> | ||
|
|
@@ -3052,6 +3081,8 @@ function DBSearchPageContent() { | |
| selectionResetKey={selectionResetKey} | ||
| onSelectedRowsChange={onSelectedRowsChange} | ||
| onResolvedColumnsChange={onResolvedColumnsChange} | ||
| toolbarLeading={resultsClauseEditors} | ||
| controlsAboveTable | ||
| /> | ||
| )} | ||
| </Box> | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔵 minor — applySelect repeats toggleColumn's logic for pruning ORDER BY
applySelectrepeatstoggleColumn's steps (lines 1838-1872): setselect, readorderBywithgetValues, callorderByAfterRemovingSelectItemwithdefaultSearchConfig.orderBy, thensetValue('orderBy'). Move this into one helper, for examplepruneOrderByForRemovedItems(items), and call it from both places, so a change to the pruning rule cannot reach only one of them.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