/** * 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 as unknown as Record)?.endpoints as | { insecure?: string[]; secure?: string[] } | undefined; return (
{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)} /> )} ); }