Skip to content

Commit

Permalink
Feedback | Repo view all attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Oct 17, 2024
1 parent 71f1f0f commit 6ed2b0e
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/components/common/EntityAttributesDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import TableRow from '@mui/material/TableRow';
import TableCell from '@mui/material/TableCell';
import { map, get } from 'lodash'
import Link from '../common/Link'
import { formatWebsiteLink } from '../../common/utils'
import { formatWebsiteLink, formatDate, formatDateTime } from '../../common/utils'

const EntityAttributesDialog = ({ entity, fields, open, onClose }) => {
const { t } = useTranslation()
Expand All @@ -21,10 +21,14 @@ const EntityAttributesDialog = ({ entity, fields, open, onClose }) => {
if(value) {
if(info.type === 'datetime')
return moment(value).format('lll')
if(info.type === 'datetime')
return formatDateTime(value)
if(info.type === 'date')
return formatDate(value)
if(info.type === 'external_link')
return formatWebsiteLink(value)
if(info.type === 'user')
return formatWebsiteLink(`${window.location.origin}/#/users/${value}/`, null, value)
return <Link sx={{fontSize: '14px'}} label={value} href={`#/users/${value}/`} />
if(info.type === 'json')
return <pre>{JSON.stringify(value, undefined, 2)}</pre>
}
Expand All @@ -35,7 +39,7 @@ const EntityAttributesDialog = ({ entity, fields, open, onClose }) => {
open={open}
onClose={onClose}
scroll='paper'
maxWidth="xs"
maxWidth="sm"
sx={{
'& .MuiDialog-paper': {
backgroundColor: 'surface.n92',
Expand Down
50 changes: 49 additions & 1 deletion src/components/repos/RepoHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Paper from '@mui/material/Paper'
import Button from '@mui/material/Button';
import Typography from '@mui/material/Typography';
import DownIcon from '@mui/icons-material/ArrowDropDown';
import { uniq, compact } from 'lodash'
import RepoVersionChip from './RepoVersionChip';
import RepoChip from './RepoChip'
import DotSeparator from '../common/DotSeparator';
Expand All @@ -12,11 +13,13 @@ import { PRIMARY_COLORS } from '../../common/colors';
import { formatDate } from '../../common/utils';
import RepoManagementList from './RepoManagementList';
import FollowActionButton from '../common/FollowActionButton'
import EntityAttributesDialog from '../common/EntityAttributesDialog'

const RepoHeader = ({repo, owner, versions, onVersionChange, onCreateConceptClick}) => {
const { t } = useTranslation()
const [menu, setMenu] = React.useState(false)
const [menuAnchorEl, setMenuAnchorEl] = React.useState(false)
const [viewAll, setViewAll] = React.useState(false)
const onMenuOpen = event => {
setMenuAnchorEl(event.currentTarget)
setMenu(true)
Expand All @@ -33,6 +36,14 @@ const RepoHeader = ({repo, owner, versions, onVersionChange, onCreateConceptClic
}
}

const getRepo = () => {
if(repo?.id) {
const {default_locale, supported_locales} = repo
repo.locales = uniq(compact([default_locale, ...(supported_locales || [])]))
}
return repo
}

return (
<Paper component="div" className='col-xs-12' sx={{backgroundColor: 'surface.main', boxShadow: 'none', padding: '16px', borderRadius: '8px 8px 0 0'}}>
<div className='col-xs-9 padding-0' style={{display: 'flex'}}>
Expand All @@ -55,13 +66,50 @@ const RepoHeader = ({repo, owner, versions, onVersionChange, onCreateConceptClic
</div>
<div className='col-xs-12 padding-0' style={{display: 'flex', alignItems: 'center', fontSize: '16px'}}>
<span style={{display: 'flex', alignItems: 'center'}}>
<a style={{color: PRIMARY_COLORS.main}} className='no-anchor-styles'>{t('common.view_all_attributes')}</a>
<a style={{color: PRIMARY_COLORS.main, cursor: 'pointer'}} className='no-anchor-styles' onClick={() => setViewAll(true)}>{t('common.view_all_attributes')}</a>
</span>
<DotSeparator margin="0 6px" />
<span style={{display: 'flex', alignItems: 'center', opacity: 0.7}}>
{t('common.updated_on')} {formatDate(repo.updated_on)}
</span>
</div>
<EntityAttributesDialog
fields={{
name: {label: t('common.name')},
full_name: {label: t('common.full_name')},
external_id: {label: t('common.external_id')},
locales: {label: t('repo.locales')},
canonical_url: {label: t('url_registry.canonical_url')},
description: {label: t('common.description')},
identifier: {label: t('repo.identifier'), type: 'json'},
contact: {label: t('repo.contact'), type: 'json'},
jurisdiction: {label: t('repo.jurisdiction'), type: 'json'},
publisher: {label: t('repo.publisher')},
purpose: {label: t('repo.purpose')},
copyright: {label: t('repo.copyright')},
content_type: {label: t('repo.content_type')},
revision_date: {label: t('repo.revision_date'), type: 'date'},
experimental: {label: t('repo.experimental')},
case_sensitive: {label: t('repo.case_sensitive')},
hierarchy_meaning: {label: t('repo.hierarchy_meaning')},
compositional: {label: t('repo.compositional')},
version_needed: {label: t('repo.version_needed')},
autoid_concept_mnemonic: {label: t('repo.autoid_concept_mnemonic')},
autoid_concept_external_id: {label: t('repo.autoid_concept_external_id')},
autoid_concept_name_external_id: {label: t('repo.autoid_concept_name_external_id')},
autoid_concept_description_external_id: {label: t('repo.autoid_concept_description_external_id')},
autoid_mapping_mnemonic: {label: t('repo.autoid_mapping_mnemonic')},
autoid_mapping_external_id: {label: t('repo.autoid_mapping_external_id')},
extras: {label: t('custom_attributes.label'), type: 'json'},
created_on: {label: t('common.created_on'), type: 'datetime'},
updated_on: {label: t('common.updated_on'), type: 'datetime'},
created_by: {label: t('common.created_by'), type: 'user'},
updated_by: {label: t('common.updated_by'), type: 'user'},
}}
entity={getRepo()}
open={viewAll}
onClose={() => setViewAll(false)}
/>
</Paper>
)
}
Expand Down
23 changes: 22 additions & 1 deletion src/i18n/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
"draft": "Draft",
"highlights": "Highlights",
"click_to_copy": "Click to Copy",
"submit": "Submit"
"submit": "Submit",
"external_id": "External ID"
},
"errors": {
"404": "Sorry your page could not be found.",
Expand Down Expand Up @@ -187,6 +188,26 @@
"compare_versions": "Compare versions",
"compare": "Compare",
"visibility": "Visibility",
"locales": "Locales",
"identifier": "Identifier",
"contact": "Contact",
"jurisdiction": "Jurisdiction",
"publisher": "Publisher",
"purpose": "Purpose",
"copyright": "Copyright",
"content_type": "Content Type",
"revision_date": "Revision Date",
"experimental": "Experimental",
"case_sensitive": "Case Sensitive",
"hierarchy_meaning": "Hierarchy Meaning",
"compositional": "Compositional",
"version_needed": "Version Needed",
"autoid_concept_mnemonic": "Concept ID Auto Assignment",
"autoid_concept_external_id": "Concept External ID Auto Assignment",
"autoid_concept_name_external_id": "Concept Name External ID Auto Assignment",
"autoid_concept_description_external_id": "Concept Description External ID Auto Assignment",
"autoid_mapping_mnemonic": "Mapping ID Auto Assignment",
"autoid_mapping_external_id": "Mapping External ID Auto Assignment",
"custom_validation_schema": "Custom Validation Schema",
"compare_origin_version_disabled_tooltip": "You must select an older version to compare",
"compare_destination_version_disabled_tooltip": "You must select a newer version to compare"
Expand Down

0 comments on commit 6ed2b0e

Please sign in to comment.