-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OpenConceptLab/ocl_issues#1621 | Concept details view | header proper…
…ties
- Loading branch information
1 parent
0439f38
commit 697d779
Showing
5 changed files
with
81 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react' | ||
import SvgIcon from '@mui/material/SvgIcon'; | ||
|
||
const ExternalIdIcon = ({fill, ...rest}) => { | ||
return ( | ||
<SvgIcon {...rest}> | ||
<path d="m16.5 9-3-3v2.25h-6v1.5h6V12m1.5 1.5a7.5 7.5 0 1 1 0-9h-2.047a6 6 0 1 0 0 9H15z" fill={fill}/> | ||
</SvgIcon> | ||
) | ||
} | ||
|
||
export default ExternalIdIcon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Tooltip title={t('common.click_to_copy')}> | ||
<span style={{display: 'flex', alignItems: 'center', cursor: 'copy', ...style}} onClick={onClick}> | ||
<ExternalIdIcon size='small' sx={{marginTop: '4px', width: '18px', height: '18px'}} /> | ||
<span style={{marginRight: '4px', fontSize: '12px', colors: SECONDARY_COLORS.main}}> | ||
{t('concept.form.external_id')} | ||
</span> | ||
<span style={{fontSize: '12px', color: SECONDARY_COLORS['50']}}> | ||
{getValue()} | ||
</span> | ||
</span> | ||
</Tooltip> | ||
) | ||
} | ||
|
||
export default ExternalIdLabel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters