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

Blank states for GitHub tab #2329

Merged
merged 26 commits into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a49a27c
Render an "uninitialized" view
smashwilson Nov 2, 2019
6c4088e
Pull in the other prototype views
smashwilson Nov 2, 2019
dd04925
Drill action props
smashwilson Nov 3, 2019
8fb24d6
Pass dialog func props to blank views
smashwilson Nov 3, 2019
7736430
Flatten and update GitHub tab component props
smashwilson Nov 3, 2019
2a50b9f
Bring in blank view styles
smashwilson Nov 3, 2019
cc41994
Bind the active repository to the openPublishDialog call
smashwilson Nov 6, 2019
200a9e6
Rename shadowing variable
smashwilson Nov 6, 2019
854dce9
Render the no-local view for absent guess repositories
smashwilson Nov 6, 2019
cc47f5d
Vertically center blank GitHub tab views
smashwilson Nov 6, 2019
2ddf6cb
Apparently that can be undefined, who knew
smashwilson Nov 6, 2019
1e0b28a
Rename openPublishDialog prop to openBoundPublishDialog when bound
smashwilson Nov 6, 2019
2e2aec3
Rename props as well
smashwilson Nov 6, 2019
ed61852
Un-style that button
smashwilson Nov 6, 2019
b108eb5
Move the git tab navigation paragraph into body
smashwilson Nov 6, 2019
c427e2a
Initialize and publish empty repositories
smashwilson Nov 6, 2019
63cb0ea
Model to unify the refresh operation in the GitHub tab
smashwilson Nov 7, 2019
ac0db9c
Drive the Refresher in GitHubTabContainer
smashwilson Nov 7, 2019
be9284c
Replace remoteOperationObserver with a Refresher
smashwilson Nov 8, 2019
c4a4e74
Ignore coverage of blank views
smashwilson Nov 8, 2019
0781b23
Report some metrics to gauge usefulness
smashwilson Nov 8, 2019
46453be
Diagnose tests failing only in CI
smashwilson Nov 8, 2019
8d1d4a1
Run all ReviewsController tests
smashwilson Nov 8, 2019
9d7188f
Grrr it only fails when the full suite runs?
smashwilson Nov 8, 2019
4693a13
Clear all global Relay state along with expectations
smashwilson Nov 8, 2019
86a8dd2
Tidy up console statements
smashwilson Nov 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/containers/comment-decorations-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export default class CommentDecorationsContainer extends React.Component {

if (
!props || !props.repository || !props.repository.ref ||
!props.repository.ref.associatedPullRequests ||
props.repository.ref.associatedPullRequests.totalCount === 0
) {
// no loading spinner for you
Expand Down
15 changes: 2 additions & 13 deletions lib/containers/current-pull-request-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import {QueryRenderer, graphql} from 'react-relay';
import {Disposable} from 'event-kit';

import {autobind, CHECK_SUITE_PAGE_SIZE, CHECK_RUN_PAGE_SIZE} from '../helpers';
import {
RemotePropType, RemoteSetPropType, BranchSetPropType, OperationStateObserverPropType, EndpointPropType,
} from '../prop-types';
import {RemotePropType, RemoteSetPropType, BranchSetPropType, EndpointPropType} 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 @@ -30,7 +28,6 @@ export default class CurrentPullRequestContainer extends React.Component {
limit: PropTypes.number,

// Repository model attributes
remoteOperationObserver: OperationStateObserverPropType.isRequired,
remote: RemotePropType.isRequired,
remotes: RemoteSetPropType.isRequired,
branches: BranchSetPropType.isRequired,
Expand Down Expand Up @@ -120,18 +117,10 @@ export default class CurrentPullRequestContainer extends React.Component {
}

renderEmptyResult() {
this.sub.dispose();
this.sub = this.props.remoteOperationObserver.onDidComplete(() => this.forceUpdate());

return <BareIssueishListController isLoading={false} {...this.controllerProps()} />;
}

renderQueryResult({error, props, retry}) {
if (retry) {
this.sub.dispose();
this.sub = this.props.remoteOperationObserver.onDidComplete(retry);
}

renderQueryResult({error, props}) {
if (error) {
return (
<BareIssueishListController
Expand Down
42 changes: 37 additions & 5 deletions lib/containers/github-tab-container.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import yubikiri from 'yubikiri';
import {Disposable} from 'event-kit';

import {GithubLoginModelPropType, RefHolderPropType} from '../prop-types';
import OperationStateObserver, {PUSH, PULL, FETCH} from '../models/operation-state-observer';
import Refresher from '../models/refresher';
import GitHubTabController from '../controllers/github-tab-controller';
import ObserveModel from '../views/observe-model';
import RemoteSet from '../models/remote-set';
Expand All @@ -15,21 +17,51 @@ export default class GitHubTabContainer extends React.Component {
repository: PropTypes.object,
loginModel: GithubLoginModelPropType.isRequired,
rootHolder: RefHolderPropType.isRequired,

changeWorkingDirectory: PropTypes.func.isRequired,
onDidChangeWorkDirs: PropTypes.func.isRequired,
getCurrentWorkDirs: PropTypes.func.isRequired,
openCreateDialog: PropTypes.func.isRequired,
openPublishDialog: PropTypes.func.isRequired,
openCloneDialog: PropTypes.func.isRequired,
openGitTab: PropTypes.func.isRequired,
}

state = {};
constructor(props) {
super(props);

this.state = {
lastRepository: null,
remoteOperationObserver: new Disposable(),
refresher: new Refresher(),
observerSub: new Disposable(),
};
}

static getDerivedStateFromProps(props, state) {
if (props.repository !== state.lastRepository) {
state.remoteOperationObserver.dispose();
state.observerSub.dispose();

const remoteOperationObserver = new OperationStateObserver(props.repository, PUSH, PULL, FETCH);
const observerSub = remoteOperationObserver.onDidComplete(() => state.refresher.trigger());

return {
lastRepository: props.repository,
remoteOperationObserver: new OperationStateObserver(props.repository, PUSH, PULL, FETCH),
remoteOperationObserver,
observerSub,
};
}

return null;
}

componentWillUnmount() {
this.state.observerSub.dispose();
this.state.remoteOperationObserver.dispose();
this.state.refresher.dispose();
}

fetchRepositoryData = repository => {
return yubikiri({
workingDirectory: repository.getWorkingDirectoryPath(),
Expand Down Expand Up @@ -58,7 +90,7 @@ export default class GitHubTabContainer extends React.Component {
return (
<GitHubTabController
{...this.props}
remoteOperationObserver={this.state.remoteOperationObserver}
refresher={this.state.refresher}

allRemotes={new RemoteSet()}
branches={new BranchSet()}
Expand All @@ -73,7 +105,7 @@ export default class GitHubTabContainer extends React.Component {
return (
<GitHubTabController
{...this.props}
remoteOperationObserver={this.state.remoteOperationObserver}
refresher={this.state.refresher}

allRemotes={new RemoteSet()}
branches={new BranchSet()}
Expand All @@ -88,7 +120,7 @@ export default class GitHubTabContainer extends React.Component {
<GitHubTabController
{...data}
{...this.props}
remoteOperationObserver={this.state.remoteOperationObserver}
refresher={this.state.refresher}
isLoading={false}
/>
);
Expand Down
10 changes: 2 additions & 8 deletions lib/containers/issueish-search-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, CHECK_SUITE_PAGE_SIZE, CHECK_RUN_PAGE_SIZE} from '../helpers';
import {SearchPropType, OperationStateObserverPropType, EndpointPropType} from '../prop-types';
import {SearchPropType, EndpointPropType} from '../prop-types';
import IssueishListController, {BareIssueishListController} from '../controllers/issueish-list-controller';
import RelayNetworkLayerManager from '../relay-network-layer-manager';

Expand All @@ -17,7 +17,6 @@ export default class IssueishSearchContainer extends React.Component {
// Search model
limit: PropTypes.number,
search: SearchPropType.isRequired,
remoteOperationObserver: OperationStateObserverPropType.isRequired,

// Action methods
onOpenIssueish: PropTypes.func.isRequired,
Expand Down Expand Up @@ -89,12 +88,7 @@ export default class IssueishSearchContainer extends React.Component {
);
}

renderQueryResult({error, props, retry}) {
if (retry) {
this.sub.dispose();
this.sub = this.props.remoteOperationObserver.onDidComplete(retry);
}

renderQueryResult({error, props}) {
if (error) {
return (
<BareIssueishListController
Expand Down
9 changes: 4 additions & 5 deletions lib/containers/remote-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import PropTypes from 'prop-types';
import {QueryRenderer, graphql} from 'react-relay';

import {incrementCounter} from '../reporter-proxy';
import {
RemotePropType, RemoteSetPropType, BranchSetPropType, OperationStateObserverPropType, EndpointPropType,
} from '../prop-types';
import {RemotePropType, RemoteSetPropType, BranchSetPropType, RefresherPropType, EndpointPropType} 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 @@ -21,7 +19,7 @@ export default class RemoteContainer extends React.Component {
endpoint: EndpointPropType.isRequired,

// Repository attributes
remoteOperationObserver: OperationStateObserverPropType.isRequired,
refresher: RefresherPropType.isRequired,
pushInProgress: PropTypes.bool.isRequired,
workingDirectory: PropTypes.string,
workspace: PropTypes.object.isRequired,
Expand Down Expand Up @@ -104,6 +102,8 @@ export default class RemoteContainer extends React.Component {
}

renderWithResult({error, props, retry}, token) {
this.props.refresher.setRetryCallback(this, retry);

if (error) {
return (
<QueryErrorView
Expand All @@ -126,7 +126,6 @@ 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}
Expand Down
19 changes: 15 additions & 4 deletions lib/controllers/github-tab-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import React from 'react';
import PropTypes from 'prop-types';

import {
GithubLoginModelPropType, RefHolderPropType, RemoteSetPropType, BranchSetPropType, OperationStateObserverPropType,
GithubLoginModelPropType, RefHolderPropType, RemoteSetPropType, BranchSetPropType, RefresherPropType,
} from '../prop-types';
import GitHubTabView from '../views/github-tab-view';

export default class GitHubTabController extends React.Component {
static propTypes = {
workspace: PropTypes.object.isRequired,
repository: PropTypes.object.isRequired,
remoteOperationObserver: OperationStateObserverPropType.isRequired,
refresher: RefresherPropType.isRequired,
loginModel: GithubLoginModelPropType.isRequired,
rootHolder: RefHolderPropType.isRequired,

workingDirectory: PropTypes.string,
repository: PropTypes.object.isRequired,
allRemotes: RemoteSetPropType.isRequired,
branches: BranchSetPropType.isRequired,
selectedRemoteName: PropTypes.string,
Expand All @@ -26,6 +26,10 @@ export default class GitHubTabController extends React.Component {
changeWorkingDirectory: PropTypes.func.isRequired,
onDidChangeWorkDirs: PropTypes.func.isRequired,
getCurrentWorkDirs: PropTypes.func.isRequired,
openCreateDialog: PropTypes.func.isRequired,
openPublishDialog: PropTypes.func.isRequired,
openCloneDialog: PropTypes.func.isRequired,
openGitTab: PropTypes.func.isRequired,
}

render() {
Expand All @@ -43,11 +47,12 @@ export default class GitHubTabController extends React.Component {
return (
<GitHubTabView
workspace={this.props.workspace}
remoteOperationObserver={this.props.remoteOperationObserver}
refresher={this.props.refresher}
loginModel={this.props.loginModel}
rootHolder={this.props.rootHolder}

workingDirectory={this.props.workingDirectory || this.props.currentWorkDir}
repository={this.props.repository}
branches={this.props.branches}
currentBranch={currentBranch}
remotes={gitHubRemotes}
Expand All @@ -62,6 +67,10 @@ export default class GitHubTabController extends React.Component {
changeWorkingDirectory={this.props.changeWorkingDirectory}
getCurrentWorkDirs={this.props.getCurrentWorkDirs}
onDidChangeWorkDirs={this.props.onDidChangeWorkDirs}
openCreateDialog={this.props.openCreateDialog}
openBoundPublishDialog={this.openBoundPublishDialog}
openCloneDialog={this.props.openCloneDialog}
openGitTab={this.props.openGitTab}
/>
);
}
Expand All @@ -77,4 +86,6 @@ export default class GitHubTabController extends React.Component {
e.preventDefault();
return this.props.repository.setConfig('atomGithub.currentRemote', remote.getName());
}

openBoundPublishDialog = () => this.props.openPublishDialog(this.props.repository);
}
7 changes: 1 addition & 6 deletions lib/controllers/issueish-searches-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import {shell} from 'electron';

import {
RemotePropType, RemoteSetPropType, BranchSetPropType, OperationStateObserverPropType, EndpointPropType,
} from '../prop-types';
import {RemotePropType, RemoteSetPropType, BranchSetPropType, EndpointPropType} from '../prop-types';
import Search from '../models/search';
import IssueishSearchContainer from '../containers/issueish-search-container';
import CurrentPullRequestContainer from '../containers/current-pull-request-container';
Expand All @@ -31,7 +29,6 @@ export default class IssueishSearchesController extends React.Component {
workspace: PropTypes.object.isRequired,

// Repository model attributes
remoteOperationObserver: OperationStateObserverPropType.isRequired,
workingDirectory: PropTypes.string,
remote: RemotePropType.isRequired,
remotes: RemoteSetPropType.isRequired,
Expand Down Expand Up @@ -60,7 +57,6 @@ export default class IssueishSearchesController extends React.Component {
repository={this.props.repository}
token={this.props.token}
endpoint={this.props.endpoint}
remoteOperationObserver={this.props.remoteOperationObserver}
remote={this.props.remote}
remotes={this.props.remotes}
branches={this.props.branches}
Expand All @@ -79,7 +75,6 @@ export default class IssueishSearchesController extends React.Component {
token={this.props.token}
endpoint={this.props.endpoint}
search={search}
remoteOperationObserver={this.props.remoteOperationObserver}

onOpenIssueish={this.onOpenIssueish}
onOpenSearch={this.onOpenSearch}
Expand Down
6 changes: 1 addition & 5 deletions lib/controllers/remote-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import {shell} from 'electron';

import {autobind} from '../helpers';
import {incrementCounter} from '../reporter-proxy';
import {
RemotePropType, RemoteSetPropType, BranchSetPropType, OperationStateObserverPropType, EndpointPropType,
} from '../prop-types';
import {RemotePropType, RemoteSetPropType, BranchSetPropType, EndpointPropType} from '../prop-types';
import IssueishSearchesController from './issueish-searches-controller';

export default class RemoteController extends React.Component {
Expand All @@ -25,7 +23,6 @@ export default class RemoteController extends React.Component {
token: PropTypes.string.isRequired,

// Repository derived attributes
remoteOperationObserver: OperationStateObserverPropType.isRequired,
workingDirectory: PropTypes.string,
workspace: PropTypes.object.isRequired,
remote: RemotePropType.isRequired,
Expand All @@ -49,7 +46,6 @@ export default class RemoteController extends React.Component {
endpoint={this.props.endpoint}
token={this.props.token}

remoteOperationObserver={this.props.remoteOperationObserver}
workingDirectory={this.props.workingDirectory}
repository={this.props.repository}

Expand Down
4 changes: 4 additions & 0 deletions lib/controllers/root-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ export default class RootController extends React.Component {
getCurrentWorkDirs={getCurrentWorkDirs}
onDidChangeWorkDirs={onDidChangeWorkDirs}
changeWorkingDirectory={this.props.changeWorkingDirectory}
openCreateDialog={this.openCreateDialog}
openPublishDialog={this.openPublishDialog}
openCloneDialog={this.openCloneDialog}
openGitTab={this.gitTabTracker.toggleFocus}
/>
)}
</PaneItem>
Expand Down
4 changes: 2 additions & 2 deletions lib/github-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,10 @@ export default class GithubPackage {
}

this.workdirCache.invalidate();

this.project.addPath(projectPath);

await this.scheduleActiveContextUpdate();

reporterProxy.addEvent('clone-repository', {project: 'github'});
}

getRepositoryForWorkdir(projectPath) {
Expand Down
8 changes: 8 additions & 0 deletions lib/items/github-tab-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ export default class GitHubTabItem extends React.Component {
loginModel: GithubLoginModelPropType.isRequired,

documentActiveElement: PropTypes.func,

changeWorkingDirectory: PropTypes.func.isRequired,
onDidChangeWorkDirs: PropTypes.func.isRequired,
getCurrentWorkDirs: PropTypes.func.isRequired,
openCreateDialog: PropTypes.func.isRequired,
openPublishDialog: PropTypes.func.isRequired,
openCloneDialog: PropTypes.func.isRequired,
openGitTab: PropTypes.func.isRequired,
}

static defaultProps = {
Expand Down
Loading