Feature/1334 please add a counters of all connectors tasks and failed connectors tasks (#2002)
* Added failed connections counter * Getting failed connectors moved to Redux selector * Failed connectors test has been rewritten in testing-library way * Update kafka-ui-react-app/src/components/Connect/List/List.tsx Co-authored-by: Oleg Shur <workshur@gmail.com> * Suggestion exepted * Added test case for failed connectors counter * Unused import removed * Added failed tasks counter * Update kafka-ui-react-app/src/redux/reducers/connect/selectors.ts Co-authored-by: Oleg Shur <workshur@gmail.com> * Reduce args renamed Co-authored-by: k.morozov <k.morozov@ffin.ru> Co-authored-by: Oleg Shur <workshur@gmail.com>
This commit is contained in:
parent
6891138f15
commit
3ee2f87255
5 changed files with 35 additions and 3 deletions
|
@ -21,6 +21,7 @@ export interface ListProps {
|
||||||
connectors: FullConnectorInfo[];
|
connectors: FullConnectorInfo[];
|
||||||
connects: Connect[];
|
connects: Connect[];
|
||||||
failedConnectors: FullConnectorInfo[];
|
failedConnectors: FullConnectorInfo[];
|
||||||
|
failedTasks: number | undefined;
|
||||||
fetchConnects(clusterName: ClusterName): void;
|
fetchConnects(clusterName: ClusterName): void;
|
||||||
fetchConnectors({ clusterName }: { clusterName: ClusterName }): void;
|
fetchConnectors({ clusterName }: { clusterName: ClusterName }): void;
|
||||||
search: string;
|
search: string;
|
||||||
|
@ -32,6 +33,7 @@ const List: React.FC<ListProps> = ({
|
||||||
areConnectsFetching,
|
areConnectsFetching,
|
||||||
areConnectorsFetching,
|
areConnectorsFetching,
|
||||||
failedConnectors,
|
failedConnectors,
|
||||||
|
failedTasks,
|
||||||
fetchConnects,
|
fetchConnects,
|
||||||
fetchConnectors,
|
fetchConnectors,
|
||||||
search,
|
search,
|
||||||
|
@ -75,12 +77,19 @@ const List: React.FC<ListProps> = ({
|
||||||
{connectors.length}
|
{connectors.length}
|
||||||
</Metrics.Indicator>
|
</Metrics.Indicator>
|
||||||
<Metrics.Indicator
|
<Metrics.Indicator
|
||||||
label="Failed"
|
label="Failed Connectors"
|
||||||
title="Failed Connectors"
|
title="Failed Connectors"
|
||||||
fetching={areConnectsFetching}
|
fetching={areConnectsFetching}
|
||||||
>
|
>
|
||||||
{failedConnectors?.length}
|
{failedConnectors?.length}
|
||||||
</Metrics.Indicator>
|
</Metrics.Indicator>
|
||||||
|
<Metrics.Indicator
|
||||||
|
label="Failed Tasks"
|
||||||
|
title="Failed Tasks"
|
||||||
|
fetching={areConnectsFetching}
|
||||||
|
>
|
||||||
|
{failedTasks}
|
||||||
|
</Metrics.Indicator>
|
||||||
</Metrics.Section>
|
</Metrics.Section>
|
||||||
</Metrics.Wrapper>
|
</Metrics.Wrapper>
|
||||||
<ControlPanelWrapper hasInput>
|
<ControlPanelWrapper hasInput>
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {
|
||||||
getAreConnectorsFetching,
|
getAreConnectorsFetching,
|
||||||
getConnectorSearch,
|
getConnectorSearch,
|
||||||
getFailedConnectors,
|
getFailedConnectors,
|
||||||
|
getFailedTasks,
|
||||||
} from 'redux/reducers/connect/selectors';
|
} from 'redux/reducers/connect/selectors';
|
||||||
import List from 'components/Connect/List/List';
|
import List from 'components/Connect/List/List';
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ const mapStateToProps = (state: RootState) => ({
|
||||||
areConnectorsFetching: getAreConnectorsFetching(state),
|
areConnectorsFetching: getAreConnectorsFetching(state),
|
||||||
connects: getConnects(state),
|
connects: getConnects(state),
|
||||||
failedConnectors: getFailedConnectors(state),
|
failedConnectors: getFailedConnectors(state),
|
||||||
|
failedTasks: getFailedTasks(state),
|
||||||
connectors: getConnectors(state),
|
connectors: getConnectors(state),
|
||||||
search: getConnectorSearch(state),
|
search: getConnectorSearch(state),
|
||||||
});
|
});
|
||||||
|
|
|
@ -37,6 +37,7 @@ describe('Connectors List', () => {
|
||||||
areConnectsFetching
|
areConnectsFetching
|
||||||
connectors={[]}
|
connectors={[]}
|
||||||
failedConnectors={[]}
|
failedConnectors={[]}
|
||||||
|
failedTasks={0}
|
||||||
connects={[]}
|
connects={[]}
|
||||||
fetchConnects={fetchConnects}
|
fetchConnects={fetchConnects}
|
||||||
fetchConnectors={fetchConnectors}
|
fetchConnectors={fetchConnectors}
|
||||||
|
|
|
@ -20,6 +20,7 @@ describe('Connect selectors', () => {
|
||||||
);
|
);
|
||||||
expect(selectors.getConnectors(store.getState())).toEqual([]);
|
expect(selectors.getConnectors(store.getState())).toEqual([]);
|
||||||
expect(selectors.getFailedConnectors(store.getState())).toEqual([]);
|
expect(selectors.getFailedConnectors(store.getState())).toEqual([]);
|
||||||
|
expect(selectors.getFailedTasks(store.getState())).toEqual(0);
|
||||||
expect(selectors.getIsConnectorFetching(store.getState())).toEqual(false);
|
expect(selectors.getIsConnectorFetching(store.getState())).toEqual(false);
|
||||||
expect(selectors.getConnector(store.getState())).toEqual(null);
|
expect(selectors.getConnector(store.getState())).toEqual(null);
|
||||||
expect(selectors.getConnectorStatus(store.getState())).toEqual(undefined);
|
expect(selectors.getConnectorStatus(store.getState())).toEqual(undefined);
|
||||||
|
@ -74,6 +75,14 @@ describe('Connect selectors', () => {
|
||||||
expect(selectors.getFailedConnectors(store.getState()).length).toEqual(1);
|
expect(selectors.getFailedConnectors(store.getState()).length).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns failed tasks', () => {
|
||||||
|
store.dispatch({
|
||||||
|
type: fetchConnectors.fulfilled.type,
|
||||||
|
payload: { connectors },
|
||||||
|
});
|
||||||
|
expect(selectors.getFailedTasks(store.getState())).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
it('returns connector', () => {
|
it('returns connector', () => {
|
||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: fetchConnector.fulfilled.type,
|
type: fetchConnector.fulfilled.type,
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
import { createSelector } from '@reduxjs/toolkit';
|
import { createSelector } from '@reduxjs/toolkit';
|
||||||
import { ConnectState, RootState } from 'redux/interfaces';
|
import { ConnectState, RootState } from 'redux/interfaces';
|
||||||
import { createFetchingSelector } from 'redux/reducers/loader/selectors';
|
import { createFetchingSelector } from 'redux/reducers/loader/selectors';
|
||||||
import { ConnectorTaskStatus, ConnectorState } from 'generated-sources';
|
import {
|
||||||
|
ConnectorTaskStatus,
|
||||||
|
ConnectorState,
|
||||||
|
FullConnectorInfo,
|
||||||
|
} from 'generated-sources';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
deleteConnector,
|
deleteConnector,
|
||||||
|
@ -47,11 +51,18 @@ export const getFailedConnectors = createSelector(
|
||||||
connectState,
|
connectState,
|
||||||
({ connectors }) => {
|
({ connectors }) => {
|
||||||
return connectors.filter(
|
return connectors.filter(
|
||||||
(connector) => connector.status.state === ConnectorState.FAILED
|
(connector: FullConnectorInfo) =>
|
||||||
|
connector.status.state === ConnectorState.FAILED
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const getFailedTasks = createSelector(connectState, ({ connectors }) => {
|
||||||
|
return connectors
|
||||||
|
.map((connector: FullConnectorInfo) => connector.failedTasksCount || 0)
|
||||||
|
.reduce((acc: number, value: number) => acc + value, 0);
|
||||||
|
});
|
||||||
|
|
||||||
const getConnectorFetchingStatus = createFetchingSelector(
|
const getConnectorFetchingStatus = createFetchingSelector(
|
||||||
fetchConnector.typePrefix
|
fetchConnector.typePrefix
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue