From b7ec785de0c72e1fc15e1ed74979becb0aca2a85 Mon Sep 17 00:00:00 2001 From: Benjamin Simmonds Date: Mon, 8 Aug 2022 15:44:43 +0200 Subject: [PATCH 1/2] disable TreeItem --- src/vs/base/browser/ui/iconLabel/iconLabel.ts | 17 +++++++--- .../base/browser/ui/iconLabel/iconlabel.css | 3 ++ src/vs/base/browser/ui/tree/media/tree.css | 3 ++ .../workbench/api/common/extHostTreeViews.ts | 4 +-- src/vs/workbench/browser/labels.ts | 3 +- .../browser/parts/views/media/views.css | 3 ++ .../workbench/browser/parts/views/treeView.ts | 32 ++++++++++++++++--- src/vs/workbench/common/views.ts | 4 +-- 8 files changed, 54 insertions(+), 15 deletions(-) diff --git a/src/vs/base/browser/ui/iconLabel/iconLabel.ts b/src/vs/base/browser/ui/iconLabel/iconLabel.ts index 5e7ff8fa7de..dbd32cc5e67 100644 --- a/src/vs/base/browser/ui/iconLabel/iconLabel.ts +++ b/src/vs/base/browser/ui/iconLabel/iconLabel.ts @@ -30,6 +30,7 @@ export interface IIconLabelValueOptions { matches?: IMatch[]; labelEscapeNewLines?: boolean; descriptionMatches?: IMatch[]; + disabledCommand?: boolean; readonly separator?: string; readonly domId?: string; } @@ -124,22 +125,28 @@ export class IconLabel extends Disposable { } setLabel(label: string | string[], description?: string, options?: IIconLabelValueOptions): void { - const classes = ['monaco-icon-label']; + const labelClasses = ['monaco-icon-label']; + const containerClasses = ['monaco-icon-label-container']; if (options) { if (options.extraClasses) { - classes.push(...options.extraClasses); + labelClasses.push(...options.extraClasses); } if (options.italic) { - classes.push('italic'); + labelClasses.push('italic'); } if (options.strikethrough) { - classes.push('strikethrough'); + labelClasses.push('strikethrough'); + } + + if (options.disabledCommand) { + containerClasses.push('disabled'); } } - this.domNode.className = classes.join(' '); + this.domNode.className = labelClasses.join(' '); + this.labelContainer.className = containerClasses.join(' '); this.setupHover(options?.descriptionTitle ? this.labelContainer : this.element, options?.title); this.nameNode.setLabel(label, options); diff --git a/src/vs/base/browser/ui/iconLabel/iconlabel.css b/src/vs/base/browser/ui/iconLabel/iconlabel.css index 45b73bece04..65bfa6db1e8 100644 --- a/src/vs/base/browser/ui/iconLabel/iconlabel.css +++ b/src/vs/base/browser/ui/iconLabel/iconlabel.css @@ -31,6 +31,9 @@ flex-shrink: 0; /* fix for https://github.com/microsoft/vscode/issues/13787 */ } +.monaco-icon-label-container.disabled { + opacity: 0.60; +} .monaco-icon-label > .monaco-icon-label-container { min-width: 0; overflow: hidden; diff --git a/src/vs/base/browser/ui/tree/media/tree.css b/src/vs/base/browser/ui/tree/media/tree.css index 1a2c0492ea7..bee620d57ef 100644 --- a/src/vs/base/browser/ui/tree/media/tree.css +++ b/src/vs/base/browser/ui/tree/media/tree.css @@ -10,6 +10,9 @@ position: relative; } +.monaco-tl-row.disabled { + cursor: default; +} .monaco-tl-indent { height: 100%; position: absolute; diff --git a/src/vs/workbench/api/common/extHostTreeViews.ts b/src/vs/workbench/api/common/extHostTreeViews.ts index 7eea30b6513..387ca11db21 100644 --- a/src/vs/workbench/api/common/extHostTreeViews.ts +++ b/src/vs/workbench/api/common/extHostTreeViews.ts @@ -696,8 +696,8 @@ class ExtHostTreeView extends Disposable { return tooltip; } - private getCommand(disposable: DisposableStore, command?: vscode.Command): Command | undefined { - return command ? this.commands.toInternal(command, disposable) : undefined; + private getCommand(disposable: DisposableStore, command?: vscode.Command): Command & { originalId: string } | undefined { + return command ? { ...this.commands.toInternal(command, disposable), originalId: command.command } : undefined; } private validateTreeItem(extensionTreeItem: vscode.TreeItem) { diff --git a/src/vs/workbench/browser/labels.ts b/src/vs/workbench/browser/labels.ts index 34679828f66..51125063365 100644 --- a/src/vs/workbench/browser/labels.ts +++ b/src/vs/workbench/browser/labels.ts @@ -540,7 +540,8 @@ class ResourceLabelWidget extends IconLabel { descriptionMatches: this.options?.descriptionMatches, extraClasses: [], separator: this.options?.separator, - domId: this.options?.domId + domId: this.options?.domId, + disabledCommand: this.options?.disabledCommand, }; const resource = toResource(this.label); diff --git a/src/vs/workbench/browser/parts/views/media/views.css b/src/vs/workbench/browser/parts/views/media/views.css index 09e6c7c8b1f..811a51dce7e 100644 --- a/src/vs/workbench/browser/parts/views/media/views.css +++ b/src/vs/workbench/browser/parts/views/media/views.css @@ -150,6 +150,9 @@ -moz-osx-font-smoothing: grayscale; } +.customview-tree .monaco-list .monaco-list-row .custom-view-tree-node-item>.custom-view-tree-node-item-icon.disabled { + opacity: 60%; +} /* makes spinning icons square */ .customview-tree .monaco-list .monaco-list-row .custom-view-tree-node-item > .custom-view-tree-node-item-icon.codicon.codicon-modifier-spin { padding-left: 6px; diff --git a/src/vs/workbench/browser/parts/views/treeView.ts b/src/vs/workbench/browser/parts/views/treeView.ts index 3c9b24faefd..9fa6a5b30fd 100644 --- a/src/vs/workbench/browser/parts/views/treeView.ts +++ b/src/vs/workbench/browser/parts/views/treeView.ts @@ -35,8 +35,8 @@ import { VSDataTransfer } from 'vs/base/common/dataTransfer'; import { Command } from 'vs/editor/common/languages'; import { localize } from 'vs/nls'; import { createActionViewItem, createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem'; -import { Action2, IMenu, IMenuService, MenuId, registerAction2 } from 'vs/platform/actions/common/actions'; -import { ICommandService } from 'vs/platform/commands/common/commands'; +import { Action2, IMenu, IMenuService, MenuId, MenuRegistry, registerAction2 } from 'vs/platform/actions/common/actions'; +import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ContextKeyExpr, IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; @@ -941,7 +941,8 @@ class TreeRenderer extends Disposable implements ITreeRenderer('explorer.decorations'); const labelResource = resource ? resource : URI.parse('missing:_icon_resource'); @@ -1039,7 +1052,8 @@ class TreeRenderer extends Disposable implements ITreeRenderer{ $treeViewId: this.treeViewId, $treeItemHandle: node.handle }; const disposableStore = new DisposableStore(); diff --git a/src/vs/workbench/common/views.ts b/src/vs/workbench/common/views.ts index e7897261291..b519b2db4d6 100644 --- a/src/vs/workbench/common/views.ts +++ b/src/vs/workbench/common/views.ts @@ -755,7 +755,7 @@ export interface ITreeItem { contextValue?: string; - command?: Command; + command?: Command & { originalId?: string }; children?: ITreeItem[]; @@ -774,7 +774,7 @@ export class ResolvableTreeItem implements ITreeItem { resourceUri?: UriComponents; tooltip?: string | IMarkdownString; contextValue?: string; - command?: Command; + command?: Command & { originalId?: string }; children?: ITreeItem[]; accessibilityInformation?: IAccessibilityInformation; resolve: (token: CancellationToken) => Promise; From 09e3dd2fc9b6f405104fbd623bac882d18023bc6 Mon Sep 17 00:00:00 2001 From: Benjamin Simmonds Date: Mon, 8 Aug 2022 18:35:51 +0200 Subject: [PATCH 2/2] Set color of label text instead of opacity --- src/vs/base/browser/ui/iconLabel/iconlabel.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/base/browser/ui/iconLabel/iconlabel.css b/src/vs/base/browser/ui/iconLabel/iconlabel.css index 65bfa6db1e8..ab4c0e131eb 100644 --- a/src/vs/base/browser/ui/iconLabel/iconlabel.css +++ b/src/vs/base/browser/ui/iconLabel/iconlabel.css @@ -32,7 +32,7 @@ } .monaco-icon-label-container.disabled { - opacity: 0.60; + color: var(--vscode-disabledForeground); } .monaco-icon-label > .monaco-icon-label-container { min-width: 0;