diff --git a/.changeset/33317-row-opens-nothing-plain.md b/.changeset/33317-row-opens-nothing-plain.md new file mode 100644 index 00000000000..1b0756e3333 --- /dev/null +++ b/.changeset/33317-row-opens-nothing-plain.md @@ -0,0 +1,13 @@ +--- +'@object-ui/plugin-grid': patch +'@object-ui/plugin-list': patch +'@object-ui/app-shell': patch +'@object-ui/console': patch +--- + +fix(plugin-grid, plugin-list, app-shell): a list row whose click opens nothing no longer looks clickable + +Clause-②: yes (widening) — `ObjectGridComponentProps` (published by `@object-ui/plugin-grid`) and `ListViewProps` (published by `@object-ui/plugin-list`) each gain one optional prop, `rowOpensRecord?: boolean`. Absent, every row renders as before. Nothing is removed or narrowed. +Metadata-protocol: none + +**Rows that open nothing.** A list row opens nothing when its view is authored `navigation: { mode: 'none' }`, or when its object's data API serves no single-record read (a list-only object, such as the SCIM connection credentials in Setup). The grid still drew such a row's first column as a link, and its right-click menu still offered Open and Open in new tab, so a click that did nothing looked like a broken page. The Console's object list, object data page and interface list pages now tell the grid that these rows open nothing (`rowOpensRecord={false}`, handed through `ListView`): the first column, and any column authored `link: true`, show the value as plain text, and the right-click menu offers no Open items. The row's actions (`list_item`) stay in the row menu and the right-click menu. The row click itself still reaches the host, so a Cmd/Ctrl-click on a row of a view authored `none` still opens the record in a new tab, as before. Rows that open a drawer or a page are unchanged. diff --git a/content/docs/frontend/plugins/plugin-grid.mdx b/content/docs/frontend/plugins/plugin-grid.mdx index c5f82eddb25..de266a67c9c 100644 --- a/content/docs/frontend/plugins/plugin-grid.mdx +++ b/content/docs/frontend/plugins/plugin-grid.mdx @@ -285,6 +285,19 @@ export const UserList = ({ needsAccess }: { needsAccess: (id: string) => boolean The console's Setup → Users list on a cloud-managed environment uses it to mark a user who holds no permission set beyond the baseline (objectui#13330). +### Rows that open nothing + +A host that owns the row click (`onRowClick`) and knows that it opens nothing +for these rows passes `rowOpensRecord={false}`. The grid then draws its +record-link cells (the first column, and any column authored `link: true`) as +plain text, with no anchor and no ARIA link semantics, and the row's right-click menu +offers no Open or Open in new tab; the row's actions stay. The row click still +reaches `onRowClick`, so anything else the host does with it is unchanged. +Absent (or `true`), every row is drawn as before. It is a host prop, not a +schema key: list metadata cannot set it. The console passes `false` for a view +authored `navigation: { mode: 'none' }` and for an object whose data API serves +no single-record read (objectstack#33317). + ### Inline Editing Enable inline cell editing for quick data updates: diff --git a/ui/packages/app-shell/src/views/InterfaceListPage.rowOpensNothing-33317.test.tsx b/ui/packages/app-shell/src/views/InterfaceListPage.rowOpensNothing-33317.test.tsx new file mode 100644 index 00000000000..8dbecbabac5 --- /dev/null +++ b/ui/packages/app-shell/src/views/InterfaceListPage.rowOpensNothing-33317.test.tsx @@ -0,0 +1,122 @@ +/** + * objectstack#33317 — an interface list page whose records open nothing + * (`recordAction: 'none'`) draws its grid's record-link column as plain text. + * + * The page resolves `none` for an authored `recordAction: 'none'` and for a + * list-only source object, and hands the real `ListView` grid + * `rowOpensRecord={false}`. Rendered through the real page, `ListView` and + * `ObjectGrid`; the record-link cell is read off the table. CONTROL: the + * default `drawer` page keeps the link. + */ + +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { render, waitFor, cleanup, screen } from '@testing-library/react'; +import React from 'react'; +import { ActionProvider } from '@object-ui/react'; + +vi.mock('react-router-dom', () => ({ + useSearchParams: () => [new URLSearchParams(), vi.fn()], + useNavigate: () => vi.fn(), + useParams: () => ({}), +})); + +vi.mock('@object-ui/auth', async (importOriginal) => { + const actual = await (importOriginal as any)(); + return { ...actual, useAuth: () => ({}) }; +}); + +let testDataSource: any; +let testObjects: any[]; + +vi.mock('@object-ui/react', async (importOriginal) => { + const actual = await (importOriginal as any)(); + return { + ...actual, + useAdapter: () => testDataSource, + useMetadata: () => ({ objects: testObjects }), + }; +}); + +import { InterfaceListPage } from './InterfaceListPage'; + +const OBJECT_NAME = 'pkg_package'; +const VIEW_KEY = 'source'; +const ROWS = [{ id: 'p1', name: 'billing-kit', status: 'live' }]; + +function mountPage(recordAction: 'none' | 'drawer') { + testDataSource = { + find: vi.fn().mockResolvedValue(ROWS), + findOne: vi.fn(), + create: vi.fn(), + update: vi.fn(), + delete: vi.fn(), + getObjectSchema: vi.fn().mockResolvedValue({ + name: OBJECT_NAME, + fields: { name: { type: 'text' }, status: { type: 'text' } }, + }), + }; + testObjects = [ + { + name: OBJECT_NAME, + label: 'Package', + fields: { name: { type: 'text', label: 'Name' }, status: { type: 'text', label: 'Status' } }, + listViews: { + [`${OBJECT_NAME}.${VIEW_KEY}`]: { + name: `${OBJECT_NAME}.${VIEW_KEY}`, + label: 'Source', + type: 'grid', + columns: ['name', 'status'], + }, + }, + }, + ]; + const page = { + name: 'my_packages', + label: 'My Packages', + interfaceConfig: { source: OBJECT_NAME, sourceView: VIEW_KEY, recordAction }, + }; + return render( + + + , + ); +} + +/** Whether the row's record-link cell wears the link face: an anchor, or a `role="link"` span. */ +async function nameCellLooksLikeALink(): Promise { + await waitFor(() => expect(screen.getByText('billing-kit')).toBeTruthy(), { timeout: 5000 }); + const cell = screen.getByText('billing-kit').closest('td') as HTMLElement; + expect(cell).not.toBeNull(); + return cell.querySelector('a[href], [role="link"]') !== null; +} + +beforeEach(() => { + cleanup(); + // The grid's permission reads go to the network; answer them empty. + vi.stubGlobal( + 'fetch', + vi.fn(async () => + new Response(JSON.stringify({ data: [] }), { + status: 200, + headers: { 'content-type': 'application/json' }, + }), + ), + ); +}); +afterEach(() => { + cleanup(); + vi.unstubAllGlobals(); +}); + +describe('objectstack#33317 — an interface list page whose records open nothing', () => { + it('`recordAction: none`: the name cell is plain text', async () => { + mountPage('none'); + expect(await nameCellLooksLikeALink()).toBe(false); + expect(screen.queryAllByTestId('primary-field-link')).toHaveLength(0); + }); + + it('CONTROL — the default drawer: the name cell is the record link', async () => { + mountPage('drawer'); + expect(await nameCellLooksLikeALink()).toBe(true); + }); +}); diff --git a/ui/packages/app-shell/src/views/InterfaceListPage.tsx b/ui/packages/app-shell/src/views/InterfaceListPage.tsx index b06d198c052..2259e27cadf 100644 --- a/ui/packages/app-shell/src/views/InterfaceListPage.tsx +++ b/ui/packages/app-shell/src/views/InterfaceListPage.tsx @@ -690,6 +690,9 @@ export function InterfaceListPage({ page, className, onConfigChange, reserveEdit onSortChange={onConfigChange ? (sort: any) => onConfigChange({ sort }) : undefined} onColumnStateChange={onConfigChange ? (st: { order?: string[] }) => { if (st?.order?.length) onConfigChange({ columns: st.order }); } : undefined} onRowClick={recordAction === 'none' ? undefined : handleRecordClick} + // objectstack#33317 — `none` (authored, or a list-only source) + // opens nothing, so the grid draws no record link and no Open. + rowOpensRecord={recordAction !== 'none'} /> {navOverlay.isOverlay && ( diff --git a/ui/packages/app-shell/src/views/ObjectDataPage.tsx b/ui/packages/app-shell/src/views/ObjectDataPage.tsx index 6c803c04a7d..459af29e6b4 100644 --- a/ui/packages/app-shell/src/views/ObjectDataPage.tsx +++ b/ui/packages/app-shell/src/views/ObjectDataPage.tsx @@ -713,6 +713,9 @@ export function ObjectDataPage({ dataSource, objects }: any) { userFilterSelections={initialUfSelections} onUserFilterSelectionsChange={handleUserFilterSelectionsChange} onRowClick={handleRecordClick} + // objectstack#33317 — a list-only object's rows open nothing, so + // the grid draws them no record link and no Open. + rowOpensRecord={recordServed} /> )} diff --git a/ui/packages/app-shell/src/views/ObjectView.rowOpensNothing-33317.test.tsx b/ui/packages/app-shell/src/views/ObjectView.rowOpensNothing-33317.test.tsx new file mode 100644 index 00000000000..bd787f436a8 --- /dev/null +++ b/ui/packages/app-shell/src/views/ObjectView.rowOpensNothing-33317.test.tsx @@ -0,0 +1,323 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * objectstack#33317 — a grid row that opens nothing does not look clickable. + * + * A row's record navigation resolves to `none` in two ways on the console's + * object list: the view authors `navigation: { mode: 'none' }`, or the object + * is list-only (its served operations leave `get` out, `servesRecordRead`, + * objectstack#33219). Either way a click on the row opens nothing, so the grid + * draws its record-link column as plain text — no anchor, no `role="link"` — + * and the row's right-click menu offers no Open / Open in new tab; the row's + * own `list_item` action (Revoke) stays. + * + * Driven through the real `ObjectView`, the real `ListView` grid and the real + * `MePermissionsProvider`, one differential per case: the same object and + * rows, only the view's `navigation` or the served operation set differs. + * CONTROL: a row that opens (the default drawer, an authored `page`) keeps + * its link and its Open item. The bare data page (`ObjectDataPage`) routes + * its own row clicks, so its list-only face is pinned too. + * + * The record body is not what this file reads, so `RecordDetailView` is a + * null sink. + */ + +import * as React from 'react'; +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { render, cleanup, screen, fireEvent, waitFor, within, act } from '@testing-library/react'; +import { MemoryRouter, Routes, Route } from 'react-router-dom'; +import { createI18n, I18nProvider } from '@object-ui/i18n'; +import { MePermissionsProvider, type MePermissionsAuthenticatedResponse } from '@object-ui/permissions'; + +vi.mock('@object-ui/auth', async (importOriginal) => ({ + ...(await importOriginal>()), + useAuth: () => ({ user: { id: 'u1', name: 'Ada' }, activeOrganization: null }), + useWorkspaceAdminStatus: () => ({ isAdmin: true, isResolved: true }), + createAuthenticatedFetch: () => vi.fn(), +})); + +vi.mock('@object-ui/collaboration', async (importOriginal) => ({ + ...(await importOriginal>()), + useRealtimeSubscription: () => ({ lastMessage: null }), + useConflictResolution: () => ({ hasConflicts: false, resolveAllConflicts: () => {} }), +})); + +vi.mock('sonner', () => ({ + toast: Object.assign(vi.fn(), { + success: vi.fn(), error: vi.fn(), info: vi.fn(), + warning: vi.fn(), loading: vi.fn(), dismiss: vi.fn(), + }), +})); + +vi.mock('./MetadataInspector', () => ({ + MetadataPanel: () => null, + useMetadataInspector: () => ({ showDebug: false, toggle: () => {} }), +})); +// The record body: not what this file reads. +vi.mock('./RecordDetailView', () => ({ RecordDetailView: () => null })); + +vi.mock('./metadata-admin/useMetadata', async (importOriginal) => ({ + ...(await importOriginal>()), + useMetadataClient: () => ({ save: vi.fn(async () => ({})), get: vi.fn(async () => null) }), +})); + +// `ObjectView` reaches a dynamic `import('@objectstack/lint')`: pay its load at +// collection, never inside a case's clocked window (`check:test-source-alias`). +import '@objectstack/lint'; +import { ObjectView } from './ObjectView'; +import { ObjectDataPage } from './ObjectDataPage'; +import { ExpressionProvider } from '../providers/ExpressionProvider'; + +const OBJECT_NAME = 'demo_credential'; +const VIEW_ID = 'all'; + +/** The served operations of a list-only object: `list` and what derives from it, no `get`. */ +const LIST_ONLY_OPERATIONS = ['list', 'aggregate', 'export', 'search']; + +const ROWS = [ + { id: 'c1', connection: 'okta-staging', token_prefix: 'scim_ab12' }, + { id: 'c2', connection: 'azure-prod', token_prefix: 'scim_cd34' }, +]; + +/** The object, its one list view carrying `navigation` when given. */ +function objectsWith(navigation?: { mode: string }) { + return [ + { + name: OBJECT_NAME, + label: 'Credential', + pluralLabel: 'Credentials', + fields: { + id: { type: 'text', label: 'Id' }, + connection: { type: 'text', label: 'Connection' }, + token_prefix: { type: 'text', label: 'Token prefix' }, + }, + actions: [ + { + name: 'revoke_credential', + label: 'Revoke', + objectName: OBJECT_NAME, + type: 'script', + target: 'revoke_credential', + locations: ['list_item', 'record_header'], + }, + ], + listViews: { + [VIEW_ID]: { + name: VIEW_ID, + label: 'All', + type: 'grid', + columns: ['connection', 'token_prefix'], + ...(navigation ? { navigation } : {}), + }, + }, + }, + ]; +} + +/** The caller's `/me/permissions` answer; `apiOperations` is the one variable. */ +function answer(apiOperations?: string[]): MePermissionsAuthenticatedResponse { + return { + authenticated: true, + userId: 'u1', + tenantId: null, + positions: [], + hasAnyQueue: false, + permissionSets: ['admin'], + systemPermissions: [], + objects: { + [OBJECT_NAME]: { + allowRead: true, + allowCreate: true, + allowEdit: true, + allowDelete: true, + ...(apiOperations ? { apiOperations } : {}), + }, + }, + fields: {}, + } as MePermissionsAuthenticatedResponse; +} + +let openSpy: ReturnType; + +beforeEach(() => { + vi.spyOn(HTMLElement.prototype, 'scrollIntoView').mockImplementation(() => {}); + vi.stubGlobal( + 'fetch', + vi.fn(async () => + new Response(JSON.stringify({ data: [] }), { + status: 200, + headers: { 'content-type': 'application/json' }, + }), + ), + ); + openSpy = vi.fn(() => null); + vi.stubGlobal('open', openSpy); +}); + +afterEach(() => { + cleanup(); + vi.unstubAllGlobals(); + vi.restoreAllMocks(); + window.history.replaceState(null, '', '/'); +}); + +const LIST_PATH = `/apps/setup/${OBJECT_NAME}/view/${VIEW_ID}`; + +function dataSourceFor(objects: ReturnType) { + return { + find: vi.fn(async () => ({ data: ROWS, total: ROWS.length })), + findOne: vi.fn(async () => null), + create: vi.fn(async () => ({})), + update: vi.fn(async () => ({})), + delete: vi.fn(async () => ({})), + getObjectSchema: vi.fn(async (name: string) => objects.find((o) => o.name === name) ?? null), + } as never; +} + +function withProviders(apiOperations: string[] | undefined, children: React.ReactNode) { + return ( + + + {children} + + + ); +} + +async function mountList(opts: { apiOperations?: string[]; navigation?: { mode: string } }) { + const objects = objectsWith(opts.navigation); + window.history.replaceState(null, '', LIST_PATH); + render( + withProviders( + opts.apiOperations, + + + {}} />} + /> + } /> + + , + ), + ); + await screen.findByText('azure-prod', undefined, { timeout: 5000 }); + // The row actions land with the object schema; read nothing before them. + await waitFor( + () => expect(screen.getAllByRole('button').some((b) => b.getAttribute('aria-haspopup') === 'menu')).toBe(true), + { timeout: 5000 }, + ); +} + +async function mountDataPage(apiOperations: string[] | undefined) { + const objects = objectsWith(); + const dataPath = `/apps/setup/${OBJECT_NAME}/data`; + window.history.replaceState(null, '', dataPath); + render( + withProviders( + apiOperations, + + + } + /> + + , + ), + ); + await screen.findByText('azure-prod', undefined, { timeout: 5000 }); +} + +/** The cell the row's record-link column draws for the row showing `text`. */ +function nameCell(text: string): HTMLElement { + return screen.getByText(text).closest('td') as HTMLElement; +} + +/** Whether that cell wears the link face: an anchor, or a `role="link"` span. */ +function looksLikeALink(text: string): boolean { + const cell = nameCell(text); + return cell.querySelector('a[href], [role="link"]') !== null; +} + +/** Right-click the row's plain cell; answers the context menu's item test ids and labels. */ +async function contextMenuOf(plainText: string): Promise<{ ids: (string | null)[]; labels: string[] }> { + const cell = screen.getByText(plainText).closest('td') as HTMLElement; + act(() => { + fireEvent.contextMenu(cell, { button: 2, clientX: 40, clientY: 60 }); + }); + const menu = await screen.findByTestId('row-context-menu', undefined, { timeout: 5000 }); + const items = within(menu).queryAllByRole('menuitem'); + return { + ids: items.map((el) => el.getAttribute('data-testid')), + labels: items.map((el) => (el.textContent ?? '').trim()), + }; +} + +const OPEN_ITEMS = ['row-context-open', 'row-context-open-new-tab']; + +describe('objectstack#33317 — the console object list: a row that opens nothing does not look clickable', () => { + it('authored `navigation.mode: none`: the name cell is plain text, and the right-click menu has no Open but keeps Revoke', async () => { + await mountList({ navigation: { mode: 'none' } }); + expect(looksLikeALink('okta-staging')).toBe(false); + expect(screen.queryAllByTestId('primary-field-link')).toHaveLength(0); + const menu = await contextMenuOf('scim_ab12'); + expect(menu.ids.filter((id) => OPEN_ITEMS.includes(id ?? ''))).toEqual([]); + expect(menu.labels).toContain('Revoke'); + }); + + it('authored `none` still hands the row click to the host: a ⌘-click on the row opens the record in a new tab, as before', async () => { + await mountList({ navigation: { mode: 'none' } }); + // A cell outside the record link: the row's own click, with the modifier. + fireEvent.click(screen.getByText('scim_ab12'), { metaKey: true }); + expect(openSpy).toHaveBeenCalledTimes(1); + // The name cell, no longer a link of its own, hands its click to the row too. + fireEvent.click(screen.getByText('okta-staging'), { metaKey: true }); + expect(openSpy).toHaveBeenCalledTimes(2); + }); + + it('a list-only object: the name cell is plain text, and the right-click menu has no Open but keeps Revoke', async () => { + await mountList({ apiOperations: LIST_ONLY_OPERATIONS }); + expect(looksLikeALink('okta-staging')).toBe(false); + expect(screen.queryAllByTestId('primary-field-link')).toHaveLength(0); + const menu = await contextMenuOf('scim_ab12'); + expect(menu.ids.filter((id) => OPEN_ITEMS.includes(id ?? ''))).toEqual([]); + expect(menu.labels).toContain('Revoke'); + }); + + it('CONTROL — the default drawer: the name cell is the record link, and the right-click menu offers Open', async () => { + await mountList({}); + expect(looksLikeALink('okta-staging')).toBe(true); + expect(within(nameCell('okta-staging')).getByTestId('primary-field-link')).toBeTruthy(); + const menu = await contextMenuOf('scim_ab12'); + expect(menu.ids).toContain('row-context-open'); + expect(menu.ids).toContain('row-context-open-new-tab'); + expect(menu.labels).toContain('Revoke'); + }); + + it('CONTROL — an authored `page`: the name cell is the record link, and the right-click menu offers Open', async () => { + await mountList({ navigation: { mode: 'page' } }); + expect(looksLikeALink('okta-staging')).toBe(true); + const menu = await contextMenuOf('scim_ab12'); + expect(menu.ids).toContain('row-context-open'); + }); +}); + +describe('objectstack#33317 — the bare data page: a list-only object\'s rows do not look clickable', () => { + it('a list-only object: the name cell is plain text', async () => { + await mountDataPage(LIST_ONLY_OPERATIONS); + expect(looksLikeALink('okta-staging')).toBe(false); + expect(screen.queryAllByTestId('primary-field-link')).toHaveLength(0); + }); + + it('CONTROL — the same object served with no restriction: the name cell is the record link', async () => { + await mountDataPage(undefined); + expect(looksLikeALink('okta-staging')).toBe(true); + }); +}); diff --git a/ui/packages/app-shell/src/views/ObjectView.tsx b/ui/packages/app-shell/src/views/ObjectView.tsx index 02bdbb6ab07..3b07cebfa0c 100644 --- a/ui/packages/app-shell/src/views/ObjectView.tsx +++ b/ui/packages/app-shell/src/views/ObjectView.tsx @@ -1090,6 +1090,9 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co handleListRowsChange, recordOpen, openAsPage, + // objectstack#33317 — the resolved mode: `none` for an authored + // `none` and for a list-only object (`servesRecordRead`). + rowOpensRecord: navOverlay.mode !== 'none', phoneTitle: !pageHeaderShown && titleSwitcher ? ( {titleSwitcher} diff --git a/ui/packages/app-shell/src/views/objectViewListRenderer.tsx b/ui/packages/app-shell/src/views/objectViewListRenderer.tsx index 248e6e7a022..7bfe17dded5 100644 --- a/ui/packages/app-shell/src/views/objectViewListRenderer.tsx +++ b/ui/packages/app-shell/src/views/objectViewListRenderer.tsx @@ -99,6 +99,7 @@ export function useObjectViewListRenderer({ handleListRowsChange, recordOpen, openAsPage, + rowOpensRecord, phoneTitle, handleListPersonalizationChange, urlFilters, @@ -139,6 +140,8 @@ export function useObjectViewListRenderer({ recordOpen: ListViewProps['recordOpen']; /** objectstack#26681 — the name cell's ↗ (`./objectViewOpenAsPage.tsx`), or `null` for none. */ openAsPage: { objectName: string; label: string; open: (recordId: string | number) => void } | null; + /** objectstack#33317 — whether a row click opens the record: `false` for the `none` mode. */ + rowOpensRecord: boolean; /** * objectstack#27058 — on a phone, the title's view switcher, drawn at the * start of the list's toolbar row (`ListView`'s `toolbarLeading`) or above @@ -1075,6 +1078,10 @@ export function useObjectViewListRenderer({ : null; } : undefined} + // objectstack#33317 — a row that opens nothing (the view + // authored `navigation.mode: 'none'`, or a list-only object) + // draws no record link and no Open in its context menu. + rowOpensRecord={rowOpensRecord} // objectstack#26681 — the Display menu's Open records section. recordOpen={recordOpen} // objectstack#27058 — on a phone the toolbar row is the title @@ -1083,7 +1090,7 @@ export function useObjectViewListRenderer({ dataSource={ds} /> ); - }, [inSetup, activeView, activeViewDeclaresColumns, activeViewIsSaved, objectDef, objectName, refreshKey, createRecord, urlFilters, initialUfSelections, handleUserFilterSelectionsChange, writeListUrlState, listPage, user?.id, pageOffersCreate, listAddRecordOpensCreate, listIdentityKey, listPrefs.ready, listPrefs.preference, listPrefs.patchView, handleListTotalChange, managedUsers, managedUserMarker, recordOpen, openAsPage, handleListRowsChange, phoneTitle, handleListPersonalizationChange, workspaceTimeZone, viewPanelFilters, previewDrafts, previewDataSource, unpublishedObjects]); + }, [inSetup, activeView, activeViewDeclaresColumns, activeViewIsSaved, objectDef, objectName, refreshKey, createRecord, urlFilters, initialUfSelections, handleUserFilterSelectionsChange, writeListUrlState, listPage, user?.id, pageOffersCreate, listAddRecordOpensCreate, listIdentityKey, listPrefs.ready, listPrefs.preference, listPrefs.patchView, handleListTotalChange, managedUsers, managedUserMarker, recordOpen, openAsPage, rowOpensRecord, handleListRowsChange, phoneTitle, handleListPersonalizationChange, workspaceTimeZone, viewPanelFilters, previewDrafts, previewDataSource, unpublishedObjects]); return { renderListView }; } diff --git a/ui/packages/plugin-grid/README.md b/ui/packages/plugin-grid/README.md index e468d26dab6..3dae97eb701 100644 --- a/ui/packages/plugin-grid/README.md +++ b/ui/packages/plugin-grid/README.md @@ -891,6 +891,19 @@ export const UserList = ({ needsAccess }: { needsAccess: (id: string) => boolean The console's Setup → Users list on a cloud-managed environment uses it to mark a user who holds no permission set beyond the baseline (objectui#13330). +### Rows that open nothing + +A host that owns the row click (`onRowClick`) and knows that it opens nothing +for these rows passes `rowOpensRecord={false}`. The grid then draws its +record-link cells (the first column, and any column authored `link: true`) as +plain text, with no anchor and no ARIA link semantics, and the row's right-click menu +offers no Open or Open in new tab; the row's actions stay. The row click still +reaches `onRowClick`, so anything else the host does with it is unchanged. +Absent (or `true`), every row is drawn as before. It is a host prop, not a +schema key: list metadata cannot set it. The console passes `false` for a view +authored `navigation: { mode: 'none' }` and for an object whose data API serves +no single-record read (objectstack#33317). + ### Inline Editing Enable inline cell editing for quick updates: diff --git a/ui/packages/plugin-grid/src/ObjectGrid.tsx b/ui/packages/plugin-grid/src/ObjectGrid.tsx index 548ed08c285..d9f6274832a 100644 --- a/ui/packages/plugin-grid/src/ObjectGrid.tsx +++ b/ui/packages/plugin-grid/src/ObjectGrid.tsx @@ -310,6 +310,23 @@ export interface ObjectGridComponentProps extends ObjectGridExternalPaginationPr * composes, nothing an author writes, and no node key reaches it. */ recordLinkAdornment?: (record: any) => React.ReactNode; + /** + * [objectstack#33317] Whether a click on a row opens anything, as the HOST + * that owns the row click knows it. `false` ⇒ the row's record-link cells + * (the primary field, and columns authored `link: true`) draw their value as + * plain text, with no anchor and no `role="link"`, and the row's right-click + * menu offers no Open / Open in new tab; its actions stay. The row click + * itself still reaches `onRowClick`, so whatever else the host routes through + * it is untouched. Absent (or `true`) ⇒ every row is drawn as before. + * + * The grid cannot read this off `onRowClick`: a host passes that handler for + * every row and decides inside it, as the console's object list does for a + * view authored `navigation.mode: 'none'` or a list-only object. + * + * A RUNTIME prop, never authored metadata: the host resolves it, and no node + * key reaches it. + */ + rowOpensRecord?: boolean; /** * TWO parameters since objectui#9357, and the second is not decoration: this * prop reaches `useNavigationOverlay` as its `onRowClick`, and `handleClick` @@ -657,6 +674,7 @@ export const ObjectGrid: React.FC = ({ rowOperations, rowAdornment, recordLinkAdornment, + rowOpensRecord, onBulkDelete, onRowSelect, onRowClick, @@ -1426,7 +1444,7 @@ export const ObjectGrid: React.FC = ({ const { generateColumns } = useObjectGridGenerateColumns({ schema, dataSource, data, dataConfig, hasInlineData, objectName, objectSchema, objectFields, objectTypesPending, schemaFields, schemaColumns, perms, navigation, executeAction, predicateScope, - resolveFieldLabel, translateOptions, uiLanguage, recordLinkAdornment, + resolveFieldLabel, translateOptions, uiLanguage, recordLinkAdornment, rowOpensRecord, }); // Formats this grid can actually deliver (objectui#2942): the server stream @@ -2692,14 +2710,18 @@ export const ObjectGrid: React.FC = ({ : null; // Open is what a click on the row does: a host's `onRowClick` owns it // outright, otherwise the navigation config does, and `none` opens nothing. - const opens = !!onRowClick || (navigation.mode !== 'none' && !schema.navigation?.preventNavigation); + // A host that says its row click opens nothing (`rowOpensRecord: false`, + // objectstack#33317) gets neither Open nor Open in new tab. + const opens = rowOpensRecord !== false + && (!!onRowClick || (navigation.mode !== 'none' && !schema.navigation?.preventNavigation)); + const openHref = rowOpensRecord === false ? null : newTabHref; // Nothing at all to list for this row: no Open, no URL, no action. - if (!opens && !newTabHref && !rowOffersAction(row)) return null; + if (!opens && !openHref && !rowOffersAction(row)) return null; return ( navigation.handleClick(row) : undefined} - newTabHref={newTabHref} + newTabHref={openHref} /> ); }; diff --git a/ui/packages/plugin-grid/src/objectGridGenerateColumns.tsx b/ui/packages/plugin-grid/src/objectGridGenerateColumns.tsx index 5e70c204a13..2ff1b2f35b7 100644 --- a/ui/packages/plugin-grid/src/objectGridGenerateColumns.tsx +++ b/ui/packages/plugin-grid/src/objectGridGenerateColumns.tsx @@ -35,7 +35,7 @@ type QueryInputs = ReturnType; export function useObjectGridGenerateColumns({ schema, dataSource, data, dataConfig, hasInlineData, objectName, objectSchema, objectFields, objectTypesPending, schemaFields, schemaColumns, perms, navigation, executeAction, predicateScope, - resolveFieldLabel, translateOptions, uiLanguage, recordLinkAdornment, + resolveFieldLabel, translateOptions, uiLanguage, recordLinkAdornment, rowOpensRecord, }: { schema: ObjectGridSchema; dataSource: DataSource | undefined; @@ -57,6 +57,8 @@ export function useObjectGridGenerateColumns({ uiLanguage: ReturnType['language']; /** objectstack#26681 — the host's node beside a row's record link (`ObjectGrid`'s prop). */ recordLinkAdornment?: (record: any) => React.ReactNode; + /** objectstack#33317 — `false` ⇒ the host's row click opens nothing (`ObjectGrid`'s prop). */ + rowOpensRecord?: boolean; }) { const generateColumns = useCallback((): ObjectGridColumnDraft[] => { // objectui#11815 — the host's verdict on a declared deadline's @@ -416,6 +418,7 @@ export function useObjectGridGenerateColumns({ navigation.handleClick(row)} + opens={rowOpensRecord} objectName={schema.objectName} recordId={rowRecordId(row)} wrap={col.wrap} @@ -435,6 +438,7 @@ export function useObjectGridGenerateColumns({ navigation.handleClick(row)} + opens={rowOpensRecord} objectName={schema.objectName} recordId={rowRecordId(row)} wrap={col.wrap} @@ -668,6 +672,7 @@ export function useObjectGridGenerateColumns({ navigation.handleClick(row)} + opens={rowOpensRecord} objectName={schema.objectName} recordId={rowRecordId(row)} trailing={recordLinkAdornment?.(row)} @@ -681,6 +686,7 @@ export function useObjectGridGenerateColumns({ navigation.handleClick(row)} + opens={rowOpensRecord} objectName={schema.objectName} recordId={rowRecordId(row)} trailing={recordLinkAdornment?.(row)} @@ -972,7 +978,7 @@ export function useObjectGridGenerateColumns({ }); return generatedColumns; - }, [objectSchema, objectFields, objectTypesPending, schemaFields, schemaColumns, dataConfig, hasInlineData, objectName, navigation.handleClick, executeAction, data, resolveFieldLabel, translateOptions, schema.objectName, perms, uiLanguage, dataSource, predicateScope, recordLinkAdornment]); + }, [objectSchema, objectFields, objectTypesPending, schemaFields, schemaColumns, dataConfig, hasInlineData, objectName, navigation.handleClick, executeAction, data, resolveFieldLabel, translateOptions, schema.objectName, perms, uiLanguage, dataSource, predicateScope, recordLinkAdornment, rowOpensRecord]); return { generateColumns }; } diff --git a/ui/packages/plugin-grid/src/objectGridLinkCell.tsx b/ui/packages/plugin-grid/src/objectGridLinkCell.tsx index f95d35c37f8..65387c6a8e1 100644 --- a/ui/packages/plugin-grid/src/objectGridLinkCell.tsx +++ b/ui/packages/plugin-grid/src/objectGridLinkCell.tsx @@ -49,6 +49,15 @@ const LINK_CELL_CLASS = */ const LINK_CELL_CLASS_WRAP = LINK_CELL_CLASS.replace('truncate', 'whitespace-normal break-words'); +/** + * The box a record-link cell keeps when its row opens nothing + * (objectstack#33317, {@link LinkCell}'s `opens: false`): the link class's + * clamp and width, without its colour, weight, underline or pointer, so the + * value sits where the link would and reads as the plain text it is. + */ +const PLAIN_CELL_CLASS = 'truncate block max-w-full'; +const PLAIN_CELL_CLASS_WRAP = PLAIN_CELL_CLASS.replace('truncate', 'whitespace-normal break-words'); + /** * A row's primary key — the value the host's record-URL builder addresses. * Mirrors what `useNavigationOverlay.handleClick` reads off the same row, so @@ -109,9 +118,18 @@ export const LinkCell: React.FC<{ * `false`) ⇒ the cell is exactly the link, as before. */ trailing?: React.ReactNode; + /** + * Whether a click on the row opens anything (objectstack#33317, `ObjectGrid`'s + * `rowOpensRecord`). `false` ⇒ the value is drawn as plain text: no anchor, + * no `role="link"`, no click or key handler of its own, so a click falls + * through to the row. Absent / `true` ⇒ the link, as before. + */ + opens?: boolean; children: React.ReactNode; -}> = ({ trailing, ...link }) => { - const own = ; +}> = ({ trailing, opens, ...link }) => { + const own = opens === false + ? {link.children} + : ; if (trailing === null || trailing === undefined || trailing === false) return own; // The link keeps its own one-line clamp: its box may shrink (`min-w-0`), // the trailing node never does. diff --git a/ui/packages/plugin-list/README.md b/ui/packages/plugin-list/README.md index f39aa5b2e34..5d53c244f5c 100644 --- a/ui/packages/plugin-list/README.md +++ b/ui/packages/plugin-list/README.md @@ -238,6 +238,17 @@ Without it every row is unchanged. The console uses it on Setup → Users on a cloud-managed environment, to mark a user who holds no permission set beyond the baseline. +### Host prop: `rowOpensRecord` + +A host whose `onRowClick` opens nothing for these rows passes +`rowOpensRecord={false}`. The list hands it to the grid as the grid's own +`rowOpensRecord` (see `@object-ui/plugin-grid`): the grid draws its record-link +cells as plain text and its row context menu offers no Open, while the row +click still reaches `onRowClick`. Only the grid is handed it. This is a React +prop for the host app, not a schema key: list metadata cannot set it. Without +it every row is unchanged. The console passes `false` for a view authored +`navigation: { mode: 'none' }` and for a list-only object. + ### Host prop: `viewDefaults` A host that stores the user's own hidden fields or density and lays that diff --git a/ui/packages/plugin-list/src/ListView.tsx b/ui/packages/plugin-list/src/ListView.tsx index 0764ae99be2..80ba40b088c 100644 --- a/ui/packages/plugin-list/src/ListView.tsx +++ b/ui/packages/plugin-list/src/ListView.tsx @@ -477,6 +477,18 @@ export interface ListViewProps { * Only the grid is handed it. Absent ⇒ every row is exactly what it was. */ recordLinkAdornment?: (record: Record) => React.ReactNode; + /** + * Whether a click on a row opens anything, as the host that owns the row + * click (`onRowClick`) knows it (objectstack#33317), handed to `ObjectGrid`'s + * `rowOpensRecord`. `false` ⇒ the grid draws its record-link cells as plain + * text and its row context menu offers no Open; the row click still reaches + * `onRowClick`. The console's object list passes `false` for a view authored + * `navigation.mode: 'none'` and for a list-only object. + * + * A HOST prop, never a schema key, for the reason `rowAdornment` is one. + * Only the grid is handed it. Absent ⇒ every row is exactly what it was. + */ + rowOpensRecord?: boolean; /** * The VIEW'S OWN hidden fields, row height and sort, for a host that lays * the user's own preference over them in `schema` (objectui#12949). The @@ -1883,6 +1895,7 @@ export const ListView = React.forwardRef(({ defaultRowNumbers = true, rowAdornment, recordLinkAdornment, + rowOpensRecord, compact = false, capped = false, onTotalChange, @@ -7600,6 +7613,12 @@ export const ListView = React.forwardRef(({ // link, on the grid's host channel (a React prop, never a node key). ? { recordLinkAdornment } : {})} + {...(viewComponentSchema.type === 'object-grid' && rowOpensRecord !== undefined + // objectstack#33317 — whether the host's row click opens + // anything, on the grid's host channel (a React prop, never a + // node key). + ? { rowOpensRecord } + : {})} // [objectui#12081] A windowed calendar keeps drawing while the // next window loads (the refresh bar above says so), and shows its // own loading state only when it has nothing to draw.