Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Merge 7054d88 into babf618
Browse files Browse the repository at this point in the history
  • Loading branch information
smashwilson committed Jul 9, 2018
2 parents babf618 + 7054d88 commit 06a41b5
Show file tree
Hide file tree
Showing 44 changed files with 1,629 additions and 276 deletions.
192 changes: 113 additions & 79 deletions lib/containers/__generated__/issueishDetailContainerQuery.graphql.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions lib/containers/current-pull-request-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {QueryRenderer, graphql} from 'react-relay';
import {Disposable} from 'event-kit';

import {autobind} from '../helpers';
import {RemotePropType, BranchSetPropType, OperationStateObserverPropType} from '../prop-types';
import {RemotePropType, RemoteSetPropType, BranchSetPropType, OperationStateObserverPropType} from '../prop-types';
import IssueishListController, {BareIssueishListController} from '../controllers/issueish-list-controller';
import CreatePullRequestTile from '../views/create-pull-request-tile';
import RelayNetworkLayerManager from '../relay-network-layer-manager';
Expand All @@ -24,7 +24,7 @@ export default class CurrentPullRequestContainer extends React.Component {
limit: PropTypes.number,
remoteOperationObserver: OperationStateObserverPropType.isRequired,
remote: RemotePropType.isRequired,
remotesByName: PropTypes.shape({get: PropTypes.func}).isRequired,
remotes: RemoteSetPropType.isRequired,
branches: BranchSetPropType.isRequired,
aheadCount: PropTypes.number,
pushInProgress: PropTypes.bool.isRequired,
Expand Down Expand Up @@ -55,8 +55,8 @@ export default class CurrentPullRequestContainer extends React.Component {
if (!push.isPresent() || !push.isRemoteTracking()) {
return this.renderEmptyResult();
}
const pushRemote = this.props.remotesByName.get(push.getRemoteName());
if (!pushRemote || !pushRemote.isPresent() || !pushRemote.isGithubRepo()) {
const pushRemote = this.props.remotes.withName(push.getRemoteName());
if (!pushRemote.isPresent() || !pushRemote.isGithubRepo()) {
return this.renderEmptyResult();
}

Expand Down
57 changes: 47 additions & 10 deletions lib/containers/issueish-detail-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class IssueishDetailContainer extends React.Component {
repo: PropTypes.string.isRequired,
issueishNumber: PropTypes.number.isRequired,

repository: PropTypes.object.isRequired,
loginModel: GithubLoginModelPropType.isRequired,

switchToIssueish: PropTypes.func.isRequired,
Expand All @@ -29,33 +30,50 @@ export default class IssueishDetailContainer extends React.Component {

constructor(props) {
super(props);
autobind(this, 'fetchData', 'renderWithToken', 'renderWithResult', 'handleLogin', 'handleLogout');
autobind(this,
'fetchToken', 'renderWithToken',
'fetchRepositoryData', 'renderWithRepositoryData',
'renderWithResult',
'handleLogin', 'handleLogout',
);
}

fetchData(loginModel) {
fetchToken(loginModel) {
return yubikiri({
token: loginModel.getToken(this.props.host),
});
}

render() {
return (
<ObserveModel model={this.props.loginModel} fetchData={this.fetchData}>
<ObserveModel model={this.props.loginModel} fetchData={this.fetchToken}>
{this.renderWithToken}
</ObserveModel>
);
}

renderWithToken(data) {
if (!data) {
fetchRepositoryData(repository) {
return yubikiri({
branches: repository.getBranches(),
remotes: repository.getRemotes(),
isMerging: repository.isMerging(),
isRebasing: repository.isRebasing(),
isAbsent: repository.isAbsent(),
isLoading: repository.isLoading(),
isPresent: repository.isPresent(),
});
}

renderWithToken(tokenData) {
if (!tokenData) {
return <LoadingView />;
}

if (data.token === UNAUTHENTICATED) {
if (tokenData.token === UNAUTHENTICATED) {
return <GithubLoginView onLogin={this.handleLogin} />;
}

if (data.token === INSUFFICIENT) {
if (tokenData.token === INSUFFICIENT) {
return (
<GithubLoginView onLogin={this.handleLogin}>
<p>
Expand All @@ -65,7 +83,19 @@ export default class IssueishDetailContainer extends React.Component {
);
}

const environment = RelayNetworkLayerManager.getEnvironmentForHost(this.props.host, data.token);
return (
<ObserveModel model={this.props.repository} fetchData={this.fetchRepositoryData}>
{repoData => this.renderWithRepositoryData(repoData, tokenData.token)}
</ObserveModel>
);
}

renderWithRepositoryData(repoData, token) {
if (!repoData) {
return <LoadingView />;
}

const environment = RelayNetworkLayerManager.getEnvironmentForHost(this.props.host, token);
const query = graphql`
query issueishDetailContainerQuery
(
Expand Down Expand Up @@ -98,13 +128,13 @@ export default class IssueishDetailContainer extends React.Component {
environment={environment}
query={query}
variables={variables}
render={this.renderWithResult}
render={queryResult => this.renderWithResult(queryResult, repoData)}
/>
</RelayEnvironment>
);
}

renderWithResult({error, props, retry}) {
renderWithResult({error, props, retry}, repoData) {
if (error) {
return (
<QueryErrorView
Expand All @@ -120,10 +150,17 @@ export default class IssueishDetailContainer extends React.Component {
return <LoadingView />;
}

const {repository} = this.props;

return (
<IssueishDetailController
{...props}
{...repoData}
issueishNumber={this.props.issueishNumber}
fetch={repository.fetch.bind(repository)}
checkout={repository.checkout.bind(repository)}
pull={repository.pull.bind(repository)}
addRemote={repository.addRemote.bind(repository)}
onTitleChange={this.props.onTitleChange}
switchToIssueish={this.props.switchToIssueish}
/>
Expand Down
8 changes: 5 additions & 3 deletions lib/containers/remote-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {QueryRenderer, graphql} from 'react-relay';

import {incrementCounter} from '../reporter-proxy';
import {autobind} from '../helpers';
import {RemotePropType, BranchSetPropType, OperationStateObserverPropType} from '../prop-types';
import {RemotePropType, RemoteSetPropType, BranchSetPropType, OperationStateObserverPropType} from '../prop-types';
import RelayNetworkLayerManager from '../relay-network-layer-manager';
import {UNAUTHENTICATED, INSUFFICIENT} from '../shared/keytar-strategy';
import RemoteController from '../controllers/remote-controller';
Expand All @@ -20,9 +20,10 @@ export default class RemoteContainer extends React.Component {
host: PropTypes.string.isRequired,

remoteOperationObserver: OperationStateObserverPropType.isRequired,
workingDirectory: PropTypes.string.isRequired,
workspace: PropTypes.object.isRequired,
remote: RemotePropType.isRequired,
remotesByName: PropTypes.shape({get: PropTypes.func}).isRequired,
remotes: RemoteSetPropType.isRequired,
branches: BranchSetPropType.isRequired,

aheadCount: PropTypes.number,
Expand Down Expand Up @@ -119,9 +120,10 @@ export default class RemoteContainer extends React.Component {
repository={props.repository}

remoteOperationObserver={this.props.remoteOperationObserver}
workingDirectory={this.props.workingDirectory}
workspace={this.props.workspace}
remote={this.props.remote}
remotesByName={this.props.remotesByName}
remotes={this.props.remotes}
branches={this.props.branches}

aheadCount={this.props.aheadCount}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 06a41b5

Please sign in to comment.