From e4d2abd496e1960a92e1cb35cbbe00ac2c4b07fd Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 15 Nov 2025 22:54:27 +0000 Subject: [PATCH] Add PropTypes and improve key handling in DockerContainersTable Improvements: - Add PropTypes validation for component props (containers, errors, captureVersion) - Use composite key for ports map instead of index for better React reconciliation - Ensures type safety and follows codebase PropTypes conventions This improves code quality and prevents potential runtime issues. --- .../DockerContainersTable/index.jsx | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/client/src/Pages/v1/Infrastructure/Details/Components/DockerContainersTable/index.jsx b/client/src/Pages/v1/Infrastructure/Details/Components/DockerContainersTable/index.jsx index cbb4d09e0..86fe8bb7a 100644 --- a/client/src/Pages/v1/Infrastructure/Details/Components/DockerContainersTable/index.jsx +++ b/client/src/Pages/v1/Infrastructure/Details/Components/DockerContainersTable/index.jsx @@ -1,5 +1,6 @@ import { Box, Stack, Typography } from "@mui/material"; import { useTheme } from "@emotion/react"; +import PropTypes from "prop-types"; import DataTable from "@/Components/v1/Table/index.jsx"; import { StatusLabel } from "@/Components/v1/Label/index.jsx"; @@ -116,7 +117,7 @@ const DockerContainersTable = ({ containers = [], errors = [], captureVersion }) {row.exposed_ports && row.exposed_ports.length > 0 ? ( row.exposed_ports.map((port, idx) => ( @@ -231,4 +232,36 @@ const DockerContainersTable = ({ containers = [], errors = [], captureVersion }) ); }; +DockerContainersTable.propTypes = { + containers: PropTypes.arrayOf( + PropTypes.shape({ + container_id: PropTypes.string, + container_name: PropTypes.string, + status: PropTypes.string, + health: PropTypes.shape({ + healthy: PropTypes.bool, + source: PropTypes.string, + message: PropTypes.string, + }), + running: PropTypes.bool, + base_image: PropTypes.string, + exposed_ports: PropTypes.arrayOf( + PropTypes.shape({ + port: PropTypes.string, + protocol: PropTypes.string, + }) + ), + started_at: PropTypes.number, + finished_at: PropTypes.number, + }) + ), + errors: PropTypes.arrayOf( + PropTypes.shape({ + metric: PropTypes.arrayOf(PropTypes.string), + err: PropTypes.string, + }) + ), + captureVersion: PropTypes.string, +}; + export default DockerContainersTable;