@@ -2,26 +2,29 @@ import React from 'react';
2
2
import PropTypes from 'prop-types' ;
3
3
4
4
import {
5
- GithubLoginModelPropType , RefHolderPropType , RemoteSetPropType , RemotePropType , BranchSetPropType , BranchPropType ,
5
+ TokenPropType , EndpointPropType , RefHolderPropType ,
6
+ RemoteSetPropType , RemotePropType , BranchSetPropType , BranchPropType ,
6
7
RefresherPropType ,
7
8
} from '../prop-types' ;
8
9
import LoadingView from './loading-view' ;
10
+ import QueryErrorView from '../views/query-error-view' ;
11
+ import GithubLoginView from '../views/github-login-view' ;
9
12
import RemoteSelectorView from './remote-selector-view' ;
10
13
import GithubTabHeaderContainer from '../containers/github-tab-header-container' ;
11
- import GithubTabHeaderController from '../controllers/github-tab-header-controller' ;
12
14
import GitHubBlankNoLocal from './github-blank-nolocal' ;
13
15
import GitHubBlankUninitialized from './github-blank-uninitialized' ;
14
16
import GitHubBlankNoRemote from './github-blank-noremote' ;
15
17
import RemoteContainer from '../containers/remote-container' ;
16
- import { nullAuthor } from '../models/author ' ;
18
+ import { UNAUTHENTICATED , INSUFFICIENT } from '../shared/keytar-strategy ' ;
17
19
18
20
export default class GitHubTabView extends React . Component {
19
21
static propTypes = {
20
22
refresher : RefresherPropType . isRequired ,
21
23
rootHolder : RefHolderPropType . isRequired ,
22
24
23
25
// Connection
24
- loginModel : GithubLoginModelPropType . isRequired ,
26
+ endpoint : EndpointPropType . isRequired ,
27
+ token : TokenPropType ,
25
28
26
29
// Workspace
27
30
workspace : PropTypes . object . isRequired ,
@@ -43,6 +46,9 @@ export default class GitHubTabView extends React.Component {
43
46
pushInProgress : PropTypes . bool . isRequired ,
44
47
45
48
// Event Handlers
49
+ handleLogin : PropTypes . func . isRequired ,
50
+ handleLogout : PropTypes . func . isRequired ,
51
+ handleTokenRetry : PropTypes . func . isRequired ,
46
52
handleWorkDirSelect : PropTypes . func ,
47
53
handlePushBranch : PropTypes . func . isRequired ,
48
54
handleRemoteSelect : PropTypes . func . isRequired ,
@@ -65,6 +71,35 @@ export default class GitHubTabView extends React.Component {
65
71
}
66
72
67
73
renderRemote ( ) {
74
+ if ( this . props . token === null ) {
75
+ return < LoadingView /> ;
76
+ }
77
+
78
+ if ( this . props . token === UNAUTHENTICATED ) {
79
+ return < GithubLoginView onLogin = { this . props . handleLogin } /> ;
80
+ }
81
+
82
+ if ( this . props . token === INSUFFICIENT ) {
83
+ return (
84
+ < GithubLoginView onLogin = { this . props . handleLogin } >
85
+ < p >
86
+ Your token no longer has sufficient authorizations. Please re-authenticate and generate a new one.
87
+ </ p >
88
+ </ GithubLoginView >
89
+ ) ;
90
+ }
91
+
92
+ if ( this . props . token instanceof Error ) {
93
+ return (
94
+ < QueryErrorView
95
+ error = { this . props . token }
96
+ retry = { this . props . handleTokenRetry }
97
+ login = { this . props . handleLogin }
98
+ logout = { this . props . handleLogout }
99
+ />
100
+ ) ;
101
+ }
102
+
68
103
if ( this . props . isLoading ) {
69
104
return < LoadingView /> ;
70
105
}
@@ -92,22 +127,22 @@ export default class GitHubTabView extends React.Component {
92
127
return (
93
128
< RemoteContainer
94
129
// Connection
95
- loginModel = { this . props . loginModel }
96
130
endpoint = { this . props . currentRemote . getEndpoint ( ) }
131
+ token = { this . props . token }
97
132
98
- // Workspace
99
- workspace = { this . props . workspace }
133
+ // Repository attributes
134
+ refresher = { this . props . refresher }
135
+ pushInProgress = { this . props . pushInProgress }
100
136
workingDirectory = { this . props . workingDirectory }
101
-
102
- // Remote
137
+ workspace = { this . props . workspace }
103
138
remote = { this . props . currentRemote }
104
139
remotes = { this . props . remotes }
105
140
branches = { this . props . branches }
106
141
aheadCount = { this . props . aheadCount }
107
- pushInProgress = { this . props . pushInProgress }
108
- refresher = { this . props . refresher }
109
142
110
- // Event Handlers
143
+ // Action methods
144
+ handleLogin = { this . props . handleLogin }
145
+ handleLogout = { this . props . handleLogout }
111
146
onPushBranch = { ( ) => this . props . handlePushBranch ( this . props . currentBranch , this . props . currentRemote ) }
112
147
/>
113
148
) ;
@@ -130,29 +165,11 @@ export default class GitHubTabView extends React.Component {
130
165
}
131
166
132
167
renderHeader ( ) {
133
- if ( this . props . currentRemote . isPresent ( ) ) {
134
- return (
135
- < GithubTabHeaderContainer
136
- // Connection
137
- loginModel = { this . props . loginModel }
138
- endpoint = { this . props . currentRemote . getEndpoint ( ) }
139
-
140
- // Workspace
141
- currentWorkDir = { this . props . workingDirectory }
142
- contextLocked = { this . props . contextLocked }
143
- changeWorkingDirectory = { this . props . changeWorkingDirectory }
144
- setContextLock = { this . props . setContextLock }
145
- getCurrentWorkDirs = { this . props . getCurrentWorkDirs }
146
-
147
- // Event Handlers
148
- // handleWorkDirSelect={e => this.props.changeWorkingDirectory(e.target.value)}
149
- onDidChangeWorkDirs = { this . props . onDidChangeWorkDirs }
150
- />
151
- ) ;
152
- }
153
168
return (
154
- < GithubTabHeaderController
155
- user = { nullAuthor }
169
+ < GithubTabHeaderContainer
170
+ // Connection
171
+ endpoint = { this . props . endpoint }
172
+ token = { this . props . token }
156
173
157
174
// Workspace
158
175
currentWorkDir = { this . props . workingDirectory }
0 commit comments