forked from atom/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub-tab-view.js
More file actions
92 lines (81 loc) · 2.99 KB
/
github-tab-view.js
File metadata and controls
92 lines (81 loc) · 2.99 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
import React from 'react';
import PropTypes from 'prop-types';
import {
GithubLoginModelPropType, RefHolderPropType, RemoteSetPropType, RemotePropType, BranchSetPropType, BranchPropType,
OperationStateObserverPropType,
} from '../prop-types';
import LoadingView from './loading-view';
import RemoteSelectorView from './remote-selector-view';
import RemoteContainer from '../containers/remote-container';
export default class GitHubTabView extends React.Component {
static propTypes = {
workspace: PropTypes.object.isRequired,
remoteOperationObserver: OperationStateObserverPropType.isRequired,
loginModel: GithubLoginModelPropType.isRequired,
rootHolder: RefHolderPropType.isRequired,
workingDirectory: PropTypes.string,
branches: BranchSetPropType.isRequired,
currentBranch: BranchPropType.isRequired,
remotes: RemoteSetPropType.isRequired,
currentRemote: RemotePropType.isRequired,
manyRemotesAvailable: PropTypes.bool.isRequired,
aheadCount: PropTypes.number,
pushInProgress: PropTypes.bool.isRequired,
isLoading: PropTypes.bool.isRequired,
handlePushBranch: PropTypes.func.isRequired,
handleRemoteSelect: PropTypes.func.isRequired,
}
render() {
return (
<div className="github-GitHub" ref={this.props.rootHolder.setter}>
<div className="github-GitHub-content">
{this.renderRemote()}
</div>
</div>
);
}
renderRemote() {
if (this.props.isLoading) {
return <LoadingView />;
}
if (this.props.currentRemote.isPresent()) {
// Single, chosen or unambiguous remote
return (
<RemoteContainer
loginModel={this.props.loginModel}
endpoint={this.props.currentRemote.getEndpoint()}
remoteOperationObserver={this.props.remoteOperationObserver}
pushInProgress={this.props.pushInProgress}
workingDirectory={this.props.workingDirectory}
workspace={this.props.workspace}
remote={this.props.currentRemote}
remotes={this.props.remotes}
branches={this.props.branches}
aheadCount={this.props.aheadCount}
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}
/>
);
}
// No remotes available
// TODO: display a view that lets you create a repository on GitHub
return (
<div className="github-GitHub-noRemotes">
<div className="github-GitHub-LargeIcon icon icon-mark-github" />
<h1>No Remotes</h1>
<div className="initialize-repo-description">
<span>This repository does not have any remotes hosted at GitHub.com.</span>
</div>
</div>
);
}
}