Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions frontend/public/components/pod-dashboard-inventory.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as React from 'react';
import { DashboardItemProps } from '@console/internal/components/dashboards-page/with-dashboard-resources';
import {
DashboardCard,
DashboardCardHeader,
DashboardCardTitle,
DashboardCardBody,
} from '@console/internal/components/dashboard/dashboard-card';
import { getPodContainers, getPodVolumes } from '@console/shared';
import { InventoryBody } from '@console/internal/components/dashboard/inventory-card/inventory-body';
import { InventoryItem } from '@console/internal/components/dashboard/inventory-card/inventory-item';
import { PodDashboardContext } from './pod-dashboard-context';

export const PodDashboardInventoryCard: React.FC<PodDashboardInventoryCardProps> = () => {
const podDashboardContext = React.useContext(PodDashboardContext);
const { pod } = podDashboardContext;

const isLoading = !pod;

// initContainers are not included
const containerCount = getPodContainers(pod).length;
const volumeCount = getPodVolumes(pod).length;

return (
<DashboardCard>
<DashboardCardHeader>
<DashboardCardTitle>Inventory</DashboardCardTitle>
</DashboardCardHeader>
<DashboardCardBody>
<InventoryBody>
<InventoryItem isLoading={isLoading} title="Container" count={containerCount} />
<InventoryItem isLoading={isLoading} title="Volume" count={volumeCount} />
</InventoryBody>
</DashboardCardBody>
</DashboardCard>
);
};

type PodDashboardInventoryCardProps = DashboardItemProps;
3 changes: 2 additions & 1 deletion frontend/public/components/pod-dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { PodKind } from '../module/k8s';
import { Dashboard, DashboardGrid } from './dashboard';
import { PodDashboardDetailsCard } from './pod-dashboard-details';
import { PodDashboardContext } from './pod-dashboard-context';
import { PodDashboardInventoryCard } from './pod-dashboard-inventory';

const mainCards = [];
const leftCards = [{ Card: PodDashboardDetailsCard }];
const leftCards = [{ Card: PodDashboardDetailsCard }, { Card: PodDashboardInventoryCard }];
const rightCards = [];

export const PodDashboard: React.FC<PodDashboardProps> = (props) => {
Expand Down