Skip to content

Commit dd02ab0

Browse files
committed
OpenConceptLab/ocl_issues#2211 | Moving Repo attributes to summary
1 parent ce6d079 commit dd02ab0

File tree

2 files changed

+81
-79
lines changed

2 files changed

+81
-79
lines changed

src/components/repos/RepoHeader.jsx

Lines changed: 5 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,18 @@ import Paper from '@mui/material/Paper'
44
import Button from '@mui/material/Button';
55
import Typography from '@mui/material/Typography';
66
import DownIcon from '@mui/icons-material/ArrowDropDown';
7-
import { uniq, compact, has } from 'lodash'
7+
import { has } from 'lodash'
88
import RepoVersionChip from './RepoVersionChip';
99
import RepoChip from './RepoChip'
10-
import DotSeparator from '../common/DotSeparator';
1110
import OwnerChip from '../common/OwnerChip';
12-
import { PRIMARY_COLORS } from '../../common/colors';
13-
import { formatDate, currentUserHasAccess } from '../../common/utils';
11+
import { currentUserHasAccess } from '../../common/utils';
1412
import RepoManagementList from './RepoManagementList';
1513
import FollowActionButton from '../common/FollowActionButton'
16-
import EntityAttributesDialog from '../common/EntityAttributesDialog'
1714

18-
const RepoHeader = ({repo, owner, versions, onVersionChange, onCreateConceptClick, onCreateMappingClick, onVersionEditClick, essentials, onCreateVersionClick, onDeleteRepoClick, isVersion, onReleaseVersionClick}) => {
15+
const RepoHeader = ({repo, owner, versions, onVersionChange, onCreateConceptClick, onCreateMappingClick, onVersionEditClick, onCreateVersionClick, onDeleteRepoClick, isVersion, onReleaseVersionClick}) => {
1916
const { t } = useTranslation()
2017
const [menu, setMenu] = React.useState(false)
2118
const [menuAnchorEl, setMenuAnchorEl] = React.useState(false)
22-
const [viewAll, setViewAll] = React.useState(false)
2319
const onMenuOpen = event => {
2420
setMenuAnchorEl(event.currentTarget)
2521
setMenu(true)
@@ -45,14 +41,6 @@ const RepoHeader = ({repo, owner, versions, onVersionChange, onCreateConceptClic
4541
onReleaseVersionClick()
4642
}
4743

48-
const getRepo = () => {
49-
if(repo?.id) {
50-
const {default_locale, supported_locales} = repo
51-
repo.locales = uniq(compact([default_locale, ...(supported_locales || [])]))
52-
}
53-
return repo
54-
}
55-
5644
const hasAccess = currentUserHasAccess()
5745

5846
return (
@@ -79,74 +67,15 @@ const RepoHeader = ({repo, owner, versions, onVersionChange, onCreateConceptClic
7967
}
8068
</span>
8169
</div>
82-
<div className='col-xs-12 padding-0' style={{margin: '8px 0', marginBottom: essentials ? 0 : '8px'}}>
70+
<div className='col-xs-12 padding-0' style={{margin: '8px 0 -8px 0'}}>
8371
<Typography component='span' sx={{fontSize: '28px', color: 'surface.dark', fontWeight: 600}}>{repo.name}</Typography>
8472
{
8573
repo?.canonical_url &&
8674
<Typography component='span' sx={{marginLeft: '8px', fontSize: '14px', color: 'secondary.main'}}>{repo.canonical_url}</Typography>
8775
}
8876
</div>
89-
{
90-
!essentials &&
91-
<>
92-
<div className='col-xs-12 padding-0' style={{display: 'flex', alignItems: 'center', fontSize: '16px'}}>
93-
<span style={{display: 'flex', alignItems: 'center'}}>
94-
<a style={{color: PRIMARY_COLORS.main, cursor: 'pointer'}} className='no-anchor-styles' onClick={() => setViewAll(true)}>{t('common.view_all_attributes')}</a>
95-
</span>
96-
<DotSeparator margin="0 6px" />
97-
<span style={{display: 'flex', alignItems: 'center', opacity: 0.7}}>
98-
{t('common.updated_on')} {formatDate(repo.updated_on)}
99-
</span>
100-
</div>
101-
<EntityAttributesDialog
102-
fields={{
103-
name: {label: t('common.name')},
104-
full_name: {label: t('common.full_name')},
105-
external_id: {label: t('common.external_id')},
106-
repo_type: {label: t('repo.repo_type')},
107-
description: {label: t('common.description')},
108-
canonical_url: {label: t('url_registry.canonical_url')},
109-
locales: {label: t('repo.locales')},
110-
custom_validation_schema: {label: t('repo.custom_validation_schema')},
111-
public_access: {label: t('common.access_level')},
112-
properties: {label: t('repo.properties'), type: 'table'},
113-
filters: {label: t('repo.filters'), type: 'table'},
114-
meta: {label: t('repo.meta'), type: 'json'},
115-
identifier: {label: t('repo.identifier'), type: 'json'},
116-
contact: {label: t('repo.contact'), type: 'json'},
117-
jurisdiction: {label: t('repo.jurisdiction'), type: 'json'},
118-
publisher: {label: t('repo.publisher')},
119-
purpose: {label: t('repo.purpose')},
120-
copyright: {label: t('repo.copyright')},
121-
content_type: {label: t('repo.content_type')},
122-
revision_date: {label: t('repo.revision_date'), type: 'date'},
123-
experimental: {label: t('repo.experimental')},
124-
case_sensitive: {label: t('repo.case_sensitive')},
125-
hierarchy_meaning: {label: t('repo.hierarchy_meaning')},
126-
compositional: {label: t('repo.compositional')},
127-
version_needed: {label: t('repo.version_needed')},
128-
autoid_concept_mnemonic: {label: t('repo.autoid_concept_mnemonic')},
129-
autoid_concept_external_id: {label: t('repo.autoid_concept_external_id')},
130-
autoid_concept_name_external_id: {label: t('repo.autoid_concept_name_external_id')},
131-
autoid_concept_description_external_id: {label: t('repo.autoid_concept_description_external_id')},
132-
autoid_mapping_mnemonic: {label: t('repo.autoid_mapping_mnemonic')},
133-
autoid_mapping_external_id: {label: t('repo.autoid_mapping_external_id')},
134-
'checksums.standard': {label: t('checksums.standard')},
135-
'checksums.smart': {label: t('checksums.smart')},
136-
extras: {label: t('custom_attributes.label'), type: 'json'},
137-
created_on: {label: t('common.created_on'), type: 'datetime'},
138-
updated_on: {label: t('common.updated_on'), type: 'datetime'},
139-
created_by: {label: t('common.created_by'), type: 'user'},
140-
updated_by: {label: t('common.updated_by'), type: 'user'},
141-
}}
142-
entity={getRepo()}
143-
open={viewAll}
144-
onClose={() => setViewAll(false)}
145-
/>
146-
</>
147-
}
14877
</Paper>
149-
)
78+
)
15079
}
15180

15281
export default RepoHeader;

src/components/repos/RepoSummary.jsx

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ import VersionIcon from '@mui/icons-material/AccountTreeOutlined';
1515
import ConceptClassIcon from '@mui/icons-material/CategoryOutlined';
1616
import RefreshIcon from '@mui/icons-material/Refresh';
1717

18-
import isEmpty from 'lodash/isEmpty'
18+
import { uniq, compact, isEmpty } from 'lodash'
1919

2020
import APIService from '../../services/APIService'
21-
import { currentUserHasAccess, pluralize } from '../../common/utils'
21+
import { currentUserHasAccess, pluralize, formatDate } from '../../common/utils'
22+
import { PRIMARY_COLORS } from '../../common/colors';
2223
import { OperationsContext } from '../app/LayoutContext';
2324
import AccessChip from '../common/AccessChip'
25+
import EntityAttributesDialog from '../common/EntityAttributesDialog'
2426
import ConceptIcon from '../concepts/ConceptIcon'
2527
import MappingIcon from '../mappings/MappingIcon'
2628

@@ -42,8 +44,9 @@ const PropertyChip = ({label, icon, ...rest}) => {
4244
const RepoSummary = ({ repo, summary }) => {
4345
const { t } = useTranslation()
4446
const { setAlert } = React.useContext(OperationsContext);
45-
const repoSubType = repo?.source_type || repo?.collection_type
47+
const [viewAll, setViewAll] = React.useState(false)
4648

49+
const repoSubType = repo?.source_type || repo?.collection_type
4750
const isLoaded = isEmpty(summary)
4851
const activeConcepts = isLoaded ? false : (summary?.concepts?.active || 0)
4952
const totalConcepts = isLoaded ? false : ((summary?.concepts?.active || 0) + (summary?.concepts?.retired || 0))
@@ -61,6 +64,13 @@ const RepoSummary = ({ repo, summary }) => {
6164
setAlert({message: t('repo.repo_summary_is_calculating')})
6265
})
6366
}
67+
const getRepo = () => {
68+
if(repo?.id) {
69+
const {default_locale, supported_locales} = repo
70+
repo.locales = uniq(compact([default_locale, ...(supported_locales || [])]))
71+
}
72+
return repo
73+
}
6474

6575
return (
6676
<div className='col-xs-12 padding-0'>
@@ -258,7 +268,25 @@ const RepoSummary = ({ repo, summary }) => {
258268
/>
259269
</ListItem>
260270
}
271+
<ListItem sx={{padding: '4px 0', fontSize: '12px'}}>
272+
<ListItemText
273+
primary={
274+
repo?.updated_on ?
275+
<>
276+
{t('common.updated_on')} {formatDate(repo.updated_on)}
277+
</> :
278+
<SkeletonText />
279+
}
280+
sx={{
281+
'.MuiListItemText-primary': {fontSize: '12px', color: 'secondary.main'}
282+
}}
283+
/>
284+
</ListItem>
285+
<ListItem sx={{padding: '4px 0', fontSize: '12px'}}>
286+
<a style={{color: PRIMARY_COLORS.main, cursor: 'pointer'}} className='no-anchor-styles' onClick={() => setViewAll(true)}>{t('common.view_all_attributes')}</a>
287+
</ListItem>
261288
</List>
289+
262290
{
263291
onRefresh && currentUserHasAccess() &&
264292
<Button
@@ -273,6 +301,51 @@ const RepoSummary = ({ repo, summary }) => {
273301
</Button>
274302
}
275303
</div>
304+
<EntityAttributesDialog
305+
fields={{
306+
name: {label: t('common.name')},
307+
full_name: {label: t('common.full_name')},
308+
external_id: {label: t('common.external_id')},
309+
repo_type: {label: t('repo.repo_type')},
310+
description: {label: t('common.description')},
311+
canonical_url: {label: t('url_registry.canonical_url')},
312+
locales: {label: t('repo.locales')},
313+
custom_validation_schema: {label: t('repo.custom_validation_schema')},
314+
public_access: {label: t('common.access_level')},
315+
properties: {label: t('repo.properties'), type: 'table'},
316+
filters: {label: t('repo.filters'), type: 'table'},
317+
meta: {label: t('repo.meta'), type: 'json'},
318+
identifier: {label: t('repo.identifier'), type: 'json'},
319+
contact: {label: t('repo.contact'), type: 'json'},
320+
jurisdiction: {label: t('repo.jurisdiction'), type: 'json'},
321+
publisher: {label: t('repo.publisher')},
322+
purpose: {label: t('repo.purpose')},
323+
copyright: {label: t('repo.copyright')},
324+
content_type: {label: t('repo.content_type')},
325+
revision_date: {label: t('repo.revision_date'), type: 'date'},
326+
experimental: {label: t('repo.experimental')},
327+
case_sensitive: {label: t('repo.case_sensitive')},
328+
hierarchy_meaning: {label: t('repo.hierarchy_meaning')},
329+
compositional: {label: t('repo.compositional')},
330+
version_needed: {label: t('repo.version_needed')},
331+
autoid_concept_mnemonic: {label: t('repo.autoid_concept_mnemonic')},
332+
autoid_concept_external_id: {label: t('repo.autoid_concept_external_id')},
333+
autoid_concept_name_external_id: {label: t('repo.autoid_concept_name_external_id')},
334+
autoid_concept_description_external_id: {label: t('repo.autoid_concept_description_external_id')},
335+
autoid_mapping_mnemonic: {label: t('repo.autoid_mapping_mnemonic')},
336+
autoid_mapping_external_id: {label: t('repo.autoid_mapping_external_id')},
337+
'checksums.standard': {label: t('checksums.standard')},
338+
'checksums.smart': {label: t('checksums.smart')},
339+
extras: {label: t('custom_attributes.label'), type: 'json'},
340+
created_on: {label: t('common.created_on'), type: 'datetime'},
341+
updated_on: {label: t('common.updated_on'), type: 'datetime'},
342+
created_by: {label: t('common.created_by'), type: 'user'},
343+
updated_by: {label: t('common.updated_by'), type: 'user'},
344+
}}
345+
entity={getRepo()}
346+
open={viewAll}
347+
onClose={() => setViewAll(false)}
348+
/>
276349
</div>
277350
)
278351
}

0 commit comments

Comments
 (0)