1- import { Card , Switch , Avatar , Button , Select , Tag , Tooltip , Popconfirm , notification } from 'antd' ;
1+ import { Card , Switch , Avatar , Button , Select , Tag , Tooltip , Popconfirm , notification , theme as antdTheme } from 'antd' ;
22
33import { UploadOutlined , DeleteFilled , PlusOutlined , MinusOutlined } from '@ant-design/icons' ;
44
@@ -17,12 +17,16 @@ const { Meta } = Card;
1717const PackageCard : React . FC < PackageCardProps > = ( props : PackageCardProps ) => {
1818 type NotificationType = 'success' | 'info' | 'warning' | 'error' ;
1919
20+ const { token : theme } = antdTheme . useToken ( ) ;
21+
2022 const [ api , contextHolder ] = notification . useNotification ( ) ;
2123
2224 const [ isDevPackage , setIsDevPackage ] = useState ( props . package . is_dev ) ;
2325
2426 const [ isDevDepToggleLoading , setIsDevDepToggleLoading ] = useState ( false ) ;
2527
28+ const [ packageDescription , ] = useState ( `${ props . package . description . slice ( 0 , 75 ) } ${ props . package . description . length >= 75 ? '...' : '' } ` ) ;
29+
2630 const [ selectedVersionToInstall , setSelectedVersionToInstall ] = useState ( props . package . versions [ 0 ] ) ;
2731
2832 function notify ( message : string , description : string , type : NotificationType ) {
@@ -39,19 +43,25 @@ const PackageCard: React.FC<PackageCardProps> = (props: PackageCardProps) => {
3943 try {
4044 await Dataservice . updatePackage ( props . package . name , props . package . installed_version , checked ) ;
4145
46+ debugger ;
4247 setIsDevDepToggleLoading ( false ) ;
4348
4449 props . reRenderPackages ( ) ;
4550
46- notify ( 'Updated the package' , `Successfully updated the package as ${ checked ? 'dev' : 'normal' } dependency` , 'success' ) ;
51+ return notify ( 'Updated the package' , `Successfully updated the package as ${ checked ? 'dev' : 'normal' } dependency` , 'success' ) ;
4752 } catch ( ex ) {
53+ console . log ( 'imma here' )
54+ debugger ;
4855 const msg = `Error updating the package ${ props . package . name } ` ;
4956
5057 console . error ( msg , ex ) ;
5158
52- notify ( 'Updating Package' , msg , 'error' ) ;
59+ return notify ( 'Updating Package' , msg , 'error' ) ;
5360 }
5461 }
62+
63+ // update the existing package - dep type
64+ props . modifyListOfPackagesToInstall ( props . package . name , selectedVersionToInstall , isDevPackage )
5565 }
5666
5767 function uninstallPackage ( packageName : string ) {
@@ -107,18 +117,25 @@ const PackageCard: React.FC<PackageCardProps> = (props: PackageCardProps) => {
107117 { contextHolder }
108118 < div className = "card-main-container" >
109119 < Meta
110- style = { { width : '90%' , overflow : 'hidden ' } }
120+ style = { { width : '90' } }
111121 avatar = { < Avatar src = { props . package . logo } /> }
112122 title = {
113- < a href = { props . package . homepage } target = '_blank' >
123+ < a href = { props . package . homepage } className = "package-link"
124+ target = '_blank' style = { { color : theme . colorText , textDecorationColor : theme . colorPrimary } } >
114125 { `${ props . package . name } ${ props . installed ? ` (${ props . package . installed_version } )` : '' } ` }
115126 </ a >
116127 }
117- description = { `${ props . package . description . slice ( 0 , 150 ) } ${ props . package . description . length >= 150 ? '...' : '' } ` }
128+ description = {
129+ < div title = { props . package . description } >
130+ { packageDescription }
131+ </ div >
132+ }
118133 />
119134 {
120135 props . installed && ( compare ( props . package . installed_version || '' , props . package . latest_version , '=' ) ? ""
121- : < Tag className = "upgradable-tag" color = "success" > Latest : { props . package . latest_version } </ Tag > )
136+ : < Tag className = "upgradable-tag" color = { props . accentColor } >
137+ Latest : { props . package . latest_version }
138+ </ Tag > )
122139 }
123140 < div className = { `card-actions-container ${ props . installed ? 'installed' : '' } ` } >
124141 < div className = "toggle-select-buttons" >
@@ -128,20 +145,23 @@ const PackageCard: React.FC<PackageCardProps> = (props: PackageCardProps) => {
128145 value : props . package . versions [ 0 ] ,
129146 label : props . package . versions [ 0 ]
130147 } }
131- onChange = { ( val ) => setSelectedVersionToInstall ( val . value ) }
148+ onChange = { ( val ) => {
149+ setSelectedVersionToInstall ( val ) ;
150+ props . modifyListOfPackagesToInstall ( props . package . name , val , isDevPackage )
151+ } }
132152 style = { { textAlign : 'center' , minWidth : 80 , maxWidth : 80 , marginRight : '10px' } }
133153 options = { props . package . versions . map ( ver => ( { value : ver , label : ver } ) ) }
134154 />
135155 )
136156 }
137157 < div className = "dev-dependency" >
138158 < Tooltip title = { isDevPackage ? 'Toggle off to make it a regular dependency' : 'Toggle to make it a development dependency' } >
139- < Switch
140- disabled = { ! props . installed && ! props . isPackageSelectedToInstall }
141- checkedChildren = "Dev" unCheckedChildren = "Dev"
142- loading = { isDevDepToggleLoading }
143- onChange = { devDependencyHandler }
144- checked = { isDevPackage } > </ Switch >
159+ < Switch
160+ disabled = { ! props . installed && ! props . isPackageSelectedToInstall }
161+ checkedChildren = "Dev" unCheckedChildren = "Dev"
162+ loading = { isDevDepToggleLoading }
163+ onChange = { devDependencyHandler }
164+ checked = { isDevPackage } > </ Switch >
145165 </ Tooltip >
146166 </ div >
147167 </ div >
0 commit comments