pierrejeambrun commented on code in PR #45501:
URL: https://github.com/apache/airflow/pull/45501#discussion_r1908492831


##########
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:
   I think `display` cannot be `card` if `cardDef` is undefined, therefore the 
`cardDef !== undefined` can be remove I think.



##########
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:
   Maybe move all the `hasRows` check as the first condition. So we it's easier 
to understand that systematically things are skipped when there are no rows.



-- 
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]

Reply via email to