Skip to content

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

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

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

Conversation

CopilotAI commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

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 方法(兼容老后端),仅本地存储并弹窗提示或打印警告
  • 对接口定义,建议参照:
    interfaceDataSource{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

vercelBot commented Feb 21, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
objectuiReadyReadyPreview, CommentFeb 21, 2026 4:51am
objectui-demoReadyReadyPreview, CommentFeb 21, 2026 4:51am
objectui-storybookReadyReadyPreview, CommentFeb 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>
CopilotAIand 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>
CopilotAI changed the title [WIP] Save draft configuration to backend in ViewConfigPanelfeat: persist ViewConfigPanel draft to backend via DataSource.updateViewConfigFeb 21, 2026
CopilotAI requested a review from hotlongFebruary 21, 2026 04:15
@hotlong
hotlong marked this pull request as ready for review February 21, 2026 04:24
CopilotAI review requested due to automatic review settings February 21, 2026 04:24
@hotlong
hotlong merged commit 71dd9e8 into mainFeb 21, 2026
4 of 5 checks passed

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

FileDescription
packages/types/src/data.tsAdds optional DataSource.updateViewConfig API for persisting view configuration.
apps/console/src/components/ObjectView.tsxCalls updateViewConfig on save when supported; logs warnings/errors for fallback and failures.
apps/console/src/tests/ObjectView.test.tsxAdds coverage for persistence behavior and updates mocks to support data-testid.
ROADMAP_CONSOLE.mdNotes 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),
);
});

CopilotAIFeb 21, 2026

Copy link

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 freeto 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

@hotlong