Skip to content

Commit e98bfca

Browse files
authored
Hide webview view icons when the view is collapsed (microsoft#188204)
Follow up on microsoft#185864 Otherwise always show them when the view is visible
1 parent 5aa6894 commit e98bfca

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

src/vs/workbench/browser/parts/views/media/paneviewlet.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
position: relative;
1616
}
1717

18-
.monaco-pane-view .pane > .pane-header > .actions.show {
18+
.monaco-pane-view .pane > .pane-header > .actions.show-always,
19+
.monaco-pane-view .pane.expanded > .pane-header > .actions.show-expanded {
1920
display: initial;
2021
}
2122

src/vs/workbench/browser/parts/views/viewPane.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,22 @@ import { BaseActionViewItem } from 'vs/base/browser/ui/actionbar/actionViewItems
4747
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
4848
import { defaultButtonStyles, defaultProgressBarStyles } from 'vs/platform/theme/browser/defaultStyles';
4949

50+
export enum ViewPaneShowActions {
51+
/** Show the actions when the view is hovered. This is the default behavior. */
52+
Default,
53+
54+
/** Always shows the actions when the view is expanded */
55+
WhenExpanded,
56+
57+
/** Always shows the actions */
58+
Always,
59+
}
60+
5061
export interface IViewPaneOptions extends IPaneOptions {
51-
id: string;
52-
showActionsAlways?: boolean;
53-
titleMenuId?: MenuId;
54-
donotForwardArgs?: boolean;
62+
readonly id: string;
63+
readonly showActions?: ViewPaneShowActions;
64+
readonly titleMenuId?: MenuId;
65+
readonly donotForwardArgs?: boolean;
5566
}
5667

5768
export interface IFilterViewPaneOptions extends IViewPaneOptions {
@@ -188,7 +199,7 @@ export abstract class ViewPane extends Pane implements IView {
188199
private progressIndicator!: IProgressIndicator;
189200

190201
private toolbar?: WorkbenchToolBar;
191-
private readonly showActionsAlways: boolean = false;
202+
private readonly showActions: ViewPaneShowActions;
192203
private headerContainer?: HTMLElement;
193204
private titleContainer?: HTMLElement;
194205
private titleDescriptionContainer?: HTMLElement;
@@ -219,7 +230,7 @@ export abstract class ViewPane extends Pane implements IView {
219230
this.id = options.id;
220231
this._title = options.title;
221232
this._titleDescription = options.titleDescription;
222-
this.showActionsAlways = !!options.showActionsAlways;
233+
this.showActions = options.showActions ?? ViewPaneShowActions.Default;
223234

224235
this.scopedContextKeyService = this._register(contextKeyService.createScoped(this.element));
225236
this.scopedContextKeyService.createKey('view', this.id);
@@ -288,7 +299,8 @@ export abstract class ViewPane extends Pane implements IView {
288299
this.renderHeaderTitle(container, this.title);
289300

290301
const actions = append(container, $('.actions'));
291-
actions.classList.toggle('show', this.showActionsAlways);
302+
actions.classList.toggle('show-always', this.showActions === ViewPaneShowActions.Always);
303+
actions.classList.toggle('show-expanded', this.showActions === ViewPaneShowActions.WhenExpanded);
292304
this.toolbar = this.instantiationService.createInstance(WorkbenchToolBar, actions, {
293305
orientation: ActionsOrientation.HORIZONTAL,
294306
actionViewItemProvider: action => this.getActionViewItem(action),

src/vs/workbench/contrib/extensions/browser/extensionsViews.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { ManageExtensionAction, getContextMenuActions, ExtensionAction } from 'v
2929
import { WorkbenchPagedList } from 'vs/platform/list/browser/listService';
3030
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
3131
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
32-
import { ViewPane, IViewPaneOptions } from 'vs/workbench/browser/parts/views/viewPane';
32+
import { ViewPane, IViewPaneOptions, ViewPaneShowActions } from 'vs/workbench/browser/parts/views/viewPane';
3333
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
3434
import { coalesce, distinct, flatten } from 'vs/base/common/arrays';
3535
import { alert } from 'vs/base/browser/ui/aria/aria';
@@ -150,7 +150,7 @@ export class ExtensionsListView extends ViewPane {
150150
) {
151151
super({
152152
...(viewletViewOptions as IViewPaneOptions),
153-
showActionsAlways: true,
153+
showActions: ViewPaneShowActions.Always,
154154
maximumBodySize: options.flexibleHeight ? (storageService.getNumber(`${viewletViewOptions.id}.size`, StorageScope.PROFILE, 0) ? undefined : 0) : undefined
155155
}, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
156156
if (this.options.onDidChangeTitle) {

src/vs/workbench/contrib/webviewView/browser/webviewViewPane.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { IProgressService } from 'vs/platform/progress/common/progress';
2020
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
2121
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
2222
import { IThemeService } from 'vs/platform/theme/common/themeService';
23-
import { ViewPane } from 'vs/workbench/browser/parts/views/viewPane';
23+
import { ViewPane, ViewPaneShowActions } from 'vs/workbench/browser/parts/views/viewPane';
2424
import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet';
2525
import { Memento, MementoObject } from 'vs/workbench/common/memento';
2626
import { IViewBadge, IViewDescriptorService, IViewsService } from 'vs/workbench/common/views';
@@ -84,7 +84,7 @@ export class WebviewViewPane extends ViewPane {
8484
@IWebviewService private readonly webviewService: IWebviewService,
8585
@IWebviewViewService private readonly webviewViewService: IWebviewViewService,
8686
) {
87-
super({ ...options, titleMenuId: MenuId.ViewTitle, showActionsAlways: true }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
87+
super({ ...options, titleMenuId: MenuId.ViewTitle, showActions: ViewPaneShowActions.WhenExpanded }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
8888
this.extensionId = options.fromExtensionId;
8989
this.defaultTitle = this.title;
9090

0 commit comments

Comments
 (0)