Repository: provectus/kafka-ui
Issue: UI now showing broker list when DISABLELOGDIRSCOLLECTION=true
Labels: type/enhancement
good first issue
scope/frontend
status/accepted

Currently, when log dir collection is disabled, UI not showing brokers list - I think it can be useful to see broker list anyway. Lets render list, but hide/(fill with N/A) columns with no values : segmentSize, segmentsCount. 

CC @Haarolean 

sample:
<img width="1528" alt="Screenshot 2022-10-13 at 10 35 40" src="https://user-images.githubusercontent.com/702205/195522479-de35a587-14f6-491f-a396-7da93e9be629.png">


How to reproduce locally:
run kafka-ui.yaml docker compose with `KAFKA_CLUSTERS_0_DISABLELOGDIRSCOLLECTION: 'true'` property added.



Issue comments:

Pull request review comments:
please check the Linter warnings
i think there with the new version of user event , you can automatically await the userEvent 
fixed
fixed
why are we deleting the empty table case ?
fixed

Patch that resolved the issue:
diff --git a/kafka-ui-react-app/src/components/Brokers/BrokersList/BrokersList.tsx b/kafka-ui-react-app/src/components/Brokers/BrokersList/BrokersList.tsx
index 3fce89fbae9..d74c1bcb700 100644
--- a/kafka-ui-react-app/src/components/Brokers/BrokersList/BrokersList.tsx
+++ b/kafka-ui-react-app/src/components/Brokers/BrokersList/BrokersList.tsx
@@ -10,6 +10,8 @@ import Table, { LinkCell, SizeCell } from 'components/common/NewTable';
 import { ColumnDef } from '@tanstack/react-table';
 import { clusterBrokerPath } from 'lib/paths';
 
+const NA = 'N/A';
+
 const BrokersList: React.FC = () => {
   const navigate = useNavigate();
   const { clusterName } = useAppParams<{ clusterName: ClusterName }>();
@@ -29,14 +31,26 @@ const BrokersList: React.FC = () => {
   } = clusterStats;
 
   const rows = React.useMemo(() => {
-    if (!diskUsage) return [];
+    let brokersResource;
+    if (!diskUsage || !diskUsage?.length) {
+      brokersResource =
+        brokers?.map((broker) => {
+          return {
+            brokerId: broker.id,
+            segmentSize: NA,
+            segmentCount: NA,
+          };
+        }) || [];
+    } else {
+      brokersResource = diskUsage;
+    }
 
-    return diskUsage.map(({ brokerId, segmentSize, segmentCount }) => {
+    return brokersResource.map(({ brokerId, segmentSize, segmentCount }) => {
       const broker = brokers?.find(({ id }) => id === brokerId);
       return {
         brokerId,
-        size: segmentSize,
-        count: segmentCount,
+        size: segmentSize || NA,
+        count: segmentCount || NA,
         port: broker?.port,
         host: broker?.host,
       };
@@ -55,7 +69,24 @@ const BrokersList: React.FC = () => {
           />
         ),
       },
-      { header: 'Segment Size', accessorKey: 'size', cell: SizeCell },
+      {
+        header: 'Segment Size',
+        accessorKey: 'size',
+        // eslint-disable-next-line react/no-unstable-nested-components
+        cell: ({ getValue, table, cell, column, renderValue, row }) =>
+          getValue() === NA ? (
+            NA
+          ) : (
+            <SizeCell
+              table={table}
+              column={column}
+              row={row}
+              cell={cell}
+              getValue={getValue}
+              renderValue={renderValue}
+            />
+          ),
+      },
       { header: 'Segment Count', accessorKey: 'count' },
       { header: 'Port', accessorKey: 'port' },
       { header: 'Host', accessorKey: 'host' },
diff --git a/kafka-ui-react-app/src/components/Brokers/BrokersList/__test__/BrokersList.spec.tsx b/kafka-ui-react-app/src/components/Brokers/BrokersList/__test__/BrokersList.spec.tsx
index b11d477b600..cf36c64059d 100644
--- a/kafka-ui-react-app/src/components/Brokers/BrokersList/__test__/BrokersList.spec.tsx
+++ b/kafka-ui-react-app/src/components/Brokers/BrokersList/__test__/BrokersList.spec.tsx
@@ -134,12 +134,36 @@ describe('BrokersList Component', () => {
         }));
       });
 
-      it('renders empty table', async () => {
+      describe('when it has no brokers', () => {
+        beforeEach(() => {
+          (useBrokers as jest.Mock).mockImplementation(() => ({
+            data: [],
+          }));
+        });
+
+        it('renders empty table', async () => {
+          renderComponent();
+          expect(screen.getByRole('table')).toBeInTheDocument();
+          expect(
+            screen.getByRole('row', { name: 'Disk usage data not available' })
+          ).toBeInTheDocument();
+        });
+      });
+
+      it('renders list of all brokers', async () => {
         renderComponent();
         expect(screen.getByRole('table')).toBeInTheDocument();
-        expect(
-          screen.getByRole('row', { name: 'Disk usage data not available' })
-        ).toBeInTheDocument();
+        expect(screen.getAllByRole('row').length).toEqual(3);
+      });
+      it('opens broker when row clicked', async () => {
+        renderComponent();
+        await userEvent.click(screen.getByRole('cell', { name: '1' }));
+
+        await waitFor(() =>
+          expect(mockedUsedNavigate).toBeCalledWith(
+            clusterBrokerPath(clusterName, '1')
+          )
+        );
       });
     });
   });


Test patch: