Skip to content

Commit 18faa87

Browse files
committed
loadable.jsx: Show modal on API limit exceed
This shows a modal with error message on exceeding API limit. Fixes #127
1 parent b872c70 commit 18faa87

File tree

1 file changed

+39
-13
lines changed

1 file changed

+39
-13
lines changed

src/components/loadable.jsx

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Component} from 'react';
22
import {SyncIcon} from 'react-octicons';
3+
import * as BS from 'react-bootstrap';
34

45
const STATUS = {
56
INITIAL: 'initial',
@@ -11,28 +12,53 @@ class Loadable extends Component {
1112
static defaultProps = {
1213
renderError: (err) => {
1314
console.error(err);
14-
// If it is a permissions error then it might be a rate limi
15+
// If it is a permissions error then it might be a rate limit
1516
if (err.status === 403) {
1617
return (
17-
<div>
18-
<h2>Insufficient Permissions (or rate limit exceeded)</h2>
19-
<p>
20-
It looks like either you do not have permission to see this repository or the rate limit for requests to GitHub has been exceeded. This usually happens when you are not logged in to gh-board. Try signing in to continue.
21-
</p>
22-
<code>{err.message}</code>
23-
</div>
18+
<BS.Modal show >
19+
<BS.Modal.Header>
20+
<BS.Modal.Title><h2>Insufficient Permissions </h2>(or rate limit exceeded)</BS.Modal.Title>
21+
</BS.Modal.Header>
22+
<BS.Modal.Body >
23+
<div>
24+
<p>
25+
It looks like either you do not have permission to see this repository or the rate limit for requests to GitHub has been exceeded. This usually happens when you are not logged in to gh-board. Try signing in to continue.
26+
</p>
27+
<code>
28+
{JSON.parse(err.message).message}
29+
<br />
30+
<a href={JSON.parse(err.message).documentation_url}>Documentation URL</a>
31+
</code>
32+
<br />
33+
<br />
34+
</div>
35+
</BS.Modal.Body>
36+
</BS.Modal>
2437
);
2538
} else if (err.name === 'InvalidStateError') {
2639
return (
2740
<span>It looks like your browser is in private browsing mode. gh-board uses IndexedDB to cache requests to GitHub. Please disable Private Browsing to see it work.</span>
2841
);
2942
} else {
3043
return (
31-
<span>
32-
Problem loading. Is it a valid repo? And have you exceeded your number of requests? Usually happens when not logged in because GitHub limits anonymous use of their API.
33-
{err.message}
34-
{JSON.stringify(err)}
35-
</span>
44+
<BS.Modal show >
45+
<BS.Modal.Header>
46+
</BS.Modal.Header>
47+
<BS.Modal.Body >
48+
<div>
49+
<p>
50+
Problem loading. Is it a valid repo? And have you exceeded your number of requests? Usually happens when not logged in because GitHub limits anonymous use of their API.
51+
</p>
52+
<code>
53+
{JSON.parse(err.message).message}
54+
<br />
55+
<a href={JSON.parse(err.message).documentation_url}>Documentation URL</a>
56+
</code>
57+
<br />
58+
<br />
59+
</div>
60+
</BS.Modal.Body>
61+
</BS.Modal>
3662
);
3763
}
3864
}

0 commit comments

Comments
 (0)