Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/cuddly-days-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hyperdx/app": patch
---

fix issue where new lines are not persisted to url params correctly
3 changes: 2 additions & 1 deletion packages/app/src/DBDashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import OnboardingModal from './components/OnboardingModal';
import { Tags } from './components/Tags';
import useDashboardFilters from './hooks/useDashboardFilters';
import { useDashboardRefresh } from './hooks/useDashboardRefresh';
import { parseAsStringWithNewLines } from './utils/queryParsers';
import api from './api';
import { DEFAULT_CHART_CONFIG } from './ChartUtils';
import { IS_LOCAL_MODE } from './config';
Expand Down Expand Up @@ -557,7 +558,7 @@ function DBDashboardPage({ presetConfig }: { presetConfig?: Dashboard }) {
) as [SQLInterval | undefined, (value: SQLInterval | undefined) => void];
const [where, setWhere] = useQueryState(
'where',
parseAsString.withDefault(''),
parseAsStringWithNewLines.withDefault(''),
);
const [whereLanguage, setWhereLanguage] = useQueryState(
'whereLanguage',
Expand Down
7 changes: 4 additions & 3 deletions packages/app/src/DBSearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ import PatternTable from './components/PatternTable';
import SourceSchemaPreview from './components/SourceSchemaPreview';
import { useTableMetadata } from './hooks/useMetadata';
import { useSqlSuggestions } from './hooks/useSqlSuggestions';
import { parseAsStringWithNewLines } from './utils/queryParsers';
import api from './api';
import { LOCAL_STORE_CONNECTIONS_KEY } from './connection';
import { DBSearchPageAlertModal } from './DBSearchPageAlertModal';
Expand Down Expand Up @@ -590,11 +591,11 @@ export function useDefaultOrderBy(sourceID: string | undefined | null) {
// This is outside as it needs to be a stable reference
const queryStateMap = {
source: parseAsString,
where: parseAsString,
select: parseAsString,
where: parseAsStringWithNewLines,
select: parseAsStringWithNewLines,
whereLanguage: parseAsStringEnum<'sql' | 'lucene'>(['sql', 'lucene']),
filters: parseAsJson<Filter[]>(),
orderBy: parseAsString,
orderBy: parseAsStringWithNewLines,
};

function DBSearchPage() {
Expand Down
8 changes: 8 additions & 0 deletions packages/app/src/utils/queryParsers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createParser } from 'nuqs';

// Note: this can be deleted once we upgrade to nuqs v2.2.3
// https://github.com/47ng/nuqs/pull/783
export const parseAsStringWithNewLines = createParser<string>({
parse: value => value.replace(/%0A/g, '\n'),
serialize: value => value.replace(/\n/g, '%0A'),
});
Loading