mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
refactor(kube/volumes): migrate to react [EE-4695] (#10987)
This commit is contained in:
parent
2b53bebcb3
commit
da615afc92
24 changed files with 347 additions and 397 deletions
49
app/react/kubernetes/volumes/ListView/columns.name.tsx
Normal file
49
app/react/kubernetes/volumes/ListView/columns.name.tsx
Normal file
|
@ -0,0 +1,49 @@
|
|||
import { CellContext } from '@tanstack/react-table';
|
||||
|
||||
import KubernetesVolumeHelper from '@/kubernetes/helpers/volumeHelper';
|
||||
import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
|
||||
|
||||
import { Link } from '@@/Link';
|
||||
import { SystemBadge } from '@@/Badge/SystemBadge';
|
||||
import { ExternalBadge } from '@@/Badge/ExternalBadge';
|
||||
import { UnusedBadge } from '@@/Badge/UnusedBadge';
|
||||
|
||||
import { useNamespacesQuery } from '../../namespaces/queries/useNamespacesQuery';
|
||||
|
||||
import { VolumeViewModel } from './types';
|
||||
import { helper } from './columns.helper';
|
||||
|
||||
export const name = helper.accessor('PersistentVolumeClaim.Name', {
|
||||
header: 'Name',
|
||||
cell: NameCell,
|
||||
});
|
||||
|
||||
export function NameCell({
|
||||
row: { original: item },
|
||||
}: CellContext<VolumeViewModel, string>) {
|
||||
const envId = useEnvironmentId();
|
||||
const namespaceListQuery = useNamespacesQuery(envId);
|
||||
const isSystem =
|
||||
namespaceListQuery.data?.[item.ResourcePool.Namespace.Name].IsSystem;
|
||||
return (
|
||||
<>
|
||||
<Link
|
||||
to="kubernetes.volumes.volume"
|
||||
params={{
|
||||
namespace: item.ResourcePool.Namespace.Name,
|
||||
name: item.PersistentVolumeClaim.Name,
|
||||
}}
|
||||
>
|
||||
{item.PersistentVolumeClaim.Name}
|
||||
</Link>
|
||||
{isSystem ? (
|
||||
<SystemBadge />
|
||||
) : (
|
||||
<>
|
||||
{KubernetesVolumeHelper.isExternalVolume(item) && <ExternalBadge />}
|
||||
{!KubernetesVolumeHelper.isUsed(item) && <UnusedBadge />}
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue