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
14 changes: 14 additions & 0 deletions .changeset/36002-refresh-display-panel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@object-ui/plugin-list': patch
'@objectstack/spec': patch
'@objectstack/platform-objects': patch
---

fix(plugin-list): Refresh alone no longer draws the Display entry in the default list toolbar

Clause-②: no
Metadata-protocol: none

The default (Display) list toolbar has no Refresh button, yet `userActions.refresh` still counted as a reason to draw the toolbar's Display entry. On a non-grid view (kanban, calendar and the rest) whose other Display controls were all off, the entry opened a panel holding only its footer. Refresh no longer counts, so such a view draws no Display entry. The wide toolbar (`compactToolbar: false`) still draws Refresh as before, and `userActions.refresh: false` still takes it off there.

`@objectstack/spec`: the `userActions.refresh` description now says the toggle governs only the wide toolbar's Refresh button and changes nothing in the default toolbar. The view form's hint for the key says the same, and `@objectstack/platform-objects` ships it as the English help text in the metadata-forms bundle; the other locales keep their existing translations. Only the description text changed: the key, its type and its default are the same.
2 changes: 1 addition & 1 deletion content/docs/references/ui/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ An any-of group: `{ or: [rule, ...] }` matches a record when ANY of its rules ma
| **sort** | `boolean` | optional (default: `true`) | Allow users to sort records |
| **search** | `boolean` | optional (default: `true`) | Allow users to search records |
| **filter** | `boolean` | optional (default: `true`) | Allow users to filter records |
| **refresh** | `boolean` | optional (default: `true`) | Allow users to reload the view data from the backend without a full page reload |
| **refresh** | `boolean` | optional (default: `true`) | Allow users to reload the view data from the backend without a full page reload. Governs only the wide toolbar's Refresh button (`compactToolbar: false`): the default toolbar has no Refresh, so the toggle changes nothing there. |
| **rowHeight** | `boolean` | optional (default: `true`) | Allow users to toggle row height/density |
| **group** | `boolean` | optional (default: `true`) | Allow users to change record grouping from the toolbar. Toggle only — the grouping itself is configured in the view-level `grouping` block. |
| **addRecordForm** | `boolean` | optional (default: `false`) | Add records through a form instead of inline |
Expand Down
6 changes: 3 additions & 3 deletions content/docs/references/ui/view.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ An any-of group: `{ or: [rule, ...] }` matches a record when ANY of its rules ma
| **sort** | `boolean` | optional (default: `true`) | Allow users to sort records |
| **search** | `boolean` | optional (default: `true`) | Allow users to search records |
| **filter** | `boolean` | optional (default: `true`) | Allow users to filter records |
| **refresh** | `boolean` | optional (default: `true`) | Allow users to reload the view data from the backend without a full page reload |
| **refresh** | `boolean` | optional (default: `true`) | Allow users to reload the view data from the backend without a full page reload. Governs only the wide toolbar's Refresh button (`compactToolbar: false`): the default toolbar has no Refresh, so the toggle changes nothing there. |
| **rowHeight** | `boolean` | optional (default: `true`) | Allow users to toggle row height/density |
| **group** | `boolean` | optional (default: `true`) | Allow users to change record grouping from the toolbar. Toggle only — the grouping itself is configured in the view-level `grouping` block. |
| **addRecordForm** | `boolean` | optional (default: `false`) | Add records through a form instead of inline |
Expand Down Expand Up @@ -1484,7 +1484,7 @@ An any-of group: `{ or: [rule, ...] }` matches a record when ANY of its rules ma
| **sort** | `boolean` | optional (default: `true`) | Allow users to sort records |
| **search** | `boolean` | optional (default: `true`) | Allow users to search records |
| **filter** | `boolean` | optional (default: `true`) | Allow users to filter records |
| **refresh** | `boolean` | optional (default: `true`) | Allow users to reload the view data from the backend without a full page reload |
| **refresh** | `boolean` | optional (default: `true`) | Allow users to reload the view data from the backend without a full page reload. Governs only the wide toolbar's Refresh button (`compactToolbar: false`): the default toolbar has no Refresh, so the toggle changes nothing there. |
| **rowHeight** | `boolean` | optional (default: `true`) | Allow users to toggle row height/density |
| **group** | `boolean` | optional (default: `true`) | Allow users to change record grouping from the toolbar. Toggle only — the grouping itself is configured in the view-level `grouping` block. |
| **addRecordForm** | `boolean` | optional (default: `false`) | Add records through a form instead of inline |
Expand Down Expand Up @@ -1669,7 +1669,7 @@ User action toggles for the view toolbar
| **sort** | `boolean` | optional (default: `true`) | Allow users to sort records |
| **search** | `boolean` | optional (default: `true`) | Allow users to search records |
| **filter** | `boolean` | optional (default: `true`) | Allow users to filter records |
| **refresh** | `boolean` | optional (default: `true`) | Allow users to reload the view data from the backend without a full page reload |
| **refresh** | `boolean` | optional (default: `true`) | Allow users to reload the view data from the backend without a full page reload. Governs only the wide toolbar's Refresh button (`compactToolbar: false`): the default toolbar has no Refresh, so the toggle changes nothing there. |
| **rowHeight** | `boolean` | optional (default: `true`) | Allow users to toggle row height/density |
| **group** | `boolean` | optional (default: `true`) | Allow users to change record grouping from the toolbar. Toggle only — the grouping itself is configured in the view-level `grouping` block. |
| **addRecordForm** | `boolean` | optional (default: `false`) | Add records through a form instead of inline |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ export const enMetadataForms: NonNullable<TranslationData['metadataForms']> = {
},
"userActions.refresh": {
label: "Refresh",
helpText: "Allow users to reload the view data from the backend without a full page reload"
helpText: "Allow users to reload the view data from the backend without a full page reload. Governs only the wide toolbar's Refresh button (`compactToolbar: false`): the default toolbar has no Refresh, so the toggle changes nothing there."
},
"userActions.rowHeight": {
label: "Row Height",
Expand Down
2 changes: 1 addition & 1 deletion packages/spec/src/ui/view.form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export const viewForm = defineForm({
{ field: 'sort', helpText: 'Allow users to sort records' },
{ field: 'search', helpText: 'Allow users to search records' },
{ field: 'filter', helpText: 'Allow users to filter records' },
{ field: 'refresh', helpText: 'Allow users to reload the view data from the backend without a full page reload' },
{ field: 'refresh', helpText: 'Allow users to reload the view data from the backend without a full page reload. Governs only the wide toolbar\'s Refresh button (`compactToolbar: false`): the default toolbar has no Refresh, so the toggle changes nothing there.' },
{ field: 'rowHeight', helpText: 'Allow users to toggle row height/density' },
{ field: 'group', helpText: 'Allow users to change record grouping from the toolbar. Toggle only — the grouping itself is configured in the view-level `grouping` block.' },
{ field: 'addRecordForm', helpText: 'Add records through a form instead of inline' },
Expand Down
2 changes: 1 addition & 1 deletion packages/spec/src/ui/view.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1968,7 +1968,7 @@ export const UserActionsConfigSchema = lazySchema(() => strictObject({
sort: z.boolean().default(true).describe('Allow users to sort records'),
search: z.boolean().default(true).describe('Allow users to search records'),
filter: z.boolean().default(true).describe('Allow users to filter records'),
refresh: z.boolean().default(true).describe('Allow users to reload the view data from the backend without a full page reload'),
refresh: z.boolean().default(true).describe('Allow users to reload the view data from the backend without a full page reload. Governs only the wide toolbar\'s Refresh button (`compactToolbar: false`): the default toolbar has no Refresh, so the toggle changes nothing there.'),
rowHeight: z.boolean().default(true).describe('Allow users to toggle row height/density'),
group: z.boolean().default(true).describe('Allow users to change record grouping from the toolbar. Toggle only — the grouping itself is configured in the view-level `grouping` block.'),
addRecordForm: z.boolean().default(false).describe('Add records through a form instead of inline'),
Expand Down
12 changes: 7 additions & 5 deletions ui/packages/plugin-list/src/ListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6992,10 +6992,12 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({
}, [shownRowsKey, shownRowsSettled]);

// The Display panel (objectui#12423) is the default form of the toolbar's
// settings cluster, drawn whenever it has a control to offer.
// settings cluster, drawn whenever it has a control to offer. Refresh is not
// one of them: the default toolbar has no Refresh (objectstack#35878), so
// `userActions.refresh` alone never draws the panel (objectstack#36002).
const displayOffered = toolbarFlags.compactToolbar && !!(
viewSwitcherOffered || toolbarFlags.showGroup || toolbarFlags.showColor || toolbarFlags.showDensity
|| toolbarFlags.showHideFields || currentView === 'grid' || toolbarFlags.showRefresh
|| toolbarFlags.showHideFields || currentView === 'grid'
|| (resolvedExportOptions && exportPermitted && exportableFormats.length > 0)
);
// The condition controls (objectstack#35549, objectstack#35550): the Filter
Expand Down Expand Up @@ -7777,9 +7779,9 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({

{/* Refresh — re-fetch the current view from the backend without a full page
reload. Filters / sort / pagination / search all live in component state,
so bumping refreshKey re-queries while preserving the view. In the wide
form a bar button (mobile + desktop); in the Display form it sits in
the panel's footer. */}
so bumping refreshKey re-queries while preserving the view. Wide form
only, a bar button (mobile + desktop): the default (Display) toolbar
has no Refresh, neither on the bar nor in the panel (objectstack#35878). */}
{toolbarFlags.showRefresh && !toolbarFlags.compactToolbar && (
<Button
variant="ghost"
Expand Down
76 changes: 76 additions & 0 deletions ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3577,3 +3577,79 @@ describe('ListView.groupPickerUnstored-32631', () => {
});
});
});

// ── ListView.refreshOnlyDisplay-36002 ───────────────────────────────────────────

/**
* objectstack#36002 — the default (Display) toolbar has no Refresh
* (objectstack#35878, 「刷新去掉」), so `userActions.refresh` is not a reason to
* draw the Display entry. A non-grid view whose every other Display control is
* off (no layout switch, Group, Row height, Hide fields, Row colour or Export)
* draws no Display entry at all, instead of one that opens a panel with only
* its footer. The grid always offers Display (its columns), so the fixture is
* a kanban. The CONTROLS: the key still draws the wide toolbar's Refresh, and
* the same fixture with one Display control on draws the entry again.
*/
describe('ListView.refreshOnlyDisplay-36002', () => {
restoreAfterBlock();

/** Every Display control off; `refresh` is left at its default, on. */
const REFRESH_ONLY: ListViewSchema = {
type: 'list-view',
objectName: 'opportunity',
viewType: 'kanban',
fields: ['name', 'stage'],
kanban: { groupByField: 'stage' },
userActions: { group: false, rowHeight: false, hideFields: false },
} as ListViewSchema;

let previousKanban: ReturnType<typeof ComponentRegistry.get>;

beforeEach(() => {
previousKanban = ComponentRegistry.get('object-kanban');
ComponentRegistry.register('object-kanban', () => <div data-testid="kanban-stub" />);
});

afterEach(() => {
cleanup();
if (previousKanban) ComponentRegistry.register('object-kanban', previousKanban as any);
});

function mount(schema: Partial<ListViewSchema> = {}) {
const dataSource = {
find: vi.fn().mockResolvedValue({ data: [{ id: '1', name: 'Acme', stage: 'won' }], total: 1 }),
findOne: vi.fn(),
create: vi.fn(),
update: vi.fn(),
delete: vi.fn(),
getObjectSchema: vi.fn().mockResolvedValue({
name: 'opportunity',
fields: { name: { type: 'text', label: 'Name' }, stage: { type: 'text', label: 'Stage' } },
}),
};
render(
<SchemaRendererProvider dataSource={dataSource as never}>
<ListView schema={{ ...REFRESH_ONLY, ...schema } as ListViewSchema} dataSource={dataSource as never} />
</SchemaRendererProvider>,
);
}

it('the default toolbar draws no Display entry when Refresh was its only option', async () => {
mount();
await screen.findByTestId('kanban-stub');
expect(screen.queryByTestId('toolbar-display-trigger')).toBeNull();
expect(screen.queryByTestId('refresh-button')).toBeNull();
});

it('CONTROL — the wide toolbar (`compactToolbar: false`) still draws Refresh for the same view', async () => {
mount({ compactToolbar: false } as Partial<ListViewSchema>);
await screen.findByTestId('kanban-stub');
expect(screen.getByTestId('refresh-button')).toBeInTheDocument();
});

it('CONTROL — the same view with Row height on draws the Display entry', async () => {
mount({ userActions: { group: false, rowHeight: true, hideFields: false } } as Partial<ListViewSchema>);
await screen.findByTestId('kanban-stub');
expect(screen.getByTestId('toolbar-display-trigger')).toBeInTheDocument();
});
});
Loading