Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c503583

Browse files
BinaryMusekuychaco
authored andcommitted
Fix up unauthenticated/401 errors and show nice GitHub login views
1 parent cd2a683 commit c503583

File tree

5 files changed

+29
-25
lines changed

5 files changed

+29
-25
lines changed

lib/containers/pr-info-container.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,6 @@ export class PrInfo extends React.Component {
7373
</a>
7474
<h3 className="pr-title">{pr.title}</h3>
7575
</div>
76-
<div className="meta-info">
77-
<div className="merge-status success">
78-
<Octicon icon="check" />
79-
Able to merge
80-
</div>
81-
<div className="build-status pending">
82-
<Octicon icon="primitive-dot" />
83-
Build pending
84-
</div>
85-
</div>
8676
<div className="conversation" onClick={this.handleClickPrLink}>
8777
<Octicon icon="comment-discussion" />
8878
Conversation
@@ -91,10 +81,6 @@ export class PrInfo extends React.Component {
9181
<Octicon icon="git-commit" />
9282
Commits <span className="count-number">{pr.commits.totalCount}</span>
9383
</div>
94-
<div className="file-count">
95-
<Octicon icon="diff" />
96-
Files changed <span className="count-number">7</span>
97-
</div>
9884
<div className="labels">
9985
{pr.labels.edges.map(({node}) => {
10086
const {name, color} = node;

lib/controllers/issueish-pane-item-controller.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {autobind} from 'core-decorators';
55
import RelayNetworkLayerManager from '../relay-network-layer-manager';
66
import RelayRootContainer from '../containers/relay-root-container';
77
import GithubLoginModel, {UNAUTHENTICATED} from '../models/github-login-model';
8+
import GithubLoginView from '../views/github-login-view';
89
import ObserveModel from '../views/observe-model';
910
import IssueishInfoByNumberRoute from '../routes/issueish-info-by-number-route';
1011
import IssueishLookupByNumberContainer from '../containers/issueish-lookup-by-number-container';
@@ -18,6 +19,7 @@ export default class IssueishPaneItemController extends React.Component {
1819
issueishNumber: React.PropTypes.number.isRequired,
1920
host: React.PropTypes.string,
2021
loginModel: React.PropTypes.instanceOf(GithubLoginModel).isRequired,
22+
onLogin: React.PropTypes.func.isRequired,
2123
}
2224

2325
static defaultProps = {
@@ -43,7 +45,7 @@ export default class IssueishPaneItemController extends React.Component {
4345
renderWithToken(data) {
4446
if (!data) { return null; }
4547
if (data.token === UNAUTHENTICATED) {
46-
return <div>Log in pls</div>;
48+
return <GithubLoginView onLogin={this.handleLogin} />;
4749
}
4850

4951
const route = new IssueishInfoByNumberRoute({
@@ -67,16 +69,19 @@ export default class IssueishPaneItemController extends React.Component {
6769
renderLoading={() => {
6870
return (
6971
<div className="github-Loader">
70-
<span className="github-Spinner"></span>
72+
<span className="github-Spinner" />
7173
</div>
7274
);
7375
}}
7476
renderFailure={(err, retry) => {
7577
if (err.response && err.response.status === 401) {
7678
return (
77-
<div>
78-
The API endpoint returned a unauthorized error. Please try to re-authenticate with the endpoint.
79-
{/* <GithubLoginView onLogin={this.props.onLogin} /> */}
79+
<div className="github-GithubLoginView-Container">
80+
<GithubLoginView onLogin={this.handleLogin}>
81+
<p>
82+
The API endpoint returned a unauthorized error. Please try to re-authenticate with the endpoint.
83+
</p>
84+
</GithubLoginView>
8085
</div>
8186
);
8287
} else {
@@ -87,4 +92,9 @@ export default class IssueishPaneItemController extends React.Component {
8792
</RelayEnvironment>
8893
);
8994
}
95+
96+
@autobind
97+
handleLogin(token) {
98+
this.props.loginModel.setToken(this.props.host, token);
99+
}
90100
}

lib/controllers/pr-info-controller.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,12 @@ export default class PrInfoController extends React.Component {
8181
renderFailure={(err, retry) => {
8282
if (err.response && err.response.status === 401) {
8383
return (
84-
<div>
85-
The API endpoint returned a unauthorized error. Please try to re-authenticate with the endpoint.
86-
<GithubLoginView onLogin={this.props.onLogin} />
84+
<div className="github-GithubLoginView-Container">
85+
<GithubLoginView onLogin={this.props.onLogin}>
86+
<p>
87+
The API endpoint returned a unauthorized error. Please try to re-authenticate with the endpoint.
88+
</p>
89+
</GithubLoginView>
8790
</div>
8891
);
8992
} else {

lib/views/github-login-view.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import {autobind} from 'core-decorators';
33

44
export default class GithubLoginView extends React.Component {
55
static propTypes = {
6+
children: React.PropTypes.node,
67
onLogin: React.PropTypes.func,
78
}
89

910
static defaultProps = {
11+
children: <p>Log in to GitHub to access PR information and more!</p>,
1012
onLogin: token => {},
1113
}
1214

@@ -36,9 +38,7 @@ export default class GithubLoginView extends React.Component {
3638
renderLogin() {
3739
return (
3840
<div className="github-GithubLoginView-Subview">
39-
<p>
40-
Log in to GitHub to access PR information and more!
41-
</p>
41+
{this.props.children}
4242
<button onClick={this.handleLoginClick} className="btn btn-primary btn-lg icon icon-octoface">
4343
Login
4444
</button>

styles/github-login-view.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
.github-GithubLoginView-Container {
2+
height: 100%;
3+
display: flex;
4+
}
5+
16
.github-GithubLoginView {
27
height: 100%;
38
display: flex;

0 commit comments

Comments
 (0)