-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
open local workspaces, files and folders in remote #14607
Open
jonah-iden
wants to merge
6
commits into
master
Choose a base branch
from
jiden/open-local-workspaces-in-remote
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
eca7223
Devcontainer workspaces openable through recent workspaces
jonah-iden e21c31a
fix devcontainer correctly mounts and opens workspace
jonah-iden 3ad1585
Remote: Ability to open local workspaces
jonah-iden 1362a30
store last container info in global context
jonah-iden ae2d023
show local files button
jonah-iden 4706cbc
small refactoring of button contribution
jonah-iden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
packages/remote/src/electron-browser/remote-workspace-service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2024 TypeFox and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
|
||
import { URI } from '@theia/core'; | ||
import { inject, injectable } from '@theia/core/shared/inversify'; | ||
import { WorkspaceInput, WorkspaceService } from '@theia/workspace/lib/browser'; | ||
import { LOCAL_FILE_SCHEME } from './local-backend-services'; | ||
import { CURRENT_PORT_PARAM, LOCAL_PORT_PARAM, getCurrentPort, getLocalPort } from '@theia/core/lib/electron-browser/messaging/electron-local-ws-connection-source'; | ||
import { RemoteStatusService } from '../electron-common/remote-status-service'; | ||
|
||
@injectable() | ||
export class RemoteWorkspaceService extends WorkspaceService { | ||
|
||
@inject(RemoteStatusService) | ||
protected readonly remoteStatusService: RemoteStatusService; | ||
|
||
override canHandle(uri: URI): boolean { | ||
return super.canHandle(uri) || uri.scheme === LOCAL_FILE_SCHEME; | ||
} | ||
|
||
override async recentWorkspaces(): Promise<string[]> { | ||
const workspaces = await super.recentWorkspaces(); | ||
return workspaces.map(workspace => { | ||
const uri = new URI(workspace); | ||
if (uri.scheme === 'file') { | ||
return uri.withScheme(LOCAL_FILE_SCHEME).toString(); | ||
} | ||
// possible check as well if a remote/dev-container worksace is from the connected remote and therefore change it to the 'file' scheme | ||
return workspace; | ||
}); | ||
} | ||
|
||
protected override reloadWindow(options?: WorkspaceInput): void { | ||
const currentPort = getCurrentPort(); | ||
const url = this.getModifiedUrl(); | ||
history.replaceState(undefined, '', url.toString()); | ||
this.remoteStatusService.connectionClosed(parseInt(currentPort ?? '0')); | ||
super.reloadWindow(options); | ||
} | ||
|
||
protected override openNewWindow(workspacePath: string, options?: WorkspaceInput): void { | ||
const url = this.getModifiedUrl(); | ||
url.hash = encodeURI(workspacePath); | ||
this.windowService.openNewWindow(url.toString()); | ||
} | ||
|
||
protected getModifiedUrl(): URL { | ||
const url = new URL(window.location.href); | ||
url.searchParams.set(CURRENT_PORT_PARAM, getLocalPort() ?? ''); | ||
url.searchParams.delete(LOCAL_PORT_PARAM); | ||
return url; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,9 @@ | |
}, | ||
{ | ||
"path": "../userstorage" | ||
}, | ||
{ | ||
"path": "../workspace" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: This should rather be a contribution, instead of a rebinding. See also the existing rebinding in the collaboration package
theia/packages/collaboration/src/browser/collaboration-frontend-module.ts
Line 28 in f6d6da0