This repository was archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 109
Open Che workspace with multiple workspace root #778
Merged
RomanNikitenko
merged 10 commits into
eclipse-che:master
from
benoitf:devfile-workspace-root
Feb 25, 2021
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
521d20a
feat(multiple-workspace-root): Multi-root workspaces based on /projec…
benoitf 0f38c80
Replace CheApiService by WorkspaceService
RomanNikitenko cf6fbf9
Add project as a workspace folder when the project has cloned
RomanNikitenko b87256b
Ensure config storage directories exist
RomanNikitenko a0f24fc
Ensure workspace folder creation when a project is imported
RomanNikitenko 24d9418
Add workspace folders in turn
RomanNikitenko 7f6ffdf
Use 'onDidChangeWorkspaceFolders' event to handle readme files
RomanNikitenko 9659215
Fix: file watcher should fire an event at launch.json file creation
RomanNikitenko 058aaad
Fix 'Open Configurations' and 'Add configuration' actions
RomanNikitenko dee2d73
An ability to switch (turn on and turn off ) multi-root mode on a dev…
RomanNikitenko 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
32 changes: 32 additions & 0 deletions
32
extensions/eclipse-che-theia-plugin-ext/src/browser/che-debug-configuration-manager.ts
This file contains hidden or 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,32 @@ | ||
| /********************************************************************** | ||
| * Copyright (c) 2021 Red Hat, Inc. | ||
| * | ||
| * This program and the accompanying materials are made | ||
| * available under the terms of the Eclipse Public License 2.0 | ||
| * which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| ***********************************************************************/ | ||
|
|
||
| import { injectable, postConstruct } from 'inversify'; | ||
|
|
||
| import { DebugConfigurationManager } from '@theia/debug/lib/browser/debug-configuration-manager'; | ||
|
|
||
| @injectable() | ||
| export class CheDebugConfigurationManager extends DebugConfigurationManager { | ||
| @postConstruct() | ||
| protected async init(): Promise<void> { | ||
| super.init(); | ||
|
|
||
| /** | ||
| * Theia creates a DebugConfigurationModel for each workspace folder in a workspace at starting the IDE. | ||
| * For the CHE multi-root workspace there no workspace folders at that step: | ||
| * CHE clones projects at starting the IDE and adds a workspace folder directly after cloning a project. | ||
| * That's why we need the following logic - | ||
| * DebugConfigurationManager should create the corresponding model when a workspace is changed (a workspace folder is added) | ||
| */ | ||
| this.workspaceService.onWorkspaceChanged(() => { | ||
| this.updateModels(); | ||
| }); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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
26 changes: 26 additions & 0 deletions
26
extensions/eclipse-che-theia-workspace/src/browser/che-navigator-widget.tsx
This file contains hidden or 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,26 @@ | ||
| /********************************************************************** | ||
| * Copyright (c) 2021 Red Hat, Inc. | ||
| * | ||
| * This program and the accompanying materials are made | ||
| * available under the terms of the Eclipse Public License 2.0 | ||
| * which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| ***********************************************************************/ | ||
|
|
||
| import * as React from 'react'; | ||
|
|
||
| import { injectable } from 'inversify'; | ||
|
|
||
| import { FileNavigatorWidget } from '@theia/navigator/lib/browser/navigator-widget'; | ||
|
|
||
| @injectable() | ||
| export class CheFileNavigatorWidget extends FileNavigatorWidget { | ||
| protected renderEmptyMultiRootWorkspace(): React.ReactNode { | ||
| return ( | ||
| <div className="theia-navigator-container"> | ||
| <div className="center">No projects in the workspace yet</div> | ||
| </div> | ||
| ); | ||
| } | ||
| } |
This file contains hidden or 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
61 changes: 61 additions & 0 deletions
61
extensions/eclipse-che-theia-workspace/src/node/che-workspace-server.ts
This file contains hidden or 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,61 @@ | ||
| /********************************************************************** | ||
| * Copyright (c) 2021 Red Hat, Inc. | ||
| * | ||
| * This program and the accompanying materials are made | ||
| * available under the terms of the Eclipse Public License 2.0 | ||
| * which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| ***********************************************************************/ | ||
|
|
||
| import * as fs from 'fs-extra'; | ||
| import * as path from 'path'; | ||
|
|
||
| import { Workspace, WorkspaceService } from '@eclipse-che/theia-remote-api/lib/common/workspace-service'; | ||
| import { inject, injectable } from 'inversify'; | ||
|
|
||
| import { DefaultWorkspaceServer } from '@theia/workspace/lib/node/default-workspace-server'; | ||
| import { FileUri } from '@theia/core/lib/node'; | ||
|
|
||
| interface TheiaWorkspace { | ||
| folders: TheiaWorkspacePath[]; | ||
| } | ||
|
|
||
| interface TheiaWorkspacePath { | ||
| path: string; | ||
| } | ||
|
|
||
| @injectable() | ||
| export class CheWorkspaceServer extends DefaultWorkspaceServer { | ||
| @inject(WorkspaceService) | ||
| protected workspaceService: WorkspaceService; | ||
|
|
||
| // override any workspace that could have been defined through CLI and use entries from the devfile | ||
| // if not possible, use default method | ||
| protected async getRoot(): Promise<string | undefined> { | ||
| const workspace = await this.workspaceService.currentWorkspace(); | ||
| if (!isMultiRoot(workspace)) { | ||
| return super.getRoot(); | ||
| } | ||
|
|
||
| const projectsRootEnvVariable = process.env.CHE_PROJECTS_ROOT; | ||
| const projectsRoot = projectsRootEnvVariable ? projectsRootEnvVariable : '/projects'; | ||
|
|
||
| // first, check if we have a che.theia-workspace file | ||
| const cheTheiaWorkspaceFile = path.resolve(projectsRoot, 'che.theia-workspace'); | ||
| const cheTheiaWorkspaceFileUri = FileUri.create(cheTheiaWorkspaceFile); | ||
| const exists = await fs.pathExists(cheTheiaWorkspaceFile); | ||
| if (!exists) { | ||
| // no, then create the file | ||
| const theiaWorkspace: TheiaWorkspace = { folders: [] }; | ||
| await fs.writeFile(cheTheiaWorkspaceFile, JSON.stringify(theiaWorkspace), { encoding: 'utf8' }); | ||
| } | ||
|
|
||
| return cheTheiaWorkspaceFileUri.toString(); | ||
| } | ||
| } | ||
|
|
||
| function isMultiRoot(workspace: Workspace): boolean { | ||
| const devfile = workspace.devfile; | ||
| return !!devfile && !!devfile.attributes && !!devfile.attributes.multiRoot && devfile.attributes.multiRoot === 'on'; | ||
| } |
This file contains hidden or 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,11 @@ | ||
| /********************************************************************** | ||
| * Copyright (c) 2021 Red Hat, Inc. | ||
| * | ||
| * This program and the accompanying materials are made | ||
| * available under the terms of the Eclipse Public License 2.0 | ||
| * which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| ***********************************************************************/ | ||
|
|
||
| export * from './workspace-backend-module'; |
18 changes: 18 additions & 0 deletions
18
extensions/eclipse-che-theia-workspace/src/node/workspace-backend-module.ts
This file contains hidden or 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,18 @@ | ||
| /********************************************************************** | ||
| * Copyright (c) 2021 Red Hat, Inc. | ||
| * | ||
| * This program and the accompanying materials are made | ||
| * available under the terms of the Eclipse Public License 2.0 | ||
| * which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| ***********************************************************************/ | ||
|
|
||
| import { CheWorkspaceServer } from './che-workspace-server'; | ||
| import { ContainerModule } from 'inversify'; | ||
| import { WorkspaceServer } from '@theia/workspace/lib/common'; | ||
|
|
||
| export default new ContainerModule((bind, unbind, isBound, rebind) => { | ||
| bind(CheWorkspaceServer).toSelf().inSingletonScope(); | ||
| rebind(WorkspaceServer).toService(CheWorkspaceServer); | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.