Enhance IdDisplay component with reference and plainCode props

- Added reference prop to allow custom display of IDs.
- Introduced plainCode prop to toggle between code and text display styles.
- Updated rendering logic to accommodate new props for improved flexibility in ID presentation.
This commit is contained in:
Tom Butcher 2025-12-07 02:41:45 +00:00
parent 8b481a9617
commit 6da485bc8f

View File

@ -11,6 +11,8 @@ const { Text, Link } = Typography
const IdDisplay = ({ const IdDisplay = ({
id, id,
reference = null,
plainCode = false,
type, type,
showCopy = true, showCopy = true,
longId = true, longId = true,
@ -44,23 +46,37 @@ const IdDisplay = ({
displayId = prefix + ':' + id.toString().slice(-6) displayId = prefix + ':' + id.toString().slice(-6)
} }
if (reference) {
displayId = prefix + ':' + reference
}
return ( return (
<Flex <Flex
align={'end'} align={'center'}
className='iddisplay' className='iddisplay'
style={{ minWidth: '0px', width: '100%' }} style={{ minWidth: '0px', width: '100%' }}
> >
{(() => { {(() => {
const textElement = ( var textElement = (
<Text <code
code
ellipsis
style={showCopy ? { marginRight: 6, minWidth: '0px' } : undefined} style={showCopy ? { marginRight: 6, minWidth: '0px' } : undefined}
> >
{displayId} {displayId}
</Text> </code>
) )
if (plainCode == false) {
textElement = (
<Text
code
ellipsis
style={showCopy ? { marginRight: 6, minWidth: '0px' } : undefined}
>
{displayId}
</Text>
)
}
// If hyperlink is enabled // If hyperlink is enabled
if (showHyperlink && hyperlink != null) { if (showHyperlink && hyperlink != null) {
const linkElement = ( const linkElement = (
@ -128,9 +144,11 @@ const IdDisplay = ({
IdDisplay.propTypes = { IdDisplay.propTypes = {
id: PropTypes.string, id: PropTypes.string,
type: PropTypes.string, type: PropTypes.string,
reference: PropTypes.string,
showCopy: PropTypes.bool, showCopy: PropTypes.bool,
longId: PropTypes.bool, longId: PropTypes.bool,
showHyperlink: PropTypes.bool, showHyperlink: PropTypes.bool,
plainCode: PropTypes.bool,
showSpotlight: PropTypes.bool showSpotlight: PropTypes.bool
} }