Skip to content

Commit 8382031

Browse files
fixed selection issue when more than one registry devfile available (#2675)
Signed-off-by: msivasubramaniaan <msivasub@redhat.com> Signed-off-by: msivasubramaniaan <msivasub@redhat.com>
1 parent 6bbee42 commit 8382031

File tree

4 files changed

+37
-49
lines changed

4 files changed

+37
-49
lines changed

src/webview/git-import/app/cardItem.style.tsx

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { Theme, createStyles } from '@material-ui/core/styles';
77

8-
export default (theme: Theme) =>
8+
export default (_theme: Theme) =>
99
createStyles({
1010
card: {
1111
display: 'inline-table',
@@ -43,17 +43,17 @@ export default (theme: Theme) =>
4343
},
4444
cardBody: {
4545
height: 'auto',
46+
width: '50%',
4647
overflow: 'hidden',
4748
margin: '1.5rem 1rem'
4849
},
4950
cardRegistryTitle: {
50-
color: 'var(--vscode-textLink-activeForeground)',
5151
minWidth: '5rem',
5252
height: '2rem',
5353
whiteSpace: 'nowrap',
5454
overflow: 'hidden',
5555
display: 'block',
56-
textAlign: 'left',
56+
textAlign: 'right',
5757
textDecoration: 'none',
5858
textOverflow: 'ellipsis',
5959
wordBreak: 'break-all',
@@ -62,38 +62,12 @@ export default (theme: Theme) =>
6262
margin: '1rem'
6363
},
6464
badge: {
65-
minWidth: '0.5rem',
66-
maxWidth: '5rem',
65+
height: '1px',
6766
padding: '0.5rem',
68-
minHeight: '2px',
69-
maxHeight: '1rem',
7067
borderRadius: '0.5rem!important',
71-
marginLeft: '0.5rem',
7268
alignItems: 'center',
7369
color: 'inherit',
74-
backgroundColor: 'var(--vscode-badge-background)',
7570
outline: '0.0625rem solid',
76-
outlineColor: 'inherit'
77-
},
78-
headerBadge: {
79-
height: '1px',
80-
outline: 'none'
81-
},
82-
firstBadge: {
83-
marginLeft: '0rem'
84-
},
85-
cardFooterTag: {
86-
marginTop: '0.125rem',
87-
marginLeft: '1.5rem',
88-
marginBottom: '1rem'
89-
},
90-
text: {
91-
textAlign: 'right'
92-
},
93-
longDescription: {
94-
overflow: 'hidden',
95-
display: '-webkit-box',
96-
WebkitLineClamp: 3,
97-
WebkitBoxOrient: 'vertical'
71+
outlineColor: '#EE0000'
9872
}
9973
});

src/webview/git-import/app/cardItem.tsx

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
* Licensed under the MIT License. See LICENSE file in the project root for license information.
44
*-----------------------------------------------------------------------------------------------*/
55
import React from 'react';
6-
import StarIcon from '@mui/icons-material/Star';
7-
import StarBorderIcon from '@mui/icons-material/StarBorder';
8-
import { Card, makeStyles, Typography } from '@material-ui/core';
6+
import CheckBoxOutlineBlankOutlinedIcon from '@mui/icons-material/CheckBoxOutlineBlankOutlined';
7+
import CheckBoxOutlinedIcon from '@mui/icons-material/CheckBoxOutlined';
8+
import { Badge, Card, makeStyles, Typography } from '@material-ui/core';
99
import { CompTypeDesc } from './gitImport';
1010
import cardItemStyle from './cardItem.style';
1111

@@ -36,27 +36,39 @@ export const CardItem: React.FC<CardProps> = ({
3636
src={compDesc.devfileData.devfile.metadata.icon}
3737
className={style.cardImage} />
3838
<div className={style.cardRegistryTitle}>
39-
{compDesc.selected ? <StarIcon style={{ fontSize: 20 }} /> : <StarBorderIcon style={{ fontSize: 20 }} />}
39+
{compDesc.selected ? <CheckBoxOutlinedIcon style={{ fontSize: 20, color: '#EE0000' }} /> : <CheckBoxOutlineBlankOutlinedIcon style={{ fontSize: 20, color: '#EE0000' }} />}
4040
</div>
4141
</div>
4242
</div>
4343
<div style={{ margin: '1.5rem' }}>
4444
<Typography variant='body1'>{compDesc.devfileData.devfile.metadata.name}</Typography>
4545
</div>
46-
<div className={style.cardBody}>
46+
<div style={{ display: 'flex', flexDirection: 'row', gap: '1rem', width: 'auto' }}>
47+
<div className={style.cardBody}>
48+
{
49+
compDesc.devfileData.devfile.metadata.version && (
50+
<Typography variant='caption'>
51+
Version: {compDesc.devfileData.devfile.metadata.version}<br />
52+
</Typography>
53+
)
54+
}
55+
<Typography variant='caption'>
56+
Project Type: {capitalizeFirstLetter(compDesc.devfileData.devfile.metadata.projectType)}<br />
57+
</Typography>
58+
<Typography variant='caption'>
59+
Language: {capitalizeFirstLetter(compDesc.devfileData.devfile.metadata.language)}<br />
60+
</Typography>
61+
</div>
4762
{
48-
compDesc.devfileData.devfile.metadata.version && (
49-
<Typography variant='caption'>
50-
Version: {compDesc.devfileData.devfile.metadata.version}<br />
51-
</Typography>
52-
)
63+
compDesc.registry.name.toLowerCase() !== 'defaultdevfileregistry' &&
64+
<div style={{alignSelf:'flex-end', marginBottom: '2rem'}}>
65+
<Badge key='badge' className={style.badge}
66+
overlap='rectangular'
67+
variant='standard'>
68+
{compDesc.registry.name}
69+
</Badge>
70+
</div>
5371
}
54-
<Typography variant='caption'>
55-
Project Type: {capitalizeFirstLetter(compDesc.devfileData.devfile.metadata.projectType)}<br />
56-
</Typography>
57-
<Typography variant='caption'>
58-
Language: {capitalizeFirstLetter(compDesc.devfileData.devfile.metadata.language)}<br />
59-
</Typography>
6072
</div>
6173
</Card>
6274
</>

src/webview/git-import/app/gitImport.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ export class GitImport extends React.Component<DefaultProps, {
278278

279279
handleSelectedCard(compTypeDesc: CompTypeDesc): void {
280280
this.state.compDescription.forEach((compDesc) => {
281-
if (compDesc.devfileData.devfile.metadata.name === compTypeDesc.devfileData.devfile.metadata.name) {
281+
if (compDesc.devfileData.devfile.metadata.name === compTypeDesc.devfileData.devfile.metadata.name
282+
&& compDesc.registry.name === compTypeDesc.registry.name) {
282283
compTypeDesc.selected = !compTypeDesc.selected;
283284
compDesc.selected = compTypeDesc.selected;
284285
} else {
@@ -341,7 +342,7 @@ export class GitImport extends React.Component<DefaultProps, {
341342
helperText={gitURL.helpText}>
342343
</TextField>
343344
{gitURL.helpText !== '' ?
344-
gitURL.helpText === 'Validated' ?
345+
gitURL.helpText.indexOf('valid') !== -1 ?
345346
<CheckCircleIcon color='success' style={{ paddingTop: '1rem' }} /> :
346347
gitURL.helpText.indexOf('but cannot be reached') !== -1 ?
347348
<ErrorIcon color='warning' style={{ paddingTop: '1rem' }} /> :

src/webview/git-import/gitImportLoader.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export class Command {
4646
projectName: event.projectName,
4747
applicationName: event.applicationName,
4848
compName: event.componentName,
49+
registryName: event.compDesc?.registry.name,
4950
devFilePath: !event.devFilePath || event.devFilePath === 'devfile.yaml' || event.devFilePath === 'devfile.yml' ?
5051
'' : event.devFilePath
5152
}, true);

0 commit comments

Comments
 (0)