Skip to content

Commit 37c140e

Browse files
committed
aaron merge open projects bug fixed
1 parent 559d756 commit 37c140e

File tree

5 files changed

+36
-31
lines changed

5 files changed

+36
-31
lines changed

app/src/components/login/ProjectsFolder.tsx

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import { stateContext } from '../../context/context';
1818
const useStyles = makeStyles({
1919
avatar: {
2020
backgroundColor: blue[100],
21-
color: blue[600],
22-
},
21+
color: blue[600]
22+
}
2323
});
2424

2525
export interface ProjectDialogProps {
@@ -32,11 +32,12 @@ export interface ProjectDialogProps {
3232
function ProjectsDialog(props: ProjectDialogProps) {
3333
const classes = useStyles();
3434
const { onClose, open, projects } = props;
35+
console.log('Inside projectsdialogbox projects is', projects);
3536
const [_, dispatch] = useContext(stateContext);
3637

3738
useEffect(() => {
3839
console.log('state is', _);
39-
}, [_])
40+
}, [_]);
4041

4142
// If no projects selected, keep the name of the current displayed
4243
const handleClose = () => {
@@ -47,18 +48,27 @@ function ProjectsDialog(props: ProjectDialogProps) {
4748

4849
// If new project selected, close and set value to new project name
4950
const handleListItemClick = (value: string) => {
50-
const selectedProject = projects.filter(project => project.name === value)[0].project;
51-
console.log('project to open', selectedProject);
51+
const selectedProject = projects.filter(
52+
project => project.name === value
53+
)[0];
5254
dispatch({ type: 'OPEN PROJECT', payload: selectedProject });
5355
onClose();
5456
};
5557

5658
return (
57-
<Dialog onClose={handleClose} aria-labelledby="project-dialog-title" open={open}>
59+
<Dialog
60+
onClose={handleClose}
61+
aria-labelledby="project-dialog-title"
62+
open={open}
63+
>
5864
<DialogTitle id="project-dialog-title">Open Project</DialogTitle>
5965
<List>
6066
{projects.map((project, index) => (
61-
<ListItem button onClick={() => handleListItemClick(project.name)} key={index}>
67+
<ListItem
68+
button
69+
onClick={() => handleListItemClick(project.name)}
70+
key={index}
71+
>
6272
<ListItemAvatar>
6373
<Avatar className={classes.avatar}>
6474
<FolderOpenIcon />
@@ -74,7 +84,7 @@ function ProjectsDialog(props: ProjectDialogProps) {
7484
<AddIcon />
7585
</Avatar>
7686
</ListItemAvatar>
77-
<ListItemText primary="New Project"/>
87+
<ListItemText primary="New Project" />
7888
</ListItem>
7989
</List>
8090
</Dialog>
@@ -83,15 +93,15 @@ function ProjectsDialog(props: ProjectDialogProps) {
8393

8494
export default function ProjectsFolder() {
8595
const [open, setOpen] = useState(false);
86-
const [projects, setProjects] = useState([{hello: 'cat'}]);
96+
const [projects, setProjects] = useState([{ hello: 'cat' }]);
8797

8898
const handleClickOpen = () => {
8999
getProjects().then(data => {
90100
setProjects(data);
91101
setOpen(true);
92-
})
102+
});
93103
};
94-
104+
95105
const handleClose = () => {
96106
setOpen(false);
97107
};
@@ -101,7 +111,7 @@ export default function ProjectsFolder() {
101111
<Button variant="outlined" color="primary" onClick={handleClickOpen}>
102112
Open Project
103113
</Button>
104-
<ProjectsDialog open={open} onClose={handleClose} projects={projects}/>
114+
<ProjectsDialog open={open} onClose={handleClose} projects={projects} />
105115
</div>
106116
);
107-
}
117+
}

app/src/components/login/SignIn.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ const SignIn: React.FC<LoginInt & RouteComponentProps> = props => {
202202
>
203203
Sign In
204204
</Button>
205-
206-
<Button
205+
{/* Hiding github oauth button as it's still buggy and not fully working */}
206+
{/* <Button
207207
fullWidth
208208
variant="contained"
209209
color="default"
@@ -221,7 +221,7 @@ const SignIn: React.FC<LoginInt & RouteComponentProps> = props => {
221221
}}
222222
>
223223
<GitHubIcon />
224-
</Button>
224+
</Button> */}
225225

226226
<Button
227227
fullWidth

app/src/containers/LeftContainer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const useStyles = makeStyles({
5454
// Left-hand portion of the app, where component options are displayed
5555
const LeftContainer = (): JSX.Element => {
5656
const [state, dispatch] = useContext(stateContext);
57+
5758
const classes = useStyles();
5859
// state to keep track of how the user wants their components to be exported
5960
// genOption = 0 --> export only components

app/src/containers/RightContainer.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ const RightContainer = (props): JSX.Element => {
232232
console.log('Logout clicked, destroying cookie, redirect to login');
233233
// destroys "cookie" by clearing localStorage if guest
234234
window.localStorage.clear();
235+
// destroy cookie on production when not seen by chromium browser using ipcrenderer
236+
window.api.delCookie();
235237
// destroys cookie if user by backdating cookie expiration date
236238
document.cookie = 'ssid=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
237239
// uses useHistory to return to the login page
@@ -434,9 +436,9 @@ const RightContainer = (props): JSX.Element => {
434436
''
435437
)}
436438
<div className={classes.logoutButton}>
437-
<SaveProjectButton/>
438-
<ProjectsFolder/>
439-
<LoginButton/>
439+
<SaveProjectButton />
440+
<ProjectsFolder />
441+
<LoginButton />
440442
</div>
441443
</div>
442444
);

app/src/reducers/componentReducer.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -319,26 +319,18 @@ const reducer = (state: State, action: Action) => {
319319
return {
320320
...state,
321321
name: projectName
322-
}
322+
};
323323
}
324324

325325
case 'OPEN PROJECT': {
326-
const { name, components, rootComponents, canvasFocus, nextComponentId, nextChildId } = action.payload;
327-
console.log('triggered reducer');
328326
return {
329-
...state,
330-
name: name,
331-
components: components,
332-
rootComponents: rootComponents,
333-
nextComponentId: nextComponentId,
334-
nextChildId: nextChildId,
335-
canvasFocus: canvasFocus
336-
}
327+
...action.payload
328+
};
337329
}
338330

339331
default:
340332
return state;
341333
}
342334
};
343335

344-
export default reducer;
336+
export default reducer;

0 commit comments

Comments
 (0)