Skip to content

feat: persist ViewConfigPanel draft to backend via DataSource.updateViewConfig#678

Merged
hotlong merged 4 commits intomainfrom
copilot/save-draft-config-to-backend
Feb 21, 2026
Merged

feat: persist ViewConfigPanel draft to backend via DataSource.updateViewConfig#678
hotlong merged 4 commits intomainfrom
copilot/save-draft-config-to-backend

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 21, 2026

ViewConfigPanel saves config changes to local state only — lost on refresh or view switch. This adds backend persistence through the DataSource adapter.

Changes

  • @object-ui/typesDataSource interface: New optional method:
    updateViewConfig?(objectName: string, viewId: string, config: Record<string, any>): Promise<Record<string, any> | void>;
  • ObjectView.handleViewConfigSave: Calls dataSource.updateViewConfig when available. Validates params before calling. Logs console.warn if method is absent (backward-compatible with older backends). Catches and logs persistence errors.
  • Tests: 3 new cases covering success path, fallback warning, and rejection handling. Fixed Button/Input/Switch mocks to forward data-testid props.
Original prompt

This section details on the original issue you should resolve

<issue_title>ViewConfigPanel 保存后持久化draft配置到后端(DataSource updateViewConfig)</issue_title>
<issue_description># 问题说明
当前ViewConfigPanel的配置变更仅保存在本地draft(useState),无法持久化到后端。页面刷新或切换视图会导致个性化配置丢失。

目标/建议

  • 在 handleViewConfigSave 回调中,调用 dataSource.updateViewConfig(接口需补充/定义)将draft view配置提交,保证保存后任何刷新/切换都能还原用户最新配置
  • 若 dataSource 未提供 updateViewConfig 方法(兼容老后端),仅本地存储并弹窗提示或打印警告
  • 对接口定义,建议参照:
    interface DataSource {
      updateViewConfig?(objectName: string, viewId: string, config: Record<string, any>): Promise<void>;
    }
  • 成功保存后应重新拉取views/view config,前端状态保持刷新

验收/测试点

  • 保存后draft配置可跨页面刷新还原
  • dataSource无此方法时给出友好提示/console.warn
  • 单测模拟该保存流程

/cc @hotlong</issue_description>

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


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 21, 2026

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

Project Deployment Actions Updated (UTC)
objectui Ready Ready Preview, Comment Feb 21, 2026 4:51am
objectui-demo Ready Ready Preview, Comment Feb 21, 2026 4:51am
objectui-storybook Ready Ready Preview, Comment Feb 21, 2026 4:51am

Request Review

…onfig on save

- Add optional updateViewConfig method to DataSource interface in @object-ui/types
- Update ObjectView.handleViewConfigSave to call dataSource.updateViewConfig when available
- Log warning when updateViewConfig is not available (backward compatible)
- Log error when updateViewConfig call fails
- Add 3 new tests covering persistence, fallback warning, and error handling
- Fix Button/Input/Switch mocks in ObjectView tests to pass through data-testid

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI and others added 2 commits February 21, 2026 04:12
…n up Input mock

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

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Save draft configuration to backend in ViewConfigPanel feat: persist ViewConfigPanel draft to backend via DataSource.updateViewConfig Feb 21, 2026
Copilot AI requested a review from hotlong February 21, 2026 04:15
@hotlong hotlong marked this pull request as ready for review February 21, 2026 04:24
Copilot AI review requested due to automatic review settings February 21, 2026 04:24
@hotlong hotlong merged commit 71dd9e8 into main Feb 21, 2026
4 of 5 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 adds backend persistence for inline view configuration edits made in the Console’s ViewConfigPanel, by extending the DataSource contract and wiring ObjectView to call it when available.

Changes:

  • Extend DataSource with optional updateViewConfig(objectName, viewId, config) for persisting view config saves.
  • Update ObjectView.handleViewConfigSave to call dataSource.updateViewConfig when present, with warnings/errors for unsupported/failing backends.
  • Add unit tests covering success, unsupported fallback warning, and rejection/error handling; adjust component mocks to forward data-testid.

Reviewed changes

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

File Description
packages/types/src/data.ts Adds optional DataSource.updateViewConfig API for persisting view configuration.
apps/console/src/components/ObjectView.tsx Calls updateViewConfig on save when supported; logs warnings/errors for fallback and failures.
apps/console/src/tests/ObjectView.test.tsx Adds coverage for persistence behavior and updates mocks to support data-testid.
ROADMAP_CONSOLE.md Notes backend persistence for ViewConfigPanel in the console roadmap.

Comment on lines +426 to +432
// Wait for the promise rejection to be caught
await vi.waitFor(() => {
expect(errorSpy).toHaveBeenCalledWith(
expect.stringContaining('Failed to persist view config'),
expect.any(Error),
);
});
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

vi.waitFor is not part of the standard Vitest API used elsewhere in this repo; this test likely fails at runtime with vi.waitFor is not a function. Use waitFor from @testing-library/react (import it alongside render/screen/fireEvent) to await the async console.error assertion.

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.

ViewConfigPanel 保存后持久化draft配置到后端(DataSource updateViewConfig)

3 participants