From 697d7792c22045d09e61fb8e603d2c116ad1f112 Mon Sep 17 00:00:00 2001 From: Sny Date: Wed, 25 Sep 2024 17:20:34 +0530 Subject: [PATCH] OpenConceptLab/ocl_issues#1621 | Concept details view | header properties --- src/components/common/Breadcrumbs.jsx | 2 +- src/components/common/ExternalIdIcon.jsx | 12 +++++++ src/components/common/ExternalIdLabel.jsx | 41 +++++++++++++++++++++++ src/components/concepts/ConceptHeader.jsx | 38 ++++++++++++++------- src/i18n/locales/en/translations.json | 3 +- 5 files changed, 81 insertions(+), 15 deletions(-) create mode 100644 src/components/common/ExternalIdIcon.jsx create mode 100644 src/components/common/ExternalIdLabel.jsx diff --git a/src/components/common/Breadcrumbs.jsx b/src/components/common/Breadcrumbs.jsx index 5fa111e6..43d0c04b 100644 --- a/src/components/common/Breadcrumbs.jsx +++ b/src/components/common/Breadcrumbs.jsx @@ -54,7 +54,7 @@ const Breadcrumbs = ({owner, ownerType, repo, repoVersion, repoURL, id, version, { !noIcons && - + } {id} diff --git a/src/components/common/ExternalIdIcon.jsx b/src/components/common/ExternalIdIcon.jsx new file mode 100644 index 00000000..edf404aa --- /dev/null +++ b/src/components/common/ExternalIdIcon.jsx @@ -0,0 +1,12 @@ +import React from 'react' +import SvgIcon from '@mui/material/SvgIcon'; + +const ExternalIdIcon = ({fill, ...rest}) => { + return ( + + + + ) +} + +export default ExternalIdIcon; diff --git a/src/components/common/ExternalIdLabel.jsx b/src/components/common/ExternalIdLabel.jsx new file mode 100644 index 00000000..9e22e7b2 --- /dev/null +++ b/src/components/common/ExternalIdLabel.jsx @@ -0,0 +1,41 @@ +import React from 'react' +import { useTranslation } from 'react-i18next'; +import { join, slice } from 'lodash' +import Tooltip from '@mui/material/Tooltip' +import { SECONDARY_COLORS } from '../../common/colors' +import ExternalIdIcon from './ExternalIdIcon' +import { OperationsContext } from '../app/LayoutContext'; +import { copyToClipboard } from '../../common/utils' + +const ExternalIdLabel = ({ value, style }) => { + const { t } = useTranslation() + const { setAlert } = React.useContext(OperationsContext); + const getValue = () => { + let newValue = value + if(value?.length > 11) { + newValue = join([slice(value, 0, 4).join(''), '...', slice(value, -4).join('')], ''); + } + return newValue + } + + const onClick = () => { + copyToClipboard(value) + setAlert({message: t('common.copied_to_clipboard'), severity: 'success', duration: 1000}) + } + + return ( + + + + + {t('concept.form.external_id')} + + + {getValue()} + + + + ) +} + +export default ExternalIdLabel; diff --git a/src/components/concepts/ConceptHeader.jsx b/src/components/concepts/ConceptHeader.jsx index 454a23fb..cf56309d 100644 --- a/src/components/concepts/ConceptHeader.jsx +++ b/src/components/concepts/ConceptHeader.jsx @@ -3,15 +3,29 @@ import { useTranslation } from 'react-i18next'; import Typography from '@mui/material/Typography' import Chip from '@mui/material/Chip' import Button from '@mui/material/Button'; -import IconButton from '@mui/material/IconButton'; -import DownloadIcon from '@mui/icons-material/Download'; import DownIcon from '@mui/icons-material/ArrowDropDown'; -import ShareIcon from '@mui/icons-material/Share'; import CloseIconButton from '../common/CloseIconButton'; import { toOwnerURI } from '../../common/utils'; import Breadcrumbs from '../common/Breadcrumbs' -import { BLACK } from '../../common/colors' +import { BLACK, SECONDARY_COLORS } from '../../common/colors' import ConceptManagementList from './ConceptManagementList' +import ExternalIdLabel from '../common/ExternalIdLabel'; + +const PropertyChip = ({name, property, sx}) => { + const label = ( + + + {name}: + + + {property} + + + ) + return ( + + ) +} const ConceptHeader = ({concept, onClose, repoURL, onEdit}) => { const { t } = useTranslation() @@ -58,17 +72,15 @@ const ConceptHeader = ({concept, onClose, repoURL, onEdit}) => { {concept.display_name}
- - - + + + + { + concept.external_id && + + } - - - - - - diff --git a/src/i18n/locales/en/translations.json b/src/i18n/locales/en/translations.json index f08891a2..83336d35 100644 --- a/src/i18n/locales/en/translations.json +++ b/src/i18n/locales/en/translations.json @@ -74,7 +74,8 @@ "with": "with", "json": "JSON", "draft": "Draft", - "highlights": "Highlights" + "highlights": "Highlights", + "click_to_copy": "Click to Copy" }, "errors": { "404": "Sorry your page could not be found.",