66 ModuleRegistry ,
77 AllCommunityModule ,
88 RowClickedEvent ,
9+ RowClassParams ,
910} from 'ag-grid-community' ;
10- import { CheckCircle2 , X } from 'lucide-react' ;
11+ import { X } from 'lucide-react' ;
1112
1213import { Ability } from '@/types/developer-dashboard/appTypes' ;
1314import {
@@ -32,19 +33,38 @@ interface SelectedAbilityWithVersion {
3233// Dynamic column definitions based on selected abilities
3334const createToolGridColumns = (
3435 selectedAbilities : Map < string , SelectedAbilityWithVersion > ,
36+ onAddClick : ( ability : Ability ) => void ,
37+ onRemoveClick : ( packageName : string ) => void ,
3538) : ColDef [ ] => [
3639 {
3740 headerName : '' ,
3841 field : 'packageName' ,
39- width : 50 ,
40- maxWidth : 50 ,
41- minWidth : 50 ,
42+ width : 80 ,
43+ maxWidth : 80 ,
44+ minWidth : 80 ,
4245 suppressNavigable : true ,
4346 cellRenderer : ( params : ICellRendererParams ) => {
4447 const isSelected = selectedAbilities . has ( params . value ) ;
4548 return (
4649 < div className = "flex items-center justify-center h-full" >
47- { isSelected && < CheckCircle2 className = "w-5 h-5" style = { { color : theme . brandOrange } } /> }
50+ < button
51+ onClick = { ( e ) => {
52+ e . stopPropagation ( ) ;
53+ if ( isSelected ) {
54+ onRemoveClick ( params . value ) ;
55+ } else {
56+ onAddClick ( params . data ) ;
57+ }
58+ } }
59+ className = { `px-3 py-1 text-xs font-semibold rounded transition-colors ${
60+ isSelected
61+ ? 'bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-400 dark:hover:bg-gray-500'
62+ : 'text-white hover:opacity-90'
63+ } `}
64+ style = { ! isSelected ? { backgroundColor : theme . brandOrange } : undefined }
65+ >
66+ { isSelected ? 'Added' : 'Add' }
67+ </ button >
4868 </ div >
4969 ) ;
5070 } ,
@@ -174,21 +194,22 @@ export function AbilitySelectorModal({
174194 ( ability ) => ! existingAbilities . includes ( ability . packageName ) && ! ability . isDeleted ,
175195 ) ;
176196
197+ const handleAddClick = ( ability : Ability ) => {
198+ // Open version selector modal to select
199+ setSelectedAbility ( ability ) ;
200+ setIsVersionSelectorOpen ( true ) ;
201+ } ;
202+
177203 const handleRowClick = async ( event : RowClickedEvent ) => {
178204 const ability = event . data ;
179205 if ( ! ability ) {
180206 return ;
181207 }
182208
183- // If already selected, deselect it
209+ // Only allow deselection via row click
184210 if ( selectedAbilities . has ( ability . packageName ) ) {
185211 handleRemoveSelection ( ability . packageName ) ;
186- return ;
187212 }
188-
189- // Open version selector modal to select
190- setSelectedAbility ( ability ) ;
191- setIsVersionSelectorOpen ( true ) ;
192213 } ;
193214
194215 const handleVersionSelect = async ( version : string ) => {
@@ -254,7 +275,7 @@ export function AbilitySelectorModal({
254275 }
255276 } ;
256277
257- const getRowClass = ( params : any ) => {
278+ const getRowClass = ( params : RowClassParams ) => {
258279 const isSelected = selectedAbilities . has ( params . data ?. packageName ) ;
259280 return `cursor-pointer hover:bg-gray-50 dark:hover:bg-neutral-700 ${ isSelected ? 'bg-orange-50 dark:bg-orange-900/10' : '' } ` ;
260281 } ;
@@ -270,8 +291,8 @@ export function AbilitySelectorModal({
270291 Add Abilities to App Version
271292 </ DialogTitle >
272293 < DialogDescription className = { `${ theme . textMuted } ` } style = { fonts . body } >
273- Click any ability to select a version. Click again to deselect. You can select multiple
274- abilities before adding them.
294+ Click "Add" to select a version for an ability . Click "Added" to deselect. You can
295+ select multiple abilities before adding them.
275296 </ DialogDescription >
276297 </ DialogHeader >
277298
@@ -293,7 +314,11 @@ export function AbilitySelectorModal({
293314 >
294315 < AgGridReact
295316 rowData = { filteredAbilities }
296- columnDefs = { createToolGridColumns ( selectedAbilities ) }
317+ columnDefs = { createToolGridColumns (
318+ selectedAbilities ,
319+ handleAddClick ,
320+ handleRemoveSelection ,
321+ ) }
297322 defaultColDef = { DEFAULT_COL_DEF }
298323 onRowClicked = { handleRowClick }
299324 getRowClass = { getRowClass }
0 commit comments