Repository navigation
Expand file tree
/
Copy pathgithub-tab-view.js
More file actions
169 lines (148 loc) · 5.41 KB
/
Copy pathgithub-tab-view.js
File metadata and controls
169 lines (148 loc) · 5.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import React from 'react';
import PropTypes from 'prop-types';
import {
GithubLoginModelPropType, RefHolderPropType, RemoteSetPropType, RemotePropType, BranchSetPropType, BranchPropType,
RefresherPropType,
} from '../prop-types';
import LoadingView from './loading-view';
import RemoteSelectorView from './remote-selector-view';
import GithubTabHeaderContainer from '../containers/github-tab-header-container';
import GithubTabHeaderController from '../controllers/github-tab-header-controller';
import GitHubBlankNoLocal from './github-blank-nolocal';
import GitHubBlankUninitialized from './github-blank-uninitialized';
import GitHubBlankNoRemote from './github-blank-noremote';
import RemoteContainer from '../containers/remote-container';
import {nullAuthor} from '../models/author';
export default class GitHubTabView extends React.Component {
static propTypes = {
refresher: RefresherPropType.isRequired,
rootHolder: RefHolderPropType.isRequired,
// Connection
loginModel: GithubLoginModelPropType.isRequired,
// Workspace
workspace: PropTypes.object.isRequired,
workingDirectory: PropTypes.string,
getCurrentWorkDirs: PropTypes.func.isRequired,
changeWorkingDirectory: PropTypes.func.isRequired,
contextLocked: PropTypes.bool.isRequired,
setContextLock: PropTypes.func.isRequired,
repository: PropTypes.object.isRequired,
// Remotes
remotes: RemoteSetPropType.isRequired,
currentRemote: RemotePropType.isRequired,
manyRemotesAvailable: PropTypes.bool.isRequired,
isLoading: PropTypes.bool.isRequired,
branches: BranchSetPropType.isRequired,
currentBranch: BranchPropType.isRequired,
aheadCount: PropTypes.number,
pushInProgress: PropTypes.bool.isRequired,
// Event Handlers
handleWorkDirSelect: PropTypes.func,
handlePushBranch: PropTypes.func.isRequired,
handleRemoteSelect: PropTypes.func.isRequired,
onDidChangeWorkDirs: PropTypes.func.isRequired,
openCreateDialog: PropTypes.func.isRequired,
openBoundPublishDialog: PropTypes.func.isRequired,
openCloneDialog: PropTypes.func.isRequired,
openGitTab: PropTypes.func.isRequired,
}
render() {
return (
<div className="github-GitHub" ref={this.props.rootHolder.setter}>
{this.renderHeader()}
<div className="github-GitHub-content">
{this.renderRemote()}
</div>
</div>
);
}
renderRemote() {
if (this.props.isLoading) {
return <LoadingView />;
}
if (this.props.repository.isAbsent() || this.props.repository.isAbsentGuess()) {
return (
<GitHubBlankNoLocal
openCreateDialog={this.props.openCreateDialog}
openCloneDialog={this.props.openCloneDialog}
/>
);
}
if (this.props.repository.isEmpty()) {
return (
<GitHubBlankUninitialized
openBoundPublishDialog={this.props.openBoundPublishDialog}
openGitTab={this.props.openGitTab}
/>
);
}
if (this.props.currentRemote.isPresent()) {
// Single, chosen or unambiguous remote
return (
<RemoteContainer
// Connection
loginModel={this.props.loginModel}
endpoint={this.props.currentRemote.getEndpoint()}
// Workspace
workspace={this.props.workspace}
workingDirectory={this.props.workingDirectory}
// Remote
remote={this.props.currentRemote}
remotes={this.props.remotes}
branches={this.props.branches}
aheadCount={this.props.aheadCount}
pushInProgress={this.props.pushInProgress}
refresher={this.props.refresher}
// Event Handlers
onPushBranch={() => this.props.handlePushBranch(this.props.currentBranch, this.props.currentRemote)}
/>
);
}
if (this.props.manyRemotesAvailable) {
// No chosen remote, multiple remotes hosted on GitHub instances
return (
<RemoteSelectorView
remotes={this.props.remotes}
currentBranch={this.props.currentBranch}
selectRemote={this.props.handleRemoteSelect}
/>
);
}
return (
<GitHubBlankNoRemote openBoundPublishDialog={this.props.openBoundPublishDialog} />
);
}
renderHeader() {
if (this.props.currentRemote.isPresent()) {
return (
<GithubTabHeaderContainer
// Connection
loginModel={this.props.loginModel}
endpoint={this.props.currentRemote.getEndpoint()}
// Workspace
currentWorkDir={this.props.workingDirectory}
contextLocked={this.props.contextLocked}
changeWorkingDirectory={this.props.changeWorkingDirectory}
setContextLock={this.props.setContextLock}
getCurrentWorkDirs={this.props.getCurrentWorkDirs}
// Event Handlers
// handleWorkDirSelect={e => this.props.changeWorkingDirectory(e.target.value)}
onDidChangeWorkDirs={this.props.onDidChangeWorkDirs}
/>
);
}
return (
<GithubTabHeaderController
user={nullAuthor}
// Workspace
currentWorkDir={this.props.workingDirectory}
contextLocked={this.props.contextLocked}
changeWorkingDirectory={this.props.changeWorkingDirectory}
setContextLock={this.props.setContextLock}
getCurrentWorkDirs={this.props.getCurrentWorkDirs}
// Event Handlers
onDidChangeWorkDirs={this.props.onDidChangeWorkDirs}
/>
);
}
}