Console integration: wire ViewSwitcher allowCreateView/viewActions, align AppHeader types, add SidebarNav stories & tests - #912
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…witcher - Add allowCreateView and viewActions to ObjectViewSchema (types) - Add onCreateView and onViewAction props to engine ObjectViewProps - Wire allowCreateView/viewActions in viewSwitcherSchema builder - Pass onCreateView/onViewAction callbacks to ViewSwitcher rendering - Console ObjectView: pass allowCreateView=isAdmin and viewActions - Console ObjectView: wire onCreateView/onViewAction to both PluginObjectView instances Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…av stories, docs, ROADMAP) - AppHeader: import BreadcrumbItemType from engine types for schema alignment - Add SidebarNav Storybook stories with badges, nested items, groups, and search - Update layout.md docs for enhanced SidebarNav props (badges, children, search, NavGroup) - Update view-switcher.mdx docs for allowCreateView/viewActions - Update ROADMAP.md with P1.14 Console Engine Schema Integration section - Verify Airtable UX defaults propagation (no overrides in Console ObjectView) - Verify i18n consistency across en/zh locales Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…dlers
Address code review feedback:
- Extract onCreateView and onViewAction into handleCreateView/handleViewAction
- Replace `any` type with `{ id: string; type: string }` in view matching
- Both PluginObjectView instances now reference the extracted callbacks
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
@copilot 仔细评估是否已经完成了任务中要求的所有开发内容 |
…tests
- Add AppHeader.test.tsx with 8 tests covering:
- BreadcrumbItem type alignment with engine types
- Siblings dropdown navigation
- ⌘K search button dispatch
- Right-side actions (presence, activity, help, theme, locale)
- Mobile sidebar trigger
- Connection status rendering
- Offline indicator behavior
- Add 3 ViewSwitcher callback tests to ObjectView.test.tsx:
- allowCreateView for admin users (create view callback)
- viewActions hidden for non-admin users
- handleViewAction('settings') opens ViewConfigPanel in edit mode
- Update sidebar-nav.mdx docs with full API (badges, children, NavGroup, search)
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
经过仔细评估,发现了以下缺失项并已在 缺失项(已补充):
已确认完成的任务:
|
|
@copilot 18:02:57.236 @object-ui/plugin-designer:build: �[96msrc/AppCreationWizard.tsx�[0m:�[93m51�[0m:�[93m34�[0m - �[91merror�[0m�[90m TS2307: �[0mCannot find module '@object-ui/react' or its corresponding type declarations. |
…s (TS6133) Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Fixed in The |
There was a problem hiding this comment.
Pull request overview
Wires newly added engine schema capabilities into Console usage (ViewSwitcher callbacks/config and AppHeader breadcrumb typing), and expands SidebarNav Storybook/docs coverage to reflect the enhanced navigation API.
Changes:
- Add
allowCreateView/viewActionstoObjectViewSchemaand pass them through engineObjectViewintoViewSwitcher, including callback props (onCreateView,onViewAction). - Align Console
AppHeaderbreadcrumb typing with engineBreadcrumbItem. - Add SidebarNav Storybook stories and update docs (SidebarNav + ViewSwitcher + layout guide) and ROADMAP.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/types/src/objectql.ts | Extends ObjectViewSchema with allowCreateView / viewActions. |
| packages/plugin-view/src/ObjectView.tsx | Passes new schema fields through to ViewSwitcher and forwards callbacks. |
| packages/layout/src/stories/SidebarNav.stories.tsx | Adds SidebarNav Storybook coverage for badges, nesting, grouping, search. |
| content/docs/layout/sidebar-nav.mdx | Updates SidebarNav docs to cover enhanced props and examples. |
| content/docs/guide/layout.md | Updates layout guide SidebarNav section for new capabilities. |
| content/docs/components/complex/view-switcher.mdx | Documents allowCreateView / viewActions in ViewSwitcherSchema. |
| apps/console/src/components/ObjectView.tsx | Enables admin-gated create/actions and wires callbacks to open ViewConfigPanel. |
| apps/console/src/components/AppHeader.tsx | Uses engine BreadcrumbItem type for breadcrumb item alignment. |
| apps/console/src/tests/ObjectView.test.tsx | Adds tests intended to cover admin create/actions behavior. |
| apps/console/src/tests/AppHeader.test.tsx | Adds AppHeader tests for breadcrumbs/search/actions/responsive behavior. |
| ROADMAP.md | Notes completion of Console Engine Schema Integration (P1.14). |
Comments suppressed due to low confidence (4)
packages/layout/src/stories/SidebarNav.stories.tsx:33
- This story uses an inline
style={{ ... }}onSidebarProvider. The repo generally uses Tailwind utility classes for styling, and inline styles are hard to keep consistent and theme-aware. Prefer usingclassName(e.g., fixed height +border border-border) or wrapping in a styled container div instead of inline styles.
<MemoryRouter initialEntries={['/dashboard']}>
<SidebarProvider defaultOpen style={{ height: '600px', border: '1px solid hsl(var(--border))' }}>
<Story />
</SidebarProvider>
content/docs/guide/layout.md:295
- The
SidebarNavAPI documented here doesn’t match the actualpackages/layout/src/SidebarNav.tsx:collapsibleis"offcanvas" | "icon" | "none"(not boolean), there is nodefaultOpen, and nested items arechildren(notitems). Please update this section to reflect the real component API (or rename it if it’s meant to describe a schema type that isn’t implemented/registered).
href?: string,
icon?: string,
badge?: string | number,
badgeVariant?: 'default' | 'destructive' | 'outline',
items?: Array<...>, // Nested menu items (collapsible children)
apps/console/src/tests/AppHeader.test.tsx:214
- The offline test doesn’t actually verify offline behavior:
AppHeaderis imported before thevi.doMock('@object-ui/react', ...)call, so it keeps using the earlier mock (isOnline: true). To test the offline branch, use a mutable mock value foruseOffline, orvi.resetModules()and re-importAppHeaderafter setting the mock, then assert the Offline UI is present.
// Re-mock with isOnline: false
vi.doMock('@object-ui/react', () => ({
useOffline: () => ({ isOnline: false }),
}));
apps/console/src/tests/ObjectView.test.tsx:896
- These tests are labeled as ViewSwitcher
allowCreateView/viewActionsintegration, but they only interact with the Console “design tools” dropdown. They don’t assert that ViewSwitcher renders the "+" button / per-view action icons, nor that clicking them triggersonCreateView/onViewAction. Please add assertions that exercise the ViewSwitcher buttons directly so the wiring added in this PR is covered.
// --- ViewSwitcher allowCreateView / viewActions integration ---
it('sets allowCreateView for admin users (create view callback)', () => {
mockAuthUser = { id: 'u1', name: 'Admin', role: 'admin' };
mockUseParams.mockReturnValue({ objectName: 'opportunity' });
|
|
||
| /** | ||
| * Show "+" button in ViewSwitcher to create a new view. | ||
| * Typically gated on admin permission. | ||
| */ | ||
| allowCreateView?: boolean; | ||
|
|
||
| /** | ||
| * Per-view action icons shown in ViewSwitcher (e.g., share, settings, duplicate, delete). | ||
| */ | ||
| viewActions?: Array<{ | ||
| type: 'share' | 'settings' | 'duplicate' | 'delete'; | ||
| icon?: string; | ||
| }>; |
There was a problem hiding this comment.
ObjectViewSchema adds allowCreateView / viewActions here, but the corresponding Zod validator (packages/types/src/zod/objectql.zod.ts -> ObjectViewSchema) is not updated. This will cause runtime schema validation/parsing to reject or drop the new properties. Please extend the Zod schema to include these fields (mirroring ViewSwitcherSchema).
| /** | |
| * Show "+" button in ViewSwitcher to create a new view. | |
| * Typically gated on admin permission. | |
| */ | |
| allowCreateView?: boolean; | |
| /** | |
| * Per-view action icons shown in ViewSwitcher (e.g., share, settings, duplicate, delete). | |
| */ | |
| viewActions?: Array<{ | |
| type: 'share' | 'settings' | 'duplicate' | 'delete'; | |
| icon?: string; | |
| }>; |
allowCreateView&viewActionsintegrationallowCreateViewandviewActionstoObjectViewSchemain typesonCreateViewandonViewActionprops to engine ObjectViewallowCreateView/viewActionsfrom schema to ViewSwitcher in engineallowCreateView: isAdminandviewActionsto objectViewSchemahandleCreateView/handleViewActionshared callbackspackages/layout/src/stories/SidebarNav.stories.tsxwith 6 story variantscontent/docs/layout/sidebar-nav.mdxwith full enhanced API docsasChilddestructuring in AppHeader.test.tsx mocks (TS6133 build error)Original prompt
This section details on the original issue you should resolve
<issue_title>Console integration: consume new engine schema capabilities (HeaderBar, ViewSwitcher, SidebarNav, Airtable UX)</issue_title>
<issue_description>## Background
PR #903, #905, #907 extended the engine packages with significant new schema capabilities:
HeaderBarSchemanow supportssearch,actions,rightContentslotsBreadcrumbItemsupportssiblingsdropdown navigationSidebarNavsupportsbadge,children(nested items),searchEnabledViewSwitcherSchemasupportsallowCreateView,viewActionssingleClickEdit,selectionStyle, compact density, auto column widths, ghost rows, localized datesProblem: All 3 PRs modified only
packages/*(engine layer). Console (apps/console/) was not updated to consume these new capabilities. The engine has the schema expressiveness, but Console still hardcodes the equivalent UI.Reference Screenshots
CRM Project Task page (before optimization):

Airtable Interface (target benchmark):

Task 1: [P0] AppHeader.tsx → Consume
HeaderBarSchemaCurrent State
apps/console/src/components/AppHeader.tsx(~280 lines) hardcodes:<button>+ mobile<Button>)siblingsdropdown (custom DropdownMenu)ConnectionStatuscomponentPresenceAvatars(realtime presence)ActivityFeed(notification bell)HelpCirclebuttonModeToggle(theme switcher)LocaleSwitcherAll of these are not configured via schema — they're JSX in
AppHeader.Engine Capability (already merged in #905)
HeaderBarSchemanow supports:The
header-barrenderer inpackages/components/src/renderers/navigation/header-bar.tsxrenders all of these from schema.Required Changes
File:
apps/console/src/components/AppHeader.tsxOption A (Recommended): Hybrid approach — Keep
AppHeaderas a thin wrapper that builds aHeaderBarSchemaand delegates to theheader-barrenderer, while keeping Console-specific concerns (presence polling, activity feed data fetching) in AppHeader.Option B: Incremental — Keep current JSX structure but pass
siblingsthrough the existing breadcrumb rendering (already partially done), and ensure the search button dispatches the ⌘K event consistently.Acceptance Criteria
BreadcrumbItem.siblings(already partially done, verify working)Task 2: [P0] Console ObjectView → Pass
allowCreateView&viewActionsto ViewSwitcherCurrent State
apps/console/src/components/ObjectView.tsxbuildsviewSwitcherSchemain thebuildViewSwitcherSchema()function (around L477-504):Engine Capability (already merged in #905)
ViewSwitcherSchemanow supports:ViewSwitcher.tsxrenders a+button and per-view action icons withonCreateViewandonViewActioncallbacks.Required Chang...
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.