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
27 changes: 19 additions & 8 deletions apps/roam/src/components/results-view/ResultsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ import React, {
useState,
useCallback,
} from "react";
import {
Button,
HTMLTable,
Icon,
IconName,
} from "@blueprintjs/core";
import { Button, HTMLTable, Icon, IconName } from "@blueprintjs/core";
import { IconNames } from "@blueprintjs/icons";
import { Column, Result } from "~/utils/types";
import type { FilterData, Sorts, Views } from "~/utils/parseResultSettings";
Expand All @@ -24,6 +19,8 @@ import openBlockInSidebar from "roamjs-components/writes/openBlockInSidebar";
import setInputSettings from "roamjs-components/util/setInputSettings";
import toCellValue from "~/utils/toCellValue";
import { ContextContent } from "~/components/DiscourseContext";
import DiscourseContextOverlay from "~/components/DiscourseContextOverlay";
import { CONTEXT_OVERLAY_SUGGESTION } from "~/utils/predefinedSelections";

const EXTRA_ROW_TYPES = ["context", "discourse"] as const;
type ExtraRowType = (typeof EXTRA_ROW_TYPES)[number] | null;
Expand Down Expand Up @@ -211,14 +208,28 @@ const ResultRow = ({
const cell = (key: string) => {
const value = toCellValue({
value: r[`${key}-display`] || r[key] || "",
uid: (r[`${key}-uid`] as string) || "",
uid: r[`${key}-uid`] || "",
});
const action = r[`${key}-action`];
if (typeof action === "string") {
const buttonProps =
value.toUpperCase().replace(/\s/g, "_") in IconNames
? { icon: value as IconName, minimal: true }
: { text: value };
const actionUid = r[`${key}-uid`];

if (
action === "discourse" &&
value === CONTEXT_OVERLAY_SUGGESTION &&
actionUid
) {
return (
<DiscourseContextOverlay
uid={actionUid}
id={`discourse-overlay-${parentUid}-${actionUid}`}
/>
);
}
return (
<Button
{...buttonProps}
Expand All @@ -227,7 +238,7 @@ const ResultRow = ({
new CustomEvent("roamjs:query-builder:action", {
detail: {
action,
uid: r[`${key}-uid`],
uid: actionUid,
val: r["text"],
onRefresh,
queryUid: parentUid,
Expand Down
3 changes: 3 additions & 0 deletions apps/roam/src/utils/predefinedSelections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ const LEAF_SUGGESTIONS: SelectionSuggestion[] = CREATE_DATE_SUGGESTIONS.concat(
.concat(EDIT_BY_SUGGESTIONS);
// .concat(ATTR_SUGGESTIONS);

export const CONTEXT_OVERLAY_SUGGESTION = "overlay";

const predefinedSelections: PredefinedSelection[] = [
{
test: CREATE_DATE_TEST,
Expand Down Expand Up @@ -522,6 +524,7 @@ const predefinedSelections: PredefinedSelection[] = [
{ text: "flows" },
{ text: "graph" },
{ text: "layout" }, // replace with { text: "search-around" }, not supported yet
{ text: CONTEXT_OVERLAY_SUGGESTION },
],
},
],
Expand Down