Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ ObjectUI is a universal Server-Driven UI (SDUI) engine built on React + Tailwind
2. ~~**Console `renderListView`:** Omits toolbar/display flags from `fullSchema`~~ → Now passes all config properties
3. ~~**`NamedListView` type:** Missing toolbar/display properties~~ → Added as first-class properties
4. ~~**Plugin `renderListView` schema missing toolbar flags:** `renderContent` → `renderListView` schema did not include `showSearch`/`showFilters`/`showSort`~~ → Now propagated (PR #771)
5. ~~**ListView toolbar unconditionally rendered:** Search/Filter/Sort buttons always visible regardless of schema flags~~ → Now conditionally rendered based on `schema.showSearch`/`showFilters`/`showSort` (PR #771)
5. ~~**ListView toolbar unconditionally rendered:** Search/Filter/Sort buttons always visible regardless of schema flags~~ → Now conditionally rendered based on `schema.showSearch`/`showFilters`/`showSort` (PR #771); `userActions.sort`/`search`/`filter`/`rowHeight`/`addRecordForm` now override toolbar flags (Issue #737)
6. ~~**Hide Fields/Group/Color/Density buttons always visible:** No schema property to control visibility~~ → Added `showHideFields`/`showGroup`/`showColor`/`showDensity` with conditional rendering (Issue #719)
7. ~~**Export toggle broken:** ViewConfigPanel writes `allowExport: boolean` but ListView checks `exportOptions` object~~ → Export now checks both `exportOptions && allowExport !== false`; Console clears `exportOptions` when `allowExport === false` (Issue #719)
8. ~~**`hasExport` logic bug:** `draft.allowExport !== false` was always true when undefined~~ → Fixed to `draft.allowExport === true || draft.exportOptions != null` (Issue #719)
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/locales/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const ar = {
list: {
recordCount: '{{count}} سجلات',
recordCountOne: '{{count}} سجل',
addRecord: 'إضافة سجل',
},
kanban: {
addCard: 'إضافة بطاقة',
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const de = {
list: {
recordCount: '{{count}} Datensätze',
recordCountOne: '{{count}} Datensatz',
addRecord: 'Datensatz hinzufügen',
},
kanban: {
addCard: 'Karte hinzufügen',
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const en = {
list: {
recordCount: '{{count}} records',
recordCountOne: '{{count}} record',
addRecord: 'Add record',
},
kanban: {
addCard: 'Add card',
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const es = {
list: {
recordCount: '{{count}} registros',
recordCountOne: '{{count}} registro',
addRecord: 'Agregar registro',
},
kanban: {
addCard: 'Añadir tarjeta',
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const fr = {
list: {
recordCount: '{{count}} enregistrements',
recordCountOne: '{{count}} enregistrement',
addRecord: 'Ajouter un enregistrement',
},
kanban: {
addCard: 'Ajouter une carte',
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/locales/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const ja = {
list: {
recordCount: '{{count}} 件のレコード',
recordCountOne: '{{count}} 件のレコード',
addRecord: 'レコードを追加',
},
kanban: {
addCard: 'カードを追加',
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/locales/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const ko = {
list: {
recordCount: '{{count}}개 레코드',
recordCountOne: '{{count}}개 레코드',
addRecord: '레코드 추가',
},
kanban: {
addCard: '카드 추가',
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/locales/pt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const pt = {
list: {
recordCount: '{{count}} registros',
recordCountOne: '{{count}} registro',
addRecord: 'Adicionar registro',
},
kanban: {
addCard: 'Adicionar cartão',
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const ru = {
list: {
recordCount: '{{count}} записей',
recordCountOne: '{{count}} запись',
addRecord: 'Добавить запись',
},
kanban: {
addCard: 'Добавить карточку',
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const zh = {
list: {
recordCount: '{{count}} 条记录',
recordCountOne: '{{count}} 条记录',
addRecord: '添加记录',
},
kanban: {
addCard: '添加卡片',
Expand Down
28 changes: 24 additions & 4 deletions packages/plugin-list/src/ListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ const LIST_DEFAULT_TRANSLATIONS: Record<string, string> = {
'list.pullToRefresh': 'Pull to refresh',
'list.refreshing': 'Refreshing…',
'list.dataLimitReached': 'Showing first {{limit}} records. More data may be available.',
'list.addRecord': 'Add record',
};

/**
Expand Down Expand Up @@ -265,6 +266,7 @@ export const ListView: React.FC<ListViewProps> = ({
// Resolve toolbar visibility flags: userActions overrides showX flags
const toolbarFlags = React.useMemo(() => {
const ua = schema.userActions;
const addRecordEnabled = schema.addRecord?.enabled === true && ua?.addRecordForm !== false;
return {
showSearch: ua?.search !== undefined ? ua.search : schema.showSearch !== false,
showSort: ua?.sort !== undefined ? ua.sort : schema.showSort !== false,
Expand All @@ -273,8 +275,10 @@ export const ListView: React.FC<ListViewProps> = ({
showHideFields: schema.showHideFields !== false,
showGroup: schema.showGroup !== false,
showColor: schema.showColor !== false,
showAddRecord: addRecordEnabled,
addRecordPosition: (schema.addRecord?.position === 'bottom' ? 'bottom' : 'top') as 'top' | 'bottom',
};
}, [schema.userActions, schema.showSearch, schema.showSort, schema.showFilters, schema.showDensity, schema.showHideFields, schema.showGroup, schema.showColor]);
}, [schema.userActions, schema.showSearch, schema.showSort, schema.showFilters, schema.showDensity, schema.showHideFields, schema.showGroup, schema.showColor, schema.addRecord, schema.userActions?.addRecordForm]);
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

The useMemo dependency array includes schema.userActions?.addRecordForm which is redundant since schema.userActions is already included. When schema.userActions changes, the memo will recalculate regardless of whether addRecordForm changed. Remove schema.userActions?.addRecordForm from the dependency array to avoid confusion and follow React best practices.

Suggested change
}, [schema.userActions, schema.showSearch, schema.showSort, schema.showFilters, schema.showDensity, schema.showHideFields, schema.showGroup, schema.showColor, schema.addRecord, schema.userActions?.addRecordForm]);
}, [schema.userActions, schema.showSearch, schema.showSort, schema.showFilters, schema.showDensity, schema.showHideFields, schema.showGroup, schema.showColor, schema.addRecord]);

Copilot uses AI. Check for mistakes.

const [currentView, setCurrentView] = React.useState<ViewType>(
(schema.viewType as ViewType)
Expand Down Expand Up @@ -1324,8 +1328,8 @@ export const ListView: React.FC<ListViewProps> = ({

{/* Right: Add Record + Search */}
<div className="flex items-center gap-1">
{/* Add Record */}
{schema.addRecord?.enabled && (
{/* Add Record (top position) */}
{toolbarFlags.showAddRecord && toolbarFlags.addRecordPosition === 'top' && (
<Button
variant="ghost"
size="sm"
Expand All @@ -1334,7 +1338,7 @@ export const ListView: React.FC<ListViewProps> = ({
onClick={() => props.onAddRecord?.()}
>
<Plus className="h-3.5 w-3.5 mr-1.5" />
<span className="hidden sm:inline">Add record</span>
<span className="hidden sm:inline">{t('list.addRecord')}</span>
</Button>
)}

Expand Down Expand Up @@ -1453,6 +1457,22 @@ export const ListView: React.FC<ListViewProps> = ({
)}
</div>

{/* Add Record (bottom position) */}
{toolbarFlags.showAddRecord && toolbarFlags.addRecordPosition === 'bottom' && (
<div className="border-t px-2 sm:px-4 py-1 bg-background shrink-0">
<Button
variant="ghost"
size="sm"
className="h-7 px-2 text-muted-foreground hover:text-primary text-xs"
data-testid="add-record-button"
onClick={() => props.onAddRecord?.()}
>
<Plus className="h-3.5 w-3.5 mr-1.5" />
<span className="hidden sm:inline">{t('list.addRecord')}</span>
</Button>
</div>
)}

{/* Bulk Actions Bar — skip for grid view since ObjectGrid renders its own BulkActionBar */}
{schema.bulkActions && schema.bulkActions.length > 0 && selectedRows.length > 0 && currentView !== 'grid' && (
<div
Expand Down
46 changes: 46 additions & 0 deletions packages/plugin-list/src/__tests__/ListView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,52 @@ describe('ListView', () => {
renderWithProvider(<ListView schema={schema} />);
expect(screen.queryByTestId('add-record-button')).not.toBeInTheDocument();
});

it('should hide add record button when userActions.addRecordForm is false', () => {
const schema: ListViewSchema = {
type: 'list-view',
objectName: 'contacts',
viewType: 'grid',
fields: ['name', 'email'],
addRecord: { enabled: true },
userActions: { addRecordForm: false },
};

renderWithProvider(<ListView schema={schema} />);
expect(screen.queryByTestId('add-record-button')).not.toBeInTheDocument();
});

it('should render add record button at bottom when position is bottom', () => {
const schema: ListViewSchema = {
type: 'list-view',
objectName: 'contacts',
viewType: 'grid',
fields: ['name', 'email'],
addRecord: { enabled: true, position: 'bottom' },
};

renderWithProvider(<ListView schema={schema} />);
const btn = screen.getByTestId('add-record-button');
expect(btn).toBeInTheDocument();
// The bottom button is wrapped in a border-t div outside the toolbar
expect(btn.closest('div.border-t')).toBeTruthy();
});

it('should render add record button in toolbar when position is top', () => {
const schema: ListViewSchema = {
type: 'list-view',
objectName: 'contacts',
viewType: 'grid',
fields: ['name', 'email'],
addRecord: { enabled: true, position: 'top' },
};

renderWithProvider(<ListView schema={schema} />);
const btn = screen.getByTestId('add-record-button');
expect(btn).toBeInTheDocument();
// The top button is inside the toolbar border-b div
expect(btn.closest('div.border-b')).toBeTruthy();
});
});

// ============================
Expand Down