Skip to content

Commit 87e4e7b

Browse files
authored
Merge pull request #33 from dieunity/accessLens
Bug fixes and some old code removal
2 parents 14fb0fa + 7662bbe commit 87e4e7b

File tree

7 files changed

+52
-49
lines changed

7 files changed

+52
-49
lines changed

public/electron.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
const { app, BrowserWindow, ipcMain, dialog } = require('electron');
1+
const {
2+
app, BrowserWindow, ipcMain, dialog,
3+
} = require('electron');
24
const path = require('path');
35
const isDev = require('electron-is-dev');
46
const fs = require('fs');
57
const os = require('os');
68
const pty = require('node-pty');
79

8-
//Dynamic variable to change terminal type based on os
9-
let shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash';
10-
11-
12-
10+
// Dynamic variable to change terminal type based on os
11+
const shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash';
1312
let mainWindow;
1413

1514
if (isDev) console.log('electron version', process.versions.electron);
@@ -41,44 +40,42 @@ function createWindow() {
4140
},
4241
});
4342
mainWindow.loadURL(
44-
isDev ? 'http://localhost:3000' : `file://${path.join(__dirname, '../build/index.html')}`
43+
isDev ? 'http://localhost:3000' : `file://${path.join(__dirname, '../build/index.html')}`,
4544
);
4645
mainWindow.on('closed', () => (mainWindow = null));
4746

4847
// PTY PROCESS FOR IN APP TERMINAL
49-
let ptyArgs = {
48+
const ptyArgs = {
5049
name: 'xterm-color',
5150
cols: 80,
5251
rows: 80,
5352
cwd: process.env.HOME,
5453
env: process.env,
55-
}
56-
54+
};
5755

5856
const ptyProcess = pty.spawn(shell, [], ptyArgs);
5957
// with ptyProcess, we want to send incoming data to the channel terminal.incData
6058
ptyProcess.on('data', (data) => {
6159
mainWindow.webContents.send('terminal.incData', data);
6260
});
63-
// in the main process, at terminal.toTerm channel, when data is received,
61+
// in the main process, at terminal.toTerm channel, when data is received,
6462
// main process will write to ptyProcess
65-
ipcMain.on('terminal.toTerm', function(event, data) {
63+
ipcMain.on('terminal.toTerm', (event, data) => {
6664
ptyProcess.write(data);
67-
})
68-
};
69-
65+
});
66+
}
7067

7168
// EDITORVIEW.JSX SAVE FILE FUNCTIONALITY
7269
ipcMain.on('EditorView.saveFile', (e, filePath, editedText) => {
7370
fs.writeFile(filePath, editedText, (err) => {
7471
if (err) throw err;
7572
});
7673
// Return a success message upon save
77-
e.returnValue = 'Changes Saved'
74+
e.returnValue = 'Changes Saved';
7875
});
7976

8077
/*
81-
EXPORTFILEMODAL.JSX FILE FUNCTIONALITY
78+
EXPORTFILEMODAL.JSX FILE FUNCTIONALITY
8279
(check existence and create folder)
8380
*/
8481
ipcMain.on('ExportFileModal.exists', (e, fileOrFolderPath) => {
@@ -106,11 +103,11 @@ ipcMain.on('ExportFileModal.readFile', (e, filePath) => {
106103
});
107104

108105
// OPENFOLDERBUTTON.JSX FILE FUNCTIONALITY
109-
ipcMain.on('OpenFolderButton.isDirectory' , (e, filePath) => {
106+
ipcMain.on('OpenFolderButton.isDirectory', (e, filePath) => {
110107
e.returnValue = fs.statSync(filePath).isDirectory();
111108
});
112109

113-
ipcMain.on('OpenFolderButton.dialog' , (e) => {
110+
ipcMain.on('OpenFolderButton.dialog', (e) => {
114111
const dialogOptions = {
115112
properties: ['openDirectory', 'createDirectory'],
116113
filters: [
@@ -127,7 +124,7 @@ ipcMain.on('OpenFolderButton.dialog' , (e) => {
127124
UNIVERSAL IPC CALLS
128125
(The following IPC calls are made from various components in the codebase)
129126
*/
130-
ipcMain.on('Universal.stat' , (e, filePath) => {
127+
ipcMain.on('Universal.stat' , (e, filePath) => {
131128
e.returnValue = fs.statSync(filePath).isDirectory();
132129
});
133130

@@ -164,4 +161,4 @@ app.on('activate', () => {
164161
if (mainWindow === null) {
165162
createWindow();
166163
}
167-
});
164+
});

src/components/NavBar/NavBar.jsx

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ import ExportFileModal from '../Modals/ExportFileModal';
2121
const menuIcon = require('../../assets/images/menu.png');
2222
const exportIcon = require('../../assets/images/file-export.png');
2323
// const browserIcon = require('../../assets/images/google-chrome.png');
24-
const codeIcon = require('../../assets/images/visual-studio-code.png');
25-
const homeIcon = require('../../assets/images/home.png');
24+
// const codeIcon = require('../../assets/images/visual-studio-code.png');
25+
// const homeIcon = require('../../assets/images/home.png');
2626

2727
const NavBar = ({ inAboutPage }) => {
2828
const [
29-
{ fileTree, isFileDirectoryOpen, projectUrl, rightPanelDisplay },
29+
{
30+
fileTree, isFileDirectoryOpen, projectUrl, rightPanelDisplay,
31+
},
3032
dispatchToGlobal,
3133
] = useContext(GlobalContext);
3234
const [isExportModalOpen, setIsExportModalOpen] = useState(false);
@@ -37,21 +39,21 @@ const NavBar = ({ inAboutPage }) => {
3739
};
3840

3941
/* switches between code and browser view */
40-
const handleEditorToggle = () => {
41-
if (!inAboutPage) dispatchToGlobal(toggleRightPanel('codeEditorView'));
42-
};
42+
// const handleEditorToggle = () => {
43+
// if (!inAboutPage) dispatchToGlobal(toggleRightPanel('codeEditorView'));
44+
// };
4345

4446
/* switches between code and browser view */
45-
const handleBrowserToggle = () => {
46-
if (inAboutPage) return;
47-
if (rightPanelDisplay === 'browserView' && projectUrl) {
48-
dispatchToGlobal(resetToProjectUrl());
49-
}
50-
if (!projectUrl) {
51-
dispatchToGlobal(setProjectUrl('https://google.com'));
52-
}
53-
dispatchToGlobal(toggleRightPanel('browserView'));
54-
};
47+
// const handleBrowserToggle = () => {
48+
// if (inAboutPage) return;
49+
// if (rightPanelDisplay === 'browserView' && projectUrl) {
50+
// dispatchToGlobal(resetToProjectUrl());
51+
// }
52+
// if (!projectUrl) {
53+
// dispatchToGlobal(setProjectUrl('https://google.com'));
54+
// }
55+
// dispatchToGlobal(toggleRightPanel('browserView'));
56+
// };
5557

5658
/* exports the file (when true) */
5759
const openExportModal = () => {

src/components/Terminal/TerminalView.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { TerminalType } from '../../utils/terminalTypes';
55
const { Terminal } = require('xterm');
66
const ipc = require('electron').ipcRenderer;
77

8-
98
const terminalArgs: TerminalType = {
109
fontSize: 15,
1110
// Currently rows are hardcoded, next step is to make terminal sizing dynamic.

src/components/TestMenu/testMenuHooks.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { useState, useContext } from 'react';
22
import { GlobalContext } from '../../context/reducers/globalReducer';
33
import { setTabIndex } from '../../context/actions/globalActions';
4+
45
export function useToggleModal(test) {
56
const [isModalOpen, setIsModalOpen] = useState(false);
67
const [title, setTitle] = useState(test);
8+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
79
const [{ isFileDirectoryOpen }, dispatchToGlobal] = useContext(GlobalContext);
810

911
const openModal = () => {
@@ -22,7 +24,9 @@ export function useToggleModal(test) {
2224
setTitle(test);
2325
};
2426

25-
return { title, isModalOpen, openModal, openScriptModal, closeModal };
27+
return {
28+
title, isModalOpen, openModal, openScriptModal, closeModal
29+
};
2630
}
2731

2832
export const validateInputs = (testSuite, testCaseState) => {

src/context/reducers/accTestCaseReducer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { createContext } from 'react';
2-
import { AccTestCaseState, Action} from '../../utils/accTypes';
1+
import { createContext } from 'react';
2+
import { AccTestCaseState, Action } from '../../utils/accTypes';
33
import { actionTypes } from '../actions/accTestCaseActions';
44

55
export const AccTestCaseContext:any = createContext([]);

src/utils/ptyTypes.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export interface PtyArgs {
2-
name: string,
3-
cols: number,
4-
rows: number,
5-
cwd: string,
6-
env: Object,
7-
}
2+
name: string;
3+
cols: number;
4+
rows: number;
5+
cwd: string;
6+
env: Object;
7+
}

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
},
2323
"include": [
2424
"src/**/*",
25+
"public/electron.js",
2526
"src/context/__tests__",
26-
"__tests__/hello.test.js",
27-
"tests/spec.integra.js"
27+
"__tests__/hello.test.js",
28+
"tests/spec.integra.js"
2829
]
2930
}

0 commit comments

Comments
 (0)