This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 402
/
Copy pathremote-container.js
102 lines (88 loc) · 2.73 KB
/
remote-container.js
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
import React from 'react';
import PropTypes from 'prop-types';
import {QueryRenderer, graphql} from 'react-relay';
import {
RemotePropType, RemoteSetPropType, BranchSetPropType, RefresherPropType,
EndpointPropType, TokenPropType,
} from '../prop-types';
import RelayNetworkLayerManager from '../relay-network-layer-manager';
import RemoteController from '../controllers/remote-controller';
import LoadingView from '../views/loading-view';
import QueryErrorView from '../views/query-error-view';
export default class RemoteContainer extends React.Component {
static propTypes = {
// Connection
endpoint: EndpointPropType.isRequired,
token: TokenPropType.isRequired,
// Repository attributes
refresher: RefresherPropType.isRequired,
pushInProgress: PropTypes.bool.isRequired,
workingDirectory: PropTypes.string,
workspace: PropTypes.object.isRequired,
remote: RemotePropType.isRequired,
remotes: RemoteSetPropType.isRequired,
branches: BranchSetPropType.isRequired,
aheadCount: PropTypes.number,
// Action methods
handleLogin: PropTypes.func.isRequired,
handleLogout: PropTypes.func.isRequired,
onPushBranch: PropTypes.func.isRequired,
}
render() {
const environment = RelayNetworkLayerManager.getEnvironmentForHost(this.props.endpoint, this.props.token);
const query = graphql`
query remoteContainerQuery($owner: String!, $name: String!) {
repository(owner: $owner, name: $name) {
id
defaultBranchRef {
prefix
name
}
}
}
`;
const variables = {
owner: this.props.remote.getOwner(),
name: this.props.remote.getRepo(),
};
return (
<QueryRenderer
environment={environment}
variables={variables}
query={query}
render={this.renderWithResult}
/>
);
}
renderWithResult = ({error, props, retry}) => {
this.props.refresher.setRetryCallback(this, retry);
if (error) {
return (
<QueryErrorView
error={error}
login={this.props.handleLogin}
logout={this.props.handleLogout}
retry={retry}
/>
);
}
if (props === null) {
return <LoadingView />;
}
return (
<RemoteController
endpoint={this.props.endpoint}
token={this.props.token}
repository={props.repository}
workingDirectory={this.props.workingDirectory}
workspace={this.props.workspace}
remote={this.props.remote}
remotes={this.props.remotes}
branches={this.props.branches}
aheadCount={this.props.aheadCount}
pushInProgress={this.props.pushInProgress}
onPushBranch={this.props.onPushBranch}
/>
);
}
}