All files / kernel-ui/src/components SubclustersTable.tsx

100% Statements 6/6
100% Branches 4/4
100% Functions 2/2
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45                3x               8x   8x 3x             5x     5x                              
import { Box, Text as TextComponent } from '@metamask/design-system-react';
 
import { SubclusterAccordion } from './SubclusterAccordion.tsx';
import { useVats } from '../hooks/useVats.ts';
 
/**
 * @returns A set of accordion-style tables for active vats, grouped by subcluster.
 */
export const SubclustersTable: React.FC = () => {
  const {
    subclusters,
    pingVat,
    restartVat,
    terminateVat,
    terminateSubcluster,
    reloadSubcluster,
  } = useVats();
 
  if (!subclusters || subclusters.length === 0) {
    return (
      <TextComponent className="text-warning-inverse text-s-body-md leading-s-body-md tracking-s-body-md md:text-l-body-md md:leading-l-body-md md:tracking-l-body-md font-regular bg-warning-default p-4 font-default rounded-lg mb-4">
        No subclusters are currently active.
      </TextComponent>
    );
  }
 
  return (
    <Box className="mb-4">
      {subclusters.map((subcluster) => (
        <SubclusterAccordion
          key={subcluster.id}
          id={subcluster.id}
          vats={subcluster.vatRecords}
          config={subcluster.config}
          onPingVat={pingVat}
          onRestartVat={restartVat}
          onTerminateVat={terminateVat}
          onTerminateSubcluster={terminateSubcluster}
          onReloadSubcluster={reloadSubcluster}
        />
      ))}
    </Box>
  );
};