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

Commit 6a34a52

Browse files
use workdirs working prototype
1 parent d33d7da commit 6a34a52

File tree

8 files changed

+53
-16
lines changed

8 files changed

+53
-16
lines changed

lib/containers/github-tab-container.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,18 @@ export default class GitHubTabContainer extends React.Component {
7070
}
7171

7272
if (!this.props.repository.isPresent()) {
73-
// TODO include a better message here.
74-
return null;
73+
return (
74+
<GitHubTabController
75+
{...this.props}
76+
remoteOperationObserver={this.state.remoteOperationObserver}
77+
78+
allRemotes={new RemoteSet()}
79+
branches={new BranchSet()}
80+
aheadCount={0}
81+
pushInProgress={false}
82+
isLoading={false}
83+
/>
84+
);
7585
}
7686

7787
return (

lib/controllers/git-tab-controller.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default class GitTabController extends React.Component {
3333
workingDirectoryPath: PropTypes.string,
3434
mergeMessage: PropTypes.string,
3535
fetchInProgress: PropTypes.bool.isRequired,
36+
currentWorkDir: PropTypes.string,
3637

3738
workspace: PropTypes.object.isRequired,
3839
commands: PropTypes.object.isRequired,
@@ -52,6 +53,8 @@ export default class GitTabController extends React.Component {
5253
openInitializeDialog: PropTypes.func.isRequired,
5354
controllerRef: RefHolderPropType,
5455
changeWorkingDirectory: PropTypes.func.isRequired,
56+
onDidChangeWorkDirs: PropTypes.func.isRequired,
57+
getCurrentWorkDirs: PropTypes.func.isRequired,
5558
};
5659

5760
constructor(props, context) {
@@ -100,7 +103,7 @@ export default class GitTabController extends React.Component {
100103
unstagedChanges={this.props.unstagedChanges}
101104
stagedChanges={this.props.stagedChanges}
102105
mergeConflicts={this.props.mergeConflicts}
103-
workingDirectoryPath={this.props.workingDirectoryPath}
106+
workingDirectoryPath={this.props.workingDirectoryPath || this.props.currentWorkDir}
104107
mergeMessage={this.props.mergeMessage}
105108
userStore={this.userStore}
106109
selectedCoAuthors={this.state.selectedCoAuthors}
@@ -121,6 +124,8 @@ export default class GitTabController extends React.Component {
121124
discardWorkDirChangesForPaths={this.props.discardWorkDirChangesForPaths}
122125
undoLastDiscard={this.props.undoLastDiscard}
123126
changeWorkingDirectory={this.props.changeWorkingDirectory}
127+
getCurrentWorkDirs={this.props.getCurrentWorkDirs}
128+
onDidChangeWorkDirs={this.props.onDidChangeWorkDirs}
124129

125130
attemptFileStageOperation={this.attemptFileStageOperation}
126131
attemptStageAllOperation={this.attemptStageAllOperation}

lib/controllers/github-tab-controller.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import GitHubTabView from '../views/github-tab-view';
88

99
export default class GitHubTabController extends React.Component {
1010
static propTypes = {
11-
project: PropTypes.object.isRequired,
1211
workspace: PropTypes.object.isRequired,
1312
repository: PropTypes.object.isRequired,
1413
remoteOperationObserver: OperationStateObserverPropType.isRequired,
@@ -22,8 +21,11 @@ export default class GitHubTabController extends React.Component {
2221
aheadCount: PropTypes.number,
2322
pushInProgress: PropTypes.bool.isRequired,
2423
isLoading: PropTypes.bool.isRequired,
24+
currentWorkDir: PropTypes.string,
2525

2626
changeWorkingDirectory: PropTypes.func.isRequired,
27+
onDidChangeWorkDirs: PropTypes.func.isRequired,
28+
getCurrentWorkDirs: PropTypes.func.isRequired,
2729
}
2830

2931
render() {
@@ -40,13 +42,12 @@ export default class GitHubTabController extends React.Component {
4042

4143
return (
4244
<GitHubTabView
43-
project={this.props.project}
4445
workspace={this.props.workspace}
4546
remoteOperationObserver={this.props.remoteOperationObserver}
4647
loginModel={this.props.loginModel}
4748
rootHolder={this.props.rootHolder}
4849

49-
workingDirectory={this.props.workingDirectory}
50+
workingDirectory={this.props.workingDirectory || this.props.currentWorkDir}
5051
branches={this.props.branches}
5152
currentBranch={currentBranch}
5253
remotes={gitHubRemotes}
@@ -59,6 +60,8 @@ export default class GitHubTabController extends React.Component {
5960
handlePushBranch={this.handlePushBranch}
6061
handleRemoteSelect={this.handleRemoteSelect}
6162
changeWorkingDirectory={this.props.changeWorkingDirectory}
63+
getCurrentWorkDirs={this.props.getCurrentWorkDirs}
64+
onDidChangeWorkDirs={this.props.onDidChangeWorkDirs}
6265
/>
6366
);
6467
}

lib/controllers/root-controller.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ export default class RootController extends React.Component {
6060
switchboard: PropTypes.instanceOf(Switchboard),
6161
pipelineManager: PropTypes.object,
6262

63+
currentWorkDir: PropTypes.string,
64+
6365
// Git actions
6466
initialize: PropTypes.func.isRequired,
6567
clone: PropTypes.func.isRequired,
@@ -259,6 +261,10 @@ export default class RootController extends React.Component {
259261
}
260262

261263
renderPaneItems() {
264+
const {workdirContextPool} = this.props;
265+
const getCurrentWorkDirs = workdirContextPool.getCurrentWorkDirs.bind(workdirContextPool);
266+
const onDidChangeWorkDirs = workdirContextPool.onDidChangePoolContexts.bind(workdirContextPool);
267+
262268
return (
263269
<Fragment>
264270
<PaneItem
@@ -285,8 +291,9 @@ export default class RootController extends React.Component {
285291
discardWorkDirChangesForPaths={this.discardWorkDirChangesForPaths}
286292
undoLastDiscard={this.undoLastDiscard}
287293
refreshResolutionProgress={this.refreshResolutionProgress}
288-
getCurrentWorkDirs={this.props.workdirContextPool.getCurrentWorkDirs}
289-
onDidChangeWorkDirs={this.props.workdirContextPool.onDidChangePoolContexts}
294+
currentWorkDir={this.props.currentWorkDir}
295+
getCurrentWorkDirs={getCurrentWorkDirs}
296+
onDidChangeWorkDirs={onDidChangeWorkDirs}
290297
changeWorkingDirectory={this.props.changeWorkingDirectory}
291298
/>
292299
)}
@@ -301,8 +308,9 @@ export default class RootController extends React.Component {
301308
repository={this.props.repository}
302309
loginModel={this.props.loginModel}
303310
workspace={this.props.workspace}
304-
getCurrentWorkDirs={this.props.workdirContextPool.getCurrentWorkDirs}
305-
onDidChangeWorkDirs={this.props.workdirContextPool.onDidChangePoolContexts}
311+
currentWorkDir={this.props.currentWorkDir}
312+
getCurrentWorkDirs={getCurrentWorkDirs}
313+
onDidChangeWorkDirs={onDidChangeWorkDirs}
306314
changeWorkingDirectory={this.props.changeWorkingDirectory}
307315
/>
308316
)}

lib/github-package.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ export default class GithubPackage {
303303
startOpen={this.startOpen}
304304
startRevealed={this.startRevealed}
305305
removeFilePatchItem={this.removeFilePatchItem}
306+
currentWorkDir={this.getActiveWorkdir()}
306307
changeWorkingDirectory={changeWorkingDirectory}
307308
/>, this.element, callback,
308309
);

lib/models/workdir-context-pool.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export default class WorkdirContextPool {
113113
}
114114

115115
getCurrentWorkDirs() {
116-
return this.context.keys();
116+
return this.contexts.keys();
117117
}
118118

119119
withResidentContexts(callback) {

lib/views/github-tab-view.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import RemoteContainer from '../containers/remote-container';
1212

1313
export default class GitHubTabView extends React.Component {
1414
static propTypes = {
15-
project: PropTypes.object.isRequired,
1615
workspace: PropTypes.object.isRequired,
1716
remoteOperationObserver: OperationStateObserverPropType.isRequired,
1817
loginModel: GithubLoginModelPropType.isRequired,

lib/views/tab-header-view.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,26 @@ export default class TabHeaderView extends React.Component {
1313

1414
constructor(props) {
1515
super(props);
16-
this.state = {currentWorkDirs: props.getCurrentWorkDirs()};
17-
this.disposable = props.onDidChangeWorkDirs(this.updateWorkDirs);
16+
this.state = {currentWorkDirs: []};
17+
}
18+
19+
static getDerivedStateFromProps(props, state) {
20+
return {
21+
currentWorkDirs: props.getCurrentWorkDirs(),
22+
};
23+
}
24+
25+
componentDidMount() {
26+
if (this.props.onDidChangeWorkDirs) {
27+
this.disposable = this.props.onDidChangeWorkDirs(this.updateWorkDirs);
28+
}
1829
}
1930

2031
render() {
2132
return (
2233
<header className="github-Project">
2334
<select className="github-Project-path input-select"
24-
value={this.props.currentWorkDir ? this.props.currentWorkDir : undefined}
35+
value={this.props.currentWorkDir ? path.normalize(this.props.currentWorkDir) : undefined}
2536
onChange={this.props.handleWorkDirSelect ? this.props.handleWorkDirSelect : () => {}}>
2637
{this.renderWorkDirs()}
2738
</select>
@@ -32,7 +43,7 @@ export default class TabHeaderView extends React.Component {
3243
renderWorkDirs() {
3344
const workdirs = [];
3445
for (const workdir of this.state.currentWorkDirs) {
35-
workdirs.push(<option key={workdir} value={workdir}>{path.basename(workdir)}</option>);
46+
workdirs.push(<option key={workdir} value={path.normalize(workdir)}>{path.basename(workdir)}</option>);
3647
}
3748
return workdirs;
3849
}

0 commit comments

Comments
 (0)