Skip to content

Commit 3a29c60

Browse files
committed
OpenConceptLab/ocl_issues#2322 | Auto match dialog | rows count and radio button
1 parent 994d79b commit 3a29c60

7 files changed

Lines changed: 89 additions & 16 deletions

File tree

src/components/common/BaseEntityChip.jsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Chip from '@mui/material/Chip'
33
import Skeleton from '@mui/material/Skeleton'
44
import { Avatar as MuiAvatar } from '@mui/material'
55
import { PRIMARY_COLORS } from '../../common/colors'
6+
import { toV3URL } from '../../common/utils'
67

78
const PRIMARY_STYLE = {
89
backgroundColor: `${PRIMARY_COLORS['95']} !important`,
@@ -114,12 +115,22 @@ const Avatar = ({ entity, icon }) => {
114115
</MuiAvatar>
115116
}
116117

117-
const Label = ({ entity, hideType }) => {
118+
const Label = ({ entity, hideType, isVersion }) => {
118119
return (
119120
<span style={{display: 'flex', alignItems: 'center'}} className='entity-label'>
120121
<span className='entity-id'>
121122
<b>{entity?.short_code || entity?.id || entity?.username}</b>
122123
</span>
124+
{
125+
isVersion &&
126+
<React.Fragment>
127+
<span className='divider-span' />
128+
<span className='entity-type'>
129+
{entity.version || entity.id}
130+
</span>
131+
</React.Fragment>
132+
133+
}
123134
{
124135
(entity?.type?.includes('Concept') && entity?.display_name) &&
125136
<span className='entity-name' style={{marginLeft: '4px'}}>
@@ -140,13 +151,13 @@ const Label = ({ entity, hideType }) => {
140151
}
141152

142153

143-
const BaseEntityChip = ({ entity, icon, hideType, primary, size, sx, noLink, ...rest }) => {
154+
const BaseEntityChip = ({ entity, icon, hideType, primary, size, sx, noLink, isVersion, ...rest }) => {
144155
const sizeStyle = ENTITY_CHIP_SIZE_MAP[size || 'medium'] || ENTITY_CHIP_SIZE_MAP.medium
145156
const baseStyle = primary ? PRIMARY_STYLE : SECONDARY_STYLE
146157
return (
147158
<Chip
148159
avatar={<Avatar entity={entity} icon={icon} />}
149-
label={<Label entity={entity} hideType={hideType} />}
160+
label={<Label entity={entity} hideType={hideType} isVersion={isVersion} />}
150161
variant='outlined'
151162
sx={{
152163
borderRadius: '4px',
@@ -161,8 +172,10 @@ const BaseEntityChip = ({ entity, icon, hideType, primary, size, sx, noLink, ...
161172
onClick={noLink ? undefined : event => {
162173
event.stopPropagation()
163174
}}
164-
href={noLink ? undefined : '#' + (entity?.version_url || entity?.url)}
175+
href={noLink ? undefined : '#' + (toV3URL(entity?.version_url || entity?.url))}
165176
component='a'
177+
target='_blank'
178+
rel='noreferrer noopener'
166179
{...rest}
167180
/>
168181
)

src/components/common/OwnerButton.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import Button from '@mui/material/Button'
33
import OwnerIcon from './OwnerIcon'
44
import OwnerTooltip from './OwnerTooltip'
5+
import { toV3URL } from '../../common/utils'
56

67
const Owner = ({owner, ownerType, ownerURL, noIcons, sx, ...rest}) => {
78
const iconProps = {color: 'secondary', style: {marginRight: '8px', width: '0.8em'}}
@@ -26,8 +27,10 @@ const Owner = ({owner, ownerType, ownerURL, noIcons, sx, ...rest}) => {
2627
...sx
2728
}}
2829
startIcon={!noIcons && <OwnerIcon noTooltip ownerType={ownerType} {...iconProps} />}
29-
href={ownerURL ? '#' + ownerURL : undefined}
30+
href={ownerURL ? toV3URL(ownerURL) : undefined}
3031
component="button"
32+
target='_blank'
33+
rel='noreferrer noopener'
3134
{...rest}
3235
>
3336
<span className='owner-button-label'>{owner}</span>

src/components/map-projects/AutoMatchDialog.jsx

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,35 @@ import DialogContent from '@mui/material/DialogContent';
66
import DialogTitle from '@mui/material/DialogTitle';
77
import DialogActions from '@mui/material/DialogActions';
88
import FormControlLabel from '@mui/material/FormControlLabel';
9+
import FormControl from '@mui/material/FormControl';
910
import Checkbox from '@mui/material/Checkbox';
1011
import FormHelperText from '@mui/material/FormHelperText';
1112
import Button from '@mui/material/Button';
13+
import RadioGroup from '@mui/material/RadioGroup';
14+
import Radio from '@mui/material/Radio';
15+
import FormLabel from '@mui/material/FormLabel';
16+
1217
import DoubleArrowIcon from '@mui/icons-material/DoubleArrow';
1318

1419
import CloseIconButton from '../common/CloseIconButton'
20+
import RepoChip from '../repos/RepoVersionChip'
1521
import AIAssistantButton from './AIAssistantButton'
1622

1723

18-
const AutoMatchDialog = ({open, onClose, autoMatchUnmappedOnly, setAutoMatchUnmappedOnly, rowStatuses, autoRunAIAnalysis, setAutoRunAIAnalysis, AIModels, AIModel, setAIModel, repo, onSubmit, inAIAssistantGroup}) => {
24+
const AutoMatchDialog = ({open, onClose, autoMatchUnmappedOnly, setAutoMatchUnmappedOnly, rowStatuses, autoRunAIAnalysis, setAutoRunAIAnalysis, AIModels, AIModel, setAIModel, repoVersion, onSubmit, inAIAssistantGroup}) => {
1925
const { t } = useTranslation()
2026

2127
const getHelperTextForAutoMatchUnmapped = () => {
2228
if (autoMatchUnmappedOnly) {
23-
const count = rowStatuses.readyForReview.length;
29+
const count = rowStatuses.unmapped.length;
2430
if (count > 0) {
2531
return t('map_project.auto_match_unmapped_only_note', {count: count.toLocaleString()});
2632
}
2733
return t('map_project.auto_match_unmapped_only_note_no_count');
2834
}
2935
const approvedCount = rowStatuses.reviewed.length;
3036
const proposedCount = rowStatuses.readyForReview.length;
31-
if (approvedCount > 0 && proposedCount > 0) {
37+
if (approvedCount > 0 || proposedCount > 0) {
3238
return t('map_project.auto_match_note', {
3339
approvedCount: approvedCount.toLocaleString(),
3440
proposedCount: proposedCount.toLocaleString()
@@ -37,6 +43,8 @@ const AutoMatchDialog = ({open, onClose, autoMatchUnmappedOnly, setAutoMatchUnma
3743
return t('map_project.auto_match_note_no_counts');
3844
};
3945

46+
const isDisabled = !repoVersion?.version_url
47+
4048
return (
4149
<Dialog
4250
open={open}
@@ -55,8 +63,34 @@ const AutoMatchDialog = ({open, onClose, autoMatchUnmappedOnly, setAutoMatchUnma
5563
<span>{t('map_project.auto_match')}</span>
5664
<CloseIconButton onClick={onClose} />
5765
</DialogTitle>
58-
<DialogContent sx={{paddingTop: '12px !important'}}>
59-
<FormControlLabel sx={{marginTop: '12px', width: '100%'}} control={<Checkbox checked={autoMatchUnmappedOnly} onChange={event => setAutoMatchUnmappedOnly(event.target.checked)} />} label={t('map_project.unmapped_only')} />
66+
<DialogContent>
67+
<div className='col-xs-12 padding-0' style={{display: 'flex', alignItems: 'center', fontSize: '1rem'}}>
68+
{t('map_project.target_repository')}
69+
{
70+
repoVersion?.id &&
71+
<RepoChip repo={repoVersion} hideType sx={{marginLeft: '16px'}} />
72+
}
73+
</div>
74+
<FormControl sx={{marginTop: '12px'}}>
75+
<FormLabel id="automatch-rows">{t('map_project.input_dataset')}</FormLabel>
76+
<RadioGroup
77+
row
78+
aria-labelledby="automatch-rows"
79+
name="automatch-rows"
80+
onChange={() => setAutoMatchUnmappedOnly(!autoMatchUnmappedOnly)}
81+
>
82+
<FormControlLabel
83+
value="unmapped"
84+
control={<Radio checked={autoMatchUnmappedOnly} />}
85+
label={t('map_project.unmapped_only') + ` (${rowStatuses.unmapped.length.toLocaleString()})`}
86+
/>
87+
<FormControlLabel
88+
value="all"
89+
control={<Radio checked={!autoMatchUnmappedOnly} />}
90+
label={t('map_project.all_rows') + ` (${(rowStatuses.unmapped.length + rowStatuses.readyForReview.length).toLocaleString()})`}
91+
/>
92+
</RadioGroup>
93+
</FormControl>
6094
<FormHelperText sx={{marginTop: '-4px'}}>
6195
{
6296
getHelperTextForAutoMatchUnmapped()
@@ -66,7 +100,7 @@ const AutoMatchDialog = ({open, onClose, autoMatchUnmappedOnly, setAutoMatchUnma
66100
inAIAssistantGroup &&
67101
<>
68102
<FormControlLabel
69-
sx={{marginTop: '0px', width: '100%'}}
103+
sx={{marginTop: '12px', width: '100%'}}
70104
control={
71105
<Checkbox
72106
checked={autoRunAIAnalysis}
@@ -102,7 +136,7 @@ const AutoMatchDialog = ({open, onClose, autoMatchUnmappedOnly, setAutoMatchUnma
102136
size='small'
103137
sx={{textTransform: 'none', marginLeft: '12px'}}
104138
endIcon={<DoubleArrowIcon />}
105-
disabled={!repo?.url}
139+
disabled={isDisabled}
106140
onClick={onSubmit}
107141
>
108142
{t('common.submit')}

src/components/map-projects/MapProject.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ const MapProject = () => {
322322
return
323323
}
324324
setFilters(response.data?.filters || {})
325-
if(response.data.url) {
325+
if(response.data?.url) {
326326
APIService.new().overrideURL(response.data.url).appendToUrl('logs/').get().then(response => {
327327
setLogs(response.data.logs?.row_logs || [])
328328
setProjectLogs(response.data.logs?.project_logs || [])
@@ -2879,7 +2879,7 @@ const MapProject = () => {
28792879
AIModels,
28802880
AIModel,
28812881
setAIModel,
2882-
repo,
2882+
repoVersion,
28832883
inAIAssistantGroup
28842884
}}
28852885
/>

src/components/repos/RepoVersionButton.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import Typography from '@mui/material/Typography'
33
import Button from '@mui/material/Button'
44
import DotSeparator from '../common/DotSeparator'
5+
import { toV3URL } from '../../common/utils'
56

67
const RepoVersionButton = ({icon, repo, repoType, version, repoLabelStyle, versionStyle, href, vertical, size, sx}) => {
78
const verticalStyle = version && vertical ? {flexDirection: 'column', alignItems: 'baseline', textAlign: 'left'} : {}
@@ -27,9 +28,11 @@ const RepoVersionButton = ({icon, repo, repoType, version, repoLabelStyle, versi
2728
...sx
2829
}}
2930
startIcon={icon}
30-
href={href ? '#' + href : undefined}
31+
href={href ? toV3URL(href) : undefined}
3132
component="button"
3233
size={size}
34+
target='_blank'
35+
rel='noreferrer noopener'
3336
>
3437
<span className='repo-button-group' style={{display: 'flex', alignItems: 'center', ...verticalStyle}}>
3538
<span style={{display: 'flex', alignItems: 'center'}}>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react'
2+
import RepoIcon from '@mui/icons-material/FolderOutlined';
3+
import RepoFilledIcon from '@mui/icons-material/Folder';
4+
import BaseEntityChip from '../common/BaseEntityChip'
5+
import RepoTooltip from './RepoTooltip'
6+
7+
const RepoChip = ({ repo, noTooltip, basicTooltip, filled, ...rest }) => {
8+
const icon = filled ? <RepoFilledIcon /> : <RepoIcon />
9+
return noTooltip ? (
10+
<BaseEntityChip entity={repo} icon={icon} isVersion {...rest} />
11+
) : (
12+
<RepoTooltip repo={repo} basicTooltip={basicTooltip}>
13+
<BaseEntityChip entity={repo} icon={icon} isVersion {...rest} />
14+
</RepoTooltip>
15+
)
16+
}
17+
18+
export default RepoChip;

src/i18n/locales/en/translations.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,9 @@
562562
"created_by_log": "<0>{{created_by}}</0> created mapping project in the <1>{{owner}}</1> workspace",
563563
"candidates_metadata": "Candidates Metadata",
564564
"full_project_export": "Full Project Export",
565-
"select_an_algo": "Select an algorithm"
565+
"select_an_algo": "Select an algorithm",
566+
"input_dataset": "Input Dataset",
567+
"all_rows": "All Rows"
566568
},
567569
"app": {
568570
"web_version": "Web Version",

0 commit comments

Comments
 (0)