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
15 changes: 15 additions & 0 deletions .changeset/30654-drill-open-in-list-exact.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@object-ui/react': patch
'@object-ui/plugin-dashboard': patch
'@object-ui/plugin-charts': patch
'@object-ui/app-shell': patch
---

fix(drill): "Open in list" from a dashboard or report drill is offered only when the list can show exactly the drawer's records

Clause-②: yes (widening)
Metadata-protocol: none

A drill filter is the clicked bucket AND the widget's filter AND the measure's drill scope. The list route holds one value per filter param and has no spelling for `$in`, so a drill with two conditions on one field (a `status = sent` bucket under a `status = paid` measure scope) or an `$in` scope opened a wider list than the drawer: the drawer showed 0 invoices and the list showed every sent one. The Console now offers "Open in list", and follows `drillDown.target: 'navigate'`, only when the route can write every condition of the drill filter, after resolving its placeholders; otherwise the drill stays in the drawer. A plain equality or date-range drill opens the same URL as before.

`DrillNavigationValue` (`@object-ui/react`) gains an optional `canOpenRecordList(objectName, filter)`. The drill drawers (`DrillDownDrawer`, `OpenInListButton`, `ObjectChart`) offer the escape hatch only when `openRecordList` is present and `canOpenRecordList` is absent or answers `true`. A host that does not provide it behaves exactly as before.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ vi.mock('react-router-dom', () => ({
useLocation: () => ({ pathname: '/dashboard/pipeline', search: '' }),
}));

vi.mock('./useOpenRecordList', () => ({ useOpenRecordList: () => vi.fn() }));
vi.mock('./useOpenRecordList', () => ({
useRecordListDrillNavigation: () => ({ openRecordList: vi.fn(), canOpenRecordList: () => true }),
}));
vi.mock('./MetadataInspector', () => ({
MetadataPanel: () => null,
useMetadataInspector: () => ({ showDebug: false }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ vi.mock('react-router-dom', () => ({
useLocation: () => ({ pathname: '/dashboards/sales_overview', search: '' }),
}));

vi.mock('./useOpenRecordList', () => ({ useOpenRecordList: () => vi.fn() }));
vi.mock('./useOpenRecordList', () => ({
useRecordListDrillNavigation: () => ({ openRecordList: vi.fn(), canOpenRecordList: () => true }),
}));
vi.mock('./MetadataInspector', () => ({
MetadataPanel: () => null,
useMetadataInspector: () => ({ showDebug: false }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ vi.mock('react-router-dom', () => ({
useLocation: () => ({ pathname: '/apps/crm/dashboard/ops_board', search: '' }),
}));

vi.mock('./useOpenRecordList', () => ({ useOpenRecordList: () => vi.fn() }));
vi.mock('./useOpenRecordList', () => ({
useRecordListDrillNavigation: () => ({ openRecordList: vi.fn(), canOpenRecordList: () => true }),
}));
vi.mock('./MetadataInspector', () => ({
MetadataPanel: () => null,
useMetadataInspector: () => ({ showDebug: false }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ vi.mock('react-router-dom', () => ({
useNavigate: () => vi.fn(),
useLocation: () => ({ pathname: '/apps/crm/dashboard/ops_board', search: '' }),
}));
vi.mock('./useOpenRecordList', () => ({ useOpenRecordList: () => vi.fn() }));
vi.mock('./useOpenRecordList', () => ({
useRecordListDrillNavigation: () => ({ openRecordList: vi.fn(), canOpenRecordList: () => true }),
}));
vi.mock('./MetadataInspector', () => ({
MetadataPanel: () => null,
useMetadataInspector: () => ({ showDebug: false }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ vi.mock('react-router-dom', () => ({
useLocation: () => ({ pathname: '/apps/crm/dashboard/ops_board', search: '' }),
}));

vi.mock('./useOpenRecordList', () => ({ useOpenRecordList: () => vi.fn() }));
vi.mock('./useOpenRecordList', () => ({
useRecordListDrillNavigation: () => ({ openRecordList: vi.fn(), canOpenRecordList: () => true }),
}));
vi.mock('./MetadataInspector', () => ({
MetadataPanel: () => null,
useMetadataInspector: () => ({ showDebug: false }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ vi.mock('react-router-dom', () => ({
useLocation: () => ({ pathname: `/dashboards/${route.dashboardName}`, search: '' }),
}));

vi.mock('./useOpenRecordList', () => ({ useOpenRecordList: () => vi.fn() }));
vi.mock('./useOpenRecordList', () => ({
useRecordListDrillNavigation: () => ({ openRecordList: vi.fn(), canOpenRecordList: () => true }),
}));
vi.mock('./MetadataInspector', () => ({
MetadataPanel: () => null,
useMetadataInspector: () => ({ showDebug: false }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ vi.mock('react-router-dom', () => ({
useLocation: () => ({ pathname: '/dashboards/sales_overview', search: '' }),
}));

vi.mock('./useOpenRecordList', () => ({ useOpenRecordList: () => vi.fn() }));
vi.mock('./useOpenRecordList', () => ({
useRecordListDrillNavigation: () => ({ openRecordList: vi.fn(), canOpenRecordList: () => true }),
}));
vi.mock('./MetadataInspector', () => ({
MetadataPanel: () => null,
useMetadataInspector: () => ({ showDebug: false }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ vi.mock('react-router-dom', () => ({
useLocation: () => ({ pathname: '/dashboards/system_overview', search: '' }),
}));

vi.mock('./useOpenRecordList', () => ({ useOpenRecordList: () => vi.fn() }));
vi.mock('./useOpenRecordList', () => ({
useRecordListDrillNavigation: () => ({ openRecordList: vi.fn(), canOpenRecordList: () => true }),
}));
vi.mock('./MetadataInspector', () => ({
MetadataPanel: () => null,
useMetadataInspector: () => ({ showDebug: false }),
Expand Down
6 changes: 3 additions & 3 deletions ui/packages/app-shell/src/views/DashboardView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useState, useEffect, useMemo, type ComponentProps } from 'react';
import { useParams } from 'react-router-dom';
import { DashboardRenderer } from '@object-ui/plugin-dashboard';
import { DrillNavigationProvider, notifyDataChanged } from '@object-ui/react';
import { useOpenRecordList } from './useOpenRecordList.js';
import { useRecordListDrillNavigation } from './useOpenRecordList.js';
import { toast } from 'sonner';
import type { ActionDef, ActionContext, ActionResult } from '@object-ui/core';
import {
Expand Down Expand Up @@ -97,7 +97,7 @@ type DashboardRefreshState = Parameters<

export function DashboardView({ dataSource }: { dataSource?: any }) {
// Drill "escape hatch": lets the drill drawers open an object's full list page.
const openRecordList = useOpenRecordList();
const drillNavigation = useRecordListDrillNavigation();
const { dashboardName } = useParams<{ dashboardName: string }>();
const { showDebug } = useMetadataInspector();
const adapter = useAdapter();
Expand Down Expand Up @@ -380,7 +380,7 @@ export function DashboardView({ dataSource }: { dataSource?: any }) {
{/* ── Main area ────────────────────────────────────────────── */}
<div className="flex-1 overflow-hidden flex flex-col sm:flex-row relative">
<div className="flex-1 min-w-0 overflow-auto p-2 sm:p-4 md:p-6">
<DrillNavigationProvider value={{ openRecordList }}>
<DrillNavigationProvider value={drillNavigation}>
{/* `localized`: this document is the `/meta` read's, already
translated for this language, so the renderer draws its
title, description and sub-caption as served (objectui#11295). */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ vi.mock('react-router-dom', () => ({
useLocation: () => ({ pathname: '/report/hours_by_status', search: '' }),
}));

vi.mock('./useOpenRecordList', () => ({ useOpenRecordList: () => vi.fn() }));
vi.mock('./useOpenRecordList', () => ({
useRecordListDrillNavigation: () => ({ openRecordList: vi.fn(), canOpenRecordList: () => true }),
}));
vi.mock('./MetadataInspector', () => ({
MetadataPanel: () => null,
useMetadataInspector: () => ({ showDebug: false }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ vi.mock('react-router-dom', () => ({
useLocation: () => ({ pathname: '/reports/revenue_by_month', search: '' }),
}));

vi.mock('./useOpenRecordList', () => ({ useOpenRecordList: () => vi.fn() }));
vi.mock('./useOpenRecordList', () => ({
useRecordListDrillNavigation: () => ({ openRecordList: vi.fn(), canOpenRecordList: () => true }),
}));
vi.mock('./MetadataInspector', () => ({
MetadataPanel: () => null,
useMetadataInspector: () => ({ showDebug: false }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ vi.mock('react-router-dom', () => ({
useLocation: () => ({ pathname: '/report/srm_delivery_scorecard', search: '' }),
}));

vi.mock('./useOpenRecordList', () => ({ useOpenRecordList: () => vi.fn() }));
vi.mock('./useOpenRecordList', () => ({
useRecordListDrillNavigation: () => ({ openRecordList: vi.fn(), canOpenRecordList: () => true }),
}));
vi.mock('./MetadataInspector', () => ({
MetadataPanel: () => null,
useMetadataInspector: () => ({ showDebug: false }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ vi.mock('react-router-dom', () => ({
useLocation: () => ({ pathname: '/reports/revenue_by_month', search: '' }),
}));

vi.mock('./useOpenRecordList', () => ({ useOpenRecordList: () => vi.fn() }));
vi.mock('./useOpenRecordList', () => ({
useRecordListDrillNavigation: () => ({ openRecordList: vi.fn(), canOpenRecordList: () => true }),
}));
vi.mock('./MetadataInspector', () => ({
MetadataPanel: () => null,
useMetadataInspector: () => ({ showDebug: false }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ vi.mock('react-router-dom', () => ({
useLocation: () => ({ pathname: `/reports/${route.reportName}`, search: '' }),
}));

vi.mock('./useOpenRecordList', () => ({ useOpenRecordList: () => vi.fn() }));
vi.mock('./useOpenRecordList', () => ({
useRecordListDrillNavigation: () => ({ openRecordList: vi.fn(), canOpenRecordList: () => true }),
}));
vi.mock('./MetadataInspector', () => ({
MetadataPanel: () => null,
useMetadataInspector: () => ({ showDebug: false }),
Expand Down
6 changes: 3 additions & 3 deletions ui/packages/app-shell/src/views/ReportView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import type { DataSource } from '@object-ui/types';
import type { DatasetDrillArgs } from '@object-ui/plugin-report';
import { DrillDownDrawer } from '@object-ui/plugin-dashboard';
import { DrillNavigationProvider } from '@object-ui/react';
import { useOpenRecordList } from './useOpenRecordList.js';
import { useRecordListDrillNavigation } from './useOpenRecordList.js';
import { metadataText } from '../hooks/useNavTargetLabel.js';

// Fallback fields when no schema is available
Expand Down Expand Up @@ -68,7 +68,7 @@ export function ReportView({ dataSource }: { dataSource?: DataSource }) {
// Drill-through (ADR-0021 D2): clicking an aggregated row/cell opens the
// underlying records in an in-place drawer (peek without leaving the report),
// with an "Open in list →" escape hatch to the full object list page.
const openRecordList = useOpenRecordList();
const drillNavigation = useRecordListDrillNavigation();
const [drill, setDrill] = useState<{ object: string; filter: Record<string, unknown>; title: string } | null>(null);

const getFieldsForObject = useCallback(
Expand Down Expand Up @@ -409,7 +409,7 @@ export function ReportView({ dataSource }: { dataSource?: DataSource }) {
// paths; DatasetReportRenderer fetches its own rows via `useDatasetRows`.

return (
<DrillNavigationProvider value={{ openRecordList }}>
<DrillNavigationProvider value={drillNavigation}>
<div className="flex flex-col h-full overflow-hidden bg-background">
<div className="flex flex-col sm:flex-row justify-between sm:items-center gap-3 sm:gap-4 p-4 sm:p-6 border-b shrink-0">
<div className="min-w-0 flex-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@
import { describe, it, expect, vi, beforeAll, afterAll } from 'vitest';
import { renderHook, act } from '@testing-library/react';
import { MemoryRouter, Routes, Route, useLocation } from 'react-router-dom';
import type { ReactNode } from 'react';
import type { ReactElement, ReactNode } from 'react';
import { composeDrillFilter } from '@object-ui/core';
import { FilterScopeProvider } from '@object-ui/react';
import { PermissionProvider } from '@object-ui/permissions';
import { parseUrlFilterTriples } from './drillUrlFilters';
import { useOpenRecordList } from './useOpenRecordList';
import { useOpenRecordList, useRecordListDrillNavigation } from './useOpenRecordList';

/**
* Noon UTC in the middle of Q2 2026, so the quarter-start macro has ONE right
Expand Down Expand Up @@ -175,3 +176,106 @@ describe('useOpenRecordList — the drilled URL carries the RESOLVED scope (obje
]);
});
});

/**
* objectstack#30654 — the drill escape hatch offers a destination only when the
* list route can say the drill filter EXACTLY.
*
* A drill filter is the bucket AND the widget's filter AND the measure's drill
* scope. The route's grammar holds one value per param and has no `$in`, so
* writing such a filter through the bare encoder kept the later of two
* conditions on one field (or skipped the `$in`) and opened a WIDER list than
* the drawer: the app-showcase "Paid Rate by Status" Sent bar's Paid Invoices
* drawer lists 0 rows (`status = sent` AND the scope `status = paid`), and the
* list it opened showed every sent invoice. Here the host answers
* `canOpenRecordList: false` for those, and `openRecordList` refuses to
* navigate on them, so neither door lands on a wider list.
*/
describe('useRecordListDrillNavigation — only an exact list destination is offered (objectstack#30654)', () => {
function harness(wrap?: (node: ReactElement) => ReactElement) {
const Scope = wrapperFor({ currentUserId: 'usr_42', currentOrgId: 'org_7' });
const wrapper = ({ children }: { children: ReactNode }) => (
<Scope>{wrap ? wrap(<>{children}</>) : children}</Scope>
);
return renderHook(
() => {
const nav = useRecordListDrillNavigation();
const { pathname, search } = useLocation();
return { ...nav, url: `${pathname}${search}` };
},
{ wrapper },
);
}
const START = '/apps/crm/dashboard/pipeline';

it('the repro shape — bucket status = sent AND scope status = paid — offers no destination', () => {
const { result } = harness();
// What a measure-scoped drill hands the host: the scope composed with the bucket.
const drill = composeDrillFilter({ status: 'paid' }, { status: 'sent' });

expect(result.current.canOpenRecordList('invoice', drill)).toBe(false);
act(() => result.current.openRecordList('invoice', drill));
expect(result.current.url).toBe(START);
});

it('an $in scope offers no destination', () => {
const { result } = harness();
const drill = composeDrillFilter({ status: { $in: ['paid', 'sent'] } }, { region: 'west' });

expect(result.current.canOpenRecordList('invoice', drill)).toBe(false);
act(() => result.current.openRecordList('invoice', drill));
expect(result.current.url).toBe(START);
});

it('CONTROL — a plain equality bucket keeps byte-for-byte the URL it opened before', () => {
const { result } = harness();

expect(result.current.canOpenRecordList('invoice', { status: 'sent' })).toBe(true);
act(() => result.current.openRecordList('invoice', { status: 'sent' }));
expect(result.current.url).toBe('/apps/crm/invoice/data?filter%5Bstatus%5D=sent');
});

it('CONTROL — the same condition twice is still one exact param', () => {
const { result } = harness();
const drill = composeDrillFilter({ status: 'sent' }, { status: 'sent' });

expect(result.current.canOpenRecordList('invoice', drill)).toBe(true);
act(() => result.current.openRecordList('invoice', drill));
expect(result.current.url).toBe('/apps/crm/invoice/data?filter%5Bstatus%5D=sent');
});

it('resolves placeholders BEFORE judging, with the scope the navigate arm resolves them with', () => {
const { result } = harness();
// Two comparands on `owner_id` only while the token is unresolved: resolved,
// both are `usr_42`, one exact param.
const drill = composeDrillFilter({ owner_id: '{current_user_id}' }, { owner_id: 'usr_42' });

expect(result.current.canOpenRecordList('opportunity', drill)).toBe(true);
act(() => result.current.openRecordList('opportunity', drill));
expect(destinationScope(result.current.url.slice(result.current.url.indexOf('?')))).toEqual([
['owner_id', '=', 'usr_42'],
]);
});

it('a condition on a field the viewer cannot read offers no destination (the list page drops it)', () => {
const { result } = harness((node) => (
<PermissionProvider
roles={[]}
userRoles={['viewer']}
permissions={
[
{
object: 'invoice',
roles: { viewer: { actions: ['read'], fieldPermissions: [{ field: 'margin', read: false }] } },
},
] as never
}
>
{node}
</PermissionProvider>
));

expect(result.current.canOpenRecordList('invoice', { status: 'sent' })).toBe(true);
expect(result.current.canOpenRecordList('invoice', composeDrillFilter({ margin: { $gte: 10 } }, { status: 'sent' }))).toBe(false);
});
});
Loading
Loading