Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Oct 28, 2024
1 parent b19acfa commit cb5f6d9
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 17 deletions.
21 changes: 21 additions & 0 deletions src/components/common/AccessChip.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'
import { useTranslation } from 'react-i18next';
import Chip from '@mui/material/Chip'
import AccessIcon from './AccessIcon'


const AccessChip = ({public_access, ...rest}) => {
const { t } = useTranslation()
const isPublic = ['view', 'edit'].includes(public_access?.toLowerCase())
return (
<Chip
size='small'
variant='outlined'
icon={<AccessIcon isPublic={isPublic} fontSize='inherit' />}
label={isPublic ? t('common.public') : t('common.private')}
{...rest}
/>
)
}

export default AccessChip;
2 changes: 1 addition & 1 deletion src/components/common/AccessIcon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PublicIcon from '@mui/icons-material/LanguageOutlined';
import PrivateIcon from '@mui/icons-material/LockOutlined';

const AccessIcon = ({isPublic, public_access, ...rest}) => {
const _isPublic = isPublic || ['view', 'edit'].includes(public_access.toLowerCase())
const _isPublic = isPublic || ['view', 'edit'].includes(public_access?.toLowerCase())
return _isPublic ? <PublicIcon {...rest} /> : <PrivateIcon {...rest} />
}

Expand Down
13 changes: 9 additions & 4 deletions src/components/repos/RepoHome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import ConceptHome from '../concepts/ConceptHome';
import MappingHome from '../mappings/MappingHome';
import ConceptForm from '../concepts/ConceptForm';
import Error404 from '../errors/Error404';
import RepoSummary from './RepoSummary'

const RepoHome = () => {
const { t } = useTranslation()
Expand All @@ -21,11 +22,9 @@ const RepoHome = () => {
const params = useParams()

const TABS = [
{key: 'about', label: t('common.overview')},
{key: 'concepts', label: t('concept.concepts')},
{key: 'mappings', label: t('mapping.mappings')},
{key: 'versions', label: t('common.versions')},
{key: 'summary', label: t('common.summary')},
{key: 'about', label: t('common.about')}
]
const TAB_KEYS = TABS.map(tab => tab.key)
const findTab = () => TAB_KEYS.includes(params?.tab || params?.repoVersion) ? params.tab || params.repoVersion : 'concepts'
Expand Down Expand Up @@ -117,6 +116,7 @@ const RepoHome = () => {
(repo?.id || loading) &&
<React.Fragment>
<RepoHeader owner={owner} repo={repo} versions={versions} onVersionChange={onVersionChange} onCreateConceptClick={onCreateConceptClick} onCloseConceptForm={() => setConceptForm(false)} />
<div className='padding-0 col-xs-12' style={{width: 'calc(100% - 272px)'}}>
<CommonTabs TABS={TABS} value={tab} onChange={onTabChange} />
{
repo?.id && ['concepts', 'mappings'].includes(tab) &&
Expand All @@ -129,9 +129,14 @@ const RepoHome = () => {
onShowItem={onShowItem}
showItem={showItem}
filtersHeight='calc(100vh - 300px)'
resultContainerStyle={{height: showItem ? 'calc(100vh - 440px)' : 'calc(100vh - 400px)', overflow: 'auto'}}
resultContainerStyle={{height: isSplitView ? 'calc(100vh - 440px)' : 'calc(100vh - 400px)', overflow: 'auto'}}
containerStyle={{padding: 0}}
/>
}
</div>
<Paper component="div" className='col-xs-12' sx={{backgroundColor: 'surface.main', boxShadow: 'none', padding: '16px', borderLeft: 'solid 0.3px', borderTop: 'solid 0.3px', borderColor: 'surface.n90', width: '272px !important', height: 'calc(100vh - 250px)', borderRadius: 0}}>
<RepoSummary repo={repo} summary={repoSummary} />
</Paper>
</React.Fragment>
}
{
Expand Down
218 changes: 218 additions & 0 deletions src/components/repos/RepoSummary.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
import React from 'react';
import { Trans, useTranslation } from 'react-i18next';

import Chip from '@mui/material/Chip'
import Skeleton from '@mui/material/Skeleton'
import Typography from '@mui/material/Typography'
import List from '@mui/material/List'
import ListItem from '@mui/material/ListItem'
import ListItemText from '@mui/material/ListItemText'
import ListItemButton from '@mui/material/ListItemButton'
import ListItemIcon from '@mui/material/ListItemIcon'
import ExperimentalIcon from '@mui/icons-material/ScienceOutlined';
import LanguageIcon from '@mui/icons-material/TranslateOutlined';
import VersionIcon from '@mui/icons-material/AccountTreeOutlined';

import isEmpty from 'lodash/isEmpty'

import AccessChip from '../common/AccessChip'
import ConceptIcon from '../concepts/ConceptIcon'
import MappingIcon from '../mappings/MappingIcon'

const SkeletonText = () => (<Skeleton width={60} variant='text' />)

const PropertyChip = ({label, icon, ...rest}) => {
return (
<Chip
size='small'
variant='outlined'
icon={icon || undefined}
label={label ? label : <SkeletonText />}
{...rest}
/>
)
}

const RepoSummary = ({ repo, summary }) => {
const { t } = useTranslation()

const isLoaded = isEmpty(summary)
const activeConcepts = isLoaded ? false : (summary?.concepts?.active || 0)
const totalConcepts = isLoaded ? false : ((summary?.concepts?.active || 0) + (summary?.concepts?.retired || 0))
const activeMappings = isLoaded ? false : (summary?.mappings?.active || 0)
const totalMappings = isLoaded ? false : ((summary?.mappings?.active || 0) + (summary?.mappings?.retired || 0))
const mapTypes = isLoaded ? false : (summary?.mappings?.map_type?.length || 0)
const datatypes = isLoaded ? false : (summary?.concepts?.datatype?.length || 0)
const conceptClasses = isLoaded ? false : (summary?.concepts?.concept_class?.length || 0)
const nameTypes = isLoaded ? false : (summary?.concepts?.name_type?.length || 0)
const locales = isLoaded ? false : (summary?.concepts?.locale?.length || 0)
const totalVersions = isLoaded ? false : (summary?.versions?.total || 0)
const releasedVersions = isLoaded ? false : (summary?.versions?.released || 0)

return (
<div className='col-xs-12 padding-0'>
<div>
<PropertyChip label={repo?.source_type || repo?.collection_type} sx={{margin: '4px 8px 4px 0'}} />
<AccessChip sx={{margin: '4px 8px 4px 0'}} public_access={repo?.public_access} />
<PropertyChip sx={{margin: '4px 8px 4px 0'}} label={t('repo.experimental')} icon={<ExperimentalIcon fontSize='inherit' />} />
</div>
<div style={{marginTop: '24px'}}>
<Typography sx={{color: '#000', fontSize: '16px', fontWeight: 'bold', marginBottom: '12px'}}>
{t('common.summary')}
</Typography>
<List dense sx={{padding: 0}}>
<ListItem disablePadding>
<ListItemButton sx={{padding: '4px 0', fontSize: '12px'}}>
<ListItemIcon sx={{minWidth: '20px', marginRight: '8px', justifyContent: 'center'}}>
<ConceptIcon selected fontSize='small' color='secondary' sx={{width: '14px', height: '14px'}} />
</ListItemIcon>
<ListItemText
primary={
totalConcepts === false ?
<SkeletonText /> :
<Trans
i18nKey='repo.summary_active_concepts_from_total'
values={{active: activeConcepts?.toLocaleString(), total: totalConcepts?.toLocaleString()}}
/>
}
sx={{
'.MuiListItemText-primary': {fontSize: '12px', color: 'secondary.main'}
}}
/>
</ListItemButton>
</ListItem>
<ListItem disablePadding>
<ListItemButton sx={{padding: '4px 0', fontSize: '12px'}}>
<ListItemIcon sx={{minWidth: '20px', marginRight: '8px', justifyContent: 'center'}}>
<MappingIcon fontSize='small' color='secondary' />
</ListItemIcon>
<ListItemText
primary={
totalMappings === false ?
<SkeletonText /> :
<Trans
i18nKey='repo.summary_active_mappings_from_total'
values={{active: activeMappings?.toLocaleString(), total: totalMappings?.toLocaleString()}}
/>
}
sx={{
'.MuiListItemText-primary': {fontSize: '12px', color: 'secondary.main'}
}}
/>
</ListItemButton>
</ListItem>
<ListItem disablePadding>
<ListItemButton sx={{padding: '4px 0', fontSize: '12px'}}>
<ListItemIcon sx={{minWidth: '20px', marginRight: '8px', justifyContent: 'center'}}>
<ConceptIcon selected fontSize='small' color='secondary' sx={{width: '14px', height: '14px'}} />
</ListItemIcon>
<ListItemText
primary={
datatypes === false ?
<SkeletonText /> :
<>{`${datatypes?.toLocaleString()} ${t('concept.datatypes')}`}</>
}
sx={{
'.MuiListItemText-primary': {fontSize: '12px', color: 'secondary.main'}
}}
/>
</ListItemButton>
</ListItem>
<ListItem disablePadding>
<ListItemButton sx={{padding: '4px 0', fontSize: '12px'}}>
<ListItemIcon sx={{minWidth: '20px', marginRight: '8px', justifyContent: 'center'}}>
<ConceptIcon selected fontSize='small' color='secondary' sx={{width: '14px', height: '14px'}} />
</ListItemIcon>
<ListItemText
primary={
conceptClasses === false ?
<SkeletonText /> :
<>{`${conceptClasses?.toLocaleString()} ${t('concept.concept_classes')}`}</>
}
sx={{
'.MuiListItemText-primary': {fontSize: '12px', color: 'secondary.main'}
}}
/>
</ListItemButton>
</ListItem>
<ListItem disablePadding>
<ListItemButton sx={{padding: '4px 0', fontSize: '12px'}}>
<ListItemIcon sx={{minWidth: '20px', marginRight: '8px', justifyContent: 'center'}}>
<ConceptIcon selected fontSize='small' color='secondary' sx={{width: '14px', height: '14px'}} />
</ListItemIcon>
<ListItemText
primary={
nameTypes === false ?
<SkeletonText /> :
<>{`${nameTypes?.toLocaleString()} ${t('concept.name_types')}`}</>
}
sx={{
'.MuiListItemText-primary': {fontSize: '12px', color: 'secondary.main'}
}}
/>
</ListItemButton>
</ListItem>
<ListItem disablePadding>
<ListItemButton sx={{padding: '4px 0', fontSize: '12px'}}>
<ListItemIcon sx={{minWidth: '20px', marginRight: '8px', justifyContent: 'center'}}>
<LanguageIcon fontSize='small' color='secondary' style={{fontSize: '1rem'}} />
</ListItemIcon>
<ListItemText
primary={
locales === false ?
<SkeletonText /> :
<>{`${locales?.toLocaleString()} ${t('repo.locales')}`}</>
}
sx={{
'.MuiListItemText-primary': {fontSize: '12px', color: 'secondary.main'}
}}
/>
</ListItemButton>
</ListItem>
<ListItem disablePadding>
<ListItemButton sx={{padding: '4px 0', fontSize: '12px'}}>
<ListItemIcon sx={{minWidth: '20px', marginRight: '8px', justifyContent: 'center'}}>
<MappingIcon fontSize='small' color='secondary' />
</ListItemIcon>
<ListItemText
primary={
mapTypes === false ?
<SkeletonText /> :
<>{`${mapTypes?.toLocaleString()} ${t('mapping.map_types')}`}</>
}
sx={{
'.MuiListItemText-primary': {fontSize: '12px', color: 'secondary.main'}
}}
/>
</ListItemButton>
</ListItem>
{
totalVersions > 0 &&
<ListItem disablePadding>
<ListItemButton sx={{padding: '4px 0', fontSize: '12px'}}>
<ListItemIcon sx={{minWidth: '20px', marginRight: '8px', justifyContent: 'center'}}>
<VersionIcon fontSize='small' color='secondary' sx={{fontSize: '1rem'}} />
</ListItemIcon>
<ListItemText
primary={
totalVersions === false ?
<SkeletonText /> :
<Trans
i18nKey='repo.summary_released_versions_from_total'
values={{released: releasedVersions?.toLocaleString(), total: totalVersions?.toLocaleString()}}
/>
}
sx={{
'.MuiListItemText-primary': {fontSize: '12px', color: 'secondary.main'}
}}
/>
</ListItemButton>
</ListItem>
}
</List>
</div>
</div>
)
}

export default RepoSummary
2 changes: 1 addition & 1 deletion src/components/search/ResultConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const ALL_COLUMNS = {
concepts: [
{id: 'id', labelKey: 'common.id', value: 'id', sortOn: 'id_lowercase', className: 'searchable'},
{id: 'name', labelKey: 'concept.display_name', value: 'display_name', sortOn: '_name', className: 'searchable', sortBy: 'asc', renderer: item => (<span><React.Fragment>{item.retired && <Retired style={{marginRight: '8px'}}/>} {item.display_name}</React.Fragment></span>)},
{id: 'concept_class', labelKey: 'concept.concept_class', value: 'concept_class', sortOn: 'concept_class'},
{id: 'concept_class', labelKey: 'concept.concept_class', value: 'concept_class', sortOn: 'concept_class', sx: {whiteSpace: 'pre'}},
{id: 'datatype', labelKey: 'concept.datatype', value: 'datatype', sortOn: 'datatype'},
{id: 'owner', labelKey: 'common.owner', value: 'owner', sortOn: 'owner', nested: false, renderer: item => (<span style={{display: 'flex', whiteSpace: 'nowrap'}}><OwnerIcon noTooltip ownerType={item.owner_type} fontSize='small' sx={{marginRight: '4px'}}/>{item.owner}</span>)},
{id: 'parent', labelKey: 'repo.repo', value: 'source', sortOn: 'source', nested: false, renderer: item => <RepoVersionButton repoType='Source' repo={item.source} version={item.latest_source_version} vertical />},
Expand Down
4 changes: 2 additions & 2 deletions src/components/search/Search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ const Search = props => {
}
<div className='col-xs-12 padding-0' style={{height: '100%'}}>
<div className='col-xs-12 padding-0' style={{height: '100%'}}>
<div className='col-xs-3 split' style={{width: showFilters ? `${FILTERS_WIDTH}px` : 0, padding: showFilters ? '0 8px' : 0, height: props.filtersHeight || 'calc(100vh - 175px)', overflow: 'auto'}}>
<div className='col-xs-3 split' style={{width: showFilters ? `${FILTERS_WIDTH}px` : 0, padding: showFilters ? '0 8px' : 0, height: props.filtersHeight || 'calc(100vh - 175px)', overflow: 'auto', ...(showFilters ? {borderRight: '0.3px solid', borderColor: COLORS.surface.n90} : {})}}>
<SearchFilters
resource={resource}
filters={result[resource]?.facets || {}}
Expand All @@ -367,7 +367,7 @@ const Search = props => {
appliedFilters={filters}
/>
</div>
<div className='col-xs-9 split' style={{width: getSearchResultsWidth(), paddingRight: 0, paddingLeft: showFilters ? '15px' : 0, float: 'right', height: '100%'}}>
<div className='col-xs-9 split' style={{width: getSearchResultsWidth(), paddingRight: 0, paddingLeft: 0, float: 'right', height: '100%'}}>
<div className='col-xs-12 padding-0' style={{height: '100%'}}>
<SearchResults
showFilters={showFilters}
Expand Down
4 changes: 2 additions & 2 deletions src/components/search/SearchResults.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const ResultsToolbar = props => {
return (
<Toolbar
sx={{
bgcolor: '#FFF',
borderRadius: 0,
pl: { sm: 1 },
pr: { xs: 1, sm: 1 },
...(numSelected > 0 && {
Expand All @@ -29,8 +31,6 @@ const ResultsToolbar = props => {
}),
borderBottom: (disabled || display === 'card') ? 'none': '1px solid rgba(224, 224, 224, 1)',
minHeight: '48px !important',
borderTopLeftRadius: '8px',
borderTopRightRadius: '8px'
}}
>
{
Expand Down
17 changes: 11 additions & 6 deletions src/components/search/TableResults.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const EnhancedTableHead = props => {
};
return (
<TableHead sx={{background: props.bgColor}}>
<TableRow sx={{background: 'inherit'}}>
<TableRow sx={{background: '#FFF'}}>
<TableCell padding="checkbox" sx={{background: 'inherit'}}>
<Checkbox
color="primary"
Expand All @@ -40,7 +40,7 @@ const EnhancedTableHead = props => {
align='left'
padding='normal'
sortDirection={orderBy === headCell.id ? order : false}
sx={{background: 'inherit'}}
sx={{background: 'inherit', ...headCell.sx}}
>
<TableSortLabel
active={orderBy === headCell.id}
Expand Down Expand Up @@ -125,13 +125,18 @@ const TableResults = ({selected, bgColor, handleClick, handleRowClick, handleSel
className={isItemSelectedToShow ? 'show-item' : ''}
sx={{
cursor: 'pointer',
backgroundColor: bgColor,
'&:nth-of-type(odd)': {
backgroundColor: 'surface.main'
},
'&:nth-of-type(even)': {
backgroundColor: '#FFF'
},
'&.Mui-selected': {
backgroundColor: bgColor
},
'&.MuiTableRow-hover:hover': {
backgroundColor: isItemSelectedToShow ? bgColor : 'primary.95'
}
},
}}
>
<TableCell padding="checkbox" onClick={event => handleClick(event, id)} style={{color: color}}>
Expand All @@ -154,11 +159,11 @@ const TableResults = ({selected, bgColor, handleClick, handleRowClick, handleSel
scope="row"
padding="normal"
className={column.className}
style={{color: color}}
sx={{color: color}}
>
{value}
</TableCell>:
<TableCell key={idx} align="left" className={column.className} style={{color: color}}>
<TableCell key={idx} align="left" className={column.className} sx={{color: color}}>
{value}
</TableCell>
})
Expand Down
Loading

0 comments on commit cb5f6d9

Please sign in to comment.