Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…edundant densityMode - Add visibleWhen to toolbar toggles: showGroup (grid/kanban), showColor (grid), showDensity (grid) - Add visibleWhen to data fields: prefixField (grid), _groupBy (hide for kanban), searchableFields/filterableFields/quickFilters/virtualScroll (grid) - Add visibleWhen to appearance fields: collapseAllByDefault (groupBy-dependent), fieldTextColor/showDescription/rowHeight/conditionalFormatting (grid) - Remove densityMode field (redundant with rowHeight) - Extend buildSwitchField and buildFieldMultiSelect helpers with visibleWhen param - Add 16 new tests for visibility predicates - Update ROADMAP.md with Phase 6 cleanup Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
@copilot 仔细评估每一个控件的每一个细节,实际差距非常大,你只修改了一小部分 |
- Remove tests for removed fields: prefixField, collapseAllByDefault, fieldTextColor, clickIntoRecordDetails - Update data/appearance/userActions section field key assertions - Convert disabledWhen tests for striped/bordered/wrapHeaders/resizable to visibleWhen tests (schema changed from disable to hide) - Update visibleWhen predicates: showGroup now includes gallery, showColor uses supportsColorField, _groupBy uses supportsGenericGroupBy, conditionalFormatting uses supportsConditionalFormatting - Update searchableFields/filterableFields/quickFilters/showDescription to be universal (no visibleWhen) - Add color field visibleWhen test for supportsColorField predicate - Remove spec coverage entries for removed fields Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove fieldTextColor and collapseAllByDefault from appearance fields test - Remove prefixField assertion from Data section test - Delete collapseAllByDefault toggle test (field removed from schema) - Delete clickIntoRecordDetails toggle test (field removed from schema) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…correct view-type visibility Removed fields not consumed by runtime: - prefixField (data section) - collapseAllByDefault (appearance section) - fieldTextColor (appearance section) - clickIntoRecordDetails (userActions section) - densityMode (appearance section, previous commit) Added semantic view-type visibility predicates: - supportsGrouping (grid/kanban/gallery) - supportsColorField (grid/calendar/timeline/gantt) - supportsConditionalFormatting (grid/kanban) - supportsRowActions (grid/kanban) - supportsGenericGroupBy (grid/gallery) Changed grid-only fields from disabledWhen to visibleWhen: - striped, bordered, wrapHeaders, resizable Added visibleWhen to previously universal fields: - showRecordCount, allowPrinting (grid only) - inlineEdit, addDeleteRecordsInline (grid only) - rowActions, bulkActions (grid/kanban) Corrected visibility for toolbar toggles: - showGroup: grid/kanban/gallery (was grid/kanban) - showColor: grid/calendar/timeline/gantt (was grid) - searchableFields/filterableFields/quickFilters/showDescription: universal (was grid) Updated 239 tests (103 schema + 136 panel), 10 integration tests pass. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
已做全面修复 (f43a480)。针对每个控件逐项对照了 ListView.tsx 运行时代码的实际消费情况: 已删除未被运行时消费的字段:
已按视图类型正确设置 visibleWhen(不再只是 disabled):
保持通用(所有视图可见): 249 个测试全部通过。 |
There was a problem hiding this comment.
Pull request overview
This PR performs a comprehensive cleanup of the view config panel to remove unused/unconsumed fields and add view-type-aware visibility conditions. The goal is to prevent users from seeing and configuring options that have no runtime effect for their selected view type (e.g., showing grid-specific options like "striped" for kanban views).
Changes:
- Removed 5 fields that are not consumed by runtime renderers:
prefixField,collapseAllByDefault,fieldTextColor,clickIntoRecordDetails, anddensityMode(redundant with rowHeight) - Added view-type visibility predicates (isGridView, supportsGrouping, supportsColorField, supportsConditionalFormatting, supportsRowActions, supportsGenericGroupBy) to hide fields that don't apply to the current view type
- Extended helper functions
buildSwitchFieldandbuildFieldMultiSelectto accept optionalvisibleWhenparameter - Changed grid-only appearance fields from
disabledWhen(grayed out) tovisibleWhen(hidden entirely)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| apps/console/src/utils/view-config-schema.tsx | Core schema factory: added visibility predicates, removed 5 unused fields, added visibleWhen to ~15 view-type-specific controls |
| apps/console/src/tests/view-config-schema.test.tsx | Updated field key lists, added comprehensive visibleWhen tests for toolbar/data/appearance sections, removed tests for deleted fields |
| apps/console/src/tests/ViewConfigPanel.test.tsx | Removed interaction tests for deleted fields (densityMode, collapseAllByDefault, clickIntoRecordDetails), updated test descriptions |
| ROADMAP.md | Added Phase 6 section documenting all cleanup activities, field removals, visibility additions, and test updates |
| /** True for views that support row/bulk actions (grid, kanban) */ | ||
| const supportsRowActions = (draft: Record<string, any>) => draft.type == null || ['grid', 'kanban'].includes(draft.type); |
There was a problem hiding this comment.
The visibility predicates supportsRowActions (lines 79, 1218, 1250) incorrectly includes 'kanban' in the list of supported view types. Based on the actual runtime code in packages/plugin-list/src/ListView.tsx (lines 768-769), rowActions and bulkActions are only passed to the grid view schema, not to kanban or any other view type.
The kanban plugin (packages/plugin-kanban) does not consume rowActions or bulkActions properties - these fields are grid-specific features. The predicates should be:
const supportsRowActions = (draft: Record<string, any>) => draft.type == null || draft.type === 'grid';
This affects:
- Line 79: predicate definition
- Line 1218: _rowActions field visibleWhen
- Line 1250: _bulkActions field visibleWhen
| /** True for views that support row/bulk actions (grid, kanban) */ | |
| const supportsRowActions = (draft: Record<string, any>) => draft.type == null || ['grid', 'kanban'].includes(draft.type); | |
| /** True for views that support row/bulk actions (grid only) */ | |
| const supportsRowActions = (draft: Record<string, any>) => draft.type == null || draft.type === 'grid'; |
| - [x] Add view-type-aware `visibleWhen` to toolbar toggles: `showGroup` (grid/kanban/gallery), `showColor` (grid/calendar/timeline/gantt), `showDensity` (grid only), `showRecordCount` (grid only), `allowPrinting` (grid only) | ||
| - [x] Add view-type-aware `visibleWhen` to data fields: `_groupBy` (grid/gallery — kanban uses dedicated type-specific option), `virtualScroll` (grid only) | ||
| - [x] Add view-type-aware `visibleWhen` to appearance fields: `striped`/`bordered`/`wrapHeaders`/`resizable`/`rowHeight` (grid only, changed from disabledWhen to visibleWhen), `color` (grid/calendar/timeline/gantt), `conditionalFormatting` (grid/kanban) | ||
| - [x] Add view-type-aware `visibleWhen` to userActions fields: `inlineEdit`/`addDeleteRecordsInline` (grid only), `rowActions`/`bulkActions` (grid/kanban) |
There was a problem hiding this comment.
The ROADMAP line 445 incorrectly states that rowActions/bulkActions support "grid/kanban" view types. Based on the runtime code investigation (packages/plugin-list/src/ListView.tsx lines 768-769), rowActions and bulkActions are only passed to the grid view schema, not to kanban or any other view type. The kanban plugin does not consume these properties.
This should be updated to:
- [x] Add view-type-aware `visibleWhen` to userActions fields: `inlineEdit`/`addDeleteRecordsInline` (grid only), `rowActions`/`bulkActions` (grid only)
This aligns with the critical bug identified in the view-config-schema.tsx predicates where supportsRowActions incorrectly includes 'kanban'.
| - [x] Add view-type-aware `visibleWhen` to userActions fields: `inlineEdit`/`addDeleteRecordsInline` (grid only), `rowActions`/`bulkActions` (grid/kanban) | |
| - [x] Add view-type-aware `visibleWhen` to userActions fields: `inlineEdit`/`addDeleteRecordsInline` (grid only), `rowActions`/`bulkActions` (grid only) |
| it('showGroup visible for grid (default), kanban, and gallery, hidden for others', () => { | ||
| const schema = buildSpecSchema(); | ||
| const section = schema.sections.find(s => s.key === 'pageConfig')!; | ||
| const field = section.fields.find(f => f.key === 'showGroup')!; | ||
| expect(field.visibleWhen).toBeDefined(); | ||
| expect(field.visibleWhen!({})).toBe(true); // default = grid | ||
| expect(field.visibleWhen!({ type: 'grid' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'kanban' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'gallery' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'calendar' })).toBe(false); | ||
| expect(field.visibleWhen!({ type: 'timeline' })).toBe(false); | ||
| expect(field.visibleWhen!({ type: 'gantt' })).toBe(false); | ||
| expect(field.visibleWhen!({ type: 'map' })).toBe(false); | ||
| }); | ||
|
|
||
| it('showColor visible for grid (default), calendar, timeline, gantt, hidden for others', () => { | ||
| const schema = buildSpecSchema(); | ||
| const section = schema.sections.find(s => s.key === 'pageConfig')!; | ||
| const field = section.fields.find(f => f.key === 'showColor')!; | ||
| expect(field.visibleWhen).toBeDefined(); | ||
| expect(field.visibleWhen!({})).toBe(true); // default = grid | ||
| expect(field.visibleWhen!({ type: 'grid' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'calendar' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'timeline' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'gantt' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'kanban' })).toBe(false); | ||
| expect(field.visibleWhen!({ type: 'gallery' })).toBe(false); | ||
| expect(field.visibleWhen!({ type: 'map' })).toBe(false); | ||
| }); | ||
|
|
||
| it('showDensity visible only for grid (default), hidden for others', () => { | ||
| const schema = buildSpecSchema(); | ||
| const section = schema.sections.find(s => s.key === 'pageConfig')!; | ||
| const field = section.fields.find(f => f.key === 'showDensity')!; | ||
| expect(field.visibleWhen).toBeDefined(); | ||
| expect(field.visibleWhen!({})).toBe(true); // default = grid | ||
| expect(field.visibleWhen!({ type: 'grid' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'kanban' })).toBe(false); | ||
| expect(field.visibleWhen!({ type: 'calendar' })).toBe(false); | ||
| }); | ||
|
|
||
| // ── Data section visibility by view type ──────────────────────── | ||
| it('_groupBy visible for grid (default) and gallery, hidden for others', () => { | ||
| const schema = buildSpecSchema(); | ||
| const section = schema.sections.find(s => s.key === 'data')!; | ||
| const field = section.fields.find(f => f.key === '_groupBy')!; | ||
| expect(field.visibleWhen).toBeDefined(); | ||
| expect(field.visibleWhen!({})).toBe(true); // default = grid | ||
| expect(field.visibleWhen!({ type: 'grid' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'gallery' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'kanban' })).toBe(false); // kanban uses dedicated groupByField | ||
| expect(field.visibleWhen!({ type: 'calendar' })).toBe(false); | ||
| expect(field.visibleWhen!({ type: 'timeline' })).toBe(false); | ||
| expect(field.visibleWhen!({ type: 'gantt' })).toBe(false); | ||
| expect(field.visibleWhen!({ type: 'map' })).toBe(false); | ||
| }); | ||
|
|
||
| it('searchableFields is universal (no visibleWhen)', () => { | ||
| const schema = buildSpecSchema(); | ||
| const section = schema.sections.find(s => s.key === 'data')!; | ||
| const field = section.fields.find(f => f.key === '_searchableFields')!; | ||
| expect(field.visibleWhen).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('filterableFields is universal (no visibleWhen)', () => { | ||
| const schema = buildSpecSchema(); | ||
| const section = schema.sections.find(s => s.key === 'data')!; | ||
| const field = section.fields.find(f => f.key === '_filterableFields')!; | ||
| expect(field.visibleWhen).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('quickFilters is universal (no visibleWhen)', () => { | ||
| const schema = buildSpecSchema(); | ||
| const section = schema.sections.find(s => s.key === 'data')!; | ||
| const field = section.fields.find(f => f.key === '_quickFilters')!; | ||
| expect(field.visibleWhen).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('virtualScroll visible only for grid', () => { | ||
| const schema = buildSpecSchema(); | ||
| const section = schema.sections.find(s => s.key === 'data')!; | ||
| const field = section.fields.find(f => f.key === 'virtualScroll')!; | ||
| expect(field.visibleWhen).toBeDefined(); | ||
| expect(field.visibleWhen!({})).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'grid' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'kanban' })).toBe(false); | ||
| }); | ||
|
|
||
| // ── Appearance section visibility by view type / state ────────── | ||
| it('color visible for grid (default), calendar, timeline, gantt, hidden for others', () => { | ||
| const schema = buildSpecSchema(); | ||
| const section = schema.sections.find(s => s.key === 'appearance')!; | ||
| const field = section.fields.find(f => f.key === 'color')!; | ||
| expect(field.visibleWhen).toBeDefined(); | ||
| expect(field.visibleWhen!({})).toBe(true); // default = grid | ||
| expect(field.visibleWhen!({ type: 'grid' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'calendar' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'timeline' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'gantt' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'kanban' })).toBe(false); | ||
| expect(field.visibleWhen!({ type: 'gallery' })).toBe(false); | ||
| expect(field.visibleWhen!({ type: 'map' })).toBe(false); | ||
| }); | ||
|
|
||
| it('showDescription is universal (no visibleWhen)', () => { | ||
| const schema = buildSpecSchema(); | ||
| const section = schema.sections.find(s => s.key === 'appearance')!; | ||
| const field = section.fields.find(f => f.key === 'showDescription')!; | ||
| expect(field.visibleWhen).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('rowHeight visible only for grid', () => { | ||
| const schema = buildSpecSchema(); | ||
| const section = schema.sections.find(s => s.key === 'appearance')!; | ||
| const field = section.fields.find(f => f.key === 'rowHeight')!; | ||
| expect(field.visibleWhen).toBeDefined(); | ||
| expect(field.visibleWhen!({})).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'grid' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'kanban' })).toBe(false); | ||
| }); | ||
|
|
||
| it('conditionalFormatting visible for grid (default) and kanban, hidden for others', () => { | ||
| const schema = buildSpecSchema(); | ||
| const section = schema.sections.find(s => s.key === 'appearance')!; | ||
| const field = section.fields.find(f => f.key === '_conditionalFormatting')!; | ||
| expect(field.visibleWhen).toBeDefined(); | ||
| expect(field.visibleWhen!({})).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'grid' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'kanban' })).toBe(true); | ||
| expect(field.visibleWhen!({ type: 'calendar' })).toBe(false); | ||
| expect(field.visibleWhen!({ type: 'gallery' })).toBe(false); | ||
| expect(field.visibleWhen!({ type: 'timeline' })).toBe(false); | ||
| expect(field.visibleWhen!({ type: 'map' })).toBe(false); | ||
| }); |
There was a problem hiding this comment.
The PR added visibleWhen predicates to several userActions fields (inlineEdit, addDeleteRecordsInline with isGridView at lines 1208, 1212; rowActions, bulkActions with supportsRowActions at lines 1218, 1250), but comprehensive tests for these visibility conditions are missing from the test suite.
The test file includes comprehensive visibility tests for toolbar toggles, data section fields, and appearance section fields (lines 812-945), but the userActions section visibility predicates are not tested. This creates an asymmetry in test coverage where some visibleWhen predicates are thoroughly tested across all view types while others are not verified at all.
Suggest adding tests similar to those at lines 812-945 for:
- inlineEdit (should be visible only for grid, hidden for kanban/calendar/etc.)
- addDeleteRecordsInline (should be visible only for grid)
- rowActions (should be visible for grid and kanban, hidden for others)
- bulkActions (should be visible for grid and kanban, hidden for others)
The view config panel exposed all fields regardless of view type, showing grid-only options for kanban/calendar/gallery views where they have no effect. Several fields were also not consumed by any runtime renderer. After a comprehensive audit of every field against
ListView.tsx,ObjectGrid.tsx,ObjectKanban.tsx, and other view components, the panel now shows only fields relevant to the selected view type.Fields removed (not consumed by any runtime renderer)
prefixField— no runtime consumer foundcollapseAllByDefault— no runtime consumer foundfieldTextColor— no runtime consumer foundclickIntoRecordDetails— behavior handled by navigation mode config, not consumed as a standalone fielddensityMode— redundant withrowHeight(5-value enum: compact/short/medium/tall/extra_tall)View-type-aware visibility conditions
Defined semantic predicates based on actual runtime consumption:
isGridView(grid only):showDensity,showRecordCount,allowPrinting,striped,bordered,wrapHeaders,resizable,rowHeight,virtualScroll,inlineEdit,addDeleteRecordsInlinesupportsGrouping(grid/kanban/gallery):showGroupsupportsColorField(grid/calendar/timeline/gantt):showColor,colorsupportsConditionalFormatting(grid/kanban):conditionalFormattingsupportsRowActions(grid/kanban):rowActions,bulkActionssupportsGenericGroupBy(grid/gallery):_groupBy— kanban uses dedicatedkanban.groupByFieldin type-specific optionsFields confirmed as universal (all view types)
searchableFields,filterableFields,quickFilters— applied at data fetch / toolbar levelshowDescription— view description displayed below toolbar for all viewsemptyState,hiddenFields— applicable to all viewsApproach change
Grid-only appearance fields (
striped,bordered,wrapHeaders,resizable) changed fromdisabledWhen(grayed out) tovisibleWhen(hidden entirely) for non-grid views.Helper changes
Extended
buildSwitchFieldandbuildFieldMultiSelectwith optionalvisibleWhenparameter.Tests
ROADMAP
Updated Phase 6 cleanup entry under P1.11 with comprehensive details.
Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.