Commit a03900e6 by Johannes Schill

react-panel: Remove comments and improve readability in render()

parent 3908e64e
...@@ -74,19 +74,12 @@ export class QueryInspector extends PureComponent<Props, State> { ...@@ -74,19 +74,12 @@ export class QueryInspector extends PureComponent<Props, State> {
}; };
onDataSourceResponse = (response: any = {}) => { onDataSourceResponse = (response: any = {}) => {
// ignore if closed
// if (!this.isOpen) {
// return;
// }
if (this.state.isMocking) { if (this.state.isMocking) {
this.handleMocking(response); this.handleMocking(response);
return; return;
} }
// this.isLoading = false; response = { ...response }; // clone - dont modify the response
// data = _.cloneDeep(data);
response = { ...response }; // clone
if (response.headers) { if (response.headers) {
delete response.headers; delete response.headers;
...@@ -109,15 +102,6 @@ export class QueryInspector extends PureComponent<Props, State> { ...@@ -109,15 +102,6 @@ export class QueryInspector extends PureComponent<Props, State> {
if (response.data) { if (response.data) {
response.response = response.data; response.response = response.data;
// if (response.status === 200) {
// // if we are in error state, assume we automatically opened
// // and auto close it again
// if (this.hasError) {
// this.hasError = false;
// this.isOpen = false;
// }
// }
delete response.data; delete response.data;
delete response.status; delete response.status;
delete response.statusText; delete response.statusText;
...@@ -175,10 +159,26 @@ export class QueryInspector extends PureComponent<Props, State> { ...@@ -175,10 +159,26 @@ export class QueryInspector extends PureComponent<Props, State> {
})); }));
}; };
renderExpandCollapse = () => {
const { allNodesExpanded } = this.state;
const collapse = (
<>
<i className="fa fa-minus-square-o" /> Collapse All
</>
);
const expand = (
<>
<i className="fa fa-plus-square-o" /> Expand All
</>
);
return allNodesExpanded ? collapse : expand;
};
render() { render() {
const { response, isLoading } = this.state.dsQuery; const { response, isLoading } = this.state.dsQuery;
const { LoadingPlaceholder } = this.props; const { LoadingPlaceholder } = this.props;
const { allNodesExpanded, isMocking } = this.state; const { isMocking } = this.state;
const openNodes = this.getNrOfOpenNodes(); const openNodes = this.getNrOfOpenNodes();
if (isLoading) { if (isLoading) {
...@@ -187,23 +187,12 @@ export class QueryInspector extends PureComponent<Props, State> { ...@@ -187,23 +187,12 @@ export class QueryInspector extends PureComponent<Props, State> {
return ( return (
<> <>
{/* <div className="query-troubleshooter__header">
<a className="pointer" ng-click="ctrl.toggleMocking()">Mock Response</a>
*/}
<div> <div>
<button className="btn btn-transparent btn-p-x-0 m-r-1" onClick={this.onToggleMocking}> <button className="btn btn-transparent btn-p-x-0 m-r-1" onClick={this.onToggleMocking}>
Mock response Mock response
</button> </button>
<button className="btn btn-transparent btn-p-x-0 m-r-1" onClick={this.onToggleExpand}> <button className="btn btn-transparent btn-p-x-0 m-r-1" onClick={this.onToggleExpand}>
{allNodesExpanded ? ( {this.renderExpandCollapse()}
<>
<i className="fa fa-minus-square-o" /> Collapse All
</>
) : (
<>
<i className="fa fa-plus-square-o" /> Expand All
</>
)}
</button> </button>
<CopyToClipboard <CopyToClipboard
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment