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/36225-preview-no-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'@object-ui/app-shell': patch
'@object-ui/plugin-detail': patch
---

feat(record-page): the side preview drops the comments icon and the comment panel; a record's comments are on its full page

Clause-②: no
Metadata-protocol: none

A record opened in the side preview (the drawer or pane a list opens, and the drawer a record page opens over itself) no longer shows the comments icon in its header, and no comment panel can be opened anywhere in it. Its 动态 tab keeps the system entries alone, with no comment and no comment box, so the preview shows no comments at all. To read or write a comment, open the record as a full page from the preview header; the full page's comments icon, panel and comment box are unchanged, and so is the phone's comment page.

This replaces the lines of the objectstack#36075 record-comment-panel entry that put the icon and the panel in the record drawer: there is no drawer placement any more (no cover of the drawer body under 760 px, no split above it), and the browser keeps one open-or-closed choice, the record page's. No props, exports or metadata change.

The `@object-ui/plugin-detail` README and the docs of `RecordCommentsInPanelContext` now describe the preview case; no code changes there.
16 changes: 9 additions & 7 deletions content/docs/frontend/plugins/plugin-detail.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,17 @@ declare const handleAddComment: (text: string) => void;
## The record's comment panel

On the desktop console, a record's comments live in a panel of their own,
opened from the comments icon in the record header (on the record page and in
the record drawer), and no longer inside the 动态 (Activity) tab
(objectstack#36075):
opened from the comments icon in the record page's header, and no longer inside
the 动态 (Activity) tab (objectstack#36075). The record drawer (the side
preview a list or a record page opens) has no icon and no panel, and its 动态
tab shows no comments either: the comments are the full page's, one
「Open as full page」 away (objectstack#36225).


- **The icon** shows how many unresolved threads the record holds (a comment
and its replies are one thread). A press
opens the panel, the next one closes it, and the browser remembers whether it
was left open, once for the record page and once for the drawer.
was left open.
- **The panel** is 380 px wide: 「评论」 and ✕ at the top, the threads oldest
first, the comment box at the foot. A thread's replies fold to 「N 条回复」
and open in place. A comment's actions (Reply, an emoji, ✓ on a thread's
Expand All @@ -228,9 +231,8 @@ the record drawer), and no longer inside the 动态 (Activity) tab
「只看我参与的」, the threads you started, replied in or are mentioned in. A
reply into a resolved thread reopens it.
- **Where it sits**: beside the record from a 1280 px window, the record giving
way; over the record's right edge in a narrower window. In a drawer narrower
than 760 px (the default drawer is 720) it covers the drawer's body, and ✕ or
Esc returns to the record.
way; over the record's right edge in a narrower window. ✕ or Esc returns to
the record.
- **The 动态 tab** then holds the system entries only: activity and field
changes, with no comment box and no All / Activity / Discussion chips. The
Changes chip stays where the record shows its field history; pressed again,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@
* - Whether the panel is open is kept in this browser: a record opened later
* opens with the panel as it was left.
* - Where it is drawn: beside the record from a 1280 window (the record gives
* way), over the record's right edge in a narrower one, and over the whole
* body of a drawer too narrow to split.
* way), over the record's right edge in a narrower one.
* - The comments are the panel's: the page's 动态 stream no longer draws them.
* - No icon where the panel is not offered: an object with feeds off, and a
* page authored by hand (option C, seat 13:24Z): that page keeps its own
* discussion block as it was. It is drawn on the desktop full page only
* (objectstack#36150): the same object's drawer draws the standard page,
* which offers the icon.
* (objectstack#36150).
* - objectstack#36225 — the side preview (the record drawn embedded, in a
* drawer or pane) has no icon and no panel, whatever the page was left
* with, and its 动态 stream draws no comment and no composer either: the
* comments are the full page's. The CONTROL is the full page, whose icon,
* panel and composer stay.
*/

import * as React from 'react';
Expand Down Expand Up @@ -60,6 +63,7 @@ import { MetadataCtx } from '@object-ui/react';
import { MePermissionsProvider, type MePermissionsAuthenticatedResponse } from '@object-ui/permissions';
import { toast } from 'sonner';
import { RecordDetailView } from './RecordDetailView';
import { COMMENTS_PANEL_OPEN_KEY } from './recordCommentsPanel';
import { __clearRecordEditableCache } from '../../../plugin-detail/src/useRecordEditable';

const OBJECT_NAME = 'crm_case';
Expand Down Expand Up @@ -150,6 +154,7 @@ interface MountOptions {
embedded?: boolean;
/** The record route's query, `?comments=…` for the phone's comment page. */
search?: string;
dataSource?: ReturnType<typeof makeDataSource>;
}

/** The router's location now, for the phone's `?comments=` entries. */
Expand All @@ -158,15 +163,15 @@ function LocationProbe() {
return <span data-testid="location" data-search={location.search} data-pushed={String(!!(location.state as any)?.__commentsPushed)} />;
}

async function mount({ objectName = OBJECT_NAME, pages = [], embedded = false, search = '' }: MountOptions = {}) {
async function mount({ objectName = OBJECT_NAME, pages = [], embedded = false, search = '', dataSource = makeDataSource() }: MountOptions = {}) {
const rendered = render(
<I18nProvider config={{ defaultLanguage: 'en', detectBrowserLanguage: false }} persistLanguage={false}>
<MePermissionsProvider initialPermissions={PERMS}>
<MemoryRouter initialEntries={[`/app/service/${objectName}/${RECORD_ID}${search}`]}>
<LocationProbe />
<MetadataCtx.Provider value={metadataFor(pages)}>
<RecordDetailView
dataSource={makeDataSource()}
dataSource={dataSource}
objects={OBJECTS}
onEdit={() => {}}
objectNameOverride={objectName}
Expand Down Expand Up @@ -248,19 +253,6 @@ describe('the record comment panel (objectstack#36075)', () => {
await waitFor(() => expect(panel(second.container)).not.toBeNull());
});

it('a drawer too narrow to split gives the panel its whole body, and remembers it apart from the page', async () => {
const page = await mount();
await waitFor(() => expect(button(page.container)).not.toBeNull());
fireEvent.click(button(page.container)!);
cleanup();
const drawer = await mount({ embedded: true });
await waitFor(() => expect(button(drawer.container)).not.toBeNull());
// The page was left open; the drawer opens closed.
expect(panel(drawer.container)).toBeNull();
fireEvent.click(button(drawer.container)!);
expect(placement(drawer.container)).toBe('cover');
});

it('the 动态 stream no longer draws the comments', async () => {
const { container } = await mount();
await waitFor(() => expect(button(container)).not.toBeNull());
Expand Down Expand Up @@ -303,12 +295,73 @@ describe('the record comment panel (objectstack#36075)', () => {
expect(panel(container)).toBeNull();
});

it('the drawer of an object with a hand-written page draws the standard page, so it offers the icon (objectstack#36150)', async () => {
const { container } = await mount({ pages: [AUTHORED_PAGE], embedded: true });
it('a comment written in the panel is posted on the record (objectstack#36225 CONTROL: the full page keeps the panel)', async () => {
const dataSource = makeDataSource();
const { container } = await mount({ dataSource });
await waitFor(() => expect(button(container)).not.toBeNull());
expect(panel(container)).toBeNull();
fireEvent.click(button(container)!);
expect(await within(panel(container)!).findByText(ADA_BODY)).toBeInTheDocument();
const box = within(panel(container)!.querySelector('[data-comments-composer]') as HTMLElement).getByRole('textbox');
fireEvent.change(box, { target: { value: 'Ada: written on the full page' } });
await act(async () => {
fireEvent.keyDown(box, { key: 'Enter', ctrlKey: true });
});
await waitFor(() =>
expect(dataSource.create).toHaveBeenCalledWith(
'sys_comment',
expect.objectContaining({ thread_id: THREAD, body: 'Ada: written on the full page' }),
expect.anything(),
),
);
expect(await within(panel(container)!).findByText('Ada: written on the full page')).toBeInTheDocument();
});
});

/**
* objectstack#36225 — the side preview: a record drawn embedded (the list's
* drawer or pane, a record page's drawer) shows no comments at all. To read
* or write one, the reader opens the full page.
*/
describe('the side preview has no comments (objectstack#36225)', () => {
it('no icon and no panel, though the page was left with the panel open', async () => {
const page = await mount();
await waitFor(() => expect(button(page.container)).not.toBeNull());
fireEvent.click(button(page.container)!);
expect(panel(page.container)).not.toBeNull();
cleanup();
const preview = await mount({ embedded: true });
await act(async () => {});
expect(within(preview.container).getByText(`Case ${RECORD_ID}`)).toBeInTheDocument();
expect(button(preview.container)).toBeNull();
expect(panel(preview.container)).toBeNull();
expect(document.querySelector('[data-comments-button]')).toBeNull();
expect(document.querySelector('[data-comments-panel]')).toBeNull();
});

it('its 动态 stream draws no comment and no composer', async () => {
const preview = await mount({ embedded: true });
const activityTab = await within(preview.container).findByRole('tab', { name: /^Activity/ });
fireEvent.mouseDown(activityTab, { button: 0 });
fireEvent.click(activityTab);
await act(async () => {});
expect(activityTab).toHaveAttribute('aria-selected', 'true');
expect(within(preview.container).queryByText(ADA_BODY)).toBeNull();
expect(within(preview.container).queryByText(GRACE_BODY)).toBeNull();
expect(preview.container.querySelector('[data-comments-composer]')).toBeNull();
expect(within(preview.container).queryByRole('textbox')).toBeNull();
expect(button(preview.container)).toBeNull();
});

it('a hand-written page’s object: the preview draws the standard page, with no icon (objectstack#36150)', async () => {
// The reader left the full page's panel open.
window.localStorage.setItem(COMMENTS_PANEL_OPEN_KEY, 'open');
const { container } = await mount({ pages: [AUTHORED_PAGE], embedded: true });
// The standard page is laid out (its tab row is drawn) before anything is asked of it.
await within(container).findByRole('tab', { name: /^Activity/ });
await act(async () => {});
expect(within(container).getByText(`Case ${RECORD_ID}`)).toBeInTheDocument();
expect(button(container)).toBeNull();
expect(panel(container)).toBeNull();
expect(within(container).queryByText(ADA_BODY)).toBeNull();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { MetadataCtx } from '@object-ui/react';
// I18nProvider is mounted. Selecting through them keeps this file pinned to
// the composer/empty-state semantics rather than to a literal string.
import { DETAIL_DEFAULT_TRANSLATIONS } from '@object-ui/plugin-detail';
import { COMMENTS_PANEL_OPEN_KEY } from './recordCommentsPanel';

vi.mock('@object-ui/auth', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
Expand Down Expand Up @@ -225,9 +226,9 @@ function tree(dataSource: any, recordId: string, pages: any[] = []) {
onEdit={() => {}}
objectNameOverride={OBJECT_NAME}
recordIdOverride={recordId}
// objectstack#36150 — an authored page draws on the full page only,
// so its cases mount the full page; the synthesized page's, the drawer.
embedded={pages.length === 0}
// objectstack#36150 — an authored page draws on the full page only;
// objectstack#36225 — the comment panel is the full page's alone.
// So every case mounts the full page.
/>
</MetadataCtx.Provider>
</MemoryRouter>
Expand Down Expand Up @@ -256,10 +257,10 @@ afterEach(() => {

describe('RecordDetailView — the feed does not follow the user to the next record (#3268)', () => {
// objectstack#36075 — on the synthesized page the record's comments are the
// comment panel's: these open the drawer with it open (the reader left it
// comment panel's: these open the page with it open (the reader left it
// so), and it stays open across the record→record navigation.
beforeEach(() => {
window.localStorage.setItem('os:record-comments-panel:drawer', 'open');
window.localStorage.setItem(COMMENTS_PANEL_OPEN_KEY, 'open');
});
afterEach(() => {
window.localStorage.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,7 @@ describe('RecordDetailView.feedRefusal-11195', () => {
} as any;
}

function renderDetail(dataSource: any) {
function renderDetail(dataSource: any, { embedded = true }: { embedded?: boolean } = {}) {
return render(
<MemoryRouter initialEntries={[`/app/demo/${OBJECT_NAME}/${RECORD_ID}?related=timeline`]}>
<MetadataCtx.Provider value={makeMetadata()}>
Expand All @@ -1659,7 +1659,7 @@ describe('RecordDetailView.feedRefusal-11195', () => {
onEdit={() => {}}
objectNameOverride={OBJECT_NAME}
recordIdOverride={RECORD_ID}
embedded
embedded={embedded}
/>
</MetadataCtx.Provider>
</MemoryRouter>,
Expand Down Expand Up @@ -1811,7 +1811,8 @@ describe('RecordDetailView.feedRefusal-11195', () => {
});

window.localStorage.clear();
renderDetail(dataSource);
// objectstack#36225 — the comment panel is the full page's: a preview has none.
renderDetail(dataSource, { embedded: false });

expect(await screen.findByText('Stage moved to qualified')).toBeTruthy();
// The 动态 stream holds no comments, so their refusal is not its to say.
Expand Down
Loading
Loading