From bde42f80adf1cebcf5d9f7a7c8657ce1f517183d Mon Sep 17 00:00:00 2001 From: Stephen Yang Date: Thu, 9 May 2024 16:54:24 -0700 Subject: [PATCH 1/3] updated serviceslink component with deconstructed props --- app/modals/ServicesModal/ServicesLink.tsx | 22 ++++++++++++---------- app/modals/ServicesModal/ServicesModal.tsx | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/modals/ServicesModal/ServicesLink.tsx b/app/modals/ServicesModal/ServicesLink.tsx index b2d45837b..7f7b5bdb1 100644 --- a/app/modals/ServicesModal/ServicesLink.tsx +++ b/app/modals/ServicesModal/ServicesLink.tsx @@ -8,22 +8,24 @@ interface IService { const ServicesLink = (props) => { + const { services, setServices, servicesData, app} = props; + const toggleService = service => { - if (props.services.includes(service)) { - props.setServices(props.services.filter(el => el !== service)); + if (services.includes(service)) { + setServices(services.filter(el => el !== service)); } else { - if (service !== 'communications' && props.services.includes('communications')) props.setServices([]); - props.setServices(props.services.concat(service)); + if (service !== 'communications' && services.includes('communications')) setServices([]); + setServices(services.concat(service)); } }; return (
- {props.servicesData.map((service: IService, index: number) => ( + {servicesData.map((service: IService, index: number) => (
toggleService(service.microservice)} > {service.microservice} @@ -31,11 +33,11 @@ const ServicesLink = (props) => { ))} 0 ? `/applications/${props.app}/${props.services.join(' ')}` : '#'} + to={services.length > 0 ? `/applications/${app}/${services.join(' ')}` : '#'} > - {props.services.length === 0 && 'Select Services'} - {props.services.length === 1 && 'Display Service'} - {props.services.length > 1 && 'Compare Services'} + {services.length === 0 && 'Select Services'} + {services.length === 1 && 'Display Service'} + {services.length > 1 && 'Compare Services'}
) diff --git a/app/modals/ServicesModal/ServicesModal.tsx b/app/modals/ServicesModal/ServicesModal.tsx index 8e02d3a86..56e028c40 100644 --- a/app/modals/ServicesModal/ServicesModal.tsx +++ b/app/modals/ServicesModal/ServicesModal.tsx @@ -26,6 +26,7 @@ const ServicesModal: React.FC = React.memo(({ i, app }) => { const { user, applications } = useContext(DashboardContext); const { servicesData, connectToDB } = useContext(ApplicationContext); const [services, setServices] = useState>([]); + console.log(services); const [ cardName,dbType,dbURI,description,serviceType ] = applications[i] From 373ca45e3061b4aae3da3b19d39b545b7e8cf5ad Mon Sep 17 00:00:00 2001 From: Stephen Yang Date: Sat, 11 May 2024 10:21:25 -0700 Subject: [PATCH 2/3] added select all services button --- app/context/ApplicationContext.tsx | 5 ++--- app/modals/ServicesModal/ServicesLink.tsx | 9 +++++++-- app/modals/ServicesModal/ServicesModal.scss | 4 ++-- app/modals/ServicesModal/ServicesModal.tsx | 1 + 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/context/ApplicationContext.tsx b/app/context/ApplicationContext.tsx index 7885794ac..6f7bdce3e 100644 --- a/app/context/ApplicationContext.tsx +++ b/app/context/ApplicationContext.tsx @@ -44,13 +44,13 @@ const ApplicationContextProvider: React.FC = React.memo(props = console.log({application}); // console.log('Hi, inside ApplicationConext - fetchServicesNames callback. Sending servicesRequest to ipcMain.'); console.log('app when fetch services name: ', application); - console.log(application) + ipcRenderer.send('servicesRequest'); ipcRenderer.on('servicesResponse', (event: Electron.Event, data: any) => { //data here refers to the data coming the services document of the database let result: any; result = JSON.parse(data); - console.log('result from ipcrenderer services response is: ', result); + // console.log('Calling setServicesData passing in above result. Current servicesData is the following: ', servicesData); setServicesData(result); ipcRenderer.removeAllListeners('servicesResponse'); @@ -71,7 +71,6 @@ const ApplicationContextProvider: React.FC = React.memo(props = ipcRenderer.removeAllListeners('databaseConnected'); ipcRenderer.send('connect', username, index, URI, databaseType); ipcRenderer.on('databaseConnected', (event: Electron.Event, data: any) => { - console.log({data}); if(data === true) { fetchServicesNames(application); } else { diff --git a/app/modals/ServicesModal/ServicesLink.tsx b/app/modals/ServicesModal/ServicesLink.tsx index 7f7b5bdb1..8bfe2f560 100644 --- a/app/modals/ServicesModal/ServicesLink.tsx +++ b/app/modals/ServicesModal/ServicesLink.tsx @@ -31,14 +31,19 @@ const ServicesLink = (props) => { {service.microservice}
))} - 0 ? `/applications/${app}/${services.join(' ')}` : '#'} > {services.length === 0 && 'Select Services'} {services.length === 1 && 'Display Service'} {services.length > 1 && 'Compare Services'} + + Select All Services + ) } diff --git a/app/modals/ServicesModal/ServicesModal.scss b/app/modals/ServicesModal/ServicesModal.scss index 86456902c..51d84e6f2 100644 --- a/app/modals/ServicesModal/ServicesModal.scss +++ b/app/modals/ServicesModal/ServicesModal.scss @@ -49,7 +49,7 @@ text-align: center; font-weight: 100; - &#selectLink { + &.selectLink { background-color: #fbdca3; } @@ -83,4 +83,4 @@ font-weight: 100; color: #444d56; border-radius: 5px; -} +} \ No newline at end of file diff --git a/app/modals/ServicesModal/ServicesModal.tsx b/app/modals/ServicesModal/ServicesModal.tsx index 56e028c40..d2b59cd82 100644 --- a/app/modals/ServicesModal/ServicesModal.tsx +++ b/app/modals/ServicesModal/ServicesModal.tsx @@ -27,6 +27,7 @@ const ServicesModal: React.FC = React.memo(({ i, app }) => { const { servicesData, connectToDB } = useContext(ApplicationContext); const [services, setServices] = useState>([]); console.log(services); + console.log(services.join(' ')); const [ cardName,dbType,dbURI,description,serviceType ] = applications[i] From 6d430d40f82367f77c66a8a09162780837bc0639 Mon Sep 17 00:00:00 2001 From: Stephen Yang Date: Sat, 11 May 2024 10:38:34 -0700 Subject: [PATCH 3/3] deconstructed props in all modal components --- app/modals/AddModal/ServiceDBType.tsx | 7 ++++--- app/modals/AddModal/ServicesDescription.tsx | 13 +++++++------ app/modals/AwsModal/AwsDescription.tsx | 9 +++++---- app/modals/AwsModal/AwsKeyUrl.tsx | 21 +++++++++++---------- app/modals/AwsModal/AwsRegion.tsx | 5 +++-- app/modals/AwsModal/AwsServiceInstance.tsx | 11 ++++++----- 6 files changed, 36 insertions(+), 30 deletions(-) diff --git a/app/modals/AddModal/ServiceDBType.tsx b/app/modals/AddModal/ServiceDBType.tsx index 34f3cf071..f436eb210 100644 --- a/app/modals/AddModal/ServiceDBType.tsx +++ b/app/modals/AddModal/ServiceDBType.tsx @@ -2,6 +2,7 @@ import React from 'react'; const ServiceDBType = (props) => { + const { typeOfService, handleChange, database } = props return ( <>
@@ -11,8 +12,8 @@ const ServiceDBType = (props) => { props.handleChange(e)}> + diff --git a/app/modals/AddModal/ServicesDescription.tsx b/app/modals/AddModal/ServicesDescription.tsx index a36cae142..174fa00dd 100644 --- a/app/modals/AddModal/ServicesDescription.tsx +++ b/app/modals/AddModal/ServicesDescription.tsx @@ -1,6 +1,7 @@ import React from 'react'; const ServicesDescription = (props) => { + const { URI, handleChange, name, description } = props; return ( <>
@@ -10,8 +11,8 @@ const ServicesDescription = (props) => { props.handleChange(e)} + value={URI} + onChange={e => handleChange(e)} placeholder="Database URI" required /> @@ -24,8 +25,8 @@ const ServicesDescription = (props) => { id="db-name" type="text" name="name" - value={props.name} - onChange={e => props.handleChange(e)} + value={name} + onChange={e => handleChange(e)} placeholder="Add a name for your new service" required /> @@ -35,8 +36,8 @@ const ServicesDescription = (props) => {