/**
* BlockPoolsPage — lists CephBlockPool resources.
*/
import {
Loader,
NameValueTable,
SectionBox,
SectionHeader,
SimpleTable,
StatusLabel,
} from '@kinvolk/headlamp-plugin/lib/CommonComponents';
import React, { useState } from 'react';
import { CephBlockPool, formatAge, phaseToStatus } from '../api/k8s';
import { useRookCephContext } from '../api/RookCephDataContext';
function BlockPoolDetail({ pool, onClose }: { pool: CephBlockPool; onClose: () => void }) {
return (
{
if (e.key === 'Escape') onClose();
}}
style={{
position: 'fixed',
top: 0,
right: 0,
bottom: 0,
width: '480px',
backgroundColor: 'var(--mui-palette-background-paper, #fff)',
boxShadow: '-4px 0 16px rgba(0,0,0,0.15)',
zIndex: 1300,
overflowY: 'auto',
padding: '24px',
}}
>
{pool.metadata.name}
{pool.status?.phase ?? 'Unknown'}
),
},
{ name: 'Age', value: formatAge(pool.metadata.creationTimestamp) },
]}
/>
{pool.spec?.erasureCoded && (
)}
{pool.status?.info && Object.keys(pool.status.info).length > 0 && (
({ name: k, value: v }))}
/>
)}
);
}
export default function BlockPoolsPage() {
const { blockPools, loading, error } = useRookCephContext();
const [selected, setSelected] = useState(null);
if (loading) return ;
return (
<>
{error && (
{error} }]}
/>
)}
{blockPools.length === 0 ? (
) : (
(
),
},
{
label: 'Phase',
getter: (p: CephBlockPool) => (
{p.status?.phase ?? 'Unknown'}
),
},
{
label: 'Replicas',
getter: (p: CephBlockPool) => String(p.spec?.replicated?.size ?? '—'),
},
{
label: 'Failure Domain',
getter: (p: CephBlockPool) => p.spec?.failureDomain ?? '—',
},
{
label: 'Mirroring',
getter: (p: CephBlockPool) => (p.spec?.mirroring?.enabled ? 'Enabled' : 'Disabled'),
},
{
label: 'Age',
getter: (p: CephBlockPool) => formatAge(p.metadata.creationTimestamp),
},
]}
data={blockPools}
/>
)}
{selected && (
<>
setSelected(null)}
/>
setSelected(null)} />
>
)}
>
);
}