Skip to content

Commit 4347f4f

Browse files
Copilothotlong
andcommitted
feat: integrate TabBar tabs propagation into console and plugin-view
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 2eabfc8 commit 4347f4f

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

apps/console/src/components/ObjectView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ export function ObjectView({ dataSource, objects, onEdit, onRowClick }: any) {
344344
virtualScroll: viewDef.virtualScroll ?? listSchema.virtualScroll,
345345
emptyState: viewDef.emptyState ?? listSchema.emptyState,
346346
aria: viewDef.aria ?? listSchema.aria,
347+
tabs: listSchema.tabs,
347348
// Propagate filter/sort as default filters/sort for data flow
348349
...(viewDef.filter?.length ? { filters: viewDef.filter } : {}),
349350
...(viewDef.sort?.length ? { sort: viewDef.sort } : {}),

packages/plugin-view/src/ObjectView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ export const ObjectView: React.FC<ObjectViewProps> = ({
855855
virtualScroll: activeView?.virtualScroll ?? (schema as any).virtualScroll,
856856
emptyState: activeView?.emptyState ?? (schema as any).emptyState,
857857
aria: activeView?.aria ?? (schema as any).aria,
858+
tabs: (schema as any).tabs,
858859
},
859860
dataSource,
860861
onEdit: handleEdit,

packages/plugin-view/src/__tests__/config-sync-integration.test.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,4 +550,39 @@ describe('Config Sync Integration — Per View Type', () => {
550550
expect(s?.emptyState).toEqual({ title: 'No data', message: 'Add records', icon: 'inbox' });
551551
expect(s?.aria).toEqual({ label: 'Contacts', describedBy: 'desc', live: 'polite' });
552552
});
553+
554+
it('propagates schema-level tabs through renderListView', () => {
555+
const tabsConfig = [
556+
{ name: 'all', label: 'All Records', isDefault: true },
557+
{ name: 'active', label: 'Active', icon: 'circle-check', filter: { logic: 'and', conditions: [{ field: 'status', operator: 'eq', value: 'active' }] } },
558+
{ name: 'vip', label: 'VIP', pinned: true },
559+
];
560+
561+
const schema: ObjectViewSchema = {
562+
type: 'object-view',
563+
objectName: 'contacts',
564+
tabs: tabsConfig,
565+
} as any;
566+
567+
const renderListViewSpy = vi.fn(({ schema: listSchema }: any) => (
568+
<div data-testid="custom-list">Grid</div>
569+
));
570+
571+
render(
572+
<ObjectView
573+
schema={schema}
574+
dataSource={mockDataSource}
575+
views={[{ id: 'v1', label: 'Grid View', type: 'grid' as const }]}
576+
activeViewId="v1"
577+
renderListView={renderListViewSpy}
578+
/>,
579+
);
580+
581+
expect(renderListViewSpy).toHaveBeenCalled();
582+
const callSchema = renderListViewSpy.mock.calls[0]?.[0]?.schema;
583+
expect(callSchema?.tabs).toEqual(tabsConfig);
584+
expect(callSchema?.tabs).toHaveLength(3);
585+
expect(callSchema?.tabs[0]?.isDefault).toBe(true);
586+
expect(callSchema?.tabs[2]?.pinned).toBe(true);
587+
});
553588
});

0 commit comments

Comments
 (0)