Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function ViewBlock({ block, config }: BlockProps): JSX.Element {
<Frame>
<TableResource
resource={table as Resource<DataBrowser.Table>}
viewSubject={config.view}
viewSubject={config.view || undefined}
embedded
/>
</Frame>
Expand Down
9 changes: 8 additions & 1 deletion browser/data-browser/src/chunks/TablePage/TableResource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export const TableResource: React.FC<TableResourceProps> = ({
setViewQuickAdd,
queryFilters,
queryExpressionFilters,
} = useTableData(resource, viewSubject);
} = useTableData(resource, viewSubject, embedded);

const { columns, allColumns, hideColumn, showColumn } = useTableColumns(
tableClass,
Expand Down Expand Up @@ -1235,6 +1235,13 @@ export const TableResource: React.FC<TableResourceProps> = ({
table={resource.subject}
/>
</AppViewWrapper>
) : viewKind === 'dashboard' && embedded ? (
// A dashboard inside a dashboard block would render itself again,
// forever. Say so instead of hanging the page.
<p>
Pick a table, board or calendar view; a dashboard can't be shown
inside a dashboard.
</p>
) : viewKind === 'dashboard' ? (
<DashboardView dashboard={viewDashboard} />
) : viewKind === 'kanban' ? (
Expand Down
3 changes: 2 additions & 1 deletion browser/data-browser/src/chunks/TablePage/useTableData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ export function useTableData(
resource: Resource,
/** Which view to show, when the caller decides rather than the URL. */
viewOverride?: string,
embedded = false,
): UseTableDataResult {
const tableView = useTableView(resource, viewOverride);
const tableView = useTableView(resource, viewOverride, embedded);
const { filters, sorting } = tableView;
const store = useStore();

Expand Down
8 changes: 7 additions & 1 deletion browser/data-browser/src/chunks/TablePage/useTableView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ export function useTableView(
* cannot say which view each of them shows.
*/
viewOverride?: string,
/**
* An embedded table never reads the host page's `?view=`: that param names a
* view of the host's table, and for a dashboard block of its own table it is
* the dashboard itself, which would render itself inside itself.
*/
embedded = false,
): UseTableViewResult {
const store = useStore();
const canWrite = useCanWrite(table);
Expand All @@ -221,7 +227,7 @@ export function useTableView(
const navigate = ShowRoute.useNavigate();
const activeView =
viewOverride ??
activeViewParam ??
(embedded ? undefined : activeViewParam) ??
defaultViewSubject ??
views[0] ??
undefined;
Expand Down