tirkarthi commented on code in PR #45501:
URL: https://github.com/apache/airflow/pull/45501#discussion_r1909171711
##########
airflow/ui/src/components/DataTable/DataTable.tsx:
##########
@@ -115,33 +115,34 @@ export const DataTable = <TData,>({
const { rows } = table.getRowModel();
const display = displayMode === "card" && Boolean(cardDef) ? "card" :
"table";
+ const hasRows = rows.length > 0;
return (
<>
<ProgressBar size="xs" visibility={Boolean(isFetching) &&
!Boolean(isLoading) ? "visible" : "hidden"} />
<Toaster />
{errorMessage}
- {display === "table" && <TableList table={table} />}
- {display === "card" && cardDef !== undefined && (
+ {display === "table" && hasRows ? <TableList table={table} /> :
undefined}
+ {display === "card" && cardDef !== undefined && hasRows ? (
Review Comment:
Thanks, moved `hasRows` checks to the front. `cardDef` is typed as optional
so removing this makes typescript not happy.
```
src/components/DataTable/DataTable.tsx:127:19 - error TS2322: Type
'CardDef<TData> | undefined' is not assignable to type 'CardDef<TData>'.
Type 'undefined' is not assignable to type 'CardDef<TData>'.
127 <CardList cardDef={cardDef} isLoading={isLoading} table={table}
/>
~~~~~~~
src/components/DataTable/CardList.tsx:25:12
25 readonly cardDef: CardDef<TData>;
~~~~~~~
The expected type comes from property 'cardDef' which is declared here
on type 'IntrinsicAttributes & DataTableProps<TData>'
Found 1 error in src/components/DataTable/DataTable.tsx:127
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]