import React, { useEffect, useState } from 'react';
import { Show } from "@refinedev/antd";
import { useShow, useMany } from "@refinedev/core";
import { Card, Descriptions, Space, Tag, Typography, Table, Button, Tooltip } from 'antd';
import { RefreshButton, DateField } from '@refinedev/antd';
import { ApiOutlined, LinkOutlined, InfoCircleOutlined } from '@ant-design/icons';
const { Title, Text } = Typography;
export const BlueprintShow = () => {
const { queryResult } = useShow();
const { data, isLoading } = queryResult;
const record = data?.data;
// Extract component IDs from the blueprint config
const componentIds = record?.config?.components?.map((component: {id: string}) => component.id) || [];
// Fetch component details for all component IDs
const { data: componentsData, isLoading: componentsLoading } = useMany({
resource: "components",
ids: componentIds,
queryOptions: {
enabled: componentIds.length > 0,
},
});
return (
}
href={`/deployments/create?blueprintId=${record?.id}`}
>
Deploy
,
]}
>
Blueprint Details
{record?.id}
{record?.name}
{record?.version}
{record?.config?.components?.length || 0} Components
{record?.config?.networkPolicies?.length || 0} Policies
{record?.description}
{record?.config?.components &&
{
// Find the full component details from the components data
const componentDetails = componentsData?.data?.find((c: any) => c.id === component.id);
return {
...component,
componentDetails,
};
})}
rowKey="id"
loading={componentsLoading}
pagination={false}
expandable={{
expandedRowRender: (record: any) => (
{record.componentDetails?.description}
{record.componentDetails?.language}
{record.componentDetails?.type}
{record.componentDetails?.version}
),
}}
>
(
{value}
{record.componentDetails && (
}
href={`/components/show/${record.id}`}
size="small"
/>
)}
)}
/>
(
{record.componentDetails?.type || "unknown"}
)}
/>
value ? Yes : No}
/>
(
<>
CPU: {resources.cpu}
Memory: {resources.memory}
Storage: {resources.storage}
>
)}
/>
autoscaling?.enabled ? (
<>
Min: {autoscaling.minReplicas}
Max: {autoscaling.maxReplicas}
CPU: {autoscaling.cpuThreshold}%
>
) : Disabled}
/>
}
{record?.config?.networkPolicies &&
sources?.map((src: string) => {src})}
/>
targets?.map((target: string) => {target})}
/>
ports?.map((port: number) => {port})}
/>
action === 'allow' ?
Allow :
Deny
}
/>
}
{record?.config?.envVariables &&
({ key, value }))}
rowKey="key"
pagination={false}
>
}
{(!record?.config?.envVariables || Object.keys(record.config.envVariables).length === 0) &&
No environment variables defined
}
{record?.config?.secrets &&
}
{(!record?.config?.secrets || record.config.secrets.length === 0) &&
No secrets defined
}
{record?.createdBy}
);
};