Skip to content

Commit

Permalink
update pods
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Mar 25, 2024
1 parent 8281202 commit 499bb74
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 26 deletions.
29 changes: 5 additions & 24 deletions assets/src/components/kubernetes/workloads/Pods.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { createColumnHelper } from '@tanstack/react-table'
import { useMemo } from 'react'

import { Chip, Tooltip, WrapWithIf } from '@pluralsh/design-system'

import {
Pod_PodList as PodListT,
Pod_Pod as PodT,
Expand All @@ -13,7 +11,7 @@ import {
import { useDefaultColumns } from '../utils'
import { ResourceList } from '../ResourceList'

import { podStatusToSeverity } from './utils'
import { PodStatusChip } from './utils'

const columnHelper = createColumnHelper<PodT>()

Expand Down Expand Up @@ -49,29 +47,12 @@ const colStatus = columnHelper.accessor((pod) => pod, {
enableSorting: true,
cell: ({ getValue }) => {
const { status, warnings } = getValue()
let severity = podStatusToSeverity[status] ?? 'neutral'

if (warnings?.length > 0) {
severity = 'danger'
}

return (
<WrapWithIf
condition={warnings?.length > 0}
wrapper={
<Tooltip
label={warnings?.map((ev) => ev?.message)?.join(', ')}
placement="bottom"
/>
}
>
<Chip
size="small"
severity={severity}
>
{status}
</Chip>
</WrapWithIf>
<PodStatusChip
status={status}
warnings={warnings}
/>
)
},
})
Expand Down
39 changes: 37 additions & 2 deletions assets/src/components/kubernetes/workloads/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Chip } from '@pluralsh/design-system'
import { Chip, Tooltip, WrapWithIf } from '@pluralsh/design-system'

export const podStatusToSeverity = {
import { Common_Event, Maybe } from '../../../generated/graphql-kubernetes'

Check failure on line 3 in assets/src/components/kubernetes/workloads/utils.tsx

View workflow job for this annotation

GitHub Actions / Lint

Identifier 'Common_Event' is not in camel case

const podStatusSeverity = {
Running: 'success',
Completed: 'info',
Succeeded: 'info',
Expand All @@ -24,3 +26,36 @@ export function CronJobSuspendChip({
</Chip>
)
}

export function PodStatusChip({
status,
warnings,
}: {
status: string
warnings: Maybe<Common_Event>[]

Check failure on line 35 in assets/src/components/kubernetes/workloads/utils.tsx

View workflow job for this annotation

GitHub Actions / Lint

Identifier 'Common_Event' is not in camel case
}) {
let severity = podStatusSeverity[status] ?? 'neutral'

if (warnings?.length > 0) {
severity = 'danger'
}

return (
<WrapWithIf
condition={warnings?.length > 0}
wrapper={
<Tooltip
label={warnings?.map((ev) => ev?.message)?.join(', ')}
placement="bottom"
/>
}
>
<Chip
size="small"
severity={severity}
>
{status}
</Chip>
</WrapWithIf>
)
}

0 comments on commit 499bb74

Please sign in to comment.