Skip to content

Commit 2763aa2

Browse files
Copilothotlong
andcommitted
fix: validate objectName/viewId before calling updateViewConfig, clean up Input mock
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 98253b8 commit 2763aa2

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

apps/console/src/__tests__/ObjectView.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ vi.mock('@object-ui/components', async (importOriginal) => {
2525
...actual,
2626
cn: (...inputs: any[]) => inputs.filter(Boolean).join(' '),
2727
Button: ({ children, onClick, title, ...rest }: any) => <button onClick={onClick} title={title} {...rest}>{children}</button>,
28-
Input: ({ ...props }: any) => <input {...props} />,
28+
Input: (props: any) => <input {...props} />,
2929
Switch: ({ checked, onCheckedChange, ...props }: any) => (
3030
<button
3131
role="switch"

apps/console/src/components/ObjectView.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,15 @@ export function ObjectView({ dataSource, objects, onEdit, onRowClick }: any) {
7575

7676
// Persist to backend if dataSource supports it
7777
if (dataSource?.updateViewConfig) {
78-
dataSource.updateViewConfig(objectName || '', draft.id || '', draft).catch((err: any) => {
79-
console.error('[ViewConfigPanel] Failed to persist view config:', err);
80-
});
78+
const objName = objectName;
79+
const vid = draft.id;
80+
if (objName && vid) {
81+
dataSource.updateViewConfig(objName, vid, draft).catch((err: any) => {
82+
console.error('[ViewConfigPanel] Failed to persist view config:', err);
83+
});
84+
} else {
85+
console.warn('[ViewConfigPanel] Cannot persist view config: missing objectName or viewId.');
86+
}
8187
} else {
8288
console.warn('[ViewConfigPanel] dataSource.updateViewConfig is not available. View config saved locally only.');
8389
}

0 commit comments

Comments
 (0)