Ver código fonte

962 - bulk connectors operations linters fix

Kamila Alekbaeva 2 anos atrás
pai
commit
afc016a7dc

+ 18 - 8
kafka-ui-react-app/src/components/Connect/Details/Actions/Actions.tsx

@@ -56,19 +56,29 @@ const Actions: React.FC = () => {
       clusterName: routerProps.clusterName,
       connectName: routerProps.connectName,
       connectorName: routerProps.connectorName,
-      action: action
-    }
-  }
+      action,
+    };
+  };
   const restartConnectorHandler = () =>
-    stateMutation.mutateAsync(mutationParams(ConnectorAction.RESTART));
+    stateMutation.mutateAsync(
+      mutationParams(ConnectorAction.RESTART)
+    );
   const restartAllTasksHandler = () =>
-    stateMutation.mutateAsync(mutationParams(ConnectorAction.RESTART_ALL_TASKS));
+    stateMutation.mutateAsync(
+      mutationParams(ConnectorAction.RESTART_ALL_TASKS)
+    );
   const restartFailedTasksHandler = () =>
-    stateMutation.mutateAsync(mutationParams(ConnectorAction.RESTART_FAILED_TASKS));
+    stateMutation.mutateAsync(
+      mutationParams(ConnectorAction.RESTART_FAILED_TASKS)
+    );
   const pauseConnectorHandler = () =>
-    stateMutation.mutateAsync(mutationParams(ConnectorAction.PAUSE));
+    stateMutation.mutateAsync(
+      mutationParams(ConnectorAction.PAUSE)
+    );
   const resumeConnectorHandler = () =>
-    stateMutation.mutateAsync(mutationParams(ConnectorAction.RESUME));
+    stateMutation.mutateAsync(
+      mutationParams(ConnectorAction.RESUME)
+    );
 
   return (
     <S.ConnectorActionsWrapperStyled>

+ 16 - 20
kafka-ui-react-app/src/components/Connect/Details/Actions/__tests__/Actions.spec.tsx

@@ -139,10 +139,10 @@ describe('Actions', () => {
           screen.getByRole('menuitem', { name: 'Restart Connector' })
         );
         expect(restartConnector).toHaveBeenCalledWith({
-          'action': ConnectorAction.RESTART,
-          'clusterName': 'myCluster',
-          'connectName': 'myConnect',
-          "connectorName": 'myConnector'
+          action: ConnectorAction.RESTART,
+          clusterName: 'myCluster',
+          connectName: 'myConnect',
+          connectorName: 'myConnector'
         });
       });
 
@@ -156,14 +156,12 @@ describe('Actions', () => {
         await userEvent.click(
           screen.getByRole('menuitem', { name: 'Restart All Tasks' })
         );
-        expect(restartAllTasks).toHaveBeenCalledWith(
-          {
-            'action': ConnectorAction.RESTART_ALL_TASKS,
-            'clusterName': 'myCluster',
-            'connectName': 'myConnect',
-            "connectorName": 'myConnector'
-          }
-        );
+        expect(restartAllTasks).toHaveBeenCalledWith({
+          action: ConnectorAction.RESTART_ALL_TASKS,
+          clusterName: 'myCluster',
+          connectName: 'myConnect',
+          connectorName: 'myConnector'
+        });
       });
 
       it('calls restartFailedTasks', async () => {
@@ -176,14 +174,12 @@ describe('Actions', () => {
         await userEvent.click(
           screen.getByRole('menuitem', { name: 'Restart Failed Tasks' })
         );
-        expect(restartFailedTasks).toHaveBeenCalledWith(
-          {
-            'action': ConnectorAction.RESTART_FAILED_TASKS,
-            'clusterName': 'myCluster',
-            'connectName': 'myConnect',
-            "connectorName": 'myConnector'
-          }
-        );
+        expect(restartFailedTasks).toHaveBeenCalledWith({
+          'action': ConnectorAction.RESTART_FAILED_TASKS,
+          'clusterName': 'myCluster',
+          'connectName': 'myConnect',
+          "connectorName": 'myConnector'
+        });
       });
 
       it('calls pauseConnector when pause button clicked', async () => {

+ 6 - 6
kafka-ui-react-app/src/components/Connect/List/BatchActionsBar.tsx

@@ -1,14 +1,14 @@
 import React from 'react';
-import {Action, ResourceType, ConnectorAction, Connector} from 'generated-sources';
+import { Action, ResourceType, ConnectorAction, Connector } from 'generated-sources';
 import useAppParams from 'lib/hooks/useAppParams';
 import { useConfirm } from 'lib/hooks/useConfirm';
 import { RouterParamsClusterConnectConnector } from 'lib/paths';
-import {useIsMutating} from '@tanstack/react-query';
-import {ActionCanButton} from 'components/common/ActionComponent';
+import { useIsMutating, useQueryClient } from '@tanstack/react-query';
+import { ActionCanButton } from 'components/common/ActionComponent';
 import { usePermission } from 'lib/hooks/usePermission';
-import {useDeleteConnector, useUpdateConnectorState} from 'lib/hooks/api/kafkaConnect';
-import {Row} from '@tanstack/react-table';
-import { useQueryClient } from '@tanstack/react-query';
+import { useDeleteConnector, useUpdateConnectorState } from 'lib/hooks/api/kafkaConnect';
+import { Row } from '@tanstack/react-table';
+
 
 interface BatchActionsBarProps {
   rows: Row<Connector>[];

+ 4 - 1
kafka-ui-react-app/src/components/Connect/List/ConnectorCell.tsx

@@ -1,10 +1,13 @@
 import React from 'react';
+import { CellContext } from '@tanstack/react-table';
 import { FullConnectorInfo } from 'generated-sources';
 import { useNavigate } from 'react-router-dom';
 import { clusterConnectConnectorPath, ClusterNameRoute } from 'lib/paths';
 import useAppParams from 'lib/hooks/useAppParams';
 
-const ConnectorCell: React.FC<{ row: FullConnectorInfo }> = ({ row: { original } }) => {
+const ConnectorCell: React.FC<CellContext<FullConnectorInfo, unknown>> = ({
+  row: { original },
+}) => {
   const navigate = useNavigate();
   const { name, connect } = original;
   const { clusterName } = useAppParams<ClusterNameRoute>();

+ 1 - 1
kafka-ui-react-app/src/components/Connect/List/List.tsx

@@ -41,7 +41,7 @@ const List: React.FC = () => {
       columns={columns}
       enableSorting
       batchActionsBar={BatchActionsBar}
-      enableRowSelection={true}
+      enableRowSelection
       emptyMessage="No connectors found"
     />
   );

+ 1 - 2
kafka-ui-react-app/src/components/Connect/List/__tests__/List.spec.tsx

@@ -16,7 +16,7 @@ const mockDelete = jest.fn();
 const mockUpdate = jest.fn();
 
 jest.mock('react-router-dom', () => ({
-  ...jest.requireActual('react-router-dom') as any,
+  ...jest.requireActual('react-router-dom'),
   useNavigate: () => mockedUsedNavigate,
 }));
 
@@ -80,7 +80,6 @@ describe('Connectors List', () => {
       const getButtonByName = (name: string) => screen.getByRole('button', { name });
 
       beforeEach(async () => {
-        useDeleteConnector.mockClear();
         (useDeleteConnector as jest.Mock).mockImplementation(() => ({
           mutateAsync: mockDelete,
         }));

+ 4 - 4
kafka-ui-react-app/src/lib/hooks/api/__tests__/kafkaConnect.spec.ts

@@ -94,10 +94,10 @@ describe('kafkaConnect hooks', () => {
         await act(() => {
           result.current.mutateAsync(
             {
-              clusterName: clusterName,
-              connectName: connectName,
-              connectorName: connectorName,
-              action: action
+              clusterName,
+              connectName,
+              connectorName,
+              action,
             },
           )
         });