fix: [Bug]: Data source module-configuration lost after creating data…#1124
fix: [Bug]: Data source module-configuration lost after creating data…#11241degrees wants to merge 3 commits intoopentiny:developfrom 1degrees:refactor/develop
Conversation
WalkthroughThis pull request updates the remote saving workflow for the data source form. The changes modify the Changes
Sequence Diagram(s)sequenceDiagram
participant DSForm as DataSourceForm.vue
participant DSRemote as DataSourceRemotePanel.vue
DSForm->>DSRemote: Call saveRemoteHandle() on save
DSRemote->>DSRemote: Increment saveWatch (reactivity trigger)
DSRemote->>DSRemote: Watcher detects change in saveWatch
DSRemote->>DSRemote: Execute saveRemote() to save data
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
packages/plugins/datasource/src/DataSourceForm.vue (1)
185-224:⚠️ Potential issueAdd consistent error handling for update operation.
The error handling is inconsistent between update and add operations. The add operation has proper error handling with a catch block, but the update operation doesn't handle potential errors.
Add error handling for the update operation:
requestUpdateDataSource(state.dataSource.id, { name: state.dataSource.name, data: Object.assign(state.dataSource.data, { columns, ...dataSourceState.remoteConfig }) -}).then(() => { +}) +.then(() => { requestGenerateDataSource(getAppId()) // 修改dataSource成功 useNotify({ title: '数据源修改成功', type: 'success' }) emit('save') dataSourceState.dataSourceColumn = {} dataSourceState.dataSourceColumnCopies = {} +}) +.catch((error) => { + message({ message: `数据源修改失败:${error?.message || ''}`, status: 'error' }) })
🧹 Nitpick comments (2)
packages/plugins/datasource/src/DataSourceForm.vue (1)
175-183: Good use of optional chaining, consider additional null checks.The optional chaining operator prevents errors when accessing nested properties. Consider adding a null check for the array before mapping:
-const columns = state.dataSource.data?.columns?.map(({ name, title, type, format, field }) => { +const columns = (state.dataSource.data?.columns || [])?.map(({ name, title, type, format, field }) => {packages/plugins/datasource/src/DataSourceRemotePanel.vue (1)
81-85: LGTM! Consider adding documentation for the save mechanism.The reactive save mechanism using
saveWatchandsaveRemoteHandleeffectively addresses the data loss issue. The synchronous watcher ensures immediate execution of the save operation.Add JSDoc comments to explain the save mechanism:
+/** + * Reactive reference to trigger remote save operations. + * Incrementing this value triggers the save operation synchronously. + */ const saveWatch = ref(0); +/** + * Triggers a remote save operation by incrementing the saveWatch value. + * This function is exported and used by DataSourceForm to ensure + * remote data is saved before the main form submission. + */ export const saveRemoteHandle = () => { saveWatch.value += 1; }Also applies to: 181-181
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/plugins/datasource/src/DataSourceForm.vue(2 hunks)packages/plugins/datasource/src/DataSourceRemotePanel.vue(2 hunks)
🔇 Additional comments (1)
packages/plugins/datasource/src/DataSourceForm.vue (1)
36-36: LGTM! The changes align with PR objectives.The addition of
saveRemoteHandleand its invocation before form submission ensures that remote data source configuration is properly saved, addressing the data loss issue.Also applies to: 172-173
… source
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
1、创建数据源后,设置远程数据字段,保存后数据丢失

2、Bugfix before
3、Bugfix after

What is the current behavior?
Issue Number: #1020
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit