Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
2 changes: 1 addition & 1 deletion app/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
import "./.next/types/routes.d.ts";
import "./.next/dev/types/routes.d.ts";

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
4 changes: 3 additions & 1 deletion app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/src/app/(dashboard)/widget-lab/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
useCreateWidgetTemplate,
} from "@/hooks/use-widget-templates";
import { useConnections } from "@/hooks/use-connections";
import { getChartConfig } from "@/lib/chart-registry";
import { getChartConfig } from "@/lib/chart-helpers";
import { DashboardPickerDialog } from "@/components/dashboard-picker-dialog";
import {
PageHeader,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ vi.mock("@neoboard/components", () => ({
),
ColumnMappingOverlay: () => <div data-testid="column-mapping-overlay" />,
substituteParams: (s: string) => s,
getChartOptions: () => [],
}));

vi.mock("next/dynamic", () => ({
Expand Down
12 changes: 9 additions & 3 deletions app/src/components/__tests__/card-container.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,26 @@ vi.mock("@/stores/parameter-store", () => ({
useParameterValues: () => ({}),
}));

vi.mock("@/lib/chart-registry", () => ({
vi.mock("@/lib/chart-helpers", () => ({
getChartConfig: (type: string) => {
if (type === "bar" || type === "markdown") {
return {
type,
label: type,
transform: (d: unknown) => d,
transformWithMapping: (d: unknown) => d,
supportsColumnMapping: false,
validate: () => null,
capabilities: {
supportsClickAction: true,
supportsStyling: false,
isECharts: false,
requiresQuery: true,
},
};
}
return null;
},
supportsColumnMapping: () => false,
}));

vi.mock("@/lib/resolve-cache-options", () => ({
Expand Down Expand Up @@ -249,7 +255,7 @@ describe("CardContainer", () => {

describe("form widget path", () => {
it("renders chart for form widgets without querying", () => {
// Need to add "form" to the mock chart-registry
// Need to add "form" to the mock chart-helpers
const widget = createWidget({
chartType: "bar",
settings: { chartOptions: {} },
Expand Down
1 change: 1 addition & 0 deletions app/src/components/__tests__/chart-error-boundary.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ vi.mock("@neoboard/components", () => ({
JsonViewer: () => <div data-testid="json-viewer" />,
MarkdownWidget: () => <div data-testid="markdown-widget" />,
IframeWidget: () => <div data-testid="iframe-widget" />,
getChartOptions: () => [],
}));

// Mock next/dynamic to just render children synchronously
Expand Down
23 changes: 13 additions & 10 deletions app/src/components/card-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import { useWidgetQuery } from "@/hooks/use-widget-query";
import { useClickAction } from "@/hooks/use-click-action";
import { resolveCacheOptions } from "@/lib/resolve-cache-options";
import { getChartConfig } from "@/lib/chart-registry";
import type { ColumnMapping } from "@/lib/chart-registry";
import {
getChartConfig,
supportsColumnMapping as chartSupportsColumnMapping,
} from "@/lib/chart-helpers";
import type { ColumnMapping } from "@/lib/chart-helpers";
import type { DashboardWidget, StylingConfig } from "@/lib/db/schema";
import type { ParameterSourceMap } from "@/lib/collect-parameter-names";
import type { ColorScaleConfig } from "@neoboard/components";
Expand Down Expand Up @@ -32,10 +35,9 @@ import {
} from "@neoboard/components";
import { ChartRenderer } from "./chart-renderer";

/** Chart types that support column mapping. */
/** Derived from registry — chart types that support column mapping overlays. */
/** Chart types that support column mapping overlays. */
function supportsColumnMapping(type: string): boolean {
return getChartConfig(type)?.supportsColumnMapping === true;
return chartSupportsColumnMapping(type);
}

interface CardContainerProps {
Expand Down Expand Up @@ -296,10 +298,9 @@ export function CardContainer({
/>
);
}
const mappedData = chartConfig.transformWithMapping(
previewData,
columnMapping,
);
const mappedData = (
chartConfig.transformWithMapping ?? chartConfig.transform
)(previewData, columnMapping);
// Skip transforms for graph charts — their data shape is incompatible with tabular transforms
const transformedData =
dataTransforms.length && widget.chartType !== "graph"
Expand Down Expand Up @@ -548,7 +549,9 @@ export function CardContainer({
);
}

const mappedData = chartConfig.transformWithMapping(rawData, columnMapping);
const mappedData = (
chartConfig.transformWithMapping ?? chartConfig.transform
)(rawData, columnMapping);
const transformedData = dataTransforms.length
? applyTransforms(
mappedData as Record<string, unknown>[],
Expand Down
3 changes: 1 addition & 2 deletions app/src/components/chart-renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import React from "react";
import { AlertCircle } from "lucide-react";
import type { ChartType } from "@/lib/chart-registry";
import { pluginRegistry } from "@/plugins";
import { ChartErrorBoundary } from "./chart-error-boundary";
import { EmptyState } from "@neoboard/components";
Expand Down Expand Up @@ -31,7 +30,7 @@ export interface ChartMetaProps {
}

export interface ChartRendererProps {
type: ChartType;
type: string;
data: unknown;
settings?: Record<string, unknown>;
styling?: ChartStylingProps;
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/graph-exploration-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {
FetchNeighborsResult,
PropertySection,
} from "@neoboard/components";
import { getChartConfig } from "@/lib/chart-registry";
import { getChartConfig } from "@/lib/chart-helpers";
import { normalizeValue } from "@/lib/normalize-value";
import { useGraphWidgetStore } from "@/stores/graph-widget-store";

Expand Down
2 changes: 1 addition & 1 deletion app/src/components/save-template-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
Label,
Textarea,
} from "@neoboard/components";
import { getChartConfig } from "@/lib/chart-registry";
import { getChartConfig } from "@/lib/chart-helpers";
import type { ConnectorType } from "@/lib/connector-types";

interface SaveTemplateDialogProps {
Expand Down
14 changes: 7 additions & 7 deletions app/src/components/widget-editor-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ import type { ColorScaleConfig } from "@neoboard/components";
import {
getCompatibleChartTypes,
getChartConfig,
chartRegistry,
chartSupportsClickAction,
chartSupportsStyling,
} from "@/lib/chart-registry";
import type { ChartType } from "@/lib/chart-registry";
getAllChartTypes,
} from "@/lib/chart-helpers";
import type { ChartType } from "@/lib/chart-helpers";
import { type ConnectorType, CONNECTOR_LANGUAGES } from "@/lib/connector-types";
import { useParameterValues } from "@/stores/parameter-store";
import { extractReferencedParams } from "@/hooks/use-widget-query";
Expand Down Expand Up @@ -402,8 +402,8 @@ export function WidgetEditorModal({
const compatibleChartTypes = useMemo(
() =>
selectedConnection
? getCompatibleChartTypes(selectedConnection.type)
: (Object.keys(chartRegistry) as ChartType[]),
? (getCompatibleChartTypes(selectedConnection.type) as ChartType[])
: (getAllChartTypes() as ChartType[]),
[selectedConnection],
);

Expand Down Expand Up @@ -1452,8 +1452,8 @@ export function WidgetEditorModal({
variant="outline"
className="text-xs font-normal"
>
{chartRegistry[w.chartType as ChartType]
?.label ?? w.chartType}
{getChartConfig(w.chartType)?.label ??
w.chartType}
</Badge>
</Label>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ describe("QueryEditorPanel", () => {
it("does not show query hint for chart types without hints", () => {
useWidgetEditorStore
.getState()
.setChartType("markdown" as import("@/lib/chart-registry").ChartType);
.setChartType("markdown" as import("@/lib/chart-helpers").ChartType);
render(<QueryEditorPanel editorLanguage="cypher" />);
// No hint text for markdown
expect(screen.queryByText(/Return 2\+ columns/)).not.toBeInTheDocument();
Expand Down
4 changes: 2 additions & 2 deletions app/src/components/widget-editor/chart-type-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import {
} from "lucide-react";
import type { LucideIcon } from "lucide-react";
import { Label, Combobox } from "@neoboard/components";
import type { ChartType } from "@/lib/chart-registry";
import { getChartConfig } from "@/lib/chart-registry";
import type { ChartType } from "@/lib/chart-helpers";
import { getChartConfig } from "@/lib/chart-helpers";

/** Icon map for chart type dropdown (labels come from chartRegistry, icons stay in UI layer) */
export const chartTypeIcons: Record<ChartType, LucideIcon> = {
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/widget-editor/query-editor-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
DropdownMenuItem,
} from "@neoboard/components";
import { FileCode } from "lucide-react";
import type { ChartType } from "@/lib/chart-registry";
import type { ChartType } from "@/lib/chart-helpers";
import { useConnectionSchema } from "@/hooks/use-schema";
import { useSchemaStore } from "@/stores/schema-store";

Expand Down
2 changes: 1 addition & 1 deletion app/src/components/widget-editor/styling-rules-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from "react";
import type { StylingRule, StylingOperator } from "@/lib/db/schema";
import { getOperatorGroups } from "@neoboard/components/charts";
import { useWidgetEditorStore } from "@/stores/widget-editor-store";
import { getStylingTargets } from "@/lib/chart-registry";
import { getStylingTargets } from "@/lib/chart-helpers";
import { ArrowLeft, GripVertical, Plus, Trash2, Bold } from "lucide-react";
import {
Accordion,
Expand Down
Loading
Loading