From 13c102f33eb8132441c71968c33eef6d9a1ea6d2 Mon Sep 17 00:00:00 2001 From: Marek Libra Date: Wed, 25 Sep 2019 14:00:47 +0200 Subject: [PATCH] Add PodDashboardInventoryCard component --- .../components/pod-dashboard-inventory.tsx | 39 +++++++++++++++++++ frontend/public/components/pod-dashboard.tsx | 3 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 frontend/public/components/pod-dashboard-inventory.tsx diff --git a/frontend/public/components/pod-dashboard-inventory.tsx b/frontend/public/components/pod-dashboard-inventory.tsx new file mode 100644 index 00000000000..334c3e9851e --- /dev/null +++ b/frontend/public/components/pod-dashboard-inventory.tsx @@ -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 = () => { + 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 ( + + + Inventory + + + + + + + + + ); +}; + +type PodDashboardInventoryCardProps = DashboardItemProps; diff --git a/frontend/public/components/pod-dashboard.tsx b/frontend/public/components/pod-dashboard.tsx index 6b234bbfe81..61149c97228 100644 --- a/frontend/public/components/pod-dashboard.tsx +++ b/frontend/public/components/pod-dashboard.tsx @@ -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 = (props) => {