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

Commit a49a27c

Browse files
committed
Render an "uninitialized" view
1 parent 2d0b976 commit a49a27c

File tree

5 files changed

+50
-1
lines changed

5 files changed

+50
-1
lines changed

lib/controllers/github-tab-controller.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import GitHubTabView from '../views/github-tab-view';
99
export default class GitHubTabController extends React.Component {
1010
static propTypes = {
1111
workspace: PropTypes.object.isRequired,
12-
repository: PropTypes.object.isRequired,
1312
remoteOperationObserver: OperationStateObserverPropType.isRequired,
1413
loginModel: GithubLoginModelPropType.isRequired,
1514
rootHolder: RefHolderPropType.isRequired,
1615

1716
workingDirectory: PropTypes.string,
17+
repository: PropTypes.object.isRequired,
1818
allRemotes: RemoteSetPropType.isRequired,
1919
branches: BranchSetPropType.isRequired,
2020
selectedRemoteName: PropTypes.string,
@@ -48,6 +48,7 @@ export default class GitHubTabController extends React.Component {
4848
rootHolder={this.props.rootHolder}
4949

5050
workingDirectory={this.props.workingDirectory || this.props.currentWorkDir}
51+
repository={this.props.repository}
5152
branches={this.props.branches}
5253
currentBranch={currentBranch}
5354
remotes={gitHubRemotes}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
3+
import Octicon from '../atom/octicon';
4+
5+
export default function GitHubBlankUninitialized() {
6+
return (
7+
<div className="github-Local-Uninit github-Blank">
8+
<main className="github-Blank-body">
9+
<div className="github-Blank-LargeIcon icon icon-mark-github" />
10+
<p className="github-Blank-context">This repository is not yet version controlled by git.</p>
11+
<p className="github-Blank-option">
12+
<button className="github-Blank-actionBtn btn icon icon-globe">
13+
Initialize and publish on GitHub...
14+
</button>
15+
</p>
16+
<p className="github-Blank-explanation">
17+
Create a new GitHub repository, then track the existing content within this directory as a git repository
18+
configured to push there.
19+
</p>
20+
</main>
21+
<footer className="github-Blank-footer github-Blank-explanation">
22+
To initialize this directory as a git repository without publishing it to GitHub, visit the
23+
<a className="github-Blank-tabLink" href="https://example.com/"><Octicon icon="git-commit" />Git tab.</a>
24+
</footer>
25+
</div>
26+
);
27+
}

lib/views/github-tab-view.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import LoadingView from './loading-view';
99
import RemoteSelectorView from './remote-selector-view';
1010
import TabHeaderView from './tab-header-view';
11+
import GitHubBlankUninitialized from './github-blank-uninitialized';
1112
import RemoteContainer from '../containers/remote-container';
1213

1314
export default class GitHubTabView extends React.Component {
@@ -18,6 +19,7 @@ export default class GitHubTabView extends React.Component {
1819
rootHolder: RefHolderPropType.isRequired,
1920

2021
workingDirectory: PropTypes.string,
22+
repository: PropTypes.object.isRequired,
2123
branches: BranchSetPropType.isRequired,
2224
currentBranch: BranchPropType.isRequired,
2325
remotes: RemoteSetPropType.isRequired,
@@ -50,6 +52,12 @@ export default class GitHubTabView extends React.Component {
5052
return <LoadingView />;
5153
}
5254

55+
if (this.props.repository.isEmpty()) {
56+
return (
57+
<GitHubBlankUninitialized />
58+
);
59+
}
60+
5361
if (this.props.currentRemote.isPresent()) {
5462
// Single, chosen or unambiguous remote
5563
return (

test/fixtures/props/github-tab-props.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ export function gitHubTabViewProps(atomEnv, repository, overrides = {}) {
4848
rootHolder: new RefHolder(),
4949

5050
workingDirectory: repository.getWorkingDirectoryPath(),
51+
repository,
5152
branches: new BranchSet(),
5253
currentBranch: nullBranch,
5354
remotes: new RemoteSet(),
5455
currentRemote: nullRemote,
5556
manyRemotesAvailable: false,
5657
aheadCount: 0,
5758
pushInProgress: false,
59+
isLoading: false,
5860

5961
handlePushBranch: () => {},
6062
handleRemoteSelect: () => {},

test/views/github-tab-view.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import {shallow} from 'enzyme';
3+
import temp from 'temp';
34

45
import {gitHubTabViewProps} from '../fixtures/props/github-tab-props';
56
import Repository from '../../lib/models/repository';
@@ -8,6 +9,8 @@ import RemoteSet from '../../lib/models/remote-set';
89
import Branch from '../../lib/models/branch';
910
import GitHubTabView from '../../lib/views/github-tab-view';
1011

12+
import {buildRepository} from '../helpers';
13+
1114
describe('GitHubTabView', function() {
1215
let atomEnv;
1316

@@ -29,6 +32,14 @@ describe('GitHubTabView', function() {
2932
assert.isTrue(wrapper.find('LoadingView').exists());
3033
});
3134

35+
it('renders a uninitialized view when a local repository is not initialized', async function() {
36+
const workdir = temp.mkdirSync();
37+
const repository = await buildRepository(workdir);
38+
39+
const wrapper = shallow(buildApp({repository}));
40+
assert.isTrue(wrapper.exists('GitHubBlankUninitialized'));
41+
});
42+
3243
it('renders a RemoteContainer if a remote has been chosen', function() {
3344
const currentRemote = new Remote('aaa', '[email protected]:aaa/bbb.git');
3445
const currentBranch = new Branch('bbb');

0 commit comments

Comments
 (0)