Skip to content

Commit 01d49a2

Browse files
committed
resolve eslint errors
1 parent 8d988c0 commit 01d49a2

File tree

4 files changed

+231
-182
lines changed

4 files changed

+231
-182
lines changed
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: 16 additions & 6 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 () {
9+
tabClickHandler() {
1010
let selectedTab = this.props.tabName;
11-
this.props.onTabSelected(selectedTab);
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)