Skip to content

Commit

Permalink
fix: properly cache-and-network on k8s dashboard resource lists (#1125)
Browse files Browse the repository at this point in the history
  • Loading branch information
floreks authored Jul 1, 2024
1 parent cdca98b commit 37250c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 9 additions & 4 deletions assets/src/components/kubernetes/common/ResourceList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export function ResourceList<
client: KubernetesClient(cluster?.id ?? ''),
skip: !cluster,
pollInterval: 30_000,
fetchPolicy: 'cache-and-network',
variables: {
filterBy: `name,${filter}`,
sortBy,
Expand All @@ -125,24 +126,28 @@ export function ResourceList<
})

const resourceList = data?.[queryName] as TResourceList
const isLoading = useMemo(
() => loading && !resourceList,
[loading, resourceList]
)
const items = useMemo(
() =>
loading
isLoading
? Array(SKELETON_ITEMS).fill({})
: (resourceList?.[itemsKey] as Array<TResource>) ?? [],
[itemsKey, loading, resourceList]
[isLoading, itemsKey, resourceList]
)
const { page, hasNextPage } = usePageInfo(items, resourceList?.listMeta)

const columnsData = useMemo(
() =>
loading
isLoading
? columns.map((col) => ({
...col,
cell: <Skeleton />,
}))
: columns,
[columns, loading]
[isLoading, columns]
)

const fetchNextPage = useCallback(() => {
Expand Down
4 changes: 0 additions & 4 deletions assets/src/components/kubernetes/workloads/Pods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Tooltip,
useSetBreadcrumbs,
} from '@pluralsh/design-system'

import { filesize } from 'filesize'

import {
Expand All @@ -26,11 +25,8 @@ import {
import { useCluster } from '../Cluster'
import { ContainerStatuses } from '../../cluster/ContainerStatuses'
import { ContainerStatusT } from '../../cluster/pods/PodsList'

import { Kind } from '../common/types'

import ResourceLink from '../common/ResourceLink'

import { UsageText } from '../../cluster/TableElements'

import { WorkloadImages, toReadiness } from './utils'
Expand Down

0 comments on commit 37250c3

Please sign in to comment.