-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEN-1793]: display source & destination errors in drawer (#1863)
- Loading branch information
1 parent
47fa3b3
commit 9d2bcf9
Showing
16 changed files
with
146 additions
and
25 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
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
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
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
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
80 changes: 80 additions & 0 deletions
80
frontend/webapp/reuseable-components/condition-details/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,80 @@ | ||
import React, { useMemo, useState } from 'react'; | ||
import Image from 'next/image'; | ||
import theme from '@/styles/theme'; | ||
import styled from 'styled-components'; | ||
import type { Condition } from '@/types'; | ||
import { BACKEND_BOOLEAN, getStatusIcon } from '@/utils'; | ||
import { ExtendIcon, FadeLoader, Text } from '@/reuseable-components'; | ||
|
||
interface Props { | ||
conditions: Condition[]; | ||
} | ||
|
||
const Container = styled.div<{ $hasErrors: boolean }>` | ||
border-radius: 24px; | ||
background-color: ${({ theme, $hasErrors }) => ($hasErrors ? theme.colors.darkest_red : theme.colors.white_opacity['004'])}; | ||
cursor: pointer; | ||
&:hover { | ||
background-color: ${({ theme, $hasErrors }) => ($hasErrors ? theme.colors.error : theme.colors.white_opacity['008'])}; | ||
} | ||
transition: background 0.3s; | ||
`; | ||
|
||
const Header = styled.div` | ||
display: flex; | ||
align-items: center; | ||
gap: 12px; | ||
padding: 12px 18px; | ||
`; | ||
|
||
const Body = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 8px; | ||
padding: 6px 18px 12px 18px; | ||
`; | ||
|
||
const Row = styled.div` | ||
display: flex; | ||
align-items: center; | ||
gap: 12px; | ||
`; | ||
|
||
export const ConditionDetails: React.FC<Props> = ({ conditions }) => { | ||
const [loading, setLoading] = useState(false); | ||
const [extend, setExtend] = useState(false); | ||
|
||
const errors = useMemo(() => conditions.filter(({ status }) => status === BACKEND_BOOLEAN.FALSE), [conditions]); | ||
const hasErrors = !!errors.length; | ||
const headerText = loading ? 'Loading...' : hasErrors ? 'Operation Failed' : 'Operation Successful'; | ||
|
||
return ( | ||
<Container onClick={() => setExtend((prev) => !prev)} $hasErrors={hasErrors}> | ||
<Header> | ||
{loading ? <FadeLoader /> : <Image src={getStatusIcon(hasErrors ? 'error' : 'success')} alt='' width={16} height={16} />} | ||
|
||
<Text color={hasErrors ? theme.text.error : theme.text.grey} size={14}> | ||
{headerText} | ||
</Text> | ||
<Text color={hasErrors ? theme.text.error_secondary : theme.text.dark_grey} size={12} family='secondary'> | ||
({hasErrors ? errors.length : conditions.length}/{conditions.length}) | ||
</Text> | ||
|
||
<ExtendIcon extend={extend} /> | ||
</Header> | ||
|
||
{extend && ( | ||
<Body> | ||
{conditions.map(({ status, message }, idx) => ( | ||
<Row key={`condition-${idx}`}> | ||
<Image src={getStatusIcon(status === BACKEND_BOOLEAN.FALSE ? 'error' : 'success')} alt='' width={14} height={14} /> | ||
<Text color={status === BACKEND_BOOLEAN.FALSE ? theme.text.error : theme.text.darker_grey} size={12}> | ||
{message} | ||
</Text> | ||
</Row> | ||
))} | ||
</Body> | ||
)} | ||
</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
24 changes: 24 additions & 0 deletions
24
frontend/webapp/reuseable-components/extend-icon/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,24 @@ | ||
import React from 'react'; | ||
import Image from 'next/image'; | ||
import styled from 'styled-components'; | ||
|
||
interface Props { | ||
extend: boolean; | ||
size?: number; | ||
align?: 'left' | 'right'; | ||
} | ||
|
||
const Icon = styled(Image)<{ $align?: Props['align'] }>` | ||
&.open { | ||
transform: rotate(180deg); | ||
} | ||
&.close { | ||
transform: rotate(0deg); | ||
} | ||
transition: transform 0.3s; | ||
margin-${({ $align }) => ($align === 'right' ? 'left' : 'right')}: auto; | ||
`; | ||
|
||
export const ExtendIcon: React.FC<Props> = ({ extend, size = 14, align = 'right' }) => { | ||
return <Icon src='/icons/common/extend-arrow.svg' alt='extend' width={size} height={size} $align={align} className={extend ? 'open' : 'close'} />; | ||
}; |
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
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
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,8 +1,9 @@ | ||
import { BACKEND_BOOLEAN } from '../constants'; | ||
import { STATUSES, type ActualDestination, type K8sActualSource } from '@/types'; | ||
|
||
export const getHealthStatus = (item: K8sActualSource | ActualDestination) => { | ||
const conditions = (item as K8sActualSource)?.instrumentedApplicationDetails?.conditions || (item as ActualDestination)?.conditions || []; | ||
const isUnhealthy = !conditions.length || !!conditions.find(({ status }) => status === 'False'); | ||
const isUnhealthy = !conditions.length || !!conditions.find(({ status }) => status === BACKEND_BOOLEAN.FALSE); | ||
|
||
return isUnhealthy ? STATUSES.UNHEALTHY : STATUSES.HEALTHY; | ||
}; |