Skip to content

Commit

Permalink
Hide webview view icons when the view is collapsed
Browse files Browse the repository at this point in the history
Follow up on microsoft#185864

Otherwise always show them when the view is visible
  • Loading branch information
mjbvz committed Jul 18, 2023
1 parent e9af68e commit b9e51fb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/vs/workbench/browser/parts/views/media/paneviewlet.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
position: relative;
}

.monaco-pane-view .pane > .pane-header > .actions.show {
.monaco-pane-view .pane > .pane-header > .actions.show-always,
.monaco-pane-view .pane.expanded > .pane-header > .actions.show-expanded {
display: initial;
}

Expand Down
26 changes: 19 additions & 7 deletions src/vs/workbench/browser/parts/views/viewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,22 @@ import { BaseActionViewItem } from 'vs/base/browser/ui/actionbar/actionViewItems
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { defaultButtonStyles, defaultProgressBarStyles } from 'vs/platform/theme/browser/defaultStyles';

export enum ViewPaneShowActions {
/** Show the actions when the view is hovered. This is the default behavior. */
Default,

/** Always shows the actions when the view is expanded */
WhenExpanded,

/** Always shows the actions */
Always,
}

export interface IViewPaneOptions extends IPaneOptions {
id: string;
showActionsAlways?: boolean;
titleMenuId?: MenuId;
donotForwardArgs?: boolean;
readonly id: string;
readonly showActions?: ViewPaneShowActions;
readonly titleMenuId?: MenuId;
readonly donotForwardArgs?: boolean;
}

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

private toolbar?: WorkbenchToolBar;
private readonly showActionsAlways: boolean = false;
private readonly showActions: ViewPaneShowActions;
private headerContainer?: HTMLElement;
private titleContainer?: HTMLElement;
private titleDescriptionContainer?: HTMLElement;
Expand Down Expand Up @@ -219,7 +230,7 @@ export abstract class ViewPane extends Pane implements IView {
this.id = options.id;
this._title = options.title;
this._titleDescription = options.titleDescription;
this.showActionsAlways = !!options.showActionsAlways;
this.showActions = options.showActions ?? ViewPaneShowActions.Default;

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

const actions = append(container, $('.actions'));
actions.classList.toggle('show', this.showActionsAlways);
actions.classList.toggle('show-always', this.showActions === ViewPaneShowActions.Always);
actions.classList.toggle('show-expanded', this.showActions === ViewPaneShowActions.WhenExpanded);
this.toolbar = this.instantiationService.createInstance(WorkbenchToolBar, actions, {
orientation: ActionsOrientation.HORIZONTAL,
actionViewItemProvider: action => this.getActionViewItem(action),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { ManageExtensionAction, getContextMenuActions, ExtensionAction } from 'v
import { WorkbenchPagedList } from 'vs/platform/list/browser/listService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { ViewPane, IViewPaneOptions } from 'vs/workbench/browser/parts/views/viewPane';
import { ViewPane, IViewPaneOptions, ViewPaneShowActions } from 'vs/workbench/browser/parts/views/viewPane';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { coalesce, distinct, flatten } from 'vs/base/common/arrays';
import { alert } from 'vs/base/browser/ui/aria/aria';
Expand Down Expand Up @@ -150,7 +150,7 @@ export class ExtensionsListView extends ViewPane {
) {
super({
...(viewletViewOptions as IViewPaneOptions),
showActionsAlways: true,
showActions: ViewPaneShowActions.Always,
maximumBodySize: options.flexibleHeight ? (storageService.getNumber(`${viewletViewOptions.id}.size`, StorageScope.PROFILE, 0) ? undefined : 0) : undefined
}, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
if (this.options.onDidChangeTitle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { IProgressService } from 'vs/platform/progress/common/progress';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ViewPane } from 'vs/workbench/browser/parts/views/viewPane';
import { ViewPane, ViewPaneShowActions } from 'vs/workbench/browser/parts/views/viewPane';
import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet';
import { Memento, MementoObject } from 'vs/workbench/common/memento';
import { IViewBadge, IViewDescriptorService, IViewsService } from 'vs/workbench/common/views';
Expand Down Expand Up @@ -84,7 +84,7 @@ export class WebviewViewPane extends ViewPane {
@IWebviewService private readonly webviewService: IWebviewService,
@IWebviewViewService private readonly webviewViewService: IWebviewViewService,
) {
super({ ...options, titleMenuId: MenuId.ViewTitle, showActionsAlways: true }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super({ ...options, titleMenuId: MenuId.ViewTitle, showActions: ViewPaneShowActions.WhenExpanded }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
this.extensionId = options.fromExtensionId;
this.defaultTitle = this.title;

Expand Down

0 comments on commit b9e51fb

Please sign in to comment.