Skip to content

feat: userActions drives toolbar visibility + AddRecord button positioning#794

Merged
hotlong merged 4 commits intomainfrom
copilot/add-toolbar-visibility-controls
Feb 23, 2026
Merged

feat: userActions drives toolbar visibility + AddRecord button positioning#794
hotlong merged 4 commits intomainfrom
copilot/add-toolbar-visibility-controls

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 23, 2026

userActions.addRecordForm was defined in types but not wired into the toolbar rendering logic. The addRecord.position field had no effect—button always rendered in the top toolbar.

Changes

  • ListView.tsx — Centralized addRecord visibility into toolbarFlags memo (showAddRecord, addRecordPosition), gated by addRecord.enabled && userActions.addRecordForm !== false. Button renders top (default) or bottom based on addRecord.position.
  • i18n — Added list.addRecord key to all 10 locale files + LIST_DEFAULT_TRANSLATIONS fallback.
  • Tests — 3 new tests: addRecordForm: false hides button, position: 'bottom' / 'top' placement.
  • ROADMAP — Updated toolbar visibility entry to reflect userActions override.

Usage

<ListView schema={{
  type: 'list-view',
  objectName: 'contacts',
  fields: ['name', 'email'],
  addRecord: { enabled: true, position: 'bottom' },
  userActions: { search: false, addRecordForm: true },
}} />

userActions.search/sort/filter/rowHeight were already wired in a prior PR—this PR completes the story by connecting addRecordForm and implementing position control.

Original prompt

This section details on the original issue you should resolve

<issue_title>[P1] UserActions 驱动 Toolbar 可见性 + AddRecord 按钮</issue_title>
<issue_description>## 背景
Parent Issue: #736

Spec userActions 配置(sort/search/filter/rowHeight/addRecordForm/buttons)应控制 toolbar 按钮可见性。ObjectUI 类型已定义但未接入 toolbar 渲染逻辑。同时 addRecord 配置应渲染 "+ Add Record" 按钮。

目标

  • schema.userActions.sort/search/filter 控制对应 toolbar 按钮(覆盖 showSort/showSearch/showFilters)
  • schema.userActions.addRecordForm 控制 "Add Record" 按钮
  • schema.addRecord 配置(enabled, position, mode, formView)渲染 "+ Add Record" 按钮

技术要点

  • packages/plugin-list/src/ListView.tsx — toolbarFlags 计算逻辑需合并 userActions
  • packages/types/src/objectql.ts L1620-1630 — userActions 已定义

改动范围

  • packages/plugin-list/src/ListView.tsx — toolbarFlags 融合 userActions + AddRecord 按钮渲染
  • packages/i18n/src/locales/*.ts — addRecord i18n key

验收标准

  • userActions.search: false 隐藏搜索按钮
  • userActions.sort: false 隐藏排序按钮
  • addRecord.enabled: true 渲染 "+ Add Record" 按钮
  • addRecord.position 控制按钮位置(top/bottom)
  • 所有新增代码有对应单元测试
  • pnpm test 全部通过
    </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectui Ready Ready Preview, Comment Feb 23, 2026 1:03pm
objectui-demo Ready Ready Preview, Comment Feb 23, 2026 1:03pm
objectui-storybook Error Error Feb 23, 2026 1:03pm

Request Review

…osition support

- Gate addRecord button with userActions.addRecordForm !== false
- Support addRecord.position (top/bottom) for button placement
- Use i18n key list.addRecord for button label
- Add addRecord i18n key to all 10 locale files
- Add 3 new unit tests for addRecordForm and position

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI and others added 2 commits February 23, 2026 12:42
…plication

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
)

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Add userActions to control toolbar button visibility feat: userActions drives toolbar visibility + AddRecord button positioning Feb 23, 2026
Copilot AI requested a review from hotlong February 23, 2026 12:46
@hotlong hotlong marked this pull request as ready for review February 23, 2026 12:46
Copilot AI review requested due to automatic review settings February 23, 2026 12:46
@hotlong hotlong merged commit 75aaa32 into main Feb 23, 2026
2 of 4 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements user-configurable toolbar visibility and add-record button positioning for ListView. It completes the userActions integration story by wiring userActions.addRecordForm (which was defined in types but not connected) and implements position control for the add-record button (top or bottom).

Changes:

  • Added showAddRecord and addRecordPosition flags to ListView's toolbarFlags memo, with logic that respects both addRecord.enabled and userActions.addRecordForm settings
  • Implemented conditional rendering of add-record button in two positions: within the top toolbar (default) or in a separate bottom bar
  • Added list.addRecord i18n key to all 10 locale files plus the fallback dictionary

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

File Description
packages/plugin-list/src/ListView.tsx Extended toolbarFlags to include showAddRecord/addRecordPosition; added conditional rendering for add-record button in top/bottom positions; added i18n fallback for 'list.addRecord'
packages/plugin-list/src/tests/ListView.test.tsx Added 3 tests: userActions.addRecordForm=false hides button, position='bottom' renders in border-t wrapper, position='top' renders in toolbar border-b wrapper
packages/i18n/src/locales/*.ts Added 'addRecord' translation key to all 10 locale files (ar, de, en, es, fr, ja, ko, pt, ru, zh)
ROADMAP.md Updated issue #737 reference to document that userActions.addRecordForm is now wired

addRecordPosition: (schema.addRecord?.position === 'bottom' ? 'bottom' : 'top') as 'top' | 'bottom',
};
}, [schema.userActions, schema.showSearch, schema.showSort, schema.showFilters, schema.showDensity, schema.showHideFields, schema.showGroup, schema.showColor]);
}, [schema.userActions, schema.showSearch, schema.showSort, schema.showFilters, schema.showDensity, schema.showHideFields, schema.showGroup, schema.showColor, schema.addRecord, schema.userActions?.addRecordForm]);
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The useMemo dependency array includes schema.userActions?.addRecordForm which is redundant since schema.userActions is already included. When schema.userActions changes, the memo will recalculate regardless of whether addRecordForm changed. Remove schema.userActions?.addRecordForm from the dependency array to avoid confusion and follow React best practices.

Suggested change
}, [schema.userActions, schema.showSearch, schema.showSort, schema.showFilters, schema.showDensity, schema.showHideFields, schema.showGroup, schema.showColor, schema.addRecord, schema.userActions?.addRecordForm]);
}, [schema.userActions, schema.showSearch, schema.showSort, schema.showFilters, schema.showDensity, schema.showHideFields, schema.showGroup, schema.showColor, schema.addRecord]);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1] UserActions 驱动 Toolbar 可见性 + AddRecord 按钮

3 participants