Skip to content

Commit 869f600

Browse files
authored
Merge pull request #251 from carlosms/move-results-msg
Move results message inside each tab
2 parents 7b85eb4 + a587fff commit 869f600

6 files changed

Lines changed: 69 additions & 69 deletions

File tree

frontend/src/App.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,6 @@ AND refs.ref_name = 'HEAD'`
449449
<QueryBox
450450
sql={this.state.sql}
451451
schema={this.state.schema}
452-
result={this.state.lastResult}
453452
handleTextChange={this.handleTextChange}
454453
handleSubmit={this.handleSubmit}
455454
exportUrl={api.queryExport(this.state.sql)}

frontend/src/components/QueryBox.js

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,8 @@ import 'codemirror/addon/hint/show-hint';
1212
import 'codemirror/addon/hint/sql-hint';
1313

1414
import './QueryBox.less';
15-
import SuccessIcon from '../icons/success-query.svg';
16-
import ErrorIcon from '../icons/error-query.svg';
1715
import HelpIcon from '../icons/help.svg';
1816

19-
function ResultInfo({ result }) {
20-
if (!result) {
21-
return null;
22-
}
23-
24-
if (result.response && result.response.meta) {
25-
return (
26-
<span className="meta meta-success">
27-
<SuccessIcon className="big-icon" />Showing rows (query took{' '}
28-
{result.response.meta.elapsedTime / 1000} seconds)
29-
</span>
30-
);
31-
}
32-
33-
if (result.errorMsg) {
34-
return (
35-
<span className="meta meta-error">
36-
<ErrorIcon className="big-icon" />Query Failed - {result.errorMsg}
37-
</span>
38-
);
39-
}
40-
41-
return null;
42-
}
43-
44-
ResultInfo.propTypes = {
45-
result: PropTypes.object
46-
};
47-
4817
class QueryBox extends Component {
4918
constructor(props) {
5019
super(props);
@@ -95,7 +64,6 @@ class QueryBox extends Component {
9564
}
9665

9766
render() {
98-
const { result } = this.props;
9967
const { codeMirrorTables } = this.state;
10068

10169
const options = {
@@ -138,9 +106,7 @@ class QueryBox extends Component {
138106
</Col>
139107
</Row>
140108
<Row className="button-row">
141-
<Col xs={7} className="meta-wrapper no-spacing">
142-
<ResultInfo result={result} />
143-
</Col>
109+
<Col xs={7} />
144110
<Col xs={5} className="buttons-wrapper no-spacing">
145111
<Button
146112
bsStyle="gbpl-secondary-tint-2-link"
@@ -179,7 +145,6 @@ QueryBox.propTypes = {
179145
).isRequired
180146
})
181147
),
182-
result: PropTypes.object,
183148
enabled: PropTypes.bool,
184149
handleTextChange: PropTypes.func.isRequired,
185150
handleSubmit: PropTypes.func.isRequired,

frontend/src/components/QueryBox.less

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,6 @@
2828
padding: @big-spacing;
2929
margin: 0;
3030

31-
.meta-wrapper {
32-
display: table;
33-
height: 100%;
34-
35-
.meta {
36-
.big-icon {
37-
margin-right: 15px;
38-
}
39-
40-
display: table-cell;
41-
vertical-align: middle;
42-
43-
font-size: 14px;
44-
45-
&.meta-success {
46-
svg path {
47-
fill: @success;
48-
}
49-
}
50-
51-
&.meta-error {
52-
color: @error-text;
53-
54-
svg path {
55-
fill: @error-text;
56-
}
57-
}
58-
}
59-
}
60-
6131
.buttons-wrapper {
6232
text-align: right;
6333
}

frontend/src/components/ResultsTable.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
flex-grow: 1;
55
flex-basis: 150px;
66
min-height: 150px;
7+
margin-top: 2em;
78

89
border: unset;
910

frontend/src/components/TabbedResults.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import TimerIcon from '../icons/history-tab.svg';
1919
import LoadingImg from '../icons/alex-loading-results.gif';
2020
import SuspendedImg from '../icons/alex-suspended-tab.gif';
2121
import ErrorImg from '../icons/broken-alex.gif';
22+
import SuccessIcon from '../icons/success-query.svg';
23+
import ErrorIcon from '../icons/error-query.svg';
2224

2325
class TabTitle extends Component {
2426
constructor(props) {
@@ -118,6 +120,36 @@ TabTitle.propTypes = {
118120
handleRemoveResult: PropTypes.func.isRequired
119121
};
120122

123+
function ResultInfo({ result }) {
124+
if (!result) {
125+
return null;
126+
}
127+
128+
if (result.response && result.response.meta) {
129+
return (
130+
<span className="meta meta-success">
131+
<SuccessIcon className="big-icon" />
132+
{`Returned ${result.response.data.length} rows
133+
(${result.response.meta.elapsedTime / 1000} seconds)`}
134+
</span>
135+
);
136+
}
137+
138+
if (result.errorMsg) {
139+
return (
140+
<span className="meta meta-error">
141+
<ErrorIcon className="big-icon" />Query Failed - {result.errorMsg}
142+
</span>
143+
);
144+
}
145+
146+
return null;
147+
}
148+
149+
ResultInfo.propTypes = {
150+
result: PropTypes.object
151+
};
152+
121153
class TabbedResults extends Component {
122154
constructor(props) {
123155
super(props);
@@ -221,7 +253,6 @@ class TabbedResults extends Component {
221253
} else if (query.errorMsg) {
222254
content = (
223255
<Fragment>
224-
<span className="result-error-msg">{query.errorMsg}</span>
225256
<Row>
226257
<Col className="text-center animation-col" xs={12}>
227258
<img src={`${ErrorImg}?${key}`} alt="error animation" />
@@ -302,6 +333,9 @@ class TabbedResults extends Component {
302333
</Button>
303334
</div>
304335
</div>
336+
<div className="meta-row">
337+
<ResultInfo result={query} />
338+
</div>
305339
{content}
306340
</Tab>
307341
);

frontend/src/components/TabbedResults.less

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@
5454
}
5555

5656
.query-row {
57+
flex: 0 0 auto;
58+
5759
display: flex;
58-
margin-bottom: 2em;
5960

6061
.query-text,
6162
.edit-query {
@@ -86,6 +87,36 @@
8687
}
8788
}
8889

90+
.meta-row {
91+
flex: 0 0 auto;
92+
margin-top: 0.5em;
93+
94+
.meta {
95+
.big-icon {
96+
margin-right: 15px;
97+
}
98+
99+
display: table-cell;
100+
vertical-align: middle;
101+
102+
font-size: 14px;
103+
104+
&.meta-success {
105+
svg path {
106+
fill: @success;
107+
}
108+
}
109+
110+
&.meta-error {
111+
color: @error-text;
112+
113+
svg path {
114+
fill: @error-text;
115+
}
116+
}
117+
}
118+
}
119+
89120
button.animation-action {
90121
padding-left: 50px;
91122
padding-right: 50px;

0 commit comments

Comments
 (0)