Skip to content

Commit 5bcdeee

Browse files
committed
lots of comments few changes
1 parent 1deffb0 commit 5bcdeee

13 files changed

+38
-206
lines changed

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!--This is the index file that is necessary for the electron app-->
12
<!DOCTYPE html>
23
<html>
34

@@ -18,8 +19,8 @@
1819
</head>
1920

2021
<body>
22+
2123
<div id="root"></div>
2224
<script src="./public/bundle.js"></script>
2325
</body>
24-
2526
</html>

main.js

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ function createWindow() {
3737
win = null;
3838
});
3939

40-
// app.server = createServer(app);
4140
}
4241

4342
// Creates our window when electron has initialized for the first time
@@ -81,7 +80,7 @@ function showExportDialog(event, gqlSchema, gqlResolvers, sqlScripts, env, queri
8180
createApolloFile('db/createTables.sql', sqlScripts);
8281
createApolloFile('.env', env);
8382
//generate test-suite
84-
createTestFile('tests/tests.js', buildExportTestSuite.createTest(queries[0], queries[1]));
83+
createApolloFile('tests/tests.js', buildExportTestSuite.createTest(queries[0], queries[1]));
8584

8685

8786
const output = fs.createWriteStream(result + '/apollo-server.zip',
@@ -122,7 +121,7 @@ function showExportDialog(event, gqlSchema, gqlResolvers, sqlScripts, env, queri
122121
createApolloFile('graphql/resolvers.js', '');
123122
createApolloFile('db/createTables.sql', '');
124123
createApolloFile('.env', '');
125-
createTestFile('tests/tests.js','')
124+
createApolloFile('tests/tests.js','')
126125

127126
dialog.showMessageBox(win,
128127
{
@@ -151,7 +150,7 @@ const createTestFile = (filePath, data) => {
151150
//---------------------TEST EXPORT -------------------//
152151

153152

154-
//function to run when user clicks export
153+
//function to run when user clicks "Export Tests"
155154
function showTestExportDialog(event, queries) {
156155
dialog.showOpenDialog(
157156
{
@@ -171,52 +170,10 @@ function showTestExportDialog(event, queries) {
171170
//changed this to the root of the folder "test-suite" rather than "tests" within the folder -VW
172171
createTestFile('tests.js', buildExportTestSuite.createTest(queries[0], queries[1]));
173172

174-
//creating a function "output" that opens a write stream for our zip file. NOW COMMENTED OUT
175-
// const output = fs.createWriteStream(result + '/test-suite.zip',
176-
// // { autoClose: false }
177-
// );
178-
179173
//make a new output function that is an fs WRITE with the same data.
180174
fs.writeFile(result + 'tests.js', buildExportTestSuite.createTest(queries[0], queries[1]),function (err) {
181175
if (err) throw err;});
182-
183-
// function "archive" that uses the "archiver" node module to make a zip format file level 9 NOW COMMENTED OUT
184-
// const archive = archiver('zip', {
185-
// zlib: { level: 9 } // Sets the compression level.
186-
// });
187-
188-
// using the "on" meathod to start the compression
189-
//good practice to catch warnings (ie stat failures and other non-blocking errors) NOW COMMENTED OUT
190-
// archive.on('warning', function (err) {
191-
// if (err.code === 'ENOENT') console.error(err)
192-
// else throw err;
193-
// });
194-
195-
// archive.on('error', function (err) {
196-
// throw err;
197-
// });
198-
199-
// append files from test-suite directory and naming it `test-suite` within the archive NOW COMMENTED OUT
200-
// archive.directory(__dirname + '/test-suite/', 'test-suite');
201-
202-
// pipe the archive details to our zip file -> pushes files into the zip NOW COMMENTED OUT
203-
// archive.pipe(output);
204-
205-
// finalize the archive (ie we are done appending files but streams have to finish yet) NOW COMMENTED OUT
206-
// 'close' will be fired afterwards
207-
// archive.finalize();
208-
209176

210-
// listen for all archive data to be written and output associated details NOW COMMENTED OUT
211-
// output.on('close', function () {
212-
// console.log('Zip file size is ', archive.pointer() + ' total bytes');
213-
// console.log('Archived zip file is complete.');
214-
215-
//instead, simply call "outputSingle" -VW
216-
//outputSingle();
217-
218-
//reverts templates to empty files for future use
219-
createTestFile('.env', '');
220177
//changed this to the root of the folder "test-suite" rather than "tests" within the folder -VW
221178
createTestFile('tests.js','')
222179

@@ -230,8 +187,6 @@ function showTestExportDialog(event, queries) {
230187
)
231188
});
232189
}
233-
//); TOO MANY BRACKETS
234-
//}
235190

236191
//listener for Apollo Server export button being clicked
237192
ipcMain.on('show-export-dialog', (event, gqlSchema, gqlResolvers, sqlScripts, env, queries) => {

palette.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* This is just a reference file not actually imported anywhere */
2+
13
/* Coolors Exported Palette - coolors.co/b7cadc-e5e7e9-324353-fefefe-dd399c */
24

35
/* HSL */

public/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!--This file does not appear to be necessary for electron at least-->
2+
13
<!DOCTYPE html>
24
<html>
35
<head>

src/components/popup/welcome.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// This is also the readme.
2+
13
/* eslint-disable no-unused-vars */
24
import React, { useContext } from "react";
35
import {

src/components/sideBar/navSidebar.jsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,6 @@ function NavSideBar() {
9797
document.querySelector("svg") ? document.querySelector("svg").remove() : "";
9898
}}
9999
/>
100-
{/* comments out button for removed component */}
101-
{/* <NavButton
102-
key='NavButton5'
103-
className='fas fa-project-diagram'
104-
view='GraphiQL'
105-
click={(e) => {
106-
dispatch({ type: SET_VIEW, payload: 'graphiql' })
107-
dispatch({ type: SET_POP_UP, payload: '' })
108-
changeButtonStyleOnClick("GraphiQL")
109-
document.querySelector("svg") ? document.querySelector("svg").remove() : "";
110-
}}
111-
/> */}
112100
<NavButton
113101
key='NavButton6'
114102
className='fas fa-clipboard-check'

src/components/sideBar/noTableButton.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const ButtonContainer = styled.div`
3030
cursor: pointer;
3131
animation: ${fontColor} 2s;
3232
animation-fill-mode: both;
33-
animation-iteration-count: 5;
33+
animation-iteration-count: 20;
3434
`;
3535

3636
// styles the 'Add Table' button and surrounding space

src/components/view/mainView.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ function MainView() {
2020
{view === 'code' && <CodeView />}
2121
{view === 'schema' && <SchemaView />}
2222
{view === 'visualize' && <VisualizeView />}
23-
{/* comment out unused component */}
24-
{/* {view === 'graphiql' && <GraphiqlView />} */}
2523
{view === 'tests' && <TestsView />}
2624
{popUp === 'table' && <TableForm />}
2725
</div>

src/components/view/testsView.jsx

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,19 @@
11
import React, { useContext } from 'react';
22
import styled from 'styled-components';
33
import { Store } from '../../state/store';
4-
import { UPDATE_QUERIES } from '../../actions/actionTypes';
5-
import { ADD_APOLLO_SERVER_URI } from '../../actions/actionTypes';
6-
7-
8-
const electron = window.require('electron');
9-
const ipc = electron.ipcRenderer;
4+
import { UPDATE_QUERIES, ADD_APOLLO_SERVER_URI } from '../../actions/actionTypes';
105

116
import { ApolloClient } from 'apollo-client';
127
import { InMemoryCache } from 'apollo-cache-inmemory';
138
import { gql, HttpLink } from 'apollo-boost';
149

10+
const electron = window.require('electron');
11+
const ipc = electron.ipcRenderer;
1512

1613
/*-------------------- Styled Components --------------------*/
14+
/* The following styles mimic the styles in codeView */
1715

18-
// const Title = styled.h1`
19-
// font-size: 1.5em;
20-
// text-align: center;
21-
// color: palevioletred;
22-
// `;
23-
24-
// const Response = styled.div`
25-
// margin: 13px;
26-
// font-family: Courier New, Consolas, Monaco, Lucida Console;
27-
// font-size: 15px;
28-
// background-color: #EFF0F1;
29-
// display: grid;
30-
// height: calc(100vh - 26px - 64px);
31-
// `;
3216

33-
/* The following styles mimic the styles in codeView */
3417
const Code = styled.div`
3518
margin: 13px;
3619
font-family: Courier New, Consolas, Monaco, Lucida Console;
@@ -117,28 +100,36 @@ const Textbox = styled.textarea`
117100
function TestsView() {
118101
const { dispatch, state: { queries, apolloServerURI }} = useContext(Store);
119102

103+
//Gets the new HttpLink when state is updated
104+
//note: initial state is localhost:3000/GraphQL
120105
const link = new HttpLink({
121106
uri: apolloServerURI
122107
})
123-
108+
//Creates a new ApolloClient connection using the link above
124109
const client = new ApolloClient({
125110
cache: new InMemoryCache(),
126111
link: link
127112
});
128113

114+
//Add the query to state
129115
function addQuery() {
116+
//"q" represents the user defined query
130117
let q = document.getElementById("query").value;
118+
//"r" represents the response from the GraphQL endpoint
131119
let r;
132120

133-
//creates query to graphQL enpoint
134-
//saves stringified result to state in the "queries" array
135-
//writes response from GraphQL to "Response" text box in DOM
121+
//packages and sends query to send to the graphQL enpoint through the client established above
136122
client.query({
137123
query: gql`${q}`
138124
}).then(result => {;
139125
console.log('apollo server result: ',result);
126+
//saves stringified result to state in the "queries" array
140127
r = JSON.stringify(result.data);
128+
//writes response from GraphQL to "Response" text box in DOM
141129
document.getElementById("response").value = r;
130+
//FOR FUTURE IMPLEMENTATION we determine the entirety of the data that is sent in a response and parse accordingly
131+
//currently we only use "data" to update r"
132+
//updating state
142133
dispatch({ type: UPDATE_QUERIES, payload: [[q], [r]] });
143134
})
144135

@@ -149,6 +140,8 @@ function TestsView() {
149140
dispatch({ type: ADD_APOLLO_SERVER_URI, payload: url });
150141
console.log('test updateURL', apolloServerURI);
151142
}
143+
//FOR FUTURE IMPLEMENTATION: Check the user input and maybe ping the endpoint to check that it is live.
144+
152145

153146
return(
154147
<div>
@@ -162,13 +155,14 @@ function TestsView() {
162155
<div style={{ width: "95%", marginLeft: "auto", marginRight: "auto" }}>
163156
<Button onClick={addQuery}>Add Query</Button>
164157
<Button onClick={(e) => {
158+
//Electron meathod to initiate the export dialog.
165159
ipc.send('show-test-export-dialog',queries)
166160
}}> Export Tests </Button>
167161
<p>{console.log("queries: ",queries)}</p>
168162
</div>
169163
</Column>
170164
<Column style={{ gridColumn: "1 / 3", gridRow: "3 / span 1" }}>
171-
<Title>Apollo Server URL</Title>
165+
<Title>GraphQL Endpoint URL</Title>
172166
<Input type='text' id='url' placeholder='Enter URL here'></Input><Button style={{ width: "20%" }} onClick={updateURL}>Add URL</Button>
173167
</Column>
174168
</Code>

src/schema.js

Lines changed: 0 additions & 110 deletions
This file was deleted.

src/state/initialState.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ export const gqlResolvers = `const pool = require('../db/sqlPool');\n\nmodule.ex
7373

7474
export const sqlScripts = ``;
7575

76+
//An array of arrays index 0 is the queries. index 1 is the responses to the queries
7677
export const queries = [[], []];
7778

78-
export const displayError = { displayStatus: false, throttleStatus: true, relatedTable: -1, relatedField: -1 };
79-
8079
// stores the Apollo server URI input by the user in tests view
8180
export const apolloServerURI = 'http://localhost:3000/GraphQL';
81+
82+
export const displayError = { displayStatus: false, throttleStatus: true, relatedTable: -1, relatedField: -1 };

0 commit comments

Comments
 (0)