Skip to content

Fix view add/edit 404 & replace design mode toggle with admin auto-detect - #633

Merged
hotlong merged 3 commits into
mainfrom
copilot/fix-view-add-edit-404
Feb 19, 2026
Merged

Fix view add/edit 404 & replace design mode toggle with admin auto-detect#633
hotlong merged 3 commits into
mainfrom
copilot/fix-view-add-edit-404

Conversation

Copilot AI commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

View designer navigation from nested view routes (:objectName/view/:viewId) produced 404s due to route-relative resolution. The "Enter/Exit Design Mode" toggle added unnecessary friction for admin users.

Navigation 404 fix

navigate() calls for Edit View, Add View, and ViewTabBar's onAddView used default route-relative resolution, which breaks on flat sibling routes. Added { relative: 'path' } for correct URL-relative resolution:

// Before — route-relative, 404 from nested view route
navigate(viewId ? '../../views/new' : 'views/new')

// After — URL path-relative, resolves correctly
navigate(viewId ? '../../views/new' : 'views/new', { relative: 'path' })

Admin auto-design mode

  • Replaced useState(false) designMode toggle with useAuth()isAdmin (user?.role === 'admin'), matching the existing pattern used in system admin pages
  • Admin users see design tools (Edit View, Add View, Metadata Inspector) directly — no toggle step
  • Non-admin users see no design entry points; ViewTabBar + button hidden via onAddView={undefined}
  • Removed unused MoreVertical import

Tests

  • 6 new test cases: admin/non-admin/unauthenticated visibility, navigation paths with { relative: 'path' } from both root and nested routes
  • Added @object-ui/auth mock and simplified dropdown mocks for testability
  • All 322 console tests pass

Roadmap

  • Added G14 (view 404 fix) and task 5.9 (admin auto-design mode) to ROADMAP_CONSOLE.md
Original prompt

This section details on the original issue you should resolve

<issue_title>修复视图新增/编辑 404 & 管理员自动进��设计模式优化</issue_title>
<issue_description>### 问题描述

  • 编辑/新增视图后,点击"添加视图"或"编辑视图"会提示 404,无法正常跳转视图设计页面。
  • 右上角的"进入设计模式"按钮(见图中截图右上角菜单),体验割裂。设计/编辑权限建议直接依据管理员权限自动生效,无需"进入/退出设计模式"切换。
404 问题与设计模式入口截图

复现步骤

  1. 任意对象页面下,切换到 Board/看板等非"全部"视图。
  2. 点击"添加视图"或"编辑视图",弹窗短暂出现后页面报 404。
  3. 打开右上角菜单,看到"进入/退出设计模式"入口,与视图内容编辑产生割裂。

建议优化

  1. 修复"新增视图、编辑视图"后触发 404 的 bug。
    • 检查路由跳转及 viewId 传递逻辑,设计器应能正常打开或回到主页面。
  2. 设计/编辑权限建议直接判断 isAdmin 权限,而非依赖显式切换"设计模式";管理员自动为设计状态。
    • 对有管理权限用户,直接展示所有编辑按钮(无须反复切换模式)。
    • 普通用户隐藏设计入口,只展示视图内容。
  3. 代码层面建议调整相关入口条件渲染逻辑,可参考主流平台"管理/编辑仅限管理员"的做法。

附截图

404 编辑视图及设计模式入口问题

请在修复后补充测试(含不同用户角色/权限下表现),更新 roadmap 并关闭本 issue。

相关 issue
#627</issue_description>

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


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel

vercel Bot commented Feb 19, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
objectui Ready Ready Preview, Comment Feb 19, 2026 3:01pm
objectui-demo Ready Ready Preview, Comment Feb 19, 2026 3:01pm
objectui-storybook Ready Ready Preview, Comment Feb 19, 2026 3:01pm

Request Review

…navigation 404

- Replace useState designMode toggle with useAuth isAdmin check
- Admin users automatically see design tools (no toggle needed)
- Non-admin users see no design entry points
- Fix 404 by adding { relative: 'path' } to all view navigate calls
- Update tests for admin/non-admin design tools visibility and navigation

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] Fix 404 error on add/edit view and streamline design mode Fix view add/edit 404 & replace design mode toggle with admin auto-detect Feb 19, 2026
Copilot AI requested a review from hotlong February 19, 2026 14:56
@hotlong
hotlong marked this pull request as ready for review February 19, 2026 15:29
Copilot AI review requested due to automatic review settings February 19, 2026 15:29
@hotlong
hotlong merged commit 370f34e into main Feb 19, 2026
4 checks passed

Copilot AI 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 addresses a critical navigation bug and improves the UX for admin users by removing unnecessary friction in the design mode workflow.

Changes:

  • Fixed 404 errors when navigating to view designer from nested view routes by adding { relative: 'path' } option to all navigate() calls
  • Replaced the "Enter/Exit Design Mode" toggle with automatic admin detection using useAuth()isAdmin pattern
  • Added comprehensive test coverage for admin/non-admin visibility and navigation paths with 6 new test cases

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
apps/console/src/components/ObjectView.tsx Fixed navigation 404s with relative: 'path' option; replaced design mode toggle with isAdmin auto-detection; removed unused MoreVertical import
apps/console/src/tests/ObjectView.test.tsx Added auth mocking infrastructure and 6 new tests for admin visibility and relative path navigation
ROADMAP_CONSOLE.md Documented G14 (view 404 fix) and task 5.9 (admin auto-design mode)

Comment thread ROADMAP_CONSOLE.md
| 5.6 | Row-level security | ⚠️ Partial (server-side assumed; client `DataScopeManager` types only) |
| 5.7 | Permission-denied fallback UI | ✅ Done (`PermissionGuard`) |
| 5.8 | Integration with ObjectStack RBAC API | ✅ Done |
| 5.9 | Admin auto-design mode (no toggle) | ✅ Done — design tools (Edit/Add View, Metadata Inspector) auto-visible for `isAdmin` users; non-admin users see no design entry. Fixes #628 |

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

The issue number referenced here (#628) doesn't match the issue number in the PR description (#632). Please verify which issue this PR actually fixes and update the reference accordingly to maintain accurate tracking.

Copilot uses AI. Check for mistakes.
fireEvent.click(addViewBtn);

expect(mockNavigate).toHaveBeenCalledWith('views/new', { relative: 'path' });
});

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

While the tests verify "Add View" navigation with the relative path fix, there's no test case for "Edit View" navigation which also uses the same { relative: 'path' } fix (line 344 in ObjectView.tsx). Consider adding a test case to verify that clicking "Edit View" also navigates correctly with the relative path option from both nested and root routes.

Suggested change
});
});
it('navigates to edit view designer with relative path from nested view route', () => {
mockAuthUser = { id: 'u1', name: 'Admin', role: 'admin' };
mockUseParams.mockReturnValue({ objectName: 'opportunity', viewId: 'pipeline' });
render(<ObjectView dataSource={mockDataSource} objects={mockObjects} onEdit={vi.fn()} />);
const designBtn = screen.getByTitle('console.objectView.designTools');
fireEvent.click(designBtn);
const editViewBtn = screen.getByText('console.objectView.editView');
fireEvent.click(editViewBtn);
expect(mockNavigate).toHaveBeenCalledWith(expect.any(String), { relative: 'path' });
});
it('navigates to edit view designer with relative path from root object route', () => {
mockAuthUser = { id: 'u1', name: 'Admin', role: 'admin' };
mockUseParams.mockReturnValue({ objectName: 'opportunity' });
render(<ObjectView dataSource={mockDataSource} objects={mockObjects} onEdit={vi.fn()} />);
const designBtn = screen.getByTitle('console.objectView.designTools');
fireEvent.click(designBtn);
const editViewBtn = screen.getByText('console.objectView.editView');
fireEvent.click(editViewBtn);
expect(mockNavigate).toHaveBeenCalledWith(expect.any(String), { relative: 'path' });
});

Copilot uses AI. Check for mistakes.
Comment thread ROADMAP_CONSOLE.md
| G11 | Collaboration data hardcoded | ✅ | Presence/activity/comments now fetched from API; fallback to defaults when API unavailable |
| G12 | ReportBuilder uses mock fields | ✅ | `availableFields` derived from object schema via `useMetadata().objects` |
| G13 | ViewDesigner save not persisted | ✅ | `handleSave` calls `dataSource.create/update('sys_view', config)` |
| G14 | View add/edit navigates to 404 | ✅ | Fixed relative navigation in ObjectView (added `{ relative: 'path' }` to all view designer navigate calls). Fixes #628 |

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

The issue number referenced here (#628) doesn't match the issue number in the PR description (#632). Please verify which issue this PR actually fixes and update the reference accordingly to maintain accurate tracking.

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.

修复视图新增/编辑 404 & 管理员自动进��设计模式优化

3 participants