Skip to content

Commit fa6342c

Browse files
committed
Built new UI for project management section of UI. Cleaned up Typescript errors
1 parent c136e42 commit fa6342c

File tree

6 files changed

+96
-59
lines changed

6 files changed

+96
-59
lines changed

app/src/components/left/ComponentPanel.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ const ComponentPanel = (): JSX.Element => {
9090
resetError();
9191
};
9292

93-
9493
const isFocus = (targetId: Number) => {
9594
return state.canvasFocus.componentId === targetId ? true : false;
9695
};
@@ -117,7 +116,11 @@ const ComponentPanel = (): JSX.Element => {
117116
<FormControlLabel
118117
value="top"
119118
control={
120-
<Checkbox color="primary" onChange={toggleRootStatus} />
119+
<Checkbox
120+
color="primary"
121+
checked={isRoot}
122+
onChange={toggleRootStatus}
123+
/>
121124
}
122125
label={state.projectType === 'Next.js' ? 'Page' : 'Root'}
123126
className={classes.rootCheckBoxLabel}

app/src/components/right/LoginButton.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ import React, { useContext } from 'react';
22
import { stateContext } from '../../context/context';
33
import Button from '@material-ui/core/Button';
44
import ExitToAppIcon from '@material-ui/icons/ExitToApp';
5-
import { useHistory } from "react-router-dom";
5+
import { useHistory } from 'react-router-dom';
6+
import { makeStyles } from '@material-ui/core/styles';
67

78
export default function LoginButton() {
89
let history = useHistory();
910
const [state, dispatch] = useContext(stateContext);
1011

12+
const classes = useStyles();
13+
1114
const handleLogout = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
1215
e.preventDefault();
13-
console.log('Logout clicked, destroying cookie, redirect to login');
1416
// destroys cookie by backdating expiration time
1517
document.cookie = 'ssid=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
1618
// uses useHistory to return to the login page
@@ -28,18 +30,28 @@ export default function LoginButton() {
2830
>
2931
Log Out
3032
</Button>
31-
)
33+
);
3234
} else {
3335
return (
3436
<Button
3537
variant="contained"
3638
onClick={handleLogout}
3739
color="secondary"
38-
style={{ textAlign: 'center' }}
40+
className={classes.button}
3941
endIcon={<ExitToAppIcon />}
4042
>
4143
Log In
4244
</Button>
43-
)
45+
);
46+
}
47+
}
48+
49+
const useStyles = makeStyles({
50+
button: {
51+
backgroundColor: 'rgba(1,212,109,0.4)',
52+
fontSize: '1em',
53+
minWidth: '300px',
54+
marginTop: '10px',
55+
marginBotton: '10px'
4456
}
45-
}
57+
});

app/src/components/right/ProjectManager.tsx

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import ExitToAppIcon from '@material-ui/icons/ExitToApp';
66
import List from '@material-ui/core/List';
77
import ListItem from '@material-ui/core/ListItem';
88
import ListItemText from '@material-ui/core/ListItemText';
9-
import SaveIcon from '@material-ui/icons/Save';
9+
import WarningIcon from '@material-ui/icons/Warning';
1010
import PublishIcon from '@material-ui/icons/Publish';
1111
import Button from '@material-ui/core/Button';
1212
import Checkbox from '@material-ui/core/Checkbox';
1313
import MenuItem from '@material-ui/core/MenuItem';
1414
import Select from '@material-ui/core/Select';
1515
import FormControl from '@material-ui/core/FormControl';
16+
import { useHistory, withRouter } from 'react-router-dom';
1617

1718
import exportProject from '../../utils/exportProject.util';
1819
import { saveProject } from '../../helperFunctions/projectGetSave';
@@ -36,19 +37,6 @@ const ProjectManager = () => {
3637
dispatch({ type: 'CHANGE PROJECT TYPE', payload: { projectType } });
3738
};
3839

39-
const handleLogout = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
40-
e.preventDefault();
41-
console.log('Logout clicked, destroying cookie, redirect to login');
42-
// destroys "cookie" by clearing localStorage if guest
43-
window.localStorage.clear();
44-
// destroy cookie on production when not seen by chromium browser using ipcrenderer
45-
window.api.delCookie();
46-
// destroys cookie if user by backdating cookie expiration date
47-
document.cookie = 'ssid=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
48-
// uses useHistory to return to the login page
49-
props.history.push('/login');
50-
};
51-
5240
// state to keep track of how the user wants their components to be exported
5341
// genOption = 0 --> export only components
5442
// genOption = 1 --> export an entire project w/ webpack, server, etc.
@@ -144,7 +132,9 @@ const ProjectManager = () => {
144132
window.api.addAppDirChosenListener(path => {
145133
exportProject(
146134
path,
147-
'NEW PROJECT',
135+
state.name
136+
? state.name
137+
: 'New_ReacType_Project_' + Math.ceil(Math.random() * 99).toString(),
148138
genOption,
149139
state.projectType,
150140
state.components,
@@ -169,7 +159,7 @@ const ProjectManager = () => {
169159
return (
170160
// <div className={classes.logoutButton}>
171161
<div className={classes.projectManagerWrapper}>
172-
<div className={classes.panelWrapper}>
162+
<div className={classes.projectTypeWrapper}>
173163
<FormControl>
174164
<Select
175165
variant="outlined"
@@ -184,22 +174,31 @@ const ProjectManager = () => {
184174
</Select>
185175
</FormControl>
186176
</div>
187-
<SaveProjectButton />
188-
<ProjectsFolder />
189-
<LoginButton />
177+
{state.isLoggedIn ? <SaveProjectButton /> : ''}
178+
{state.isLoggedIn ? <ProjectsFolder /> : ''}
190179
{/* <div className={classes.btnGroup}> */}
191180
<Button
192-
className={classes.exportBtn}
181+
className={classes.button}
193182
variant="outlined"
194183
color="primary"
195184
onClick={showGenerateAppModal}
196185
endIcon={<PublishIcon />}
197186
>
198187
EXPORT PROJECT
199188
</Button>
200-
<Button onClick={clearWorkspace} className={classes.clearBtn}>
189+
190+
<Button
191+
className={classes.button}
192+
variant="outlined"
193+
color="primary"
194+
onClick={clearWorkspace}
195+
endIcon={<WarningIcon />}
196+
>
201197
CLEAR WORKSPACE
202198
</Button>
199+
<br />
200+
<br />
201+
<LoginButton />
203202
{/* </div> */}
204203
{modal}
205204
</div>
@@ -210,7 +209,10 @@ const useStyles = makeStyles({
210209
projectManagerWrapper: {
211210
border: '1px solid rgba(70,131,83)',
212211
padding: '20px',
213-
margin: '20px'
212+
margin: '40px',
213+
display: 'flex',
214+
flexDirection: 'column',
215+
alignItems: 'center'
214216
},
215217

216218
logoutButton: {
@@ -229,28 +231,23 @@ const useStyles = makeStyles({
229231
left: '0px'
230232
},
231233

232-
exportBtn: {
233-
width: '55%',
234+
button: {
234235
backgroundColor: 'rgba(1,212,109,0.1)',
235-
fontSize: '1em'
236-
},
237-
clearBtn: {
238-
width: '55%',
239236
fontSize: '1em',
240-
marginTop: '15px',
241-
color: 'red'
237+
minWidth: '300px',
238+
marginTop: '10px',
239+
marginBotton: '10px'
242240
},
243241
projectTypeWrapper: {
244-
paddingLeft: '20px',
245-
paddingRight: '20px',
246-
marginBottom: '15px',
247-
width: '100%'
242+
width: '300px',
243+
marginTop: '10px',
244+
marginBotton: '10px'
248245
},
249246
projectSelector: {
250247
backgroundColor: 'rgba(255,255,255,0.15)',
251-
width: '317px',
248+
width: '300px',
252249
color: '#fff'
253250
}
254251
});
255252

256-
export default ProjectManager;
253+
export default withRouter(ProjectManager);

app/src/components/right/ProjectsFolder.tsx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@ import { blue } from '@material-ui/core/colors';
1515
import { getProjects } from '../../helperFunctions/projectGetSave';
1616
import { stateContext } from '../../context/context';
1717

18-
const useStyles = makeStyles({
19-
avatar: {
20-
backgroundColor: blue[100],
21-
color: blue[600]
22-
}
23-
});
24-
2518
export interface ProjectDialogProps {
2619
open: boolean;
2720
projects: Array<Object>;
@@ -32,7 +25,6 @@ export interface ProjectDialogProps {
3225
function ProjectsDialog(props: ProjectDialogProps) {
3326
const classes = useStyles();
3427
const { onClose, open, projects } = props;
35-
console.log('Inside projectsdialogbox projects is', projects);
3628
const [_, dispatch] = useContext(stateContext);
3729

3830
useEffect(() => {
@@ -42,14 +34,13 @@ function ProjectsDialog(props: ProjectDialogProps) {
4234
// If no projects selected, keep the name of the current displayed
4335
const handleClose = () => {
4436
// onClose(selectedValue);
45-
console.log('tab closed');
4637
onClose();
4738
};
4839

4940
// If new project selected, close and set value to new project name
5041
const handleListItemClick = (value: string) => {
5142
const selectedProject = projects.filter(
52-
project => project.name === value
43+
(project: any) => project.name === value
5344
)[0];
5445
dispatch({ type: 'OPEN PROJECT', payload: selectedProject });
5546
onClose();
@@ -63,7 +54,7 @@ function ProjectsDialog(props: ProjectDialogProps) {
6354
>
6455
<DialogTitle id="project-dialog-title">Open Project</DialogTitle>
6556
<List>
66-
{projects.map((project, index) => (
57+
{projects.map((project: any, index: number) => (
6758
<ListItem
6859
button
6960
onClick={() => handleListItemClick(project.name)}
@@ -95,8 +86,10 @@ export default function ProjectsFolder() {
9586
const [open, setOpen] = useState(false);
9687
const [projects, setProjects] = useState([{ hello: 'cat' }]);
9788

89+
const classes = useStyles();
90+
9891
const handleClickOpen = () => {
99-
getProjects().then(data => {
92+
getProjects().then((data: any) => {
10093
setProjects(data);
10194
setOpen(true);
10295
});
@@ -109,6 +102,7 @@ export default function ProjectsFolder() {
109102
return (
110103
<div>
111104
<Button
105+
className={classes.button}
112106
variant="outlined"
113107
color="primary"
114108
onClick={handleClickOpen}
@@ -120,3 +114,18 @@ export default function ProjectsFolder() {
120114
</div>
121115
);
122116
}
117+
118+
const useStyles = makeStyles({
119+
button: {
120+
width: '55%',
121+
backgroundColor: 'rgba(1,212,109,0.1)',
122+
fontSize: '1em',
123+
minWidth: '300px',
124+
marginTop: '10px',
125+
marginBotton: '10px'
126+
},
127+
avatar: {
128+
backgroundColor: blue[100],
129+
color: blue[600]
130+
}
131+
});

app/src/components/right/SaveProjectButton.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React, { useState, useContext } from 'react';
22
import { stateContext } from '../../context/context';
3+
4+
import { makeStyles } from '@material-ui/core/styles';
35
import Button from '@material-ui/core/Button';
46
import TextField from '@material-ui/core/TextField';
57
import Dialog from '@material-ui/core/Dialog';
@@ -19,6 +21,8 @@ export default function FormDialog() {
1921
''
2022
);
2123

24+
const classes = useStyles();
25+
2226
const handleClickOpen = () => {
2327
setInvalidProjectName(false);
2428
setOpen(true);
@@ -52,12 +56,13 @@ export default function FormDialog() {
5256
return (
5357
<div>
5458
<Button
59+
className={classes.button}
5560
variant="outlined"
5661
color="primary"
5762
onClick={handleClickOpen}
5863
endIcon={<SaveOutlinedIcon />}
5964
>
60-
Save Project As
65+
SAVE PROJECT AS
6166
</Button>
6267
<Dialog
6368
open={open}
@@ -91,3 +96,14 @@ export default function FormDialog() {
9196
</div>
9297
);
9398
}
99+
100+
const useStyles = makeStyles({
101+
button: {
102+
width: '55%',
103+
backgroundColor: 'rgba(1,212,109,0.1)',
104+
fontSize: '1em',
105+
minWidth: '300px',
106+
marginTop: '10px',
107+
marginBotton: '10px'
108+
}
109+
});

app/src/containers/RightContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Button from '@material-ui/core/Button';
99

1010
import { stateContext } from '../context/context';
1111
import HTMLTypes from '../context/HTMLTypes';
12-
import { useHistory, withRouter } from 'react-router-dom';
12+
1313

1414
import ProjectManager from '../components/right/ProjectManager';
1515

@@ -426,4 +426,4 @@ const useStyles = makeStyles({
426426

427427
});
428428

429-
export default withRouter(RightContainer);
429+
export default RightContainer;

0 commit comments

Comments
 (0)