Skip to content

Commit 21f7159

Browse files
committed
Revert "Merge pull request atom#2308 from wadethestealth/project-management"
This reverts commit aae4848, reversing changes made to 79afbab.
1 parent 2d0b976 commit 21f7159

29 files changed

Lines changed: 396 additions & 790 deletions

lib/atom/marker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const DecorableContext = React.createContext();
2525
class BareMarker extends React.Component {
2626
static propTypes = {
2727
...markerProps,
28-
id: PropTypes.number,
28+
id: PropTypes.string,
2929
bufferRange: RangePropType,
3030
markableHolder: RefHolderPropType,
3131
children: PropTypes.node,

lib/containers/current-pull-request-container.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export default class CurrentPullRequestContainer extends React.Component {
3737
aheadCount: PropTypes.number,
3838
pushInProgress: PropTypes.bool.isRequired,
3939

40+
workspace: PropTypes.object.isRequired,
41+
4042
// Actions
4143
onOpenIssueish: PropTypes.func.isRequired,
4244
onOpenReviews: PropTypes.func.isRequired,
@@ -162,6 +164,7 @@ export default class CurrentPullRequestContainer extends React.Component {
162164
total={associatedPullRequests.totalCount}
163165
results={associatedPullRequests.nodes}
164166
isLoading={false}
167+
workspace={this.props.workspace}
165168
endpoint={this.props.endpoint}
166169
resultFilter={issueish => issueish.getHeadRepositoryID() === this.props.repository.id}
167170
{...this.controllerProps()}

lib/containers/github-tab-container.js

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

7272
if (!this.props.repository.isPresent()) {
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-
);
73+
// TODO include a better message here.
74+
return null;
8575
}
8676

8777
return (

lib/controllers/git-tab-controller.js

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

3837
workspace: PropTypes.object.isRequired,
3938
commands: PropTypes.object.isRequired,
@@ -52,9 +51,6 @@ export default class GitTabController extends React.Component {
5251
openFiles: PropTypes.func.isRequired,
5352
openInitializeDialog: PropTypes.func.isRequired,
5453
controllerRef: RefHolderPropType,
55-
changeWorkingDirectory: PropTypes.func.isRequired,
56-
onDidChangeWorkDirs: PropTypes.func.isRequired,
57-
getCurrentWorkDirs: PropTypes.func.isRequired,
5854
};
5955

6056
constructor(props, context) {
@@ -103,7 +99,7 @@ export default class GitTabController extends React.Component {
10399
unstagedChanges={this.props.unstagedChanges}
104100
stagedChanges={this.props.stagedChanges}
105101
mergeConflicts={this.props.mergeConflicts}
106-
workingDirectoryPath={this.props.workingDirectoryPath || this.props.currentWorkDir}
102+
workingDirectoryPath={this.props.workingDirectoryPath}
107103
mergeMessage={this.props.mergeMessage}
108104
userStore={this.userStore}
109105
selectedCoAuthors={this.state.selectedCoAuthors}
@@ -123,9 +119,6 @@ export default class GitTabController extends React.Component {
123119
openFiles={this.props.openFiles}
124120
discardWorkDirChangesForPaths={this.props.discardWorkDirChangesForPaths}
125121
undoLastDiscard={this.props.undoLastDiscard}
126-
changeWorkingDirectory={this.props.changeWorkingDirectory}
127-
getCurrentWorkDirs={this.props.getCurrentWorkDirs}
128-
onDidChangeWorkDirs={this.props.onDidChangeWorkDirs}
129122

130123
attemptFileStageOperation={this.attemptFileStageOperation}
131124
attemptStageAllOperation={this.attemptStageAllOperation}

lib/controllers/github-tab-controller.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ export default class GitHubTabController extends React.Component {
2121
aheadCount: PropTypes.number,
2222
pushInProgress: PropTypes.bool.isRequired,
2323
isLoading: PropTypes.bool.isRequired,
24-
currentWorkDir: PropTypes.string,
25-
26-
changeWorkingDirectory: PropTypes.func.isRequired,
27-
onDidChangeWorkDirs: PropTypes.func.isRequired,
28-
getCurrentWorkDirs: PropTypes.func.isRequired,
2924
}
3025

3126
render() {
@@ -47,7 +42,7 @@ export default class GitHubTabController extends React.Component {
4742
loginModel={this.props.loginModel}
4843
rootHolder={this.props.rootHolder}
4944

50-
workingDirectory={this.props.workingDirectory || this.props.currentWorkDir}
45+
workingDirectory={this.props.workingDirectory}
5146
branches={this.props.branches}
5247
currentBranch={currentBranch}
5348
remotes={gitHubRemotes}
@@ -59,9 +54,6 @@ export default class GitHubTabController extends React.Component {
5954

6055
handlePushBranch={this.handlePushBranch}
6156
handleRemoteSelect={this.handleRemoteSelect}
62-
changeWorkingDirectory={this.props.changeWorkingDirectory}
63-
getCurrentWorkDirs={this.props.getCurrentWorkDirs}
64-
onDidChangeWorkDirs={this.props.onDidChangeWorkDirs}
6557
/>
6658
);
6759
}

lib/controllers/issueish-list-controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export class BareIssueishListController extends React.Component {
5656
onOpenMore: PropTypes.func,
5757

5858
emptyComponent: PropTypes.func,
59+
workspace: PropTypes.object,
5960
endpoint: EndpointPropType,
6061
needReviewsButton: PropTypes.bool,
6162
};

lib/controllers/root-controller.js

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

63-
currentWorkDir: PropTypes.string,
64-
6563
// Git actions
6664
initialize: PropTypes.func.isRequired,
6765
clone: PropTypes.func.isRequired,
6866

6967
// Control
70-
changeWorkingDirectory: PropTypes.func.isRequired,
7168
startOpen: PropTypes.bool,
7269
startRevealed: PropTypes.bool,
7370
}
@@ -261,10 +258,6 @@ export default class RootController extends React.Component {
261258
}
262259

263260
renderPaneItems() {
264-
const {workdirContextPool} = this.props;
265-
const getCurrentWorkDirs = workdirContextPool.getCurrentWorkDirs.bind(workdirContextPool);
266-
const onDidChangeWorkDirs = workdirContextPool.onDidChangePoolContexts.bind(workdirContextPool);
267-
268261
return (
269262
<Fragment>
270263
<PaneItem
@@ -291,10 +284,6 @@ export default class RootController extends React.Component {
291284
discardWorkDirChangesForPaths={this.discardWorkDirChangesForPaths}
292285
undoLastDiscard={this.undoLastDiscard}
293286
refreshResolutionProgress={this.refreshResolutionProgress}
294-
currentWorkDir={this.props.currentWorkDir}
295-
getCurrentWorkDirs={getCurrentWorkDirs}
296-
onDidChangeWorkDirs={onDidChangeWorkDirs}
297-
changeWorkingDirectory={this.props.changeWorkingDirectory}
298287
/>
299288
)}
300289
</PaneItem>
@@ -308,10 +297,6 @@ export default class RootController extends React.Component {
308297
repository={this.props.repository}
309298
loginModel={this.props.loginModel}
310299
workspace={this.props.workspace}
311-
currentWorkDir={this.props.currentWorkDir}
312-
getCurrentWorkDirs={getCurrentWorkDirs}
313-
onDidChangeWorkDirs={onDidChangeWorkDirs}
314-
changeWorkingDirectory={this.props.changeWorkingDirectory}
315300
/>
316301
)}
317302
</PaneItem>

lib/error-boundary.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

lib/github-package.js

Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,9 @@ export default class GithubPackage {
175175
return !!event.target.closest('.github-FilePatchListView').querySelector('.is-selected');
176176
};
177177

178-
const handleProjectPathsChange = () => {
179-
const activeRepository = this.getActiveRepository();
180-
const activeRepositoryPath = activeRepository ? activeRepository.getWorkingDirectoryPath() : null;
181-
this.scheduleActiveContextUpdate({activeRepositoryPath});
182-
};
183-
184178
this.subscriptions.add(
185-
this.project.onDidChangePaths(handleProjectPathsChange),
179+
this.project.onDidChangePaths(this.scheduleActiveContextUpdate),
180+
this.workspace.getCenter().onDidChangeActivePaneItem(this.scheduleActiveContextUpdate),
186181
this.styleCalculator.startWatching(
187182
'github-package-styles',
188183
['editor.fontSize', 'editor.fontFamily', 'editor.lineHeight', 'editor.tabLength'],
@@ -274,10 +269,6 @@ export default class GithubPackage {
274269
}));
275270
}
276271

277-
const changeWorkingDirectory = workingDirectory => {
278-
this.scheduleActiveContextUpdate({activeRepositoryPath: workingDirectory});
279-
};
280-
281272
this.renderFn(
282273
<RootController
283274
ref={c => { this.controller = c; }}
@@ -303,8 +294,6 @@ export default class GithubPackage {
303294
startOpen={this.startOpen}
304295
startRevealed={this.startRevealed}
305296
removeFilePatchItem={this.removeFilePatchItem}
306-
currentWorkDir={this.getActiveWorkdir()}
307-
changeWorkingDirectory={changeWorkingDirectory}
308297
/>, this.element, callback,
309298
);
310299
}
@@ -506,13 +495,14 @@ export default class GithubPackage {
506495
* Derive the git working directory context that should be used for the package's git operations based on the current
507496
* state of the Atom workspace. In priority, this prefers:
508497
*
509-
* - The preferred git working directory set by the user (This is also the working directory that was active when the
510-
* package was last serialized).
511-
* - A git working directory corresponding to "first" Project, whether or not there is a single project or multiple.
498+
* - A git working directory that contains the active pane item in the workspace's center.
499+
* - A git working directory corresponding to a single Project.
500+
* - When initially activating the package, the working directory that was active when the package was last
501+
* serialized.
512502
* - The current context, unchanged, which may be a `NullWorkdirContext`.
513503
*
514504
* First updates the pool of resident contexts to match all git working directories that correspond to open
515-
* projects.
505+
* projects and pane items.
516506
*/
517507
async getNextContext(savedState) {
518508
const workdirs = new Set(
@@ -524,34 +514,50 @@ export default class GithubPackage {
524514
),
525515
);
526516

527-
// Update pool with the open projects
528-
this.contextPool.set(workdirs, savedState);
517+
const fromPaneItem = async maybeItem => {
518+
const itemPath = pathForPaneItem(maybeItem);
529519

530-
if (savedState.activeRepositoryPath) {
531-
// Preferred git directory (the preferred directory or the last serialized directory).
532-
const stateContext = this.contextPool.getContext(savedState.activeRepositoryPath);
533-
// If the context exists chose it, else continue.
534-
if (stateContext.isPresent()) {
535-
return stateContext;
520+
if (!itemPath) {
521+
return {};
536522
}
537-
}
538523

539-
const projectPaths = this.project.getPaths();
524+
const itemWorkdir = await this.workdirCache.find(itemPath);
525+
526+
if (itemWorkdir && !this.project.contains(itemPath)) {
527+
workdirs.add(itemWorkdir);
528+
}
529+
530+
return {itemPath, itemWorkdir};
531+
};
532+
533+
const active = await fromPaneItem(this.workspace.getCenter().getActivePaneItem());
534+
535+
this.contextPool.set(workdirs, savedState);
540536

541-
if (projectPaths.length >= 1) {
542-
// Single or multiple projects (just choose the first, the user can select after)
543-
const projectPath = projectPaths[0];
537+
if (active.itemPath) {
538+
// Prefer an active item
539+
return this.contextPool.getContext(active.itemWorkdir || active.itemPath);
540+
}
541+
542+
if (this.project.getPaths().length === 1) {
543+
// Single project
544+
const projectPath = this.project.getPaths()[0];
544545
const activeWorkingDir = await this.workdirCache.find(projectPath);
545546
return this.contextPool.getContext(activeWorkingDir || projectPath);
546547
}
547548

548-
if (projectPaths.length === 0 && !this.activeContext.getRepository().isUndetermined()) {
549+
if (this.project.getPaths().length === 0 && !this.activeContext.getRepository().isUndetermined()) {
549550
// No projects. Revert to the absent context unless we've guessed that more projects are on the way.
550551
return WorkdirContext.absent({pipelineManager: this.pipelineManager});
551552
}
552553

553-
// It is only possible to reach here if there there was no preferred directory, there are no project paths and the
554-
// the active context's repository is not undetermined.
554+
// Restore models from saved state. Will return a NullWorkdirContext if this path is not presently
555+
// resident in the pool.
556+
const savedWorkingDir = savedState.activeRepositoryPath;
557+
if (savedWorkingDir) {
558+
return this.contextPool.getContext(savedWorkingDir);
559+
}
560+
555561
return this.activeContext;
556562
}
557563

@@ -594,3 +600,22 @@ export default class GithubPackage {
594600
}
595601
}
596602
}
603+
604+
function pathForPaneItem(paneItem) {
605+
if (!paneItem) {
606+
return null;
607+
}
608+
609+
// Likely GitHub package provided pane item
610+
if (typeof paneItem.getWorkingDirectory === 'function') {
611+
return paneItem.getWorkingDirectory();
612+
}
613+
614+
// TextEditor-like
615+
if (typeof paneItem.getPath === 'function') {
616+
return paneItem.getPath();
617+
}
618+
619+
// Oh well
620+
return null;
621+
}

0 commit comments

Comments
 (0)