Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…ight split edit mode Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
@copilot 仔细评估是否完整实现的任务中要求的所有功能 |
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Completed gap analysis and addressed the missing features in Added to ReportConfigPanel:
Restored in ReportView:
Coverage summary vs issue requirements:
Not in this PR (more complex, can follow-up):
|
There was a problem hiding this comment.
Pull request overview
This PR refactors the ReportView edit mode from a full-page ReportBuilder replacement to a left-right split layout with DesignDrawer and live preview, aligning the architecture with DashboardView and ListView patterns. The new ReportConfigPanel is schema-driven via ConfigPanelRenderer + useConfigDraft, providing a consistent configuration experience across all view types.
Changes:
- Introduced ReportConfigPanel with 7 collapsible sections (Basic, Data, Filters, Group By, Export, Schedule, Appearance) using ConfigPanelRenderer pattern
- Refactored ReportView to use DesignDrawer for right-side edit panel while maintaining live preview of ReportViewer on the left
- Changed field structure from
{ name, label, type }to{ value, label, type }to align with FilterBuilder/SortBuilder expectations
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/plugin-report/src/index.tsx | Added exports for ReportConfigPanel and AvailableField type |
| packages/plugin-report/src/ReportConfigPanel.tsx | New schema-driven config panel with 7 sections, mirroring DashboardConfigPanel pattern |
| packages/plugin-report/src/tests/ReportConfigPanel.test.tsx | Comprehensive test suite with 18 tests covering all sections, save/discard, live updates |
| apps/console/src/components/ReportView.tsx | Refactored to use DesignDrawer + ReportConfigPanel instead of full-page ReportBuilder; updated field mapping from name to value |
| ROADMAP.md | Updated to mark ReportView refactoring and ReportConfigPanel implementation as complete |
| if (Array.isArray(fields)) { | ||
| return fields.map((f: any) => | ||
| typeof f === 'string' | ||
| ? { name: f, label: f, type: 'text' } | ||
| : { name: f.name, label: f.label || f.name, type: f.type || 'text' }, | ||
| ? { value: f, label: f, type: 'text' } | ||
| : { value: f.name, label: f.label || f.name, type: f.type || 'text' }, | ||
| ); | ||
| } | ||
| return Object.entries(fields).map(([name, def]: [string, any]) => ({ | ||
| name, | ||
| value: name, | ||
| label: def.label || name, | ||
| type: def.type || 'text', | ||
| })); |
There was a problem hiding this comment.
The field structure has been changed from using name property to value property (lines 50, 51, 55) to align with FilterBuilder/SortBuilder expectations. However, the existing test file apps/console/src/__tests__/ReportDynamicFields.test.tsx still expects fields with name property and was not updated in this PR. This will cause the existing tests to fail.
The test file should be updated as part of this refactoring to match the new field structure, or a migration guide/comment should be added explaining this breaking change.
|
|
||
| // Use live-edited schema for preview when the drawer is open | ||
| const previewReport = drawerOpen && editSchema ? editSchema : reportData; | ||
| const reportForViewer = mapReportForViewer(previewReport); |
There was a problem hiding this comment.
The mapReportForViewer function is called on every render (line 230) without memoization. Since report schemas can be large and the mapping logic is non-trivial (handling columns/fields conversion, section auto-generation), consider wrapping this in a useMemo hook with previewReport as a dependency to avoid redundant computation on unrelated renders.
Example:
const reportForViewer = useMemo(() => mapReportForViewer(previewReport), [previewReport]);
| const reportForViewer = mapReportForViewer(previewReport); | |
| const reportForViewer = useMemo( | |
| () => mapReportForViewer(previewReport), | |
| [previewReport], | |
| ); |
| {reportData.description && ( | ||
| <p className="text-sm text-muted-foreground mt-1 line-clamp-2">{reportData.description}</p> | ||
| )} |
There was a problem hiding this comment.
The report description is now displayed in the page header (lines 245-247) with line-clamp-2 class. This is a new feature not mentioned in the PR description. While this aligns with the DashboardView pattern (which also shows descriptions), ensure that:
- The ReportSchema type includes an optional
descriptionfield - This change is intentional and documented
- Long descriptions are properly truncated and accessible
This appears to be an enhancement beyond the stated scope of "left-right split with DesignDrawer + config panel".
| const [reportData, setReportData] = useState(initialReport); | ||
|
|
||
| // Local schema state for live preview — initialized from metadata | ||
| const [editSchema, setEditSchema] = useState<any>(null); |
There was a problem hiding this comment.
The editSchema state is typed as any (line 34), which bypasses TypeScript's type checking. This should be typed as ReportSchema | null for type safety, similar to how DashboardView types editSchema as DashboardSchema | null (apps/console/src/components/DashboardView.tsx:42).
This will help catch type errors and provide better IDE autocompletion.
ReportView edit mode replaced the entire page with
ReportBuilder(a hand-rolled Card+Tabs form), breaking WYSIWYG preview and diverging from the DashboardView/ListView design pattern. No ConfigPanelRenderer reuse, no auto-save, no undo/redo.Changes
New
ReportConfigPanel(packages/plugin-report/src/) — schema-driven config panel usingConfigPanelRenderer+useConfigDraft, mirroringDashboardConfigPanel. Seven sections covering all report-level properties:filtercontrol type (field/operator/value conditions with AND/OR logic)sortcontrol type (field selection + asc/desc ordering)customrender (enable/disable, frequency, time, timezone, recipients, formats)Refactored
ReportView(apps/console/src/components/) — edit mode now opens aDesignDrawer(right-side Sheet,modal={false}) whileReportViewerstays visible as live preview. Schema changes flow througheditSchemastate for real-time preview, same asDashboardView. Available fields are derived from object schema metadata and passed to filter/sort editors.ReportBuilderpreserved — still registered in ComponentRegistry for backward compat; just no longer used as the primary edit surface.Architecture alignment with DashboardView
Tests
ReportConfigPanelunit tests (open/close, all 7 sections, save/discard, live updates)ReportViewintegration tests passReportBuildertests unaffectedOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.