Skip to content

Commit

Permalink
Merge branch 'master' into common-header-update
Browse files Browse the repository at this point in the history
  • Loading branch information
rikinsk committed Jun 6, 2020
2 parents 756d6cb + d67757c commit 87ac82e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Read more about the session argument for computed fields in the [docs](https://h
- server: flush log buffer during shutdown (#4800)
- server: fix edge case with printing logs on startup failure (fix #4772)
- console: allow entering big int values in the console (close #3667) (#4775)
- console: add support for subscriptions analyze in API explorer (close #2541) (#2541)
- console: avoid count queries for large tables (#4692)
- console: add read replica support section to pro popup (#4118)
- console: fix regression in editing permissions manually (fix #4683) (#4826)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import Modal from 'react-modal';
import RootFields from './RootFields';

export default class QueryAnalyser extends React.Component {
constructor() {
Expand All @@ -11,6 +12,7 @@ export default class QueryAnalyser extends React.Component {
activeNode: 0,
};
}

componentDidMount() {
this.props
.analyzeFetcher(this.props.analyseQuery.query)
Expand All @@ -22,7 +24,7 @@ export default class QueryAnalyser extends React.Component {
})
.then(data => {
this.setState({
analyseData: data,
analyseData: Array.isArray(data) ? data : [data],
activeNode: 0,
});
})
Expand All @@ -33,19 +35,6 @@ export default class QueryAnalyser extends React.Component {
}
render() {
const { show, clearAnalyse } = this.props;
const analysisList = this.state.analyseData.map((analysis, i) => {
return (
<li
className={i === this.state.activeNode ? 'active' : ''}
key={i}
data-key={i}
onClick={this.handleAnalyseNodeChange.bind(this)}
>
<i className="fa fa-table" aria-hidden="true" />
{analysis.field}
</li>
);
});
return (
<Modal
className="modalWrapper"
Expand All @@ -64,7 +53,11 @@ export default class QueryAnalyser extends React.Component {
<div className="wd25">
<div className="topLevelNodesWrapper">
<div className="title">Top level nodes</div>
<ul>{analysisList}</ul>
<RootFields
data={this.state.analyseData}
activeNode={this.state.activeNode}
onClick={this.handleAnalyseNodeChange}
/>
</div>
</div>
<div className="wd75">
Expand Down Expand Up @@ -171,12 +164,12 @@ export default class QueryAnalyser extends React.Component {
}
*/

handleAnalyseNodeChange(e) {
handleAnalyseNodeChange = e => {
const nodeKey = e.target.getAttribute('data-key');
if (nodeKey) {
this.setState({ activeNode: parseInt(nodeKey, 10) });
}
}
};
copyToClip(type, id) {
let text = '';
if (this.state.analyseData.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react';

type ExplainPayload = {
field: string;
sql: string;
plan: string[];
};

type RootFieldsProps = {
data: ExplainPayload[];
activeNode: number;
onClick: (e: React.MouseEvent<HTMLLIElement>) => void;
};

const RootFields: React.FC<RootFieldsProps> = ({
data,
activeNode,
onClick,
}) => (
<ul>
{data.map((analysis, i) => {
return (
analysis.field && (
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
<li
className={i === activeNode ? 'active' : ''}
key={i}
data-key={i}
onClick={onClick}
>
<i className="fa fa-table" aria-hidden="true" />
{analysis.field}
</li>
)
);
})}
</ul>
);

export default RootFields;

0 comments on commit 87ac82e

Please sign in to comment.