Skip to content

Commit 915f3a4

Browse files
committed
revert irrelevant changes
1 parent 5288eaa commit 915f3a4

2 files changed

Lines changed: 67 additions & 21 deletions

File tree

apps/roam/src/components/AdvancedNodeSearchDialog/AdvancedSearchDialog.tsx

Lines changed: 65 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
Button,
1010
Dialog,
1111
InputGroup,
12+
NonIdealState,
1213
Spinner,
1314
SpinnerSize,
1415
Tag,
@@ -37,6 +38,7 @@ import {
3738
type SearchResult,
3839
type SortConfig,
3940
buildSearchIndex,
41+
formatMetadataDate,
4042
searchIndexedNodes,
4143
sortSearchResults,
4244
splitWithHighlights,
@@ -108,6 +110,43 @@ const ResultRow = ({
108110
</Button>
109111
);
110112

113+
const PreviewPane = ({ result }: { result: SearchResult | null }) => {
114+
if (!result) {
115+
return (
116+
<div className="flex min-h-0 flex-1 items-center justify-center overflow-hidden">
117+
<NonIdealState
118+
icon="search"
119+
title="Search DG nodes"
120+
description="Type a keyword to preview matching discourse graph nodes."
121+
/>
122+
</div>
123+
);
124+
}
125+
const isPage = !!getPageTitleByPageUid(result.uid);
126+
127+
return (
128+
<div className="flex min-h-0 flex-1 flex-col overflow-hidden">
129+
<div className="flex-none flex-row gap-2 border-b border-gray-200 px-5 py-3 text-xs text-gray-500">
130+
Created: {formatMetadataDate(result.createdAt)} · Last modified:{" "}
131+
{formatMetadataDate(result.lastModified)} · Author:{" "}
132+
{result.authorName || "Unknown"}
133+
</div>
134+
<div
135+
className="min-h-0 flex-1 overflow-y-auto border-t border-gray-200 px-5 py-3"
136+
onMouseDown={(event) => event.preventDefault()}
137+
>
138+
<div className="pointer-events-none">
139+
{isPage ? (
140+
<RenderRoamPage hideMentions key={result.uid} uid={result.uid} />
141+
) : (
142+
<RenderRoamBlock key={result.uid} uid={result.uid} zoomPath />
143+
)}
144+
</div>
145+
</div>
146+
</div>
147+
);
148+
};
149+
111150
const AdvancedNodeSearchDialog = ({
112151
isOpen,
113152
onClose,
@@ -408,6 +447,8 @@ const AdvancedNodeSearchDialog = ({
408447
],
409448
);
410449

450+
const showSplitView = contentState === "results";
451+
411452
return (
412453
<Dialog
413454
autoFocus={false}
@@ -459,25 +500,30 @@ const AdvancedNodeSearchDialog = ({
459500
/>
460501
</div>
461502
<div className="flex min-h-0 w-full flex-1 overflow-hidden">
462-
{contentState === "results" ? (
463-
<div
464-
aria-label="Search results"
465-
className="w-full overflow-y-auto py-1"
466-
ref={resultsPanelRef}
467-
role="listbox"
468-
>
469-
{results.map((result, index) => (
470-
<ResultRow
471-
active={index === activeIndex}
472-
key={result.uid}
473-
keywords={keywords}
474-
nodeConfig={nodeConfigByType[result.type]}
475-
onClick={() => setActiveIndex(index)}
476-
onMouseEnter={() => setActiveIndex(index)}
477-
result={result}
478-
/>
479-
))}
480-
</div>
503+
{showSplitView ? (
504+
<>
505+
<div
506+
aria-label="Search results"
507+
className="w-1/3 shrink-0 overflow-y-auto border-r border-gray-200 py-1"
508+
ref={resultsPanelRef}
509+
role="listbox"
510+
>
511+
{results.map((result, index) => (
512+
<ResultRow
513+
active={index === activeIndex}
514+
key={result.uid}
515+
keywords={keywords}
516+
nodeConfig={nodeConfigByType[result.type]}
517+
onClick={() => setActiveIndex(index)}
518+
onMouseEnter={() => setActiveIndex(index)}
519+
result={result}
520+
/>
521+
))}
522+
</div>
523+
<div className="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
524+
<PreviewPane result={activeResult} />
525+
</div>
526+
</>
481527
) : (
482528
<div className="flex min-h-0 w-full flex-1 items-center justify-center px-4 py-8 text-center text-sm text-gray-500">
483529
{contentState === "indexing" && (

apps/roam/src/utils/registerCommandPaletteCommands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import { getUidAndBooleanSetting } from "~/utils/getExportSettings";
4646
import refreshConfigTree from "~/utils/refreshConfigTree";
4747
import { refreshAndNotify } from "~/components/LeftSidebarView";
4848
import { sectionsToBlockProps } from "~/components/settings/LeftSidebarPersonalSettings";
49-
import { renderAdvancedNodeSearchSidebar } from "~/components/AdvancedNodeSearchDialog/AdvancedSearchDialog";
49+
import { renderAdvancedNodeSearchDialog } from "~/components/AdvancedNodeSearchDialog/AdvancedSearchDialog";
5050
import {
5151
getBlockSelection,
5252
insertPageRefAtRange,
@@ -367,7 +367,7 @@ export const registerCommandPaletteCommands = (onloadArgs: OnloadArgs) => {
367367
if (getFeatureFlag("Advanced node search enabled")) {
368368
void addCommand("DG: Open Node Search", () => {
369369
posthog.capture("Node Search: Open Command Triggered");
370-
renderAdvancedNodeSearchSidebar();
370+
renderAdvancedNodeSearchDialog();
371371
});
372372
}
373373
void addCommand("DG: Open - Query drawer", openQueryDrawerWithArgs);

0 commit comments

Comments
 (0)