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: Minor bug fixes on detected by cloud deprecations #1430

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
26 changes: 21 additions & 5 deletions assets/src/components/cd/clusters/ClusterUpgradeFlyover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import {
import {
ClustersRowFragment,
UpgradeInsight,
UpgradeInsightStatus,
useRuntimeServicesQuery,
} from 'generated/graphql'
import isEmpty from 'lodash/isEmpty'
import React, { useRef, useState } from 'react'
import styled, { useTheme } from 'styled-components'

import { IconProps } from '@pluralsh/design-system/dist/components/icons/createIcon'

import { Row } from '@tanstack/react-table'
import { ChipProps } from '@pluralsh/design-system/dist/components/Chip'

import { GqlError } from '../../utils/Alert'

Expand All @@ -45,17 +45,26 @@ export enum DeprecationType {
CloudProvider = 'cloudProvider',
}

function DeprecationCountChip({ count }: { count: number }) {
function DeprecationCountChip({
count,
...props
}: { count: number } & ChipProps) {
return (
<Chip
size="small"
severity={count === 0 ? 'neutral' : 'warning'}
{...props}
>
{count}
</Chip>
)
}

const statesWithIssues = [
UpgradeInsightStatus.Warning,
UpgradeInsightStatus.Failed,
]

function FlyoverContent({ open, cluster, refetch }) {
const theme = useTheme()
const tabStateRef = useRef<any>(null)
Expand All @@ -78,6 +87,10 @@ function FlyoverContent({ open, cluster, refetch }) {
const apiDeprecations = data?.cluster?.apiDeprecations
const upgradeInsights = data?.cluster?.upgradeInsights

const upgradeIssues = upgradeInsights?.filter(
(i) => i?.status && statesWithIssues.includes(i.status)
)

return (
<div
css={{
Expand Down Expand Up @@ -161,11 +174,14 @@ function FlyoverContent({ open, cluster, refetch }) {
}}
css={{ display: 'flex', flexGrow: 1 }}
>
{!isEmpty(upgradeInsights) && (
{!isEmpty(upgradeIssues) && (
<WarningIcon color="icon-warning" />
)}
Detected by Cloud Provider
<DeprecationCountChip count={upgradeInsights?.length ?? 0} />
<DeprecationCountChip
count={upgradeInsights?.length ?? 0}
severity={isEmpty(upgradeIssues) ? 'neutral' : 'warning'}
/>
</Tab>
</TabList>
</div>
Expand Down
25 changes: 19 additions & 6 deletions assets/src/components/cd/clusters/UpgradeInsights.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,13 @@ export function UpgradeInsightExpansionPanel({
paddingTop: theme.spacing.xsmall,
}}
>
<div>
<div
css={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
}}
>
<div
css={{
...theme.partials.text.body2Bold,
Expand All @@ -146,11 +152,16 @@ export function UpgradeInsightExpansionPanel({
color: theme.colors['text-light'],
}}
>
{!!replacement && <>Replaced with: {replacement}</>}
{!!removedIn && <>Removed</>}
{!!replacement && <div>Replaced with: {replacement}</div>}
</div>
</div>
<div>
<div
css={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
}}
>
<div css={{ display: 'flex', justifyContent: 'end' }}>
<UpgradeInsightStatusChip
status={status}
Expand All @@ -165,8 +176,10 @@ export function UpgradeInsightExpansionPanel({
textAlign: 'right',
}}
>
{replacedIn && <>Replacement version: {replacedIn}</>}
{removedIn && <>Removal version: {removedIn}</>}
{replacedIn && (
<div>Replacement version: {replacedIn}</div>
)}
{removedIn && <div>Removal version: {removedIn}</div>}
</div>
</div>
</div>
Expand Down
Loading