Skip to content

Commit f74aaf9

Browse files
Merge pull request #26 from brianjshan/feature
Merged 🐝
2 parents e387cb3 + 41d1ee7 commit f74aaf9

File tree

20 files changed

+172
-58
lines changed

20 files changed

+172
-58
lines changed

app/electron/main.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ const isDev =
2929
const port = 8080;
3030
const selfHost = `http://localhost:${port}`;
3131

32-
// main.js is what controls the lifecycle of the electron application
32+
// main.js is what controls the lifecycle of the electron applicaton
3333

3434
// Keep a global reference of the window object, if you don't, the window will
3535
// be closed automatically when the JavaScript object is garbage collected.
3636
let win;
3737
let menuBuilder;
3838

39-
// function to create a new browser window
39+
// function to create a new broswer window
4040
// this function will be called when Electron has initialized itself
4141
async function createWindow() {
4242
if (isDev) {
@@ -58,22 +58,22 @@ async function createWindow() {
5858
minWidth: 980,
5959
// window title
6060
title: `ReacType`,
61-
// the browser window will not display initially as it's loading
61+
// the browser window will not display intiially as it's loading
6262
// once the browser window renders, a function is called below that hides the splash screen and displays the browser window
6363
show: false,
6464
// icon: path.join(__dirname, '../src/public/icons/png/256x256.png'),
6565
webPreferences: {
6666
zoomFactor: 0.7,
6767
// enable devtools when in development mode
6868
devTools: isDev,
69-
// crucial security feature - blocks rendering process from having access to node modules
69+
// crucial security feature - blocks rendering process from having access to node moduels
7070
nodeIntegration: false,
7171
// web workers will not have access to node
7272
nodeIntegrationInWorker: false,
73-
// disallow experimental feature to allow node.js support in sub-frames (i-frames/child windows)
73+
// disallow experimental feature to allow node.js suppport in subframes (iframes/child windows)
7474
nodeIntegrationInSubFrames: false,
75-
// runs electron apis and preload script in a separate JS context
76-
// separate context has access to document/window but has it's own built-ins and is isolate from changes to global environment by loaded page
75+
// runs electron apis and preload script in a seperate JS context
76+
// sepearate context has access to document/window but has it's own built-ins and is isolate from chagnes to gloval environment by locaded page
7777
// Electron API only available from preload, not loaded page
7878
contextIsolation: true,
7979
// disables remote module. critical for ensuring that rendering process doesn't have access to node functionality
@@ -101,7 +101,7 @@ async function createWindow() {
101101

102102
// Load app
103103
if (isDev) {
104-
// load app from web-dev server
104+
// load app from webdev server
105105
win.loadURL(selfHost);
106106
} else {
107107
// load local file if in production
@@ -263,7 +263,7 @@ app.on('web-contents-created', (event, contents) => {
263263

264264
// https://electronjs.org/docs/tutorial/security#11-verify-webview-options-before-creation
265265
// The web-view is used to embed guest content in a page
266-
// This event listener deletes web-views if they happen to occur in the app
266+
// This event listener deletes webviews if they happen to occur in the app
267267
// https://www.electronjs.org/docs/api/web-contents#event-will-attach-webview
268268
contents.on('will-attach-webview', (event, webPreferences, params) => {
269269
// Strip away preload scripts if unused or verify their location is legitimate
@@ -361,9 +361,15 @@ ipcMain.on('delete_cookie', event => {
361361
.catch(err => console.log('Error deleting cookie:', err));
362362
});
363363

364-
// opens new window for github oauth when button on sign in page is clicked
364+
// opens new window for github oauth when button on signin page is clicked
365365
ipcMain.on('github', event => {
366-
// create new browser window object with size, title, security options
366+
// your github applications credentials
367+
const options = {
368+
client_id: 'your_client_id',
369+
client_secret: 'your_client_secret',
370+
scopes: ['user:email', 'notifications']
371+
};
372+
// create new browserwindow object with size, title, security options
367373
const github = new BrowserWindow({
368374
width: 800,
369375
height: 600,
@@ -377,8 +383,11 @@ ipcMain.on('github', event => {
377383
zoomFactor: 1.0
378384
}
379385
});
386+
const githubUrl = 'https://github.com/login/oauth/authorize?';
387+
const authUrl =
388+
githubUrl + 'client_id=' + options.client_id + '&scope=' + options.scopes;
380389
// redirects to relevant server endpoint
381-
github.loadURL(`${serverUrl}/github`);
390+
github.loadURL(authUrl);
382391
// show window
383392
github.show();
384393
// if final callback is reached and we get a redirect from server back to our app, close oauth window
@@ -400,7 +409,7 @@ ipcMain.on('github', event => {
400409
});
401410

402411
ipcMain.on('tutorial', event => {
403-
// create new browser window object with size, title, security options
412+
// create new browserwindow object with size, title, security options
404413
const tutorial = new BrowserWindow({
405414
width: 800,
406415
height: 600,
@@ -437,8 +446,4 @@ ipcMain.on('tutorial', event => {
437446
// });
438447
});
439448

440-
441-
442-
443-
444449
//module.exports = dialog;

app/electron/menu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var MenuBuilder = function(mainWindow, appName) {
2727
contextIsolation: true,
2828
enableRemoteModule: false,
2929
zoomFactor: 1.0,
30-
// devTools: false
30+
devTools: false
3131
}
3232
});
3333
tutorial.loadURL(`http://localhost:8080/#/tutorial`);

app/src/components/login/SignIn.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { makeStyles, withStyles } from '@material-ui/core/styles';
2222
import Container from '@material-ui/core/Container';
2323
import GitHubIcon from '@material-ui/icons/GitHub';
2424
import LockOutlinedIcon from '@material-ui/icons/LockOutlined';
25+
import { ipcRenderer } from 'electron';
2526

2627
function Copyright() {
2728
return (
@@ -111,12 +112,12 @@ const SignIn: React.FC<LoginInt & RouteComponentProps> = props => {
111112
};
112113

113114
/*
114-
Response Options:
115+
Response Options:
115116
Success
116117
Error
117-
No Username Input
118-
No Password Input
119-
Incorrect Password
118+
No Username Input
119+
No Password Input
120+
Incorrect Password
120121
Invalid Username
121122
*/
122123
const handleLogin = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
@@ -226,7 +227,9 @@ const SignIn: React.FC<LoginInt & RouteComponentProps> = props => {
226227
className={classes.submit}
227228
onClick={() => {
228229
// messages the main proces to open new window for github oauth
229-
console.log('open github')
230+
console.log('open github');
231+
console.log(window.api);
232+
// ipcRenderer.send('github-oauth', 'getToken');
230233
window.api.github();
231234
}}
232235
>

app/src/containers/RightContainer.tsx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -162,24 +162,24 @@ const RightContainer = (): JSX.Element => {
162162
});
163163
});
164164
return isChild;
165-
}
165+
};
166166

167167
const isLinkedTo = (): boolean => {
168168
const { id } = configTarget;
169-
const pageName = state.components[id-1].name;
169+
const pageName = state.components[id - 1].name;
170170
let isLinked = false;
171-
const searchNestedChildren = (comps) => {
171+
const searchNestedChildren = comps => {
172172
if (comps.length === 0) return;
173-
comps.forEach((comp, i) => {
174-
if (comp.type === 'Route Link' && comp.name === pageName) {
175-
isLinked = true;
176-
}
177-
if (comp.children.length > 0) searchNestedChildren(comp.children);
178-
});
179-
}
173+
comps.forEach((comp, i) => {
174+
if (comp.type === 'Route Link' && comp.name === pageName) {
175+
isLinked = true;
176+
}
177+
if (comp.children.length > 0) searchNestedChildren(comp.children);
178+
});
179+
};
180180
searchNestedChildren(state.components);
181181
return isLinked;
182-
}
182+
};
183183

184184
// dispatch to 'UPDATE CSS' called when save button is clicked,
185185
// passing in style object constructed from all changed input values
@@ -206,14 +206,14 @@ const RightContainer = (): JSX.Element => {
206206
dispatch({ type: 'DELETE CHILD', payload: {} });
207207
};
208208

209-
const handlePageDelete = (id) => () => {
210-
// TODO: return modal
209+
const handlePageDelete = id => () => {
210+
// TODO: return modal
211211
if (isLinkedTo()) return setDeleteLinkedPageError(true);
212-
isIndex()
213-
? handleDialogError('index')
214-
: dispatch({ type: 'DELETE PAGE', payload: { id }});
215-
}
216-
212+
isIndex()
213+
? handleDialogError('index')
214+
: dispatch({ type: 'DELETE PAGE', payload: { id } });
215+
};
216+
217217
const handleDeleteReusableComponent = () => {
218218
/*isChildOfPage()
219219
? handleDialogError('component')
@@ -235,7 +235,7 @@ const RightContainer = (): JSX.Element => {
235235
setDeleteIndexError(false);
236236
setDeleteComponentError(false);
237237
setDeleteLinkedPageError(false);
238-
}
238+
};
239239

240240
return (
241241
<div className="column right" style={style}>
@@ -469,14 +469,14 @@ const RightContainer = (): JSX.Element => {
469469
>
470470
<DialogTitle id="alert-dialog-title">
471471
{deleteIndexError ? ErrorMessages.deleteIndexTitle : ''}
472-
{deleteComponentError ? ErrorMessages.deleteComponentTitle : ''}
472+
{deleteComponentError ? ErrorMessages.deleteComponentTitle : ''}
473473
{deleteLinkedPageError ? ErrorMessages.deleteLinkedPageTitle : ''}
474474
</DialogTitle>
475475
<DialogContent>
476476
<DialogContentText id="alert-dialog-description">
477-
{deleteIndexError ? ErrorMessages.deleteIndexMessage : ''}
478-
{deleteComponentError ? ErrorMessages.deleteComponentMessage : ''}
479-
{deleteLinkedPageError ? ErrorMessages.deleteLinkedPageMessage : ''}
477+
{deleteIndexError ? ErrorMessages.deleteIndexMessage : ''}
478+
{deleteComponentError ? ErrorMessages.deleteComponentMessage : ''}
479+
{deleteLinkedPageError ? ErrorMessages.deleteLinkedPageMessage : ''}
480480
</DialogContentText>
481481
</DialogContent>
482482
<DialogActions>

app/src/tutorial/Customization.tsx

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import React from 'react';
2-
import { Link, RouteComponentProps } from 'react-router-dom';
2+
import display from '../../../resources/customizing_elements_images/Display.png';
3+
import flex from '../../../resources/customizing_elements_images/Flex.png';
4+
import height from '../../../resources/customizing_elements_images/Height.png';
5+
import width from '../../../resources/customizing_elements_images/Width.png';
6+
import backgroundcolor from '../../../resources/customizing_elements_images/BackgroundColor.png';
37

48
// import Grid from '@material-ui/core/Grid';
59

@@ -13,11 +17,50 @@ const Customization: React.FC<{
1317
setPage: Function;
1418
}> = ({ classes, setPage }) => {
1519
return (
16-
<div>
17-
Customization
20+
<div className="tutorial_styling">
21+
<h1 style={{ color: 'black' }}>Customizing Elements</h1>
22+
<hr />
23+
<h2>Display</h2>
24+
<br />
25+
<img src={display} />
26+
<p>
27+
After having moved a page, component, route link, or element into the
28+
canvas, select the one that needs customizing simply by clicking on it.
29+
Then, to give it a display feature of either a block, inline-block, or
30+
flex styling, select from the drop down box.
31+
<br />
32+
<br />
33+
<img src={flex} />
34+
<br />
35+
<br />
36+
If the display option 'flex' is chosen, few more sub-options are
37+
displayed under the display option.
38+
</p>
39+
<br />
40+
<hr />
41+
<h2>Width</h2>
42+
<img src={width} />
43+
<br />
44+
<p>Change the width of each component, route link, or element.</p>
45+
<br />
46+
<hr />
47+
<h2>Height</h2>
48+
<img src={height} />
49+
<br />
50+
<p>Change the height of each component, route link, or element.</p>
51+
<br />
52+
<hr />
53+
<h2>Background Color</h2>
54+
<img src={backgroundcolor} />
55+
<br />
56+
<p>
57+
Select an element, type in the color you wish to change the background
58+
color to, and click save!
59+
</p>
60+
<br />
61+
<hr />
1862
</div>
1963
);
2064
};
2165

2266
export default Customization;
23-

app/src/tutorial/Pages.tsx

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import React from 'react';
2-
import { Link, RouteComponentProps } from 'react-router-dom';
2+
import pages from '../../../resources/pages_images/Pages.png';
3+
import toggle from '../../../resources/pages_images/Toggle.png';
4+
import deletepage from '../../../resources/pages_images/DeletePage.png';
5+
import addelements from '../../../resources/pages_images/AddElements.png';
36

47
// import Grid from '@material-ui/core/Grid';
58

@@ -13,11 +16,31 @@ const Pages: React.FC<{
1316
setPage: Function;
1417
}> = ({ classes, setPage }) => {
1518
return (
16-
<div>
17-
Pages
19+
<div className="tutorial_styling">
20+
<h1 style={{ color: 'black' }}>Pages</h1>
21+
<hr />
22+
<br />
23+
<img src={pages} />
24+
<p>
25+
Start off by giving your page a name. Make sure to check the page box
26+
next to the textbox. Then, simply click the add button and it'll show in
27+
the pages section below.
28+
</p>
29+
<br />
30+
<img src={toggle} style={{ marginRight: '20px' }} />
31+
<img src={addelements} style={{ outline: '1px solid black' }} />
32+
<br />
33+
<p>
34+
Switch between pages by selecting the page and customize it by dragging
35+
the elements you want into the canvas of the page you're on. (Note the
36+
green dot next to the page name shows you which page you are currently
37+
on).
38+
</p>
39+
<br />
40+
<img src={deletepage} />
41+
<p>Delete the page by simply clicking the button.</p>
1842
</div>
1943
);
2044
};
2145

2246
export default Pages;
23-

0 commit comments

Comments
 (0)