@@ -15,56 +15,53 @@ const ApplicationsCard = (props) => {
1515 const { application, i, setModal, classes } = props
1616 const { deleteApp, user, applications } = useContext ( DashboardContext )
1717 const { setAppIndex, setApp, setServicesData, app, example, connectToDB, setChart } = useContext ( ApplicationContext )
18- const [ cardName , dbType , dbURI , description , serviceType ] = applications [ i ]
18+ const [ cardName , dbType , dbURI , description , serviceType ] = application
1919
2020 //dynamic refs
21- const delRef = useRef < any > ( [ ] ) ;
21+ // const delRef = useRef<any>([]);
2222
2323 const navigate = useNavigate ( ) ;
2424
2525 // Handle clicks on Application cards
2626 // v10 info: when card is clicked (not on the delete button) if the service is an AWS instance,
2727 // you are redirected to AWSGraphsContainer passing in the state object containing typeOfService
2828 const handleClick = (
29- event : ClickEvent ,
3029 selectedApp : string ,
3130 selectedService : string ,
3231 i : number
3332 ) => {
34- //delRef refers to the delete button
35- if ( delRef . current [ i ] && ! delRef . current [ i ] . contains ( event . target ) ) {
33+ const services = [ 'auth' , 'client' , 'event-bus' , 'items' , 'inventory' , 'orders' ]
34+ // if (delRef.current[i] && !delRef.current[i].contains(event.target)) {
35+ setAppIndex ( i ) ;
36+ setApp ( selectedApp ) ;
3637 if (
3738 selectedService === 'AWS' ||
3839 selectedService === 'AWS/EC2' ||
3940 selectedService === 'AWS/ECS' ||
4041 selectedService === 'AWS/EKS'
4142 ) {
42- setAppIndex ( i ) ;
43- setApp ( selectedApp ) ;
4443 navigate ( `/aws/:${ app } ` , { state : { typeOfService : selectedService } } ) ;
4544 }
4645 else if ( example ) {
47- setAppIndex ( i ) ;
48- setApp ( selectedApp ) ;
4946 setServicesData ( [ ] ) ;
5047 setChart ( 'communications' )
5148
5249 connectToDB ( user , i , app , dbURI , dbType )
50+ navigate ( `/applications/example/${ services . join ( ' ' ) } ` )
5351 }
5452 else {
55- setAppIndex ( i ) ;
56- setApp ( selectedApp ) ;
5753 setServicesData ( [ ] ) ;
5854 //When we open the service modal a connection is made to the db in a useEffect inside of the service modal component
5955 setModal ( { isOpen :true , type :'serviceModal' } )
6056 }
61- }
57+ // }
6258 } ;
6359
6460 // Asks user to confirm deletion
65- const confirmDelete = ( event : ClickEvent , application : string , i : number ) => {
61+ const confirmDelete = ( event : ClickEvent , i : number ) => {
62+ event . stopPropagation ( )
6663 const message = `The application '${ app } ' will be permanently deleted. Continue?` ;
67- if ( confirm ( message ) ) deleteApp ( i ) ;
64+ if ( confirm ( message ) ) deleteApp ( i , "" ) ;
6865 } ;
6966
7067 return (
@@ -73,41 +70,29 @@ const ApplicationsCard = (props) => {
7370 key = { `card-${ i } ` }
7471 className = { classes . paper }
7572 variant = "outlined"
76- onClick = { event => handleClick ( event , application [ 0 ] , application [ 3 ] , i ) }
73+ onClick = { ( ) => handleClick ( application [ 0 ] , application [ 3 ] , i ) }
7774 >
7875 < div className = "databaseIconContainer" >
7976 < div className = "databaseIconHeader" >
80- { /* {application[1] === 'SQL' ? (
81- <img className="databaseIcon" alt="SQL" />
82- ) : (
83- <img className="databaseIcon" alt="MongoDB" />
84- )} */ }
8577 </ div >
8678 </ div >
8779
8880 < CardHeader
8981 avatar = {
9082 < IconButton
9183 id = "iconButton"
92- ref = { element => {
93- delRef . current [ i ] = element ;
94- } }
9584 className = { classes . iconbutton }
9685 aria-label = "Delete"
97- onClick = { event => confirmDelete ( event , application [ 0 ] , i ) }
86+ onClick = { event => confirmDelete ( event , i ) }
9887 >
9988 < HighlightOffIcon
10089 className = { classes . btnStyle }
10190 id = "deleteIcon"
102- ref = { element => {
103- delRef . current [ i ] = element ;
104- } }
10591 />
10692 </ IconButton >
10793 }
10894 />
10995 < CardContent >
110- { /* <p id="databaseName">Name:</p> */ }
11196 < Typography noWrap id = "databaseName" className = { classes . fontStyles } >
11297 { application [ 0 ] }
11398 </ Typography >
0 commit comments