diff --git a/kafka-ui-react-app/README.md b/kafka-ui-react-app/README.md index 43af77d4f5a..dfd8e75dfe3 100644 --- a/kafka-ui-react-app/README.md +++ b/kafka-ui-react-app/README.md @@ -1,7 +1,9 @@ # UI for Apache Kafka UI for Apache Kafka management -[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=provectus_kafka-ui_frontend&metric=alert_status)](https://sonarcloud.io/dashboard?id=provectus_kafka-ui_frontend) +[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=com.provectus%3Akafka-ui_frontend&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=com.provectus%3Akafka-ui_frontend) +[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=com.provectus%3Akafka-ui_frontend&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=com.provectus%3Akafka-ui_frontend) +[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=com.provectus%3Akafka-ui_frontend&metric=coverage)](https://sonarcloud.io/summary/new_code?id=com.provectus%3Akafka-ui_frontend) ## Table of contents - [Requirements](#requirements) diff --git a/kafka-ui-react-app/src/components/Brokers/Brokers.tsx b/kafka-ui-react-app/src/components/Brokers/Brokers.tsx index 6d20911714f..bb8f40f290f 100644 --- a/kafka-ui-react-app/src/components/Brokers/Brokers.tsx +++ b/kafka-ui-react-app/src/components/Brokers/Brokers.tsx @@ -32,7 +32,7 @@ const Brokers: React.FC = () => { const replicas = inSyncReplicasCount ?? 0 + (outOfSyncReplicasCount ?? 0); const areAllInSync = inSyncReplicasCount && replicas === inSyncReplicasCount; - + const partitionIsOffline = offlinePartitionCount && offlinePartitionCount > 0; React.useEffect(() => { dispatch(fetchClusterStats(clusterName)); dispatch(fetchBrokers(clusterName)); @@ -60,13 +60,9 @@ const Brokers: React.FC = () => { 0 - ? 'error' - : 'success' - } + alertType={partitionIsOffline ? 'error' : 'success'} > - {offlinePartitionCount && offlinePartitionCount > 0 ? ( + {partitionIsOffline ? ( {onlinePartitionCount} ) : ( onlinePartitionCount @@ -80,11 +76,9 @@ const Brokers: React.FC = () => { label="URP" title="Under replicated partitions" isAlert - alertType={ - underReplicatedPartitionCount === 0 ? 'success' : 'error' - } + alertType={!underReplicatedPartitionCount ? 'success' : 'error'} > - {underReplicatedPartitionCount === 0 ? ( + {!underReplicatedPartitionCount ? ( {underReplicatedPartitionCount} diff --git a/kafka-ui-react-app/src/components/Connect/Details/Tasks/ListItem/ListItemContainer.ts b/kafka-ui-react-app/src/components/Connect/Details/Tasks/ListItem/ListItemContainer.ts index 5cc302d0048..df16bbac130 100644 --- a/kafka-ui-react-app/src/components/Connect/Details/Tasks/ListItem/ListItemContainer.ts +++ b/kafka-ui-react-app/src/components/Connect/Details/Tasks/ListItem/ListItemContainer.ts @@ -10,7 +10,7 @@ interface OwnProps extends RouteComponentProps { task: Task; } -const mapStateToProps = (state: RootState, { task }: OwnProps) => ({ +const mapStateToProps = (_state: RootState, { task }: OwnProps) => ({ task, }); diff --git a/kafka-ui-react-app/src/components/Topics/List/List.tsx b/kafka-ui-react-app/src/components/Topics/List/List.tsx index 362010d1fc7..7431dabf633 100644 --- a/kafka-ui-react-app/src/components/Topics/List/List.tsx +++ b/kafka-ui-react-app/src/components/Topics/List/List.tsx @@ -149,6 +149,8 @@ const List: React.FC = ({ '' | 'deleteTopics' | 'purgeMessages' >(''); + const [confirmationModalText, setConfirmationModalText] = + React.useState(''); const closeConfirmationModal = () => { setConfirmationModal(''); }; @@ -157,22 +159,6 @@ const List: React.FC = ({ tableState.toggleSelection(false); }, [tableState]); - const deleteTopicsHandler = React.useCallback(() => { - deleteTopics(clusterName, Array.from(tableState.selectedIds)); - closeConfirmationModal(); - clearSelectedTopics(); - }, [clearSelectedTopics, clusterName, deleteTopics, tableState.selectedIds]); - const purgeMessagesHandler = React.useCallback(() => { - clearTopicsMessages(clusterName, Array.from(tableState.selectedIds)); - closeConfirmationModal(); - clearSelectedTopics(); - }, [ - clearSelectedTopics, - clearTopicsMessages, - clusterName, - tableState.selectedIds, - ]); - const searchHandler = React.useCallback( (searchString: string) => { setTopicsSearch(searchString); @@ -187,6 +173,23 @@ const List: React.FC = ({ }, [setTopicsSearch, history, pathname, perPage, page] ); + const deleteOrPurgeConfirmationHandler = React.useCallback(() => { + const selectedIds = Array.from(tableState.selectedIds); + if (confirmationModal === 'deleteTopics') { + deleteTopics(clusterName, selectedIds); + } else { + clearTopicsMessages(clusterName, selectedIds); + } + closeConfirmationModal(); + clearSelectedTopics(); + }, [ + confirmationModal, + clearSelectedTopics, + clusterName, + deleteTopics, + clearTopicsMessages, + tableState.selectedIds, + ]); const ActionsCell = React.memo>( ({ hovered, dataItem: { internal, cleanUpPolicy, name } }) => { @@ -306,6 +309,9 @@ const List: React.FC = ({ buttonType="secondary" onClick={() => { setConfirmationModal('deleteTopics'); + setConfirmationModalText( + 'Are you sure you want to remove selected topics?' + ); }} > Delete selected topics @@ -329,6 +335,9 @@ const List: React.FC = ({ buttonType="secondary" onClick={() => { setConfirmationModal('purgeMessages'); + setConfirmationModalText( + 'Are you sure you want to purge messages of selected topics?' + ); }} > Purge messages of selected topics @@ -337,15 +346,9 @@ const List: React.FC = ({ - {confirmationModal === 'deleteTopics' - ? 'Are you sure you want to remove selected topics?' - : 'Are you sure you want to purge messages of selected topics?'} + {confirmationModalText} )} diff --git a/kafka-ui-react-app/src/components/Topics/Topic/Details/Messages/Filters/AddEditFilterContainer.tsx b/kafka-ui-react-app/src/components/Topics/Topic/Details/Messages/Filters/AddEditFilterContainer.tsx index 8f710cb8f54..fcb0da429d1 100644 --- a/kafka-ui-react-app/src/components/Topics/Topic/Details/Messages/Filters/AddEditFilterContainer.tsx +++ b/kafka-ui-react-app/src/components/Topics/Topic/Details/Messages/Filters/AddEditFilterContainer.tsx @@ -2,12 +2,12 @@ import React from 'react'; import * as S from 'components/Topics/Topic/Details/Messages/Filters/Filters.styled'; import { InputLabel } from 'components/common/Input/InputLabel.styled'; import Input from 'components/common/Input/Input'; -import { Textarea } from 'components/common/Textbox/Textarea.styled'; import { FormProvider, Controller, useForm } from 'react-hook-form'; import { ErrorMessage } from '@hookform/error-message'; import { Button } from 'components/common/Button/Button'; import { FormError } from 'components/common/Input/Input.styled'; import { AddMessageFilters } from 'components/Topics/Topic/Details/Messages/Filters/AddFilter'; +import Editor from 'components/common/Editor/Editor'; import { yupResolver } from '@hookform/resolvers/yup'; import yup from 'lib/yupExtended'; @@ -66,8 +66,16 @@ const AddEditFilterContainer: React.FC = ({ control={control} name="code" defaultValue={inputCodeDefaultValue} - render={({ field: { onChange, ref } }) => ( -