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

polish activity bar actions #195273

Merged
merged 4 commits into from
Oct 10, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,13 @@ export class ActivityBarCompositeBar extends PaneCompositeBar {
@IMenuService private readonly menuService: IMenuService,
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
) {
options = {
super({
...options,
fillExtraContextMenuActions: (actions, e) => {
this.fillContextMenuActions(actions, e);
options.fillExtraContextMenuActions(actions, e);
}
};
super(options, part, paneCompositePart, instantiationService, storageService, extensionService, viewDescriptorService, contextKeyService, environmentService);
}, part, paneCompositePart, instantiationService, storageService, extensionService, viewDescriptorService, contextKeyService, environmentService);

if (showGlobalActivities) {
this.globalCompositeBar = this._register(instantiationService.createInstance(GlobalCompositeBar, () => this.getContextMenuActions(), (theme: IColorTheme) => this.options.colors(theme), this.options.activityHoverOptions));
Expand Down
31 changes: 13 additions & 18 deletions src/vs/workbench/browser/parts/paneCompositePart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { MenuId, SubmenuItemAction } from 'vs/platform/actions/common/actions';
import { ActionsOrientation, prepareActions } from 'vs/base/browser/ui/actionbar/actionbar';
import { Gesture, EventType as GestureEventType } from 'vs/base/browser/touch';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import { IAction, Separator, SubmenuAction } from 'vs/base/common/actions';
import { IAction, SubmenuAction } from 'vs/base/common/actions';
import { Composite } from 'vs/workbench/browser/composite';
import { ViewsSubMenu } from 'vs/workbench/browser/parts/views/viewPaneContainer';

Expand Down Expand Up @@ -481,25 +481,8 @@ export abstract class AbstractPaneCompositePart extends CompositePart<PaneCompos
}

private onTitleAreaContextMenu(event: StandardMouseEvent): void {

if (this.shouldShowCompositeBar() && this.paneCompositeBar.value) {
const actions: IAction[] = [...this.paneCompositeBar.value.getContextMenuActions()];

const viewsActions: IAction[] = [];
const activePaneComposite = this.getActivePaneComposite() as PaneComposite;
const activePaneCompositeActions = activePaneComposite ? activePaneComposite.getSecondaryActions() : [];
const viewsSubmenuAction = activePaneCompositeActions.find(action => action instanceof SubmenuItemAction && action.item.submenu === ViewsSubMenu) as SubmenuItemAction | undefined;
if (viewsSubmenuAction) {
viewsActions.push(...viewsSubmenuAction.actions);
} else {
viewsActions.push(...activePaneCompositeActions);
}

if (viewsActions.length > 1) {
actions.push(new Separator());
actions.push(new SubmenuAction('views', localize('views', "Views"), viewsActions));
}

if (actions.length) {
this.contextMenuService.showContextMenu({
getAnchor: () => event,
Expand All @@ -519,8 +502,20 @@ export abstract class AbstractPaneCompositePart extends CompositePart<PaneCompos
skipTelemetry: true
});
}
}
}

protected getViewsSubmenuAction(): SubmenuAction | undefined {
const viewsActions: IAction[] = [];
const activePaneComposite = this.getActivePaneComposite() as PaneComposite;
const activePaneCompositeActions = activePaneComposite ? activePaneComposite.getSecondaryActions() : [];
const viewsSubmenuAction = activePaneCompositeActions.find(action => action instanceof SubmenuItemAction && action.item.submenu === ViewsSubMenu) as SubmenuItemAction | undefined;
if (viewsSubmenuAction) {
viewsActions.push(...viewsSubmenuAction.actions);
} else {
viewsActions.push(...activePaneCompositeActions);
}
return viewsActions.length > 1 ? new SubmenuAction('views', localize('views', "Views"), viewsActions) : undefined;
}

protected abstract shouldShowCompositeBar(): boolean;
Expand Down
19 changes: 19 additions & 0 deletions src/vs/workbench/browser/parts/sidebar/media/sidebarpart.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,22 @@
width: 16px;
height: 16px;
}

.monaco-workbench .sidebar.pane-composite-part > .title > .composite-bar-container {
flex: 1;
}

.monaco-workbench .sidebar.pane-composite-part > .title > .composite-bar-container >.composite-bar > .monaco-action-bar .action-item.icon {
height: 24px;
padding: 0 5px;
}

.monaco-workbench .sidebar.pane-composite-part > .title > .composite-bar-container >.composite-bar .monaco-action-bar .action-label.codicon {
font-size: 18px;
}

.monaco-workbench .sidebar.pane-composite-part > .title > .composite-bar-container > .composite-bar > .monaco-action-bar .badge .badge-content {
font-size: 9px;
min-width: 11px;
height: 16px;
}
9 changes: 8 additions & 1 deletion src/vs/workbench/browser/parts/sidebar/sidebarPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { localize } from 'vs/nls';
import { ACCOUNTS_ACTIVITY_ID, GLOBAL_ACTIVITY_ID } from 'vs/workbench/common/activity';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { ILifecycleService, LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { Separator } from 'vs/base/common/actions';

export class SidebarPart extends AbstractPaneCompositePart {

Expand Down Expand Up @@ -170,7 +171,13 @@ export class SidebarPart extends AbstractPaneCompositePart {
activityHoverOptions: {
position: () => HoverPosition.BELOW,
},
fillExtraContextMenuActions: actions => { },
fillExtraContextMenuActions: actions => {
const viewsSubmenuAction = this.getViewsSubmenuAction();
if (viewsSubmenuAction) {
actions.push(new Separator());
actions.push(viewsSubmenuAction);
}
},
compositeSize: 0,
iconSize: 16,
overflowActionSize: 44,
Expand Down