Skip to content

Commit 3337f85

Browse files
committed
Multple cards can now be added at once
Inside of application context add app was adjusted to render multiple cards at once. Each cards data is added to an object that is iterated over
1 parent af08add commit 3337f85

3 files changed

Lines changed: 44 additions & 35 deletions

File tree

app/containers/SidebarContainer.tsx

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,39 @@ const SidebarContainer = React.memo(() => {
3232

3333
setExample(true)
3434

35-
// const examplesData = {
36-
// microServicesFields: {
37-
// typeOfService: 'Microservices',
38-
// database: 'MongoDB',
39-
// URI: "mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.2.5",
40-
// name: 'Microservices',
41-
// description: 'Example'
42-
// },
43-
44-
// ,
45-
// dockerData: {
46-
// typeOfService: 'Docker',
47-
// database: 'MongoDB',
48-
// URI: "mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.2.5",
49-
// name: 'Docker',
50-
// description: 'Example'
51-
// }
52-
// }
53-
54-
const fields = {
55-
typeOfService: 'Microservices',
56-
database: 'MongoDB',
57-
URI: "mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.2.5",
58-
name: 'Microservices',
59-
description: 'Example'
35+
const examplesData = {
36+
microServicesMongoFields: {
37+
typeOfService: 'Microservices',
38+
database: 'MongoDB',
39+
URI: "mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.2.5",
40+
name: 'Microservices-Mongo',
41+
description: 'Mongo Microservices Example'
42+
},
43+
microServicesSQLFields: {
44+
typeOfService: 'Microservices',
45+
database: 'SQL',
46+
URI: "mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.2.5",
47+
name: 'Microservices-SQL',
48+
description: 'SQL Microservices Example'
49+
}
50+
,
51+
dockerMongoData: {
52+
typeOfService: 'Docker',
53+
database: 'MongoDB',
54+
URI: "mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.2.5",
55+
name: 'Docker-Mongo',
56+
description: 'Docker Example'
57+
},
58+
dockerSQLData: {
59+
typeOfService: 'Docker',
60+
database: 'SQL',
61+
URI: "mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.2.5",
62+
name: 'Docker-SQL',
63+
description: 'Docker Example'
64+
}
6065
}
6166

62-
addApp(fields)
67+
addApp(examplesData)
6368
}
6469

6570
const handleExitExample = () => {

app/context/DashboardContext.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,19 @@ const DashboardContextProvider = React.memo((props: any) => {
5757
}, []);
5858

5959
const addApp = useCallback((fields: IFields) => {
60-
const { typeOfService, database, URI, name, description } = fields;
6160

62-
const result = ipcRenderer.sendSync(
63-
'addApp',
64-
JSON.stringify([name, database, URI, description, typeOfService])
65-
);
66-
setApplications(result);
67-
// console.log({result})
68-
// console.log('the current application that was added is : ', result);
61+
for(let field of Object.keys(fields)) {
62+
const { typeOfService, database, URI, name, description } = fields[field];
63+
const result = ipcRenderer.sendSync(
64+
'addApp',
65+
JSON.stringify([name, database, URI, description, typeOfService])
66+
);
67+
setApplications(result);
68+
// console.log({result})
69+
// console.log('the current application that was added is : ', result);
70+
}
71+
72+
6973
}, []);
7074

7175
const addAwsApp = useCallback((awsFields: AwsFields) => {

app/modals/AddModal/AddModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const AddModal: React.FC<TModalSetter> = React.memo(({ setModal }) => {
3939
event.preventDefault();
4040
// const newApp = [name, database, URI, description, typeOfService];
4141
// setApplications(prev => [...prev, ...newApp])
42-
addApp(fields);
42+
addApp({fields});
4343
setModal({isOpen:false,type:''})
4444
};
4545

0 commit comments

Comments
 (0)