You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// if statement is used to replace hard coded data. Hard coded data and the michelleWasHere key is needed to avoid a load error caused by Electron querying the database before a user has added or selected a database.
143
142
144
-
//* ** What is happening here --> Ousman */
143
+
// Checks if setup is required by checking if the value for the state key 'setupRequired' is true
145
144
if(state.setupRequired){
145
+
// If setup is required, the value for key 'setupRequired' is reassign to false and the value for key 'services' is reassign to an array with newService as its only element
// Declare a constant ipcRenderer by deconstructing window.require('electron') so that the onDelete function can initialize an IPC Communication
6
6
const{ ipcRenderer }=window.require('electron');
7
7
8
8
9
+
// Deletes a Service
9
10
constDeleteService=(props)=>{
10
-
console.log('in the DeleteService')
11
-
12
-
// Used to toggle setup required if user wants delete all of the databases and the user needs to be sent to the front page.
11
+
// Declares a constant setup and initialize it to the SetupContext.
12
+
// SetupContext indicates whether or not an initial setup is necessary.
13
+
// An initial setup is necessary when the user has not saved any database to chronos frontend application.
13
14
constsetup=useContext(SetupContext);
14
15
15
-
// List of the databases saved by users to track microservices.
16
+
// Declares a variable serviceList and initialize it to the DashboardContext.
17
+
// DashboardContext lists the databases saved by users.
16
18
letserviceList=useContext(DashboardContext);
17
19
18
-
// Only happens when a DB button is clicked
20
+
/*
21
+
Sends a deleteService request with an index to an ipcMain.on function within the Main.js
22
+
On return, the function reassigns the serviceList variable to the updated services provided within the deleteResponse. If the serviceList equals ["hard","coded","in"], then the user has no database saved to the chronos frontend application. If this is true, the function reassigns setup.setupRequired to true by invoking setup.toggleSetup with the argument 'false'. Then the function reloads the application to show the changes made to the services.
23
+
*/
19
24
constonDelete=(index)=>{
20
-
// IPC communication used to delete the button pressed.
// Declares a constant databaseButtons and initialize it an empty array
32
36
constdatabaseButtons=[];
37
+
38
+
/* Iterates over the serviceList to create a button for each service. Each button is pushed into the databaseButtons array as the button is created. Each button has an onclick function that invokes the window confirm function with a warning message (ex:'Are you sure you want to delete this service?') and stores the result of invoking confirm into a constant moveForward. If the moveForward is true, then onDelete function is invoked with the index of where the service is stored within the serviceList*/
0 commit comments