-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK-922] feat: sources condition (#1221)
add a new component in the sources page that describes the status of the instrumentation
- Loading branch information
1 parent
dc105ce
commit cf194fd
Showing
14 changed files
with
270 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from 'react'; | ||
import { GreenCheck, RedError } from '@/assets/icons/app'; | ||
import styled from 'styled-components'; | ||
import { KeyvalText } from '@/design.system'; | ||
|
||
const Container = styled.div` | ||
display: inline-block; | ||
position: relative; | ||
`; | ||
|
||
const StatusIcon = styled.div` | ||
font-size: 24px; | ||
cursor: pointer; | ||
`; | ||
|
||
const Tooltip = styled.div` | ||
visibility: hidden; | ||
width: max-content; | ||
background-color: black; | ||
color: #fff; | ||
text-align: center; | ||
border-radius: 5px; | ||
padding: 8px; | ||
position: absolute; | ||
z-index: 1; | ||
bottom: 100%; /* Position above the icon */ | ||
left: 50%; | ||
transform: translateX(-50%); | ||
opacity: 0; | ||
transition: opacity 0.3s; | ||
${Container}:hover & { | ||
visibility: visible; | ||
opacity: 1; | ||
} | ||
`; | ||
|
||
export const ConditionCheck = ({ conditions }) => { | ||
const healthyCount = conditions.filter( | ||
(condition) => condition.status === 'True' | ||
).length; | ||
const totalCount = conditions.length; | ||
const allHealthy = healthyCount === totalCount; | ||
|
||
return ( | ||
<Container> | ||
<StatusIcon>{allHealthy ? <GreenCheck /> : <RedError />}</StatusIcon> | ||
<Tooltip> | ||
<KeyvalText | ||
size={12} | ||
>{`${healthyCount}/${totalCount} checks OK`}</KeyvalText> | ||
</Tooltip> | ||
</Container> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './multi.checkbox'; | ||
export * from './conditions.check'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
frontend/webapp/design.system/condition.alert/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import theme from '@/styles/palette'; | ||
import { Condition } from '@/types'; | ||
import { KeyvalText } from '../text/text'; | ||
import { GreenCheck, RedError } from '@/assets/icons/app'; | ||
|
||
interface ConditionAlertProps { | ||
conditions: Condition[] | undefined; | ||
title?: string; | ||
} | ||
|
||
const ConditionAlertContainer = styled.div` | ||
border: 1px solid ${theme.colors.blue_grey}; | ||
border-radius: 8px; | ||
padding: 10px; | ||
margin-top: 8px; | ||
`; | ||
|
||
const ConditionItem = styled.div` | ||
padding: 10px; | ||
`; | ||
|
||
const ConditionIconContainer = styled.div``; | ||
|
||
const ConditionDetails = styled.div` | ||
display: flex; | ||
flex-wrap: wrap; | ||
margin-top: 4px; | ||
`; | ||
|
||
const ConditionSeparator = styled.div` | ||
width: 2px; | ||
height: 30px; | ||
border-radius: 20px; | ||
background-color: ${theme.colors.blue_grey}; | ||
margin-left: 10px; | ||
`; | ||
|
||
const IconWrapper = styled.div<{ bgColor: string }>` | ||
width: 32px; | ||
height: 32px; | ||
border-radius: 20px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
background-color: ${({ bgColor }) => bgColor}; | ||
`; | ||
|
||
const InnerIconWrapper = styled.div<{ borderColor: string }>` | ||
width: 16px; | ||
height: 16px; | ||
border-radius: 20px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
border: 2px solid ${({ borderColor }) => borderColor}; | ||
`; | ||
|
||
export const Conditions: React.FC<ConditionAlertProps> = ({ | ||
conditions, | ||
title = 'Status', | ||
}) => { | ||
const getSuccessIcon = () => ( | ||
<IconWrapper bgColor="#3fb94f40"> | ||
<InnerIconWrapper borderColor="#3fb950"> | ||
<GreenCheck style={{ width: 10, height: 10 }} /> | ||
</InnerIconWrapper> | ||
</IconWrapper> | ||
); | ||
|
||
const getErrorIcon = () => ( | ||
<IconWrapper bgColor="#f8524952"> | ||
<InnerIconWrapper borderColor="#f85249"> | ||
<RedError | ||
style={{ width: 10, height: 10, marginLeft: 2, marginBottom: 2 }} | ||
/> | ||
</InnerIconWrapper> | ||
</IconWrapper> | ||
); | ||
|
||
return conditions ? ( | ||
<div> | ||
<KeyvalText size={14} weight={600}> | ||
{title} | ||
</KeyvalText> | ||
<ConditionAlertContainer> | ||
{conditions.map((condition, index) => ( | ||
<ConditionItem key={index}> | ||
<div style={{ display: 'flex', gap: '8px' }}> | ||
<ConditionIconContainer> | ||
{condition.status === 'True' | ||
? getSuccessIcon() | ||
: getErrorIcon()} | ||
</ConditionIconContainer> | ||
<div> | ||
<KeyvalText size={14}>{condition.message}</KeyvalText> | ||
<ConditionDetails> | ||
<KeyvalText | ||
style={{ marginRight: '8px' }} | ||
color={theme.text.grey} | ||
size={12} | ||
> | ||
{condition.type} | ||
</KeyvalText> | ||
<KeyvalText color={theme.text.grey} size={12}> | ||
{condition.last_transition_time} | ||
</KeyvalText> | ||
</ConditionDetails> | ||
</div> | ||
</div> | ||
{index !== conditions.length - 1 && <ConditionSeparator />} | ||
</ConditionItem> | ||
))} | ||
</ConditionAlertContainer> | ||
</div> | ||
) : null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.