Skip to content
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

workspace: cleanup multiroot handling #11538

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

- [tasks] if the variables of a task should be reevaluated on a rerun (this was the behavior until now) the `reevaluateOnRerun` run option in the task description needs to be set to `true` from now on [#11759](https://github.com/eclipse-theia/theia/pull/11759) - Contributed on behalf of STMicroelectronics
- [preferences] `PreferenceHeaderRendererContribution` moved to `preference-node-renderer-creator.ts`. [#11432](https://github.com/eclipse-theia/theia/pull/11432)
- [workspace] removed `workspace.supportMultiRootWorkspace` preference [#11538](https://github.com/eclipse-theia/theia/pull/11538)
- [workspace] removed method `isMultiRootWorkspaceEnabled` from `WorkspaceService` [#11538](https://github.com/eclipse-theia/theia/pull/11538)

## v1.31.0 - 10/27/2022

Expand Down
1 change: 0 additions & 1 deletion packages/core/i18n/nls.cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@
"preserveWindow": "Povolit otevírání pracovních ploch v aktuálním okně.",
"removeFolder": "Jste si jisti, že chcete z pracovního prostoru odebrat následující složku?",
"removeFolders": "Jste si jisti, že chcete z pracovního prostoru odebrat následující složky?",
"supportMultiRootWorkspace": "Řídí, zda je povolena podpora více kořenových pracovních prostorů.",
"trashTitle": "Přesun {0} do koše",
"trustEmptyWindow": "Řídí, zda má být prázdný pracovní prostor ve výchozím nastavení důvěryhodný.",
"trustEnabled": "Řídí, zda je povolena důvěryhodnost pracovního prostoru. Pokud je zakázáno, jsou důvěryhodné všechny pracovní prostory.",
Expand Down
1 change: 0 additions & 1 deletion packages/core/i18n/nls.de.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@
"preserveWindow": "Aktivieren Sie das Öffnen von Arbeitsbereichen im aktuellen Fenster.",
"removeFolder": "Sind Sie sicher, dass Sie den folgenden Ordner aus dem Arbeitsbereich entfernen möchten?",
"removeFolders": "Sind Sie sicher, dass Sie die folgenden Ordner aus dem Arbeitsbereich entfernen möchten?",
"supportMultiRootWorkspace": "Steuert, ob die Unterstützung von Multi-Root-Arbeitsbereichen aktiviert ist.",
"trashTitle": "Verschiebe {0} in den Papierkorb",
"trustEmptyWindow": "Steuert, ob dem leeren Arbeitsbereich standardmäßig vertraut wird oder nicht.",
"trustEnabled": "Steuert, ob das Vertrauen in Arbeitsbereiche aktiviert ist oder nicht. Wenn deaktiviert, wird allen Arbeitsbereichen vertraut.",
Expand Down
1 change: 0 additions & 1 deletion packages/core/i18n/nls.es.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@
"preserveWindow": "Habilitar la apertura de espacios de trabajo en la ventana actual.",
"removeFolder": "¿Está seguro de que quiere eliminar la siguiente carpeta del espacio de trabajo?",
"removeFolders": "¿Está seguro de que quiere eliminar las siguientes carpetas del espacio de trabajo?",
"supportMultiRootWorkspace": "Controla si el soporte de espacios de trabajo multi-root está habilitado.",
"trashTitle": "Mover {0} a la Papelera",
"trustEmptyWindow": "Controla si el espacio de trabajo vacío es de confianza o no por defecto.",
"trustEnabled": "Controla si la confianza del espacio de trabajo está activada o no. Si se desactiva, todos los espacios de trabajo son de confianza.",
Expand Down
1 change: 0 additions & 1 deletion packages/core/i18n/nls.fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@
"preserveWindow": "Permet d'ouvrir les espaces de travail dans la fenêtre actuelle.",
"removeFolder": "Êtes-vous sûr de vouloir supprimer le dossier suivant de l'espace de travail?",
"removeFolders": "Êtes-vous sûr de vouloir supprimer les dossiers suivants de l'espace de travail?",
"supportMultiRootWorkspace": "Contrôle si le support de l'espace de travail multi-root est activé.",
"trashTitle": "Déplacer {0} vers la corbeille",
"trustEmptyWindow": "Contrôle si l'espace de travail vide est fiable ou non par défaut.",
"trustEnabled": "Contrôle si la confiance de l'espace de travail est activée ou non. S'il est désactivé, tous les espaces de travail sont fiables.",
Expand Down
1 change: 0 additions & 1 deletion packages/core/i18n/nls.hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@
"preserveWindow": "Munkaterületek megnyitásának engedélyezése az aktuális ablakban.",
"removeFolder": "Biztos, hogy a következő mappát szeretné eltávolítani a munkaterületről?",
"removeFolders": "Biztos, hogy a következő mappákat szeretné eltávolítani a munkaterületről?",
"supportMultiRootWorkspace": "Szabályozza, hogy a több gyökérrel rendelkező munkaterület támogatása engedélyezve legyen-e.",
"trashTitle": "Mozgassa {0} a szemetesbe",
"trustEmptyWindow": "Szabályozza, hogy az üres munkaterület alapértelmezés szerint megbízható legyen-e vagy sem.",
"trustEnabled": "Szabályozza, hogy a munkaterület megbízhatósága engedélyezve legyen-e vagy sem. Ha le van tiltva, akkor minden munkaterület megbízható.",
Expand Down
1 change: 0 additions & 1 deletion packages/core/i18n/nls.it.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@
"preserveWindow": "Abilita l'apertura degli spazi di lavoro nella finestra corrente.",
"removeFolder": "Sei sicuro di voler rimuovere la seguente cartella dall'area di lavoro?",
"removeFolders": "Sei sicuro di voler rimuovere le seguenti cartelle dallo spazio di lavoro?",
"supportMultiRootWorkspace": "Controlla se il supporto allo spazio di lavoro multi-root è abilitato.",
"trashTitle": "Sposta {0} nel Cestino",
"trustEmptyWindow": "Controlla se lo spazio di lavoro vuoto è fidato o meno per impostazione predefinita.",
"trustEnabled": "Controlla se la fiducia dello spazio di lavoro è abilitata o meno. Se disabilitato, tutti gli spazi di lavoro sono affidabili.",
Expand Down
1 change: 0 additions & 1 deletion packages/core/i18n/nls.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@
"preserveWindow": "ワークスペースを現在のウィンドウで開けるようにします。",
"removeFolder": "ワークスペースから以下のフォルダを削除してよろしいですか?",
"removeFolders": "ワークスペースから以下のフォルダを削除してよろしいですか?",
"supportMultiRootWorkspace": "マルチルート・ワークスペースのサポートを有効にするかどうかを制御します。",
"trashTitle": "{0}をゴミ箱に移動",
"trustEmptyWindow": "空のワークスペースをデフォルトで信頼するかどうかを制御します。",
"trustEnabled": "ワークスペースの信頼を有効にするかどうかを制御します。無効の場合、すべてのワークスペースが信頼されます。",
Expand Down
1 change: 0 additions & 1 deletion packages/core/i18n/nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@
"preserveWindow": "Enable opening workspaces in current window.",
"removeFolder": "Are you sure you want to remove the following folder from the workspace?",
"removeFolders": "Are you sure you want to remove the following folders from the workspace?",
"supportMultiRootWorkspace": "Controls whether multi-root workspace support is enabled.",
"trashTitle": "Move {0} to Trash",
"trustEmptyWindow": "Controls whether or not the empty workspace is trusted by default.",
"trustEnabled": "Controls whether or not workspace trust is enabled. If disabled, all workspaces are trusted.",
Expand Down
1 change: 0 additions & 1 deletion packages/core/i18n/nls.pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@
"preserveWindow": "Umożliwia otwieranie obszarów roboczych w bieżącym oknie.",
"removeFolder": "Czy na pewno chcesz usunąć poniższy folder z obszaru roboczego?",
"removeFolders": "Czy na pewno chcesz usunąć następujące foldery z obszaru roboczego?",
"supportMultiRootWorkspace": "Określa, czy włączona jest obsługa przestrzeni roboczej z wieloma rootami.",
"trashTitle": "Przenieś {0} do kosza",
"trustEmptyWindow": "Określa, czy pusty obszar roboczy jest domyślnie zaufany, czy nie.",
"trustEnabled": "Określa, czy zaufanie do obszaru roboczego jest włączone, czy nie. Jeśli wyłączone, wszystkie obszary robocze są zaufane.",
Expand Down
1 change: 0 additions & 1 deletion packages/core/i18n/nls.pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@
"preserveWindow": "Permitir a abertura de espaços de trabalho na janela atual.",
"removeFolder": "Você tem certeza de que deseja remover a seguinte pasta do espaço de trabalho?",
"removeFolders": "Você tem certeza de que quer remover as seguintes pastas do espaço de trabalho?",
"supportMultiRootWorkspace": "Controla se o suporte de espaço de trabalho multi-raiz está habilitado.",
"trashTitle": "Mudar {0} para Lixo",
"trustEmptyWindow": "Controla se o espaço de trabalho vazio é ou não confiável por padrão.",
"trustEnabled": "Controla se a confiança no espaço de trabalho está ou não habilitada. Se desativado, todos os espaços de trabalho são confiáveis.",
Expand Down
1 change: 0 additions & 1 deletion packages/core/i18n/nls.pt-pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@
"preserveWindow": "Activar a abertura de espaços de trabalho na janela actual.",
"removeFolder": "Tem a certeza de que quer remover a seguinte pasta do espaço de trabalho?",
"removeFolders": "Tem a certeza de que quer remover as seguintes pastas do espaço de trabalho?",
"supportMultiRootWorkspace": "Controla se o suporte multi-raiz do espaço de trabalho está activado.",
"trashTitle": "Mover {0} para o Lixo",
"trustEmptyWindow": "Controla se o espaço de trabalho vazio é ou não de confiança por defeito.",
"trustEnabled": "Controla se a confiança no espaço de trabalho está ou não activada. Se estiver desactivado, todos os espaços de trabalho são de confiança.",
Expand Down
1 change: 0 additions & 1 deletion packages/core/i18n/nls.ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@
"preserveWindow": "Включить открытие рабочих пространств в текущем окне.",
"removeFolder": "Вы уверены, что хотите удалить следующую папку из рабочей области?",
"removeFolders": "Вы уверены, что хотите удалить следующие папки из рабочей области?",
"supportMultiRootWorkspace": "Управляет тем, включена ли поддержка многокорневого рабочего пространства.",
"trashTitle": "Переместить {0} в корзину",
"trustEmptyWindow": "Управляет тем, доверяется ли пустая рабочая область по умолчанию.",
"trustEnabled": "Управляет тем, включено или нет доверие к рабочему пространству. Если отключено, все рабочие пространства являются доверенными.",
Expand Down
1 change: 0 additions & 1 deletion packages/core/i18n/nls.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@
"preserveWindow": "启用在当前窗口中打开工作空间。",
"removeFolder": "你确定要从工作区删除以下文件夹吗?",
"removeFolders": "你确定要从工作区删除以下文件夹吗?",
"supportMultiRootWorkspace": "控制是否启用多根工作区支持。",
"trashTitle": "将{0}移至垃圾箱",
"trustEmptyWindow": "控制空工作区是否被默认信任。",
"trustEnabled": "控制是否启用工作区信任。如果禁用,所有工作空间都被信任。",
Expand Down
34 changes: 8 additions & 26 deletions packages/navigator/src/browser/navigator-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
import { FileDownloadCommands } from '@theia/filesystem/lib/browser/download/file-download-command-contribution';
import {
CommandRegistry,
DisposableCollection,
isOSX,
MenuModelRegistry,
MenuPath,
Expand Down Expand Up @@ -205,17 +204,6 @@ export class FileNavigatorContribution extends AbstractViewContribution<FileNavi
}
}

async onStart(app: FrontendApplication): Promise<void> {
this.workspacePreferences.ready.then(() => {
this.updateAddRemoveFolderActions(this.menuRegistry);
this.workspacePreferences.onPreferenceChanged(change => {
if (change.preferenceName === 'workspace.supportMultiRootWorkspace') {
this.updateAddRemoveFolderActions(this.menuRegistry);
}
});
});
}

async initializeLayout(app: FrontendApplication): Promise<void> {
await this.openView();
}
Expand Down Expand Up @@ -495,6 +483,14 @@ export class FileNavigatorContribution extends AbstractViewContribution<FileNavi
label: nls.localizeByDefault('Close All'),
order: 'c'
});

registry.registerMenuAction(NavigatorContextMenu.WORKSPACE, {
commandId: FileNavigatorCommands.ADD_ROOT_FOLDER.id,
label: WorkspaceCommands.ADD_FOLDER.label
});
registry.registerMenuAction(NavigatorContextMenu.WORKSPACE, {
commandId: WorkspaceCommands.REMOVE_FOLDER.id
});
}

override registerKeybindings(registry: KeybindingRegistry): void {
Expand Down Expand Up @@ -658,18 +654,4 @@ export class FileNavigatorContribution extends AbstractViewContribution<FileNavi
await model.refresh();
}

private readonly toDisposeAddRemoveFolderActions = new DisposableCollection();
private updateAddRemoveFolderActions(registry: MenuModelRegistry): void {
this.toDisposeAddRemoveFolderActions.dispose();
if (this.workspacePreferences['workspace.supportMultiRootWorkspace']) {
this.toDisposeAddRemoveFolderActions.push(registry.registerMenuAction(NavigatorContextMenu.WORKSPACE, {
commandId: FileNavigatorCommands.ADD_ROOT_FOLDER.id,
label: WorkspaceCommands.ADD_FOLDER.label!
}));
this.toDisposeAddRemoveFolderActions.push(registry.registerMenuAction(NavigatorContextMenu.WORKSPACE, {
commandId: WorkspaceCommands.REMOVE_FOLDER.id
}));
}
}

}
12 changes: 5 additions & 7 deletions packages/workspace/src/browser/quick-open-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import URI from '@theia/core/lib/common/uri';
import { FileService } from '@theia/filesystem/lib/browser/file-service';
import { FileStat } from '@theia/filesystem/lib/common/files';
import { nls, Path } from '@theia/core/lib/common';
import { CommonWorkspaceUtils } from '../common/utils';

interface RecentlyOpenedPick extends QuickPickItem {
resource?: URI
Expand All @@ -39,6 +40,7 @@ export class QuickOpenWorkspace {
@inject(LabelProvider) protected readonly labelProvider: LabelProvider;
@inject(WorkspacePreferences) protected preferences: WorkspacePreferences;
@inject(EnvVariablesServer) protected readonly envServer: EnvVariablesServer;
@inject(CommonWorkspaceUtils) protected workspaceUtils: CommonWorkspaceUtils;

protected readonly removeRecentWorkspaceButton: QuickInputButton = {
iconClass: 'codicon-remove-close',
Expand All @@ -47,7 +49,7 @@ export class QuickOpenWorkspace {

async open(workspaces: string[]): Promise<void> {
this.items = [];
const [homeDirUri, tempWorkspaceFile] = await Promise.all([
const [homeDirUri] = await Promise.all([
this.envServer.getHomeDirUri(),
this.workspaceService.getUntitledWorkspace()
]);
Expand All @@ -63,12 +65,8 @@ export class QuickOpenWorkspace {
try {
stat = await this.fileService.resolve(uri);
} catch { }
if (!stat ||
!this.preferences['workspace.supportMultiRootWorkspace'] && !stat.isDirectory) {
continue; // skip the workspace files if multi root is not supported
}
if (uri.toString() === tempWorkspaceFile.toString()) {
continue; // skip the temporary workspace files
if (this.workspaceUtils.isUntitledWorkspace(uri) || !stat) {
continue; // skip the temporary workspace files or an undefined stat.
}
const icon = this.labelProvider.getIcon(stat);
const iconClasses = icon === '' ? undefined : [icon + ' file-icon'];
Expand Down
6 changes: 3 additions & 3 deletions packages/workspace/src/browser/workspace-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ export class WorkspaceCommandContribution implements CommandContribution {
}));
this.preferences.ready.then(() => {
registry.registerCommand(WorkspaceCommands.ADD_FOLDER, {
isEnabled: () => this.workspaceService.isMultiRootWorkspaceEnabled,
isVisible: () => this.workspaceService.isMultiRootWorkspaceEnabled,
isEnabled: () => this.workspaceService.opened,
isVisible: () => this.workspaceService.opened,
execute: async () => {
const selection = await this.fileDialogService.showOpenDialog({
title: WorkspaceCommands.ADD_FOLDER.label!,
Expand All @@ -348,7 +348,7 @@ export class WorkspaceCommandContribution implements CommandContribution {
});
registry.registerCommand(WorkspaceCommands.REMOVE_FOLDER, this.newMultiUriAwareCommandHandler({
execute: uris => this.removeFolderFromWorkspace(uris),
isEnabled: () => this.workspaceService.isMultiRootWorkspaceEnabled,
isEnabled: () => this.workspaceService.isMultiRootWorkspaceOpened,
isVisible: uris => this.areWorkspaceRoots(uris) && this.workspaceService.saved
}));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,21 @@ describe('workspace-frontend-contribution', () => {
after(() => disableJSDOM());

([

[OS.Type.Linux, 'browser', true, { title, canSelectFiles: true, canSelectFolders: true, filters }],
[OS.Type.Linux, 'browser', false, { title, canSelectFiles: false, canSelectFolders: true }],
[OS.Type.Linux, 'electron', true, { title, canSelectFiles: true, canSelectFolders: false, filters }],
[OS.Type.Linux, 'electron', false, { title, canSelectFiles: false, canSelectFolders: true }],

[OS.Type.Windows, 'browser', true, { title, canSelectFiles: true, canSelectFolders: true, filters }],
[OS.Type.Windows, 'browser', false, { title, canSelectFiles: false, canSelectFolders: true }],
[OS.Type.Windows, 'electron', true, { title, canSelectFiles: true, canSelectFolders: false, filters }],
[OS.Type.Windows, 'electron', false, { title, canSelectFiles: false, canSelectFolders: true }],

[OS.Type.OSX, 'browser', true, { title, canSelectFiles: true, canSelectFolders: true, filters }],
[OS.Type.OSX, 'browser', false, { title, canSelectFiles: false, canSelectFolders: true }],
[OS.Type.OSX, 'electron', true, { title, canSelectFiles: true, canSelectFolders: true, filters }],
[OS.Type.OSX, 'electron', false, { title, canSelectFiles: true, canSelectFolders: true, filters }]

] as [OS.Type, 'browser' | 'electron', boolean, OpenFileDialogProps][]).forEach(test => {
const [type, environment, supportMultiRootWorkspace, expected] = test;
const [type, environment, _, expected] = test;
const electron = environment === 'electron' ? true : false;
const os = (OS.Type as any)[type]; // eslint-disable-line @typescript-eslint/no-explicit-any
const actual = WorkspaceFrontendContribution.createOpenWorkspaceOpenFileDialogProps({
type,
electron,
supportMultiRootWorkspace
});
it(`createOpenWorkspaceOpenFileDialogProps - OS: ${os}, Environment: ${environment}, Multi-root workspace: ${supportMultiRootWorkspace ? 'yes' : 'no'}`, () => {
it(`createOpenWorkspaceOpenFileDialogProps - OS: ${os}, Environment: ${environment}`, () => {
expect(actual).to.be.deep.equal(expected);
});
});
Expand Down
Loading