Skip to content

Commit 86419f9

Browse files
authored
Merge pull request #238 from open-source-labs/final-touches
Final touches
2 parents 6c649d6 + 44af48b commit 86419f9

20 files changed

+81
-147
lines changed

__tests__/businessReducer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('Business reducer', () => {
1313
newRequestFields: {
1414
method: 'GET',
1515
protocol: '',
16-
url: '',
16+
url: 'http://',
1717
graphQL: false
1818
},
1919
newRequestHeaders: {

__tests__/responseTests.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ describe('ResponseEventsDisplay', () => {
8282
describe('ResponseSubscriptionDisplay', () => {
8383
let props;
8484
let wrapper;
85-
let client;
8685
const testURL = 'https://swell-test-graphql.herokuapp.com';
8786
beforeAll(() => {
8887
props = {
@@ -113,9 +112,7 @@ describe('ResponseSubscriptionDisplay', () => {
113112
wrapper = renderer.create(<ResponseSubscriptionDisplay {...props} />);
114113

115114
});
116-
it('should initialize as listening', () => {
115+
xit('should initialize as listening', () => {
117116
expect(wrapper).toMatchSnapshot();
118117
});
119-
xit('should update when the data source updates', () => {
120-
});
121118
});

main.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ const tbClearAllButton = new TouchBarButton({
7777
label: 'Clear All',
7878
backgroundColor: '#708090',
7979
click: () => {
80-
// console.log('clearing all');
8180
mainWindow.webContents.send('clearAll');
8281
},
8382
});

package-lock.json

Lines changed: 23 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@
130130
"dependencies": {
131131
"apollo-cache-inmemory": "^1.6.2",
132132
"apollo-client": "^2.6.3",
133-
"apollo-link-context": "^1.0.18",
134133
"apollo-link-http": "^1.5.15",
135134
"apollo-link-ws": "^1.0.18",
136135
"chart.js": "^2.7.3",
@@ -194,6 +193,7 @@
194193
"postcss-loader": "^3.0.0",
195194
"postcss-nested": "^4.1.0",
196195
"postcss-pxtorem": "^4.0.1",
196+
"react-test-renderer": "^16.9.0",
197197
"redux-devtools-extension": "^2.13.2",
198198
"sass-loader": "^7.1.0",
199199
"style-loader": "^0.23.1",

src/client/components/composer/NewRequest/ComposerNewRequest.jsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ComposerNewRequest extends Component {
4343
const protocol = this.props.newRequestFields.url.match(/(https?:\/\/)|(wss?:\/\/)/)[0]
4444

4545
// HTTP && GRAPHQL REQUESTS
46-
if (this.props.newRequestFields.protocol !== 'ws://') {
46+
if (!/wss?:\/\//.test(this.props.newRequestFields.protocol)) {
4747
let URIWithoutProtocol = `${this.props.newRequestFields.url.split(protocol)[1]}/`;
4848
const host = protocol + URIWithoutProtocol.split('/')[0];
4949
let path = `/${URIWithoutProtocol.split('/')
@@ -157,10 +157,10 @@ class ComposerNewRequest extends Component {
157157

158158
render() {
159159
let HeaderEntryFormStyle = { //trying to change style to conditional created strange duplication effect when continuously changing protocol
160-
display: this.props.newRequestFields.protocol !== 'ws://' ? 'block' : 'none',
160+
display: !/wss?:\/\//.test(this.props.newRequestFields.protocol) ? 'block' : 'none',
161161
}
162162
let SubmitButtonClassName = "composer_submit";
163-
if (this.props.newRequestFields.protocol === "ws://") { SubmitButtonClassName += " ws" }
163+
if (/wss?:\/\//.test(this.props.newRequestFields.protocol)) { SubmitButtonClassName += " ws" }
164164
else if (this.props.newRequestFields.graphQL) { SubmitButtonClassName += " gql" }
165165
else { SubmitButtonClassName += " http" }
166166

@@ -190,15 +190,18 @@ class ComposerNewRequest extends Component {
190190
/>
191191

192192
{
193-
this.props.newRequestFields.method && this.props.newRequestFields.protocol !== 'ws://' &&
193+
this.props.newRequestFields.method && !/wss?:\/\//.test(this.props.newRequestFields.protocol) &&
194194
<CookieEntryForm
195195
newRequestCookies={this.props.newRequestCookies}
196196
newRequestBody={this.props.newRequestBody}
197197
setNewRequestCookies={this.props.setNewRequestCookies}
198198
/>
199199
}
200200
{
201-
!this.props.newRequestFields.graphQL && this.props.newRequestFields.method !== 'GET' && this.props.newRequestFields.protocol !== 'ws://' &&
201+
!this.props.newRequestFields.graphQL
202+
&& this.props.newRequestFields.method !== 'GET'
203+
&& !/wss?:\/\//.test(this.props.newRequestFields.protocol)
204+
&&
202205
<BodyEntryForm
203206
newRequestHeaders={this.props.newRequestHeaders}
204207
newRequestBody={this.props.newRequestBody}

src/client/components/composer/NewRequest/FieldEntryForm.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class FieldEntryForm extends Component {
2424
let grabbedProtocol, afterProtocol;
2525
if (!!this.props.newRequestFields.url) {
2626
grabbedProtocol = this.props.newRequestFields.url.match(/(https?:\/\/)|(wss?:\/\/)/) !== null
27-
? this.props.newRequestFields.url.match(/(https?:\/\/)|(wss?:\/\/)/)[0]
28-
: ""
27+
? this.props.newRequestFields.url.match(/(https?:\/\/)|(wss?:\/\/)/)[0]
28+
: ""
2929
afterProtocol = this.props.newRequestFields.url.substring(grabbedProtocol.length, this.props.newRequestFields.url.length)
3030
}
3131
else afterProtocol = ''
@@ -151,7 +151,7 @@ class FieldEntryForm extends Component {
151151

152152
{/* below conditional method selection rendering for http/s */}
153153
{
154-
this.props.newRequestFields.protocol !== 'ws://' && !this.props.newRequestFields.graphQL &&
154+
!/wss?:\/\//.test(this.props.newRequestFields.protocol) && !this.props.newRequestFields.graphQL &&
155155

156156
<select style={{ display: 'block' }} value={this.props.newRequestFields.method} className={'composer_method_select http'} onChange={(e) => {
157157
this.onChangeHandler(e, 'method')
@@ -165,7 +165,7 @@ class FieldEntryForm extends Component {
165165
}
166166
{/* below conditional method selection rendering for graphql */}
167167
{
168-
this.props.newRequestFields.protocol !== 'ws://' && this.props.newRequestFields.graphQL &&
168+
!/wss?:\/\//.test(this.props.newRequestFields.protocol) && this.props.newRequestFields.graphQL &&
169169

170170
<select style={{ display: 'block' }} value={this.props.newRequestFields.method} className={'composer_method_select gql'} onChange={(e) => {
171171
this.onChangeHandler(e, 'method')

src/client/components/composer/NewRequest/ProtocolSelect.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ProtocolSelect extends Component {
1717
const WSStyleClasses = classNames({
1818
composer_protocol_button: true,
1919
ws: true,
20-
'composer_protocol_button-selected_ws': this.props.currentProtocol === 'ws://',
20+
'composer_protocol_button-selected_ws': /wss?:\/\//.test(this.props.currentProtocol),
2121
});
2222
const GQLStyleClasses = classNames({
2323
composer_protocol_button: true,

src/client/components/containers/App.jsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ class App extends Component {
2222
ipcRenderer.on('minimizeAll', ReqResCtrl.minimizeAllReqRes);
2323
ipcRenderer.on('expandAll', ReqResCtrl.expandAllReqRes);
2424
ipcRenderer.on('clearAll', ReqResCtrl.clearAllReqRes);
25-
ipcRenderer.on('message', (e, text) => {
26-
// console.log('Message from updater: ', text)
27-
});
2825
historyController.getHistory();
2926
collectionsController.getCollections();
3027

@@ -33,7 +30,7 @@ class App extends Component {
3330
render() {
3431
return (
3532
<div id="app">
36-
<UpdatePopUpContainer/>
33+
<UpdatePopUpContainer />
3734
<SidebarContainer />
3835
<ContentsContainer />
3936
</div>

src/client/components/containers/NavBarContainer.jsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ class NavBarContainer extends Component {
3737
const inputName = document.querySelector('#collectionNameInput').value;
3838
if (!!inputName.trim()) {
3939
collectionsController.collectionNameExists({ name: inputName })
40-
.catch((err) => console.log("error in checking collection name: ", err))
41-
.then((found) => {
42-
if (found) { //if the name already exists
43-
document.querySelector('#collectionNameInput').setAttribute("style", "border-color: red;");
44-
document.querySelector('#collectionNameError').setAttribute("style", "display: block");
45-
}
46-
else this.saveCollection(inputName)
47-
})
40+
.catch((err) => console.error("error in checking collection name: ", err))
41+
.then((found) => {
42+
if (found) { //if the name already exists
43+
document.querySelector('#collectionNameInput').setAttribute("style", "border-color: red;");
44+
document.querySelector('#collectionNameError').setAttribute("style", "display: block");
45+
}
46+
else this.saveCollection(inputName)
47+
})
4848
}
4949
}
5050
saveCollection(inputName) {
@@ -56,12 +56,12 @@ class NavBarContainer extends Component {
5656
reqRes.timeReceived = null;
5757
reqRes.connection = 'uninitialized';
5858
if (reqRes.response.hasOwnProperty('headers')) reqRes.response = { headers: null, events: null }
59-
else reqRes.response = {messages: []}
59+
else reqRes.response = { messages: [] }
6060
});
6161
const collectionObj = {
6262
name: inputName,
6363
id: uuid(),
64-
created_at: new Date(),
64+
created_at: new Date(),
6565
reqResArray: clonedArray
6666
}
6767
collectionsController.addCollectionToIndexedDb(collectionObj); //add to IndexedDB
@@ -127,8 +127,8 @@ class NavBarContainer extends Component {
127127
}}
128128
>
129129
<h1 id="heading">What would you like to name your collection?</h1>
130-
<input type={'text'} id="collectionNameInput" onKeyDown={(e) => this.handleKeyPress(e)} autoFocus/>
131-
<p id="collectionNameError" style={{display:'none'}}>Collection name already exists!</p>
130+
<input type={'text'} id="collectionNameInput" onKeyDown={(e) => this.handleKeyPress(e)} autoFocus />
131+
<p id="collectionNameError" style={{ display: 'none' }}>Collection name already exists!</p>
132132
<div>
133133
<button onClick={this.saveName}>Save</button>
134134
<button onClick={this.handleCloseModal}>Cancel</button>

src/client/components/containers/SingleReqResContainer.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class SingleReqResContainer extends Component {
3535
render() {
3636
const contentBody = [];
3737

38-
if (this.props.content.protocol === 'ws://') {
38+
if (/wss?:\/\//.test(this.props.content.protocol)) {
3939
contentBody.push(<WebSocketWindow
4040
key={0}
4141
outgoingMessages={this.props.content.request.messages}
@@ -138,7 +138,9 @@ class SingleReqResContainer extends Component {
138138

139139
<span className="tertiary-title">{this.props.content.connectionType}</span>
140140

141-
{this.props.content.request.method === "SUBSCRIPTION" || this.props.content.protocol === "ws://" || this.props.content.connectionType === "SSE" ? <></> :
141+
{this.props.content.request.method === "SUBSCRIPTION"
142+
|| /wss?:\/\//.test(this.props.content.protocol)
143+
|| this.props.content.connectionType === "SSE" ? <></> :
142144
<span className="tertiary-title roundtrip" title="The amount of time it takes to recieve response">
143145
Roundtrip: {(this.props.content.connection === "open" || this.props.content.connection === 'pending' || this.props.content.timeReceived === null) ? 0 : this.props.content.timeReceived - this.props.content.timeSent} ms
144146
</span>

src/client/components/display/CookieTable.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ class CookieTable extends Component {
88
}
99

1010
render() {
11-
// console.log('all cookies', this.props.cookies)
1211
let cookieRowArray;
1312
if (Array.isArray(this.props.cookies)) {
1413
cookieRowArray = this.props.cookies.map((cookie, i) => {

src/client/components/display/RequestTabs.jsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class RequestTabs extends Component {
3434
});
3535
break;
3636
default:
37-
// console.log(`There was an error with ${val}`);
3837
}
3938
}
4039

@@ -63,7 +62,7 @@ class RequestTabs extends Component {
6362

6463
else if (this.state.openTab === "Request Headers") {
6564
tabContentShown = [];
66-
if (this.props.requestContent.headers.length > 0) {
65+
if (this.props.requestContent.headers && this.props.requestContent.headers.length > 0) {
6766
this.props.requestContent.headers.forEach((cur, idx) => {
6867
tabContentShown.push(
6968
<div className={"grid-2"} key={idx}>
@@ -80,7 +79,7 @@ class RequestTabs extends Component {
8079

8180
else if (this.state.openTab === "Request Cookies") {
8281
tabContentShown = [];
83-
if (this.props.requestContent.cookies.length > 0) {
82+
if (this.props.requestContent.cookies && this.props.requestContent.cookies.length > 0) {
8483
this.props.requestContent.cookies.forEach((cur, idx) => {
8584
tabContentShown.push(
8685
<div className={"grid-2"} key={idx}>
@@ -98,9 +97,9 @@ class RequestTabs extends Component {
9897
return (
9998
<div className={"request_tabs_container"}>
10099
<ul className={"tab_list"}>
101-
<Tab onTabSelected={this.handleTabSelect} tabName={headers} openTab={this.state.openTab}/>
102-
<Tab onTabSelected={this.handleTabSelect} tabName={cookies} openTab={this.state.openTab}/>
103-
<Tab onTabSelected={this.handleTabSelect} tabName={body} openTab={this.state.openTab}/>
100+
<Tab onTabSelected={this.handleTabSelect} tabName={headers} openTab={this.state.openTab} />
101+
<Tab onTabSelected={this.handleTabSelect} tabName={cookies} openTab={this.state.openTab} />
102+
<Tab onTabSelected={this.handleTabSelect} tabName={body} openTab={this.state.openTab} />
104103
{
105104
this.props.requestContent.bodyType === "GQL" &&
106105
<Tab onTabSelected={this.handleTabSelect} tabName={variables} openTab={this.state.openTab} />

src/client/components/display/ResponseSubscriptionDisplay.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import { WebSocketLink } from 'apollo-link-ws';
88

99

1010
const ResponseSubscriptionDisplay = ({ content, reqResUpdate }) => {
11-
const { body, bodyVariables } = content.request;
12-
const uri = content.protocol === /wss?:\/\// ? content.url : content.url.replace(content.protocol, 'ws://');
11+
let { body, bodyVariables } = content.request;
12+
if (bodyVariables === '') bodyVariables = null
13+
const uri = /wss?:\/\//.test(content.protocol) ? content.url : content.url.replace(content.protocol, 'ws://');
1314

1415
const link = new WebSocketLink({
1516
uri,

src/client/components/display/WebSocketWindow.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class WebSocketWindow extends Component {
5555
const messageInputStyles = {
5656
display: this.props.connection === 'open' ? 'block' : 'none',
5757
};
58-
console.log(this.props)
5958
return (
6059
<div
6160
style={{}}

src/client/controllers/collectionsController.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,35 @@ const collectionsController = {
77

88
addCollectionToIndexedDb(collection) {
99
db.collections.put({ ...collection })
10-
.catch((err) => console.log('Error in addToCollection', err))
10+
.catch(err => console.log('Error in addToCollection', err));
1111
},
1212

1313
deleteCollectionFromIndexedDb(id) {
1414
db.collections.delete(id)
15-
.catch((err) => console.log('Error in deleteFromCollection', err))
15+
.catch(err => console.log('Error in deleteFromCollection', err));
1616
},
1717

1818
getCollections() {
1919
db.table('collections')
2020
.toArray()
21-
.then(collections => {
21+
.then((collections) => {
2222
const collectionsArr = collections.sort((a, b) => b.created_at - a.created_at);
2323
store.default.dispatch(actions.getCollections(collectionsArr));
2424
})
2525
.catch(err => console.log('Error in getCollections', err));
2626
},
2727

2828
collectionNameExists(obj) {
29-
const { name } = obj
30-
console.log(name)
31-
return new Promise((resolve, reject) => { //resolve and reject are functions!
32-
db.collections.where("name").equalsIgnoreCase(name).first(foundCollection => {
33-
foundCollection ? console.log(`Found ${name}`) : console.log("nope not here")
34-
return !!foundCollection
35-
})
36-
.then((found) => { console.log("found: ", found); resolve(found)})
37-
.catch(error => {
38-
console.error(error.stack || error);
39-
reject(error)
40-
});
41-
})
42-
}
43-
}
29+
const { name } = obj;
30+
return new Promise((resolve, reject) => { // resolve and reject are functions!
31+
db.collections.where('name').equalsIgnoreCase(name).first(foundCollection => !!foundCollection)
32+
.then(found => resolve(found))
33+
.catch((error) => {
34+
console.error(error.stack || error);
35+
reject(error);
36+
});
37+
});
38+
},
39+
};
4440

4541
export default collectionsController;

0 commit comments

Comments
 (0)