From 8319d3d7b381736af221da29866fdf1c0027f64c Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Sun, 26 Jul 2026 20:02:44 +0100 Subject: [PATCH] Enhance ObjectDisplay and StateTag components for improved state representation - Integrated StateTag into ObjectDisplay to display the object's state conditionally. - Updated gap handling in ObjectDisplay to account for both color and state properties. - Modified StateTag to include a new 'showTag' prop for conditional rendering of the tag, enhancing flexibility in state display. --- src/components/Dashboard/common/ObjectDisplay.jsx | 10 +++++++++- src/components/Dashboard/common/StateTag.jsx | 9 +++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/components/Dashboard/common/ObjectDisplay.jsx b/src/components/Dashboard/common/ObjectDisplay.jsx index 88af03c..57fa390 100644 --- a/src/components/Dashboard/common/ObjectDisplay.jsx +++ b/src/components/Dashboard/common/ObjectDisplay.jsx @@ -9,6 +9,7 @@ import { AuthContext } from '../context/AuthContext' import merge from 'lodash/merge' import IdDisplay from './IdDisplay' import SpotlightTooltip from './SpotlightTooltip' +import StateTag from './StateTag' const { Text, Link } = Typography @@ -255,7 +256,7 @@ const ObjectDisplay = ({ className='object-display-tag' > @@ -267,6 +268,13 @@ const ObjectDisplay = ({ style={{ marginBottom: '1.5px' }} /> ) : null} + {objectData?.state ? ( + + ) : null}
{renderNameDisplay()} diff --git a/src/components/Dashboard/common/StateTag.jsx b/src/components/Dashboard/common/StateTag.jsx index 7c9c1b9..a812f95 100644 --- a/src/components/Dashboard/common/StateTag.jsx +++ b/src/components/Dashboard/common/StateTag.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types' import { Badge, Flex, Tag } from 'antd' import { useMemo } from 'react' -const StateTag = ({ state, showBadge = true, style = {} }) => { +const StateTag = ({ state, showBadge = true, showTag = true, style = {} }) => { const { badgeStatus, badgeText } = useMemo(() => { let status = 'default' let text = 'Unknown' @@ -196,6 +196,10 @@ const StateTag = ({ state, showBadge = true, style = {} }) => { badgeProps = { color: badgeStatus } } + if (showTag == false) { + return + } + return ( @@ -209,7 +213,8 @@ const StateTag = ({ state, showBadge = true, style = {} }) => { StateTag.propTypes = { state: PropTypes.string, showBadge: PropTypes.bool, - style: PropTypes.object + style: PropTypes.object, + showTag: PropTypes.bool } export default StateTag