Skip to content

Commit 9449d50

Browse files
authored
Merge pull request #13 from h15200/main-http2-error-debug
Main http2 error debug
2 parents a1bd7fd + cc08c4e commit 9449d50

File tree

5 files changed

+273
-208
lines changed

5 files changed

+273
-208
lines changed

main.js

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,12 @@ require("./menu/mainMenu");
4848
// autoUpdater.logger.transports.file.level = "info";
4949
// log.info("App starting...");
5050

51-
console.log("app.name is ->", app.name)
52-
5351
let mainWindow;
5452

55-
// -----------------------------------------------------------------
56-
// Create Touchbar buttons
57-
// -----------------------------------------------------------------
53+
/****************************
54+
** Create Touchbar buttons **
55+
*****************************/
56+
5857
const tbSelectAllButton = new TouchBarButton({
5958
label: "Select All",
6059
backgroundColor: "#3DADC2",
@@ -116,9 +115,10 @@ const tbSpacer = new TouchBarSpacer();
116115
const tbFlexSpacer = new TouchBarSpacer({
117116
size: "flexible",
118117
});
119-
// -----------------------------------------------------------------
120-
// Attach earlier made buttons to a touch bar
121-
// -----------------------------------------------------------------
118+
119+
/********************************
120+
** Attach buttons to touchbar **
121+
********************************/
122122

123123
const touchBar = new TouchBar([
124124
tbSpacer,
@@ -131,16 +131,34 @@ const touchBar = new TouchBar([
131131
tbClearAllButton,
132132
]);
133133

134-
// -----------------------------------------------
135-
// prod / dev mode determined by boolean 'isDev'
136-
// -----------------------------------------------
134+
/************************
135+
******** SET isDev *****
136+
************************/
137137

138138
let isDev;
139139
// if using Spectron, run it in production
140140
process.argv.includes("--noDevServer") || process.argv.includes("TEST_MODE")
141141
? (isDev = false)
142142
: (isDev = true);
143-
console.log("is this in dev mode? ", isDev);
143+
144+
/*************************
145+
******* MODE DISPLAY ****
146+
*************************/
147+
148+
isDev
149+
? console.log(`
150+
151+
========================
152+
Launching in DEV mode
153+
========================
154+
`)
155+
: console.log(`
156+
157+
==============================
158+
Launching in PRODUCTION mode
159+
==============================
160+
`);
161+
144162
// let isDev = false;
145163
// console.log("process.defaultApp ->", process.defaultApp);
146164
// console.log("process.execPath -> ", process.execPath);
@@ -168,7 +186,7 @@ if (process.platform === "win32") {
168186
}
169187

170188
/***********************************************
171-
******* createWindow function declaration ******
189+
******* createWindow function declaration *****
172190
***********************************************/
173191

174192
function createWindow() {
@@ -190,28 +208,26 @@ function createWindow() {
190208
icon: `${__dirname}/src/assets/icons/64x64.png`,
191209
});
192210

193-
if (isDev) {
194-
// If we are in developer mode Add React & Redux DevTools to Electon App
195-
installExtension(REACT_DEVELOPER_TOOLS)
196-
.then((name) => console.log(`Added Extension: ${name}`))
197-
.catch((err) => console.log("An error occurred: ", err));
198-
199-
installExtension(REDUX_DEVTOOLS)
200-
.then((name) => console.log(`Added Extension: ${name}`))
201-
.catch((err) => console.log("An error occurred: ", err));
202-
}
203-
204211
// and load the index.html of the app.
205212
let indexPath;
206213

207-
if (isDev && process.argv.indexOf("--noDevServer") === -1) {
214+
if (isDev) {
208215
// if we are in dev mode load up 'http://localhost:8080/index.html'
209216
indexPath = url.format({
210217
protocol: "http:",
211218
host: "localhost:8080",
212219
pathname: "index.html",
213220
slashes: true,
214221
});
222+
223+
// If we are in developer mode Add React & Redux DevTools to Electon App
224+
installExtension(REACT_DEVELOPER_TOOLS)
225+
.then((name) => console.log(`Added Extension: ${name}`))
226+
.catch((err) => console.log("An error occurred: ", err));
227+
228+
installExtension(REDUX_DEVTOOLS)
229+
.then((name) => console.log(`Added Extension: ${name}`))
230+
.catch((err) => console.log("An error occurred: ", err));
215231
} else {
216232
indexPath = url.format({
217233
// if we are not in dev mode load production build file
Lines changed: 56 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,89 @@
1-
import React from 'react';
2-
import SSERow from './SSERow.jsx';
3-
import JSONPretty from 'react-json-pretty';
4-
import createDOMPurify from 'dompurify';
5-
6-
1+
import React from "react";
2+
import JSONPretty from "react-json-pretty";
3+
import createDOMPurify from "dompurify";
4+
import SSERow from "./SSERow.jsx";
75

86
const ResponseEventsDisplay = ({ response }) => {
97
const { events, headers } = response;
108
const displayContents = [];
119

1210
// If it's an SSE, render event rows
13-
14-
if (headers && headers['content-type'] && headers['content-type'].includes('text/event-stream')) {
11+
12+
if (
13+
headers &&
14+
headers["content-type"] &&
15+
headers["content-type"].includes("text/event-stream")
16+
) {
1517
events.forEach((cur, idx) => {
1618
displayContents.push(<SSERow key={idx} content={cur} />);
1719
});
1820
}
1921
// if the response content-type, purify and render html
20-
else if (headers && headers['content-type'] && headers['content-type'].includes('text/html')) {
22+
else if (
23+
headers &&
24+
headers["content-type"] &&
25+
headers["content-type"].includes("text/html")
26+
) {
27+
// console.log("headers:content-type ->", headers["content-type"]);
28+
// console.log("events0 -> ", events[0]);
2129
displayContents.push(
22-
<div className="okay" dangerouslySetInnerHTML={{__html: createDOMPurify.sanitize(events[0])}} />
23-
)
24-
}
25-
else if (events && events.length > 1) {
30+
<div
31+
className="okay"
32+
key="http2_html_content"
33+
dangerouslySetInnerHTML={{
34+
__html: createDOMPurify.sanitize(events[0]),
35+
}}
36+
/>
37+
);
38+
} else if (events && events.length > 1) {
2639
if (events) {
27-
let resEvents = '';
40+
let resEvents = "";
2841
let eventJSON;
2942
for (const event of events) {
3043
eventJSON = JSON.stringify(event, null, 4);
3144
resEvents = `${resEvents}
32-
${eventJSON}`
45+
${eventJSON}`;
3346
}
3447
displayContents.push(
3548
<div className="json-response" key="jsonresponsediv">
36-
<JSONPretty data={resEvents} space="4" theme={{
37-
main: 'line-height:1.3; color: midnightblue; background:#RRGGBB; overflow:auto;',
38-
key: 'color:#0089D0;', // bluetwo
39-
string: 'color:#15B78F;',// greenone
40-
value: 'color:#fd971f;', // a nice orange
41-
boolean: 'color:#E00198;', // gqlpink
42-
}}
49+
<JSONPretty
50+
data={resEvents}
51+
space="4"
52+
theme={{
53+
main:
54+
"line-height:1.3; color: midnightblue; background:#RRGGBB; overflow:auto;",
55+
key: "color:#0089D0;", // bluetwo
56+
string: "color:#15B78F;", // greenone
57+
value: "color:#fd971f;", // a nice orange
58+
boolean: "color:#E00198;", // gqlpink
59+
}}
4360
/>
4461
</div>
4562
);
4663
}
47-
4864
}
4965

5066
// Otherwise, render a single display
51-
else {
52-
if (events) {
53-
displayContents.push(
54-
<div className="json-response" key="jsonresponsediv">
55-
<JSONPretty data={events[0]} space="4" theme={{
56-
main: 'line-height:1.3; color: midnightblue; background:#RRGGBB; overflow:auto;',
57-
key: 'color:#0089D0;', // bluetwo
58-
string: 'color:#15B78F;',// greenone
59-
value: 'color:#fd971f;', // a nice orange
60-
boolean: 'color:#E00198;', // gqlpink
67+
else if (events) {
68+
displayContents.push(
69+
<div className="json-response" key="jsonresponsediv">
70+
<JSONPretty
71+
data={events[0]}
72+
space="4"
73+
theme={{
74+
main:
75+
"line-height:1.3; color: midnightblue; background:#RRGGBB; overflow:auto;",
76+
key: "color:#0089D0;", // bluetwo
77+
string: "color:#15B78F;", // greenone
78+
value: "color:#fd971f;", // a nice orange
79+
boolean: "color:#E00198;", // gqlpink
6180
}}
62-
/>
63-
</div>
64-
);
65-
}
81+
/>
82+
</div>
83+
);
6684
}
6785

6886
return <div className="tab_content-response">{displayContents}</div>;
69-
}
87+
};
7088

7189
export default ResponseEventsDisplay;
Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
1-
import React, { Component } from 'react';
1+
import React, { Component } from "react";
22

33
class Tab extends Component {
44
constructor(props) {
55
super(props);
66
this.tabClickHandler = this.tabClickHandler.bind(this);
77
}
88

9-
tabClickHandler () {
10-
let selectedTab = this.props.tabName;
11-
this.props.onTabSelected(selectedTab);
9+
tabClickHandler() {
10+
const selectedTab = this.props.tabName;
11+
this.props.onTabSelected(selectedTab);
1212
}
1313

1414
render() {
1515
return (
16-
<li onClick={this.tabClickHandler} className={this.props.tabName === this.props.openTab ? 'tab-list-item-active': 'tab-list-item'} key={this.props.tabName}>{this.props.tabName}</li>
17-
)
16+
<li
17+
onClick={this.tabClickHandler}
18+
className={
19+
this.props.tabName === this.props.openTab
20+
? "tab-list-item-active"
21+
: "tab-list-item"
22+
}
23+
key={this.props.tabName}
24+
>
25+
{this.props.tabName}
26+
</li>
27+
);
1828
}
1929
}
2030

21-
export default (Tab);
31+
export default Tab;

0 commit comments

Comments
 (0)