-
-
Notifications
You must be signed in to change notification settings - Fork 192
FE: Show connector-level trace when status is FAILED #1319
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
base: main
Are you sure you want to change the base?
Changes from all commits
76ca5b4
5425423
63c2072
275ff90
a3777d2
a461b3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import styled, { css } from 'styled-components'; | ||
|
|
||
| export const ModalOverlay = styled.div` | ||
| position: fixed; | ||
| top: 0; | ||
| left: 0; | ||
| right: 0; | ||
| bottom: 0; | ||
| background-color: ${({ theme }) => theme.modal.overlay}; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| z-index: 1000; | ||
| `; | ||
|
|
||
| export const ModalContent = styled.div( | ||
| ({ theme: { modal } }) => css` | ||
| background-color: ${modal.backgroundColor}; | ||
| color: ${modal.color}; | ||
| border-radius: 8px; | ||
| padding: 24px; | ||
| max-width: 65vw; | ||
| max-height: 80vh; | ||
| overflow: auto; | ||
| position: relative; | ||
| border: 1px solid ${modal.border.contrast}; | ||
| box-shadow: 0 4px 20px ${modal.shadow}; | ||
| ` | ||
| ); | ||
|
|
||
| export const ModalHeader = styled.div( | ||
| ({ theme: { modal } }) => css` | ||
| display: flex; | ||
| justify-content: space-between; | ||
| align-items: center; | ||
| margin-bottom: 16px; | ||
| border-bottom: 1px solid ${modal.border.bottom}; | ||
| padding-bottom: 12px; | ||
| ` | ||
| ); | ||
|
|
||
| export const ModalTitle = styled.h3` | ||
| margin: 0; | ||
| font-size: 18px; | ||
| font-weight: 600; | ||
| `; | ||
|
|
||
| export const WorkerInfo = styled.p( | ||
| ({ theme: { modal } }) => css` | ||
| margin: 4px 0 0 0; | ||
| font-size: 14px; | ||
| color: ${modal.contentColor}; | ||
| ` | ||
| ); | ||
|
|
||
| export const TraceContent = styled.div( | ||
| ({ theme: { modal } }) => css` | ||
| background-color: ${modal.border.contrast}; | ||
| padding: 16px; | ||
| border-radius: 6px; | ||
| font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; | ||
| font-size: 12px; | ||
| color: ${modal.color}; | ||
| border: 1px solid ${modal.border.contrast}; | ||
| max-height: 400px; | ||
| overflow-y: auto; | ||
| white-space: pre-wrap; | ||
| word-break: break-word; | ||
| ` | ||
| ); | ||
|
|
||
| export const ModalFooter = styled.div( | ||
| ({ theme: { modal } }) => css` | ||
| margin-top: 16px; | ||
| padding-top: 12px; | ||
| border-top: 1px solid ${modal.border.top}; | ||
| text-align: center; | ||
| display: flex; | ||
| justify-content: center; | ||
| ` | ||
| ); | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,15 +1,19 @@ | ||||||||||||||||||||||
| import React from 'react'; | ||||||||||||||||||||||
| import React, { useState } from 'react'; | ||||||||||||||||||||||
| import * as C from 'components/common/Tag/Tag.styled'; | ||||||||||||||||||||||
| import * as Metrics from 'components/common/Metrics'; | ||||||||||||||||||||||
| import { Button } from 'components/common/Button/Button'; | ||||||||||||||||||||||
| import getTagColor from 'components/common/Tag/getTagColor'; | ||||||||||||||||||||||
| import { RouterParamsClusterConnectConnector } from 'lib/paths'; | ||||||||||||||||||||||
| import useAppParams from 'lib/hooks/useAppParams'; | ||||||||||||||||||||||
| import { useConnector, useConnectorTasks } from 'lib/hooks/api/kafkaConnect'; | ||||||||||||||||||||||
| import { ConnectorState } from 'generated-sources'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import getTaskMetrics from './getTaskMetrics'; | ||||||||||||||||||||||
| import * as S from './Overview.styled'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const Overview: React.FC = () => { | ||||||||||||||||||||||
| const routerProps = useAppParams<RouterParamsClusterConnectConnector>(); | ||||||||||||||||||||||
| const [showTraceModal, setShowTraceModal] = useState(false); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const { data: connector } = useConnector(routerProps); | ||||||||||||||||||||||
| const { data: tasks } = useConnectorTasks(routerProps); | ||||||||||||||||||||||
|
|
@@ -20,35 +24,90 @@ const Overview: React.FC = () => { | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| const { running, failed } = getTaskMetrics(tasks); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const hasTraceInfo = connector.status.trace; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const handleStateClick = () => { | ||||||||||||||||||||||
| if (connector.status.state === ConnectorState.FAILED && hasTraceInfo) { | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like will be better to move this condition into separate helper. Something like
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like will be better to move this condition into separate helper. Something like const canShowTrace = (connector: Connector) =>
connector.status.state === ConnectorState.FAILED && !!connector.status.trace;And use it here firstly const handleStateClick = () => {
if (canShowTrace(connector)) {
setShowTraceModal(true);
}
}; |
||||||||||||||||||||||
| setShowTraceModal(true); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return ( | ||||||||||||||||||||||
| <Metrics.Wrapper> | ||||||||||||||||||||||
| <Metrics.Section> | ||||||||||||||||||||||
| {connector.status?.workerId && ( | ||||||||||||||||||||||
| <Metrics.Indicator label="Worker"> | ||||||||||||||||||||||
| {connector.status.workerId} | ||||||||||||||||||||||
| <> | ||||||||||||||||||||||
| <Metrics.Wrapper> | ||||||||||||||||||||||
| <Metrics.Section> | ||||||||||||||||||||||
| {connector.status?.workerId && ( | ||||||||||||||||||||||
| <Metrics.Indicator label="Worker"> | ||||||||||||||||||||||
| {connector.status.workerId} | ||||||||||||||||||||||
| </Metrics.Indicator> | ||||||||||||||||||||||
| )} | ||||||||||||||||||||||
| <Metrics.Indicator label="Type">{connector.type}</Metrics.Indicator> | ||||||||||||||||||||||
| {connector.config['connector.class'] && ( | ||||||||||||||||||||||
| <Metrics.Indicator label="Class"> | ||||||||||||||||||||||
| {connector.config['connector.class']} | ||||||||||||||||||||||
| </Metrics.Indicator> | ||||||||||||||||||||||
| )} | ||||||||||||||||||||||
| <Metrics.Indicator label="State"> | ||||||||||||||||||||||
| <C.Tag | ||||||||||||||||||||||
| color={getTagColor(connector.status.state)} | ||||||||||||||||||||||
| style={{ | ||||||||||||||||||||||
| cursor: | ||||||||||||||||||||||
| connector.status.state === ConnectorState.FAILED && | ||||||||||||||||||||||
| hasTraceInfo | ||||||||||||||||||||||
| ? 'pointer' | ||||||||||||||||||||||
| : 'default', | ||||||||||||||||||||||
| }} | ||||||||||||||||||||||
|
Comment on lines
+53
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here instead of inline style - create an optional prop <C.Tag
color={getTagColor(connector.status.state)}
clickable={canShowTrace(connector)}
onClick={handleStateClick}
>
{connector.status.state}
</C.Tag> |
||||||||||||||||||||||
| onClick={handleStateClick} | ||||||||||||||||||||||
| > | ||||||||||||||||||||||
| {connector.status.state} | ||||||||||||||||||||||
| </C.Tag> | ||||||||||||||||||||||
| </Metrics.Indicator> | ||||||||||||||||||||||
| )} | ||||||||||||||||||||||
| <Metrics.Indicator label="Type">{connector.type}</Metrics.Indicator> | ||||||||||||||||||||||
| {connector.config['connector.class'] && ( | ||||||||||||||||||||||
| <Metrics.Indicator label="Class"> | ||||||||||||||||||||||
| {connector.config['connector.class']} | ||||||||||||||||||||||
| <Metrics.Indicator label="Tasks Running">{running}</Metrics.Indicator> | ||||||||||||||||||||||
| <Metrics.Indicator | ||||||||||||||||||||||
| label="Tasks Failed" | ||||||||||||||||||||||
| isAlert | ||||||||||||||||||||||
| alertType={failed > 0 ? 'error' : 'success'} | ||||||||||||||||||||||
| > | ||||||||||||||||||||||
| {failed} | ||||||||||||||||||||||
| </Metrics.Indicator> | ||||||||||||||||||||||
| )} | ||||||||||||||||||||||
| <Metrics.Indicator label="State"> | ||||||||||||||||||||||
| <C.Tag color={getTagColor(connector.status.state)}> | ||||||||||||||||||||||
| {connector.status.state} | ||||||||||||||||||||||
| </C.Tag> | ||||||||||||||||||||||
| </Metrics.Indicator> | ||||||||||||||||||||||
| <Metrics.Indicator label="Tasks Running">{running}</Metrics.Indicator> | ||||||||||||||||||||||
| <Metrics.Indicator | ||||||||||||||||||||||
| label="Tasks Failed" | ||||||||||||||||||||||
| isAlert | ||||||||||||||||||||||
| alertType={failed > 0 ? 'error' : 'success'} | ||||||||||||||||||||||
| > | ||||||||||||||||||||||
| {failed} | ||||||||||||||||||||||
| </Metrics.Indicator> | ||||||||||||||||||||||
| </Metrics.Section> | ||||||||||||||||||||||
| </Metrics.Wrapper> | ||||||||||||||||||||||
| </Metrics.Section> | ||||||||||||||||||||||
| </Metrics.Wrapper> | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| {showTraceModal && ( | ||||||||||||||||||||||
| <S.ModalOverlay onClick={() => setShowTraceModal(false)}> | ||||||||||||||||||||||
| <S.ModalContent | ||||||||||||||||||||||
| onClick={(e: React.MouseEvent) => e.stopPropagation()} | ||||||||||||||||||||||
| > | ||||||||||||||||||||||
| <S.ModalHeader> | ||||||||||||||||||||||
| <div> | ||||||||||||||||||||||
| <S.ModalTitle>Connector Error Details</S.ModalTitle> | ||||||||||||||||||||||
| {connector.status.workerId && ( | ||||||||||||||||||||||
| <S.WorkerInfo> | ||||||||||||||||||||||
| Worker: {connector.status.workerId} | ||||||||||||||||||||||
| </S.WorkerInfo> | ||||||||||||||||||||||
| )} | ||||||||||||||||||||||
| </div> | ||||||||||||||||||||||
| </S.ModalHeader> | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| <S.TraceContent> | ||||||||||||||||||||||
| {connector.status.trace ? ( | ||||||||||||||||||||||
| <div>{connector.status.trace}</div> | ||||||||||||||||||||||
| ) : null} | ||||||||||||||||||||||
| </S.TraceContent> | ||||||||||||||||||||||
|
Comment on lines
+92
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| <S.ModalFooter> | ||||||||||||||||||||||
| <Button | ||||||||||||||||||||||
| buttonType="primary" | ||||||||||||||||||||||
| buttonSize="M" | ||||||||||||||||||||||
| onClick={() => setShowTraceModal(false)} | ||||||||||||||||||||||
| > | ||||||||||||||||||||||
| Close | ||||||||||||||||||||||
| </Button> | ||||||||||||||||||||||
| </S.ModalFooter> | ||||||||||||||||||||||
| </S.ModalContent> | ||||||||||||||||||||||
| </S.ModalOverlay> | ||||||||||||||||||||||
| )} | ||||||||||||||||||||||
| </> | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could create reusable component
Modalincomponents/common?You are already have everything to do it and I think that there will be a lot of another cases where
kafbat/uiwill needModalcomponent.