Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: kafka - misc fix and features #6379

Merged
merged 6 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,7 @@ const checkValidityOfDetailConfigs = (
return false;
}

if (currentTab === MessagingQueueServiceDetailType.ConsumerDetails) {
return Boolean(configDetails?.topic && configDetails?.partition);
}
return Boolean(
configDetails?.group && configDetails?.topic && configDetails?.partition,
);
return Boolean(configDetails?.topic && configDetails?.partition);
}

if (selectedView === MessagingQueuesViewType.producerLatency.value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import {
MessagingQueuesPayloadProps,
} from './getConsumerLagDetails';

const INITIAL_PAGE_SIZE = 10;

// eslint-disable-next-line sonarjs/cognitive-complexity
export function getColumns(
data: MessagingQueuesPayloadProps['payload'],
Expand Down Expand Up @@ -155,8 +157,8 @@ function MessagingQueuesTable({

const paginationConfig = useMemo(
() =>
tableData?.length > 20 && {
pageSize: 20,
tableData?.length > INITIAL_PAGE_SIZE && {
pageSize: INITIAL_PAGE_SIZE,
showTotal: showPaginationItem,
showSizeChanger: false,
hideOnSinglePage: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable jsx-a11y/no-static-element-interactions */
/* eslint-disable jsx-a11y/click-events-have-key-events */
import './MessagingQueueHealthCheck.styles.scss';

import { CaretDownOutlined, LoadingOutlined } from '@ant-design/icons';
Expand All @@ -11,10 +13,20 @@ import {
Typography,
} from 'antd';
import { OnboardingStatusResponse } from 'api/messagingQueues/onboarding/getOnboardingStatus';
import { QueryParams } from 'constants/query';
import ROUTES from 'constants/routes';
import { History } from 'history';
import { Bolt, Check, OctagonAlert, X } from 'lucide-react';
import { ReactNode, useEffect, useState } from 'react';
import { useHistory } from 'react-router-dom';
import { isCloudUser } from 'utils/app';
import { v4 as uuid } from 'uuid';

import {
KAFKA_SETUP_DOC_LINK,
MessagingQueueHealthCheckService,
} from '../MessagingQueuesUtils';

interface AttributeCheckListProps {
visible: boolean;
onClose: () => void;
Expand All @@ -34,13 +46,42 @@ export enum AttributesFilters {

function ErrorTitleAndKey({
title,
parentTitle,
history,
isCloudUserVal,
errorMsg,
isLeaf,
}: {
title: string;
parentTitle: string;
isCloudUserVal: boolean;
history: History<unknown>;
errorMsg?: string;
isLeaf?: boolean;
}): TreeDataNode {
const handleRedirection = (): void => {
let link = '';

switch (parentTitle) {
case 'Consumers':
link = `${ROUTES.GET_STARTED_APPLICATION_MONITORING}?${QueryParams.getStartedSource}=kafka&${QueryParams.getStartedSourceService}=${MessagingQueueHealthCheckService.Consumers}`;
break;
case 'Producers':
link = `${ROUTES.GET_STARTED_APPLICATION_MONITORING}?${QueryParams.getStartedSource}=kafka&${QueryParams.getStartedSourceService}=${MessagingQueueHealthCheckService.Producers}`;
break;
case 'Kafka':
link = `${ROUTES.GET_STARTED_INFRASTRUCTURE_MONITORING}?${QueryParams.getStartedSource}=kafka&${QueryParams.getStartedSourceService}=${MessagingQueueHealthCheckService.Kafka}`;
break;
default:
link = '';
}

if (isCloudUserVal && !!link) {
history.push(link);
} else {
window.open(KAFKA_SETUP_DOC_LINK, '_blank');
}
};
return {
key: `${title}-key-${uuid()}`,
title: (
Expand All @@ -49,7 +90,13 @@ function ErrorTitleAndKey({
{title}
</Typography.Text>
<Tooltip title={errorMsg}>
<div className="attribute-error-warning">
<div
className="attribute-error-warning"
onClick={(e): void => {
e.preventDefault();
handleRedirection();
}}
>
<OctagonAlert size={14} />
Fix
</div>
Expand Down Expand Up @@ -98,6 +145,9 @@ function treeTitleAndKey({

function generateTreeDataNodes(
response: OnboardingStatusResponse['data'],
parentTitle: string,
isCloudUserVal: boolean,
history: History<unknown>,
): TreeDataNode[] {
return response
.map((item) => {
Expand All @@ -109,6 +159,9 @@ function generateTreeDataNodes(
return ErrorTitleAndKey({
title: item.attribute,
errorMsg: item.error_message || '',
parentTitle,
history,
isCloudUserVal,
});
}
}
Expand All @@ -129,6 +182,8 @@ function AttributeCheckList({
const handleFilterChange = (value: AttributesFilters): void => {
setFilter(value);
};
const isCloudUserVal = isCloudUser();
const history = useHistory();

useEffect(() => {
const filteredData = onboardingStatusResponses.map((response) => {
Expand All @@ -137,6 +192,9 @@ function AttributeCheckList({
title: response.title,
errorMsg: response.errorMsg,
isLeaf: true,
parentTitle: response.title,
history,
isCloudUserVal,
});
}
let filteredData = response.data;
Expand All @@ -149,11 +207,17 @@ function AttributeCheckList({

return {
...treeTitleAndKey({ title: response.title }),
children: generateTreeDataNodes(filteredData),
children: generateTreeDataNodes(
filteredData,
response.title,
isCloudUserVal,
history,
),
};
});

setTreeData(filteredData);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [filter, onboardingStatusResponses]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@

.ant-tree {
.ant-tree-title {
cursor: default;

.attribute-error-title {
display: flex;
align-items: center;
Expand All @@ -88,6 +90,7 @@
font-style: normal;
font-weight: 400;
line-height: 16px;
cursor: pointer;
}
}

Expand Down
28 changes: 11 additions & 17 deletions frontend/src/pages/MessagingQueues/MessagingQueues.styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,22 @@

border-bottom: 1px solid var(--bg-slate-500);

.header-content {
.header-config {
display: flex;
gap: 12px;
align-items: center;

.header-config {
display: flex;
gap: 10px;
align-items: center;
.messaging-queue-options {
.ant-select-selector {
display: flex;
height: 32px;
padding: 6px 6px 6px 8px;
align-items: center;
gap: 4px;

.messaging-queue-options {
.ant-select-selector {
display: flex;
height: 32px;
padding: 6px 6px 6px 8px;
align-items: center;
gap: 4px;

border-radius: 2px;
border: 1px solid var(--bg-slate-400);
background: var(--bg-ink-300);
}
border-radius: 2px;
border: 1px solid var(--bg-slate-400);
background: var(--bg-ink-300);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/MessagingQueues/MessagingQueues.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ function MessagingQueues(): JSX.Element {
{t('breadcrumb')}
</div>
<div className="messaging-header">
<div className="header-content">
<div className="header-config">{t('header')}</div>
<div className="header-config">
{t('header')} /
<MessagingQueueHealthCheck
serviceToInclude={[
MessagingQueueHealthCheckService.Consumers,
Expand Down
Loading