Skip to content

Commit 5210bb8

Browse files
authored
refactor: table connections standardized and single by default. Special case for dashboard (#1195)
Closes HDX-2469
1 parent 1cda148 commit 5210bb8

25 files changed

+216
-156
lines changed

.changeset/two-melons-admire.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@hyperdx/common-utils": patch
3+
"@hyperdx/app": patch
4+
---
5+
6+
refactor: clean up table connections

packages/app/src/DBSearchPage.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ function DBSearchPage() {
12651265
</Group>
12661266
<Box style={{ minWidth: 100, flexGrow: 1 }}>
12671267
<SQLInlineEditorControlled
1268-
tableConnections={tcFromSource(inputSourceObj)}
1268+
tableConnection={tcFromSource(inputSourceObj)}
12691269
control={control}
12701270
name="select"
12711271
defaultValue={inputSourceObj?.defaultTableSelectExpression}
@@ -1279,7 +1279,7 @@ function DBSearchPage() {
12791279
</Box>
12801280
<Box style={{ maxWidth: 400, width: '20%' }}>
12811281
<SQLInlineEditorControlled
1282-
tableConnections={tcFromSource(inputSourceObj)}
1282+
tableConnection={tcFromSource(inputSourceObj)}
12831283
control={control}
12841284
name="orderBy"
12851285
defaultValue={defaultOrderBy}
@@ -1401,7 +1401,7 @@ function DBSearchPage() {
14011401
sqlInput={
14021402
<Box style={{ width: '75%', flexGrow: 1 }}>
14031403
<SQLInlineEditorControlled
1404-
tableConnections={tcFromSource(inputSourceObj)}
1404+
tableConnection={tcFromSource(inputSourceObj)}
14051405
control={control}
14061406
name="where"
14071407
placeholder="SQL WHERE clause (ex. column = 'foo')"
@@ -1421,7 +1421,7 @@ function DBSearchPage() {
14211421
}
14221422
luceneInput={
14231423
<SearchInputV2
1424-
tableConnections={tcFromSource(inputSourceObj)}
1424+
tableConnection={tcFromSource(inputSourceObj)}
14251425
control={control}
14261426
name="where"
14271427
onLanguageChange={lang =>

packages/app/src/DBSearchPageAlertModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const AlertForm = ({
147147
grouped by
148148
</Text>
149149
<SQLInlineEditorControlled
150-
tableConnections={tcFromSource(source)}
150+
tableConnection={tcFromSource(source)}
151151
control={control}
152152
name={`groupBy`}
153153
placeholder="SQL Columns"

packages/app/src/DashboardFilters.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const DashboardFilterSelect = ({
3131

3232
const { data: keys, isLoading: isKeyValuesLoading } = useGetKeyValues(
3333
{
34-
chartConfigs: {
34+
chartConfig: {
3535
dateRange,
3636
timestampValueExpression: timestampValueExpression!,
3737
connection: connection!,

packages/app/src/DashboardFiltersModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ const DashboardFilterEditForm = ({
179179
error={formState.errors.expression}
180180
>
181181
<SQLInlineEditorControlled
182-
tableConnections={tableConnection}
182+
tableConnection={tableConnection}
183183
control={control}
184184
name="expression"
185185
placeholder="SQL column or expression"

packages/app/src/NamespaceDetailsSidePanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export default function NamespaceDetailsSidePanel({
281281

282282
const { data: logServiceNames } = useGetKeyValues(
283283
{
284-
chartConfigs: {
284+
chartConfig: {
285285
from: logSource.from,
286286
where: `${logSource?.resourceAttributesExpression}.k8s.namespace.name:"${namespaceName}"`,
287287
whereLanguage: 'lucene',

packages/app/src/NodeDetailsSidePanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ export default function NodeDetailsSidePanel({
297297

298298
const { data: logServiceNames } = useGetKeyValues(
299299
{
300-
chartConfigs: {
300+
chartConfig: {
301301
from: logSource.from,
302302
where: `${logSource?.resourceAttributesExpression}.k8s.node.name:"${nodeName}"`,
303303
whereLanguage: 'lucene',

packages/app/src/PodDetailsSidePanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ export default function PodDetailsSidePanel({
285285

286286
const { data: logServiceNames } = useGetKeyValues(
287287
{
288-
chartConfigs: {
288+
chartConfig: {
289289
from: logSource.from,
290290
where: `${logSource?.resourceAttributesExpression}.k8s.pod.name:"${podName}"`,
291291
whereLanguage: 'lucene',

packages/app/src/SearchInputV2.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { useEffect, useRef, useState } from 'react';
22
import { useController, UseControllerProps } from 'react-hook-form';
33
import { useHotkeys } from 'react-hotkeys-hook';
4-
import { Field, TableConnection } from '@hyperdx/common-utils/dist/metadata';
4+
import {
5+
Field,
6+
TableConnectionChoice,
7+
} from '@hyperdx/common-utils/dist/metadata';
58
import { genEnglishExplanation } from '@hyperdx/common-utils/dist/queryParser';
69

710
import AutocompleteInput from '@/AutocompleteInput';
@@ -25,6 +28,7 @@ export class LuceneLanguageFormatter implements ILanguageFormatter {
2528

2629
const luceneLanguageFormatter = new LuceneLanguageFormatter();
2730
export default function SearchInputV2({
31+
tableConnection,
2832
tableConnections,
2933
placeholder = 'Search your events for anything...',
3034
size = 'sm',
@@ -38,7 +42,6 @@ export default function SearchInputV2({
3842
'data-testid': dataTestId,
3943
...props
4044
}: {
41-
tableConnections?: TableConnection | TableConnection[];
4245
placeholder?: string;
4346
size?: 'xs' | 'sm' | 'lg';
4447
zIndex?: number;
@@ -49,7 +52,8 @@ export default function SearchInputV2({
4952
additionalSuggestions?: string[];
5053
queryHistoryType?: string;
5154
'data-testid'?: string;
52-
} & UseControllerProps<any>) {
55+
} & UseControllerProps<any> &
56+
TableConnectionChoice) {
5357
const {
5458
field: { onChange, value },
5559
} = useController(props);
@@ -59,9 +63,9 @@ export default function SearchInputV2({
5963

6064
const autoCompleteOptions = useAutoCompleteOptions(
6165
luceneLanguageFormatter,
62-
value != null ? `${value}` : '', // value can be null at times
66+
value != null ? `${value}` : '',
6367
{
64-
tableConnections,
68+
tableConnection: tableConnection ? tableConnection : tableConnections,
6569
additionalSuggestions,
6670
},
6771
);

packages/app/src/ServicesDashboardPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ function ServicesDashboardPage() {
955955
control={control}
956956
sqlInput={
957957
<SQLInlineEditorControlled
958-
tableConnections={tcFromSource(source)}
958+
tableConnection={tcFromSource(source)}
959959
onSubmit={onSubmit}
960960
control={control}
961961
name="where"
@@ -973,7 +973,7 @@ function ServicesDashboardPage() {
973973
}
974974
luceneInput={
975975
<SearchInputV2
976-
tableConnections={tcFromSource(source)}
976+
tableConnection={tcFromSource(source)}
977977
control={control}
978978
name="where"
979979
onLanguageChange={lang =>

0 commit comments

Comments
 (0)