Skip to content

Commit c8a2d39

Browse files
authored
Merge pull request #270 from carlosms/cancel-disable
Disable cancel button for older browsers
2 parents 30eca23 + 7a4361b commit c8a2d39

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

frontend/src/App.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ FROM ( SELECT MONTH(committer_when) as month,
198198

199199
loadQuery(key, sql) {
200200
const { history } = this.state;
201-
const abortController = new window.AbortController();
201+
const abortController = window.AbortController
202+
? new window.AbortController()
203+
: undefined;
202204

203205
const loadingResults = new Map(this.state.results);
204206
loadingResults.set(key, { sql, loading: true, abortController });
@@ -220,8 +222,9 @@ FROM ( SELECT MONTH(committer_when) as month,
220222
() => this.handleSetActiveResult(key)
221223
);
222224

225+
const signal = abortController ? abortController.signal : undefined;
223226
api
224-
.query(sql, abortController.signal)
227+
.query(sql, signal)
225228
.then(response => {
226229
this.setResult(key, { sql, response });
227230

frontend/src/components/TabbedResults.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ class TabbedResults extends Component {
210210
const { codeModalShow, codeModalContent } = this.state;
211211
const { showUAST, history, languages } = this.props;
212212

213+
const cancelDisabled = window.AbortController === undefined;
214+
213215
return (
214216
<div className="results-padding full-height full-width">
215217
<DivTabs
@@ -242,6 +244,7 @@ class TabbedResults extends Component {
242244
<Button
243245
className="animation-action cancel"
244246
bsStyle="gbpl-tertiary"
247+
disabled={cancelDisabled}
245248
onClick={() => this.props.handleAbortQuery(key)}
246249
>
247250
CANCEL

frontend/src/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import 'abortcontroller-polyfill/dist/polyfill-patch-fetch';
43
import 'bootstrap/dist/css/bootstrap.css';
54
import './variables.less';
65
import App from './App';
76

87
ReactDOM.render(<App />, document.getElementById('root'));
8+
9+
if (!window.AbortController) {
10+
// eslint-disable-next-line no-console
11+
console.warn(`Cancelling gitbase queries is disabled; your browser does not support the AbortController interface.
12+
Please check for compatibility here: https://developer.mozilla.org/en-US/docs/Web/API/AbortController#Browser_compatibility`);
13+
}

0 commit comments

Comments
 (0)