Skip to content

Commit a75eef4

Browse files
Merge pull request #95 from ronellecaguioa/newbug
Resolve bugs
2 parents 9360080 + 21d5861 commit a75eef4

File tree

9 files changed

+25
-21
lines changed

9 files changed

+25
-21
lines changed

app/assets/chronos-v4-bw.png

775 KB
Loading

app/assets/chronos-v4-pangolin.png

421 KB
Loading

app/components/Applications.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useEffect, useState } from 'react';
1+
import React, { useContext, useEffect, useState, useRef } from 'react';
22
import {
33
IconButton,
44
Grid,
@@ -10,33 +10,37 @@ import {
1010
} from '@material-ui/core';
1111
import DeleteForeverOutlinedIcon from '@material-ui/icons/DeleteForeverOutlined';
1212
import { makeStyles } from '@material-ui/core/styles';
13-
import { DashboardContext } from '../context/DashboardContext';
1413

14+
import { DashboardContext } from '../context/DashboardContext';
1515
import ServicesModal from '../modals/ServicesModal';
1616
import '../stylesheets/Applications.css';
1717

18+
type ClickEvent = React.MouseEvent<HTMLElement>;
19+
1820
const Applications = () => {
1921
const { applications, getApplications, deleteApp } = useContext(DashboardContext);
2022
const [open, setOpen] = useState<boolean>(false);
2123
const [index, setIndex] = useState<number>(0);
2224
const [app, setApp] = useState<string>('');
25+
const delRef = useRef<any>(null);
2326

2427
useEffect(() => {
2528
getApplications();
2629
}, []);
2730

2831
// Ask user for deletetion confirmation
29-
const confirmDelete = (app: string, i: number) => {
32+
const confirmDelete = (event: ClickEvent, app: string, i: number) => {
3033
const message = `The application '${app}' will be permanently deleted. Continue?`;
3134
if (confirm(message)) deleteApp(i);
3235
};
3336

3437
// Handle clicks on Application cards
35-
const handleClick = (selectedApp: string, i: number) => {
36-
setIndex(i);
37-
setApp(selectedApp);
38-
console.log('handle', selectedApp);
39-
setOpen(true);
38+
const handleClick = (event: ClickEvent, selectedApp: string, i: number) => {
39+
if (!delRef.current.contains(event.target)) {
40+
setIndex(i);
41+
setApp(selectedApp);
42+
setOpen(true);
43+
}
4044
};
4145

4246
const useStyles = makeStyles(theme => ({
@@ -82,14 +86,15 @@ const Applications = () => {
8286
<Card
8387
className={classes.paper}
8488
variant="outlined"
85-
onClick={(event: React.MouseEvent<HTMLElement>) => handleClick(app[0], i)}
89+
onClick={event => handleClick(event, app[0], i)}
8690
>
8791
<CardHeader
8892
avatar={
8993
<IconButton
94+
ref={delRef}
9095
className={classes.hover}
9196
aria-label="Delete"
92-
onClick={(event: React.MouseEvent<HTMLElement>) => confirmDelete(app[0], i)}
97+
onClick={event => confirmDelete(event, app[0], i)}
9398
>
9499
<DeleteForeverOutlinedIcon />
95100
</IconButton>

app/components/Home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import '../stylesheets/Home.scss';
66
const Home = () => (
77
<div className="home">
88
<div className="pangolin-container">
9-
<img src={'../assets/pangolin.png'} alt="Chronos logo" />
9+
<img src={'../assets/chronos-v4-pangolin.png'} alt="Chronos logo" />
1010
</div>
1111
<h1 id="welcome">Welcome to Chronos</h1>
1212
<p>A very short short description about Chronos...</p>

app/containers/SidebarContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const SidebarContainer: React.FC = (): JSX.Element => (
2929
>
3030
<div className="sidebar">
3131
<img alt="Chronos Logo" id="serviceDashLogo" src={'../assets/icon2Cropped.png'} />
32-
<img alt="Chronos Logo Mini" id="miniLogo" src={'../assets/pangolin.png'} />
32+
<img alt="Chronos Logo Mini" id="miniLogo" src={'../assets/chronos-v4-pangolin.png'} />
3333
<Link className="sidebar-link" to="/" id="home">
3434
<HomeSharpIcon style={{ boxShadow: 'none', width: '40px', height: '40px' }} />
3535
&emsp;Home

app/stylesheets/Header.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ select {
3838
button {
3939
&:first-of-type {
4040
position: absolute;
41-
top: 25px;
42-
left: 130px;
41+
top: 20px;
42+
left: 115px;
4343
background-color: transparent;
4444
border: 1px solid $sidebarblue;
4545
color: $sidebarblue;

app/stylesheets/Home.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
flex-direction: column;
1010

1111
.pangolin-container {
12-
margin-top: 65px;
1312
height: auto;
1413
width: 40%;
1514
max-width: 650px;

app/stylesheets/SidebarContainer.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@
5858
#miniLogo {
5959
position: absolute;
6060
animation: twirl 20s infinite linear;
61-
left: 12px;
62-
top: 35px;
63-
height: 75px;
64-
width: 75px;
61+
left: 18px;
62+
top: 15px;
63+
height: auto;
64+
width: 65px;
6565
opacity: 1;
6666
transition: 200ms;
6767
margin-top: 10px;

electron/routes/dashboard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ ipcMain.on('addApp', (message: IpcMainEvent, application: any) => {
2828
fs.writeFileSync(path.resolve(__dirname, '../user/settings.json'), JSON.stringify(state));
2929

3030
// Sync event - return new applications list
31-
message.returnValue = state.services.map((arr: string[]) => arr[0]);
31+
message.returnValue = state.services.map((arr: string[]) => [arr[0], arr[3], arr[4]]);
3232
});
3333

3434
/**
@@ -70,7 +70,7 @@ ipcMain.on('deleteApp', (message: IpcMainEvent, index) => {
7070
});
7171

7272
// Sync event - return new applications list
73-
message.returnValue = state.services.map((arr: string[]) => arr[0]);
73+
message.returnValue = state.services.map((arr: string[]) => [arr[0], arr[3], arr[4]]);
7474
});
7575

7676
// module.exports = dashboard;

0 commit comments

Comments
 (0)