/**
* ObjectStoresPage — lists CephObjectStore resources.
*/
import {
Loader,
NameValueTable,
SectionBox,
SectionHeader,
SimpleTable,
StatusLabel,
} from '@kinvolk/headlamp-plugin/lib/CommonComponents';
import React, { useState } from 'react';
import { CephObjectStore, formatAge, phaseToStatus } from '../api/k8s';
import { useRookCephContext } from '../api/RookCephDataContext';
function ObjectStoreDetail({ store, onClose }: { store: CephObjectStore; onClose: () => void }) {
const endpoints = store.status?.endpoints;
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',
}}
>
{store.metadata.name}
{store.status?.phase ?? 'Unknown'}
),
},
{ name: 'Age', value: formatAge(store.metadata.creationTimestamp) },
]}
/>
{endpoints?.insecure?.length || endpoints?.secure?.length ? (
) : null}
{store.status?.info && Object.keys(store.status.info).length > 0 && (
({ name: k, value: v }))}
/>
)}
);
}
export default function ObjectStoresPage() {
const { objectStores, loading, error } = useRookCephContext();
const [selected, setSelected] = useState(null);
if (loading) return ;
return (
<>
{error && (
{error} }]}
/>
)}
{objectStores.length === 0 ? (
) : (
(
),
},
{
label: 'Phase',
getter: (o: CephObjectStore) => (
{o.status?.phase ?? 'Unknown'}
),
},
{
label: 'Gateway Port',
getter: (o: CephObjectStore) => String(o.spec?.gateway?.port ?? '—'),
},
{
label: 'Instances',
getter: (o: CephObjectStore) => String(o.spec?.gateway?.instances ?? '—'),
},
{
label: 'Age',
getter: (o: CephObjectStore) => formatAge(o.metadata.creationTimestamp),
},
]}
data={objectStores}
/>
)}
{selected && (
<>
setSelected(null)}
/>
setSelected(null)} />
>
)}
>
);
}