Merge pull request #115599 from microsoft/ben/114753

Web: remove old home indicator
This commit is contained in:
Benjamin Pasero 2021-02-09 08:04:30 +01:00 committed by GitHub
parent be5126d37c
commit 65505d8bec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 190 deletions

View file

@ -19,7 +19,7 @@ import { IColorTheme, IThemeService, registerThemingParticipant } from 'vs/platf
import { ActivityAction, ActivityActionViewItem, ICompositeBar, ICompositeBarColors, ToggleCompositePinnedAction } from 'vs/workbench/browser/parts/compositeBarActions';
import { CATEGORIES } from 'vs/workbench/common/actions';
import { IActivity } from 'vs/workbench/common/activity';
import { ACTIVITY_BAR_FOREGROUND, ACTIVITY_BAR_ACTIVE_BORDER, ACTIVITY_BAR_ACTIVE_FOCUS_BORDER, ACTIVITY_BAR_ACTIVE_BACKGROUND, ACTIVITY_BAR_BACKGROUND } from 'vs/workbench/common/theme';
import { ACTIVITY_BAR_FOREGROUND, ACTIVITY_BAR_ACTIVE_BORDER, ACTIVITY_BAR_ACTIVE_FOCUS_BORDER, ACTIVITY_BAR_ACTIVE_BACKGROUND } from 'vs/workbench/common/theme';
import { IActivityBarService } from 'vs/workbench/services/activityBar/browser/activityBarService';
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
@ -182,54 +182,6 @@ class MenuActivityActionViewItem extends ActivityActionViewItem {
}
}
export class HomeActivityActionViewItem extends MenuActivityActionViewItem {
static readonly HOME_BAR_VISIBILITY_PREFERENCE = 'workbench.activity.showHomeIndicator';
constructor(
private readonly goHomeHref: string,
action: ActivityAction,
contextMenuActionsProvider: () => IAction[],
colors: (theme: IColorTheme) => ICompositeBarColors,
@IThemeService themeService: IThemeService,
@IMenuService menuService: IMenuService,
@IContextMenuService contextMenuService: IContextMenuService,
@IContextKeyService contextKeyService: IContextKeyService,
@IConfigurationService configurationService: IConfigurationService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@IStorageService private readonly storageService: IStorageService
) {
super(MenuId.MenubarHomeMenu, action, contextMenuActionsProvider, colors, themeService, menuService, contextMenuService, contextKeyService, configurationService, environmentService);
}
protected async resolveMainMenuActions(homeMenu: IMenu, disposables: DisposableStore): Promise<IAction[]> {
const actions = [];
// Go Home
actions.push(toAction({ id: 'goHome', label: localize('goHome', "Go Home"), run: () => window.location.href = this.goHomeHref }));
// Contributed
const contributedActions = await super.resolveMainMenuActions(homeMenu, disposables);
if (contributedActions.length) {
actions.push(disposables.add(new Separator()));
actions.push(...contributedActions);
}
return actions;
}
protected async resolveContextMenuActions(disposables: DisposableStore): Promise<IAction[]> {
const actions = await super.resolveContextMenuActions(disposables);
actions.unshift(...[
toAction({ id: 'hideHomeButton', label: localize('hideHomeButton', "Hide Home Button"), run: () => this.storageService.store(HomeActivityActionViewItem.HOME_BAR_VISIBILITY_PREFERENCE, false, StorageScope.GLOBAL, StorageTarget.USER) }),
new Separator()
]);
return actions;
}
}
export class AccountsActivityActionViewItem extends MenuActivityActionViewItem {
static readonly ACCOUNTS_VISIBILITY_PREFERENCE_KEY = 'workbench.activity.showAccounts';
@ -422,15 +374,6 @@ registerAction2(
);
registerThemingParticipant((theme, collector) => {
const activityBarBackgroundColor = theme.getColor(ACTIVITY_BAR_BACKGROUND);
if (activityBarBackgroundColor) {
collector.addRule(`
.monaco-workbench .activitybar > .content > .home-bar > .home-bar-icon-badge {
background-color: ${activityBarBackgroundColor};
}
`);
}
const activityBarForegroundColor = theme.getColor(ACTIVITY_BAR_FOREGROUND);
if (activityBarForegroundColor) {
collector.addRule(`
@ -439,7 +382,6 @@ registerThemingParticipant((theme, collector) => {
.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item:hover .action-label:not(.codicon) {
background-color: ${activityBarForegroundColor} !important;
}
.monaco-workbench .activitybar > .content .home-bar > .monaco-action-bar .action-item .action-label.codicon,
.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item.active .action-label.codicon,
.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item:focus .action-label.codicon,
.monaco-workbench .activitybar > .content :not(.monaco-menu) > .monaco-action-bar .action-item:hover .action-label.codicon {

View file

@ -8,7 +8,7 @@ import { localize } from 'vs/nls';
import { ActionsOrientation, ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { GLOBAL_ACTIVITY_ID, IActivity, ACCOUNTS_ACTIVITY_ID } from 'vs/workbench/common/activity';
import { Part } from 'vs/workbench/browser/part';
import { GlobalActivityActionViewItem, ViewContainerActivityAction, PlaceHolderToggleCompositePinnedAction, PlaceHolderViewContainerActivityAction, AccountsActivityActionViewItem, HomeActivityActionViewItem } from 'vs/workbench/browser/parts/activitybar/activitybarActions';
import { GlobalActivityActionViewItem, ViewContainerActivityAction, PlaceHolderToggleCompositePinnedAction, PlaceHolderViewContainerActivityAction, AccountsActivityActionViewItem } from 'vs/workbench/browser/parts/activitybar/activitybarActions';
import { IBadge, NumberBadge } from 'vs/workbench/services/activity/common/activity';
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
@ -34,7 +34,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { getMenuBarVisibility } from 'vs/platform/windows/common/windows';
import { isNative, isWeb } from 'vs/base/common/platform';
import { Before2D } from 'vs/workbench/browser/dnd';
import { Codicon, iconRegistry } from 'vs/base/common/codicons';
import { Codicon } from 'vs/base/common/codicons';
import { IAction, Separator, toAction } from 'vs/base/common/actions';
import { Event } from 'vs/base/common/event';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
@ -94,9 +94,6 @@ export class ActivitybarPart extends Part implements IActivityBarService {
private content: HTMLElement | undefined;
private homeBar: ActionBar | undefined;
private homeBarContainer: HTMLElement | undefined;
private menuBar: CustomMenubarControl | undefined;
private menuBarContainer: HTMLElement | undefined;
@ -165,21 +162,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
getCompositePinnedAction: compositeId => this.getCompositeActions(compositeId).pinnedAction,
getOnCompositeClickAction: compositeId => toAction({ id: compositeId, label: '', run: async () => this.viewsService.isViewContainerVisible(compositeId) ? this.viewsService.closeViewContainer(compositeId) : this.viewsService.openViewContainer(compositeId) }),
fillExtraContextMenuActions: actions => {
// Home
const topActions: IAction[] = [];
if (this.homeBarContainer) {
topActions.push({
id: 'toggleHomeBarAction',
label: localize('homeButton', "Home Button"),
class: undefined,
tooltip: localize('homeButton', "Home Button"),
checked: this.homeBarVisibilityPreference,
enabled: true,
run: async () => this.homeBarVisibilityPreference = !this.homeBarVisibilityPreference,
dispose: () => { }
});
}
// Menu
const menuBarVisibility = getMenuBarVisibility(this.configurationService);
@ -311,12 +294,6 @@ export class ActivitybarPart extends Part implements IActivityBarService {
}
}
private onDidChangeHomeBarVisibility(): void {
if (this.homeBarContainer) {
this.homeBarContainer.style.display = this.homeBarVisibilityPreference ? '' : 'none';
}
}
private onDidRegisterExtensions(): void {
this.hasExtensionsRegistered = true;
@ -461,11 +438,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
this.menuBarContainer.classList.add('menubar');
const content = assertIsDefined(this.content);
if (this.homeBarContainer) {
content.insertBefore(this.menuBarContainer, this.homeBarContainer.nextSibling);
} else {
content.prepend(this.menuBarContainer);
}
content.prepend(this.menuBarContainer);
// Menubar: install a custom menu bar depending on configuration
this.menuBar = this._register(this.instantiationService.createInstance(CustomMenubarControl));
@ -481,19 +454,6 @@ export class ActivitybarPart extends Part implements IActivityBarService {
this.content.classList.add('content');
parent.appendChild(this.content);
// Home action bar
const homeIndicator = this.environmentService.options?.homeIndicator;
// TODO @sbatten remove the fake setting and associated code
if (homeIndicator && this.configurationService.getValue<boolean>('window.showHomeIndicator')) {
let codicon = iconRegistry.get(homeIndicator.icon);
if (!codicon) {
codicon = Codicon.code;
}
this.createHomeBar(homeIndicator.href, codicon);
this.onDidChangeHomeBarVisibility();
}
// Install menubar if compact
if (getMenuBarVisibility(this.configurationService) === 'compact') {
this.installMenubar();
@ -517,20 +477,6 @@ export class ActivitybarPart extends Part implements IActivityBarService {
private registerKeyboardNavigationListeners(): void {
this.keyboardNavigationDisposables.clear();
// Down arrow on home indicator
if (this.homeBarContainer) {
this.keyboardNavigationDisposables.add(addDisposableListener(this.homeBarContainer, EventType.KEY_DOWN, e => {
const kbEvent = new StandardKeyboardEvent(e);
if (kbEvent.equals(KeyCode.DownArrow) || kbEvent.equals(KeyCode.RightArrow)) {
if (this.menuBar) {
this.menuBar.toggleFocus();
} else if (this.compositeBar) {
this.compositeBar.focus();
}
}
}));
}
// Up/Down arrow on compact menu
if (this.menuBarContainer) {
this.keyboardNavigationDisposables.add(addDisposableListener(this.menuBarContainer, EventType.KEY_DOWN, e => {
@ -539,10 +485,6 @@ export class ActivitybarPart extends Part implements IActivityBarService {
if (this.compositeBar) {
this.compositeBar.focus();
}
} else if (kbEvent.equals(KeyCode.UpArrow) || kbEvent.equals(KeyCode.LeftArrow)) {
if (this.homeBar) {
this.homeBar.focus();
}
}
}));
}
@ -558,8 +500,6 @@ export class ActivitybarPart extends Part implements IActivityBarService {
} else if (kbEvent.equals(KeyCode.UpArrow) || kbEvent.equals(KeyCode.LeftArrow)) {
if (this.menuBar) {
this.menuBar.toggleFocus();
} else if (this.homeBar) {
this.homeBar.focus();
}
}
}));
@ -578,35 +518,6 @@ export class ActivitybarPart extends Part implements IActivityBarService {
}
}
private createHomeBar(href: string, icon: Codicon): void {
this.homeBarContainer = document.createElement('div');
this.homeBarContainer.setAttribute('aria-label', localize('homeIndicator', "Home"));
this.homeBarContainer.setAttribute('role', 'toolbar');
this.homeBarContainer.classList.add('home-bar');
this.homeBar = this._register(new ActionBar(this.homeBarContainer, {
actionViewItemProvider: action => this.instantiationService.createInstance(HomeActivityActionViewItem, href, action as ActivityAction, () => this.compositeBar.getContextMenuActions(), (theme: IColorTheme) => this.getActivitybarItemColors(theme)),
orientation: ActionsOrientation.VERTICAL,
ariaLabel: localize('home', "Home"),
animated: false,
preventLoopNavigation: true,
ignoreOrientationForPreviousAndNextKey: true
}));
const homeBarIconBadge = document.createElement('div');
homeBarIconBadge.classList.add('home-bar-icon-badge');
this.homeBarContainer.appendChild(homeBarIconBadge);
this.homeBar.push(this._register(new ActivityAction({
id: 'workbench.actions.home',
name: localize('home', "Home"),
cssClass: icon.classNames
})));
const content = assertIsDefined(this.content);
content.appendChild(this.homeBarContainer);
}
private createGlobalActivityActionBar(container: HTMLElement): void {
this.globalActivityActionBar = this._register(new ActionBar(container, {
actionViewItemProvider: action => {
@ -890,9 +801,6 @@ export class ActivitybarPart extends Part implements IActivityBarService {
// Layout composite bar
let availableHeight = contentAreaSize.height;
if (this.homeBarContainer) {
availableHeight -= this.homeBarContainer.clientHeight;
}
if (this.menuBarContainer) {
availableHeight -= this.menuBarContainer.clientHeight;
}
@ -940,10 +848,6 @@ export class ActivitybarPart extends Part implements IActivityBarService {
this.compositeBar.setCompositeBarItems(newCompositeItems);
}
if (e.key === HomeActivityActionViewItem.HOME_BAR_VISIBILITY_PREFERENCE && e.scope === StorageScope.GLOBAL) {
this.onDidChangeHomeBarVisibility();
}
if (e.key === AccountsActivityActionViewItem.ACCOUNTS_VISIBILITY_PREFERENCE_KEY && e.scope === StorageScope.GLOBAL) {
this.toggleAccountsActivity();
}
@ -1080,14 +984,6 @@ export class ActivitybarPart extends Part implements IActivityBarService {
this.storageService.store(ActivitybarPart.PLACEHOLDER_VIEW_CONTAINERS, value, StorageScope.GLOBAL, StorageTarget.MACHINE);
}
private get homeBarVisibilityPreference(): boolean {
return this.storageService.getBoolean(HomeActivityActionViewItem.HOME_BAR_VISIBILITY_PREFERENCE, StorageScope.GLOBAL, true);
}
private set homeBarVisibilityPreference(value: boolean) {
this.storageService.store(HomeActivityActionViewItem.HOME_BAR_VISIBILITY_PREFERENCE, value, StorageScope.GLOBAL, StorageTarget.USER);
}
private get accountsVisibilityPreference(): boolean {
return this.storageService.getBoolean(AccountsActivityActionViewItem.ACCOUNTS_VISIBILITY_PREFERENCE_KEY, StorageScope.GLOBAL, true);
}

View file

@ -45,30 +45,6 @@
background-color: inherit;
}
/** Home Bar */
.monaco-workbench .activitybar > .content > .home-bar {
position: relative;
width: 100%;
height: 48px;
}
.monaco-workbench .activitybar > .content > .home-bar > .home-bar-icon-badge {
position: absolute;
right: 10px;
bottom: 9px;
width: 14px;
height: 14px;
z-index: 1; /* on top of home indicator */
background-image: url('../../../media/code-icon.svg');
background-repeat: no-repeat;
background-position: center center;
background-size: 14px;
pointer-events: none;
border-top: 2px solid transparent;
border-left: 2px solid transparent;
}
/** Viewlet Switcher */
.monaco-workbench .activitybar > .content .monaco-action-bar {