forked from openkylin/kylin-code
移除活动栏账户管理功能.
This commit is contained in:
parent
8d0ae4eba5
commit
8af01e66e9
|
@ -6,9 +6,11 @@
|
||||||
import 'vs/css!./media/activitybarpart';
|
import 'vs/css!./media/activitybarpart';
|
||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
import { ActionsOrientation, ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
|
import { ActionsOrientation, ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||||
import { GLOBAL_ACTIVITY_ID, IActivity, ACCOUNTS_ACTIVITY_ID } from 'vs/workbench/common/activity';
|
// import { GLOBAL_ACTIVITY_ID, IActivity, ACCOUNTS_ACTIVITY_ID } from 'vs/workbench/common/activity';
|
||||||
|
import { GLOBAL_ACTIVITY_ID, IActivity } from 'vs/workbench/common/activity';
|
||||||
import { Part } from 'vs/workbench/browser/part';
|
import { Part } from 'vs/workbench/browser/part';
|
||||||
import { GlobalActivityActionViewItem, ViewContainerActivityAction, PlaceHolderToggleCompositePinnedAction, PlaceHolderViewContainerActivityAction, AccountsActivityActionViewItem } from 'vs/workbench/browser/parts/activitybar/activitybarActions';
|
// import { GlobalActivityActionViewItem, ViewContainerActivityAction, PlaceHolderToggleCompositePinnedAction, PlaceHolderViewContainerActivityAction, AccountsActivityActionViewItem } from 'vs/workbench/browser/parts/activitybar/activitybarActions';
|
||||||
|
import { GlobalActivityActionViewItem, ViewContainerActivityAction, PlaceHolderToggleCompositePinnedAction, PlaceHolderViewContainerActivityAction } from 'vs/workbench/browser/parts/activitybar/activitybarActions';
|
||||||
import { IBadge, NumberBadge } from 'vs/workbench/services/activity/common/activity';
|
import { IBadge, NumberBadge } from 'vs/workbench/services/activity/common/activity';
|
||||||
import { IWorkbenchLayoutService, Parts, Position } from 'vs/workbench/services/layout/browser/layoutService';
|
import { IWorkbenchLayoutService, Parts, Position } from 'vs/workbench/services/layout/browser/layoutService';
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
|
@ -79,10 +81,10 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart
|
||||||
private static readonly PINNED_VIEW_CONTAINERS = 'workbench.activity.pinnedViewlets2';
|
private static readonly PINNED_VIEW_CONTAINERS = 'workbench.activity.pinnedViewlets2';
|
||||||
private static readonly PLACEHOLDER_VIEW_CONTAINERS = 'workbench.activity.placeholderViewlets';
|
private static readonly PLACEHOLDER_VIEW_CONTAINERS = 'workbench.activity.placeholderViewlets';
|
||||||
private static readonly ACTION_HEIGHT = 48;
|
private static readonly ACTION_HEIGHT = 48;
|
||||||
private static readonly ACCOUNTS_ACTION_INDEX = 0;
|
// private static readonly ACCOUNTS_ACTION_INDEX = 0;
|
||||||
|
|
||||||
private static readonly GEAR_ICON = registerIcon('settings-view-bar-icon', Codicon.settingsGear, localize('settingsViewBarIcon', "Settings icon in the view bar."));
|
private static readonly GEAR_ICON = registerIcon('settings-view-bar-icon', Codicon.settingsGear, localize('settingsViewBarIcon', "Settings icon in the view bar."));
|
||||||
private static readonly ACCOUNTS_ICON = registerIcon('accounts-view-bar-icon', Codicon.account, localize('accountsViewBarIcon', "Accounts icon in the view bar."));
|
// private static readonly ACCOUNTS_ICON = registerIcon('accounts-view-bar-icon', Codicon.account, localize('accountsViewBarIcon', "Accounts icon in the view bar."));
|
||||||
|
|
||||||
//#region IView
|
//#region IView
|
||||||
|
|
||||||
|
@ -106,9 +108,9 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart
|
||||||
private globalActivitiesContainer: HTMLElement | undefined;
|
private globalActivitiesContainer: HTMLElement | undefined;
|
||||||
private readonly globalActivity: ICompositeActivity[] = [];
|
private readonly globalActivity: ICompositeActivity[] = [];
|
||||||
|
|
||||||
private accountsActivityAction: ActivityAction | undefined;
|
// private accountsActivityAction: ActivityAction | undefined;
|
||||||
|
|
||||||
private readonly accountsActivity: ICompositeActivity[] = [];
|
// private readonly accountsActivity: ICompositeActivity[] = [];
|
||||||
|
|
||||||
private readonly compositeActions = new Map<string, { activityAction: ViewContainerActivityAction; pinnedAction: ToggleCompositePinnedAction }>();
|
private readonly compositeActions = new Map<string, { activityAction: ViewContainerActivityAction; pinnedAction: ToggleCompositePinnedAction }>();
|
||||||
private readonly viewContainerDisposables = new Map<string, IDisposable>();
|
private readonly viewContainerDisposables = new Map<string, IDisposable>();
|
||||||
|
@ -147,10 +149,12 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart
|
||||||
.registerKeys([{
|
.registerKeys([{
|
||||||
key: ActivitybarPart.PINNED_VIEW_CONTAINERS,
|
key: ActivitybarPart.PINNED_VIEW_CONTAINERS,
|
||||||
description: localize('pinned view containers', "Activity bar entries visibility customizations")
|
description: localize('pinned view containers', "Activity bar entries visibility customizations")
|
||||||
}, {
|
}
|
||||||
key: AccountsActivityActionViewItem.ACCOUNTS_VISIBILITY_PREFERENCE_KEY,
|
// , {
|
||||||
description: localize('accounts visibility key', "Accounts entry visibility customization in the activity bar.")
|
// key: AccountsActivityActionViewItem.ACCOUNTS_VISIBILITY_PREFERENCE_KEY,
|
||||||
}]);
|
// description: localize('accounts visibility key', "Accounts entry visibility customization in the activity bar.")
|
||||||
|
// }
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private createCompositeBar() {
|
private createCompositeBar() {
|
||||||
|
@ -188,8 +192,8 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accounts
|
// Accounts
|
||||||
actions.push(new Separator());
|
// actions.push(new Separator());
|
||||||
actions.push(toAction({ id: 'toggleAccountsVisibility', label: localize('accounts', "Accounts"), checked: this.accountsVisibilityPreference, run: () => this.accountsVisibilityPreference = !this.accountsVisibilityPreference }));
|
// actions.push(toAction({ id: 'toggleAccountsVisibility', label: localize('accounts', "Accounts"), checked: this.accountsVisibilityPreference, run: () => this.accountsVisibilityPreference = !this.accountsVisibilityPreference }));
|
||||||
actions.push(new Separator());
|
actions.push(new Separator());
|
||||||
|
|
||||||
// Toggle Sidebar
|
// Toggle Sidebar
|
||||||
|
@ -342,9 +346,9 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart
|
||||||
return this.showGlobalActivity(GLOBAL_ACTIVITY_ID, badge, clazz, priority);
|
return this.showGlobalActivity(GLOBAL_ACTIVITY_ID, badge, clazz, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewContainerOrActionId === ACCOUNTS_ACTIVITY_ID) {
|
// if (viewContainerOrActionId === ACCOUNTS_ACTIVITY_ID) {
|
||||||
return this.showGlobalActivity(ACCOUNTS_ACTIVITY_ID, badge, clazz, priority);
|
// return this.showGlobalActivity(ACCOUNTS_ACTIVITY_ID, badge, clazz, priority);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return Disposable.None;
|
return Disposable.None;
|
||||||
}
|
}
|
||||||
|
@ -355,7 +359,7 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart
|
||||||
}
|
}
|
||||||
|
|
||||||
const activity: ICompositeActivity = { badge, clazz, priority };
|
const activity: ICompositeActivity = { badge, clazz, priority };
|
||||||
const activityCache = activityId === GLOBAL_ACTIVITY_ID ? this.globalActivity : this.accountsActivity;
|
const activityCache = this.globalActivity;
|
||||||
|
|
||||||
for (let i = 0; i <= activityCache.length; i++) {
|
for (let i = 0; i <= activityCache.length; i++) {
|
||||||
if (i === activityCache.length) {
|
if (i === activityCache.length) {
|
||||||
|
@ -372,7 +376,7 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart
|
||||||
}
|
}
|
||||||
|
|
||||||
private removeGlobalActivity(activityId: string, activity: ICompositeActivity): void {
|
private removeGlobalActivity(activityId: string, activity: ICompositeActivity): void {
|
||||||
const activityCache = activityId === GLOBAL_ACTIVITY_ID ? this.globalActivity : this.accountsActivity;
|
const activityCache = this.globalActivity;
|
||||||
const index = activityCache.indexOf(activity);
|
const index = activityCache.indexOf(activity);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
activityCache.splice(index, 1);
|
activityCache.splice(index, 1);
|
||||||
|
@ -381,12 +385,12 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateGlobalActivity(activityId: string): void {
|
private updateGlobalActivity(activityId: string): void {
|
||||||
const activityAction = activityId === GLOBAL_ACTIVITY_ID ? this.globalActivityAction : this.accountsActivityAction;
|
const activityAction = this.globalActivityAction;
|
||||||
if (!activityAction) {
|
if (!activityAction) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const activityCache = activityId === GLOBAL_ACTIVITY_ID ? this.globalActivity : this.accountsActivity;
|
const activityCache = this.globalActivity;
|
||||||
if (activityCache.length) {
|
if (activityCache.length) {
|
||||||
const [{ badge, clazz, priority }] = activityCache;
|
const [{ badge, clazz, priority }] = activityCache;
|
||||||
if (badge instanceof NumberBadge && activityCache.length > 1) {
|
if (badge instanceof NumberBadge && activityCache.length > 1) {
|
||||||
|
@ -526,9 +530,9 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart
|
||||||
return this.instantiationService.createInstance(GlobalActivityActionViewItem, action as ActivityAction, () => this.compositeBar.getContextMenuActions(), (theme: IColorTheme) => this.getActivitybarItemColors(theme), this.getActivityHoverOptions());
|
return this.instantiationService.createInstance(GlobalActivityActionViewItem, action as ActivityAction, () => this.compositeBar.getContextMenuActions(), (theme: IColorTheme) => this.getActivitybarItemColors(theme), this.getActivityHoverOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action.id === 'workbench.actions.accounts') {
|
// if (action.id === 'workbench.actions.accounts') {
|
||||||
return this.instantiationService.createInstance(AccountsActivityActionViewItem, action as ActivityAction, () => this.compositeBar.getContextMenuActions(), (theme: IColorTheme) => this.getActivitybarItemColors(theme), this.getActivityHoverOptions());
|
// return this.instantiationService.createInstance(AccountsActivityActionViewItem, action as ActivityAction, () => this.compositeBar.getContextMenuActions(), (theme: IColorTheme) => this.getActivitybarItemColors(theme), this.getActivityHoverOptions());
|
||||||
}
|
// }
|
||||||
|
|
||||||
throw new Error(`No view item for action '${action.id}'`);
|
throw new Error(`No view item for action '${action.id}'`);
|
||||||
},
|
},
|
||||||
|
@ -544,36 +548,36 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart
|
||||||
cssClass: ThemeIcon.asClassName(ActivitybarPart.GEAR_ICON)
|
cssClass: ThemeIcon.asClassName(ActivitybarPart.GEAR_ICON)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (this.accountsVisibilityPreference) {
|
// if (this.accountsVisibilityPreference) {
|
||||||
this.accountsActivityAction = this._register(new ActivityAction({
|
// this.accountsActivityAction = this._register(new ActivityAction({
|
||||||
id: 'workbench.actions.accounts',
|
// id: 'workbench.actions.accounts',
|
||||||
name: localize('accounts', "Accounts"),
|
// name: localize('accounts', "Accounts"),
|
||||||
cssClass: ThemeIcon.asClassName(ActivitybarPart.ACCOUNTS_ICON)
|
// cssClass: ThemeIcon.asClassName(ActivitybarPart.ACCOUNTS_ICON)
|
||||||
}));
|
// }));
|
||||||
|
|
||||||
this.globalActivityActionBar.push(this.accountsActivityAction, { index: ActivitybarPart.ACCOUNTS_ACTION_INDEX });
|
// this.globalActivityActionBar.push(this.accountsActivityAction, { index: ActivitybarPart.ACCOUNTS_ACTION_INDEX });
|
||||||
}
|
// }
|
||||||
|
|
||||||
this.globalActivityActionBar.push(this.globalActivityAction);
|
this.globalActivityActionBar.push(this.globalActivityAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
private toggleAccountsActivity() {
|
// private toggleAccountsActivity() {
|
||||||
if (this.globalActivityActionBar) {
|
// if (this.globalActivityActionBar) {
|
||||||
if (this.accountsActivityAction) {
|
// if (this.accountsActivityAction) {
|
||||||
this.globalActivityActionBar.pull(ActivitybarPart.ACCOUNTS_ACTION_INDEX);
|
// this.globalActivityActionBar.pull(ActivitybarPart.ACCOUNTS_ACTION_INDEX);
|
||||||
this.accountsActivityAction = undefined;
|
// this.accountsActivityAction = undefined;
|
||||||
} else {
|
// } else {
|
||||||
this.accountsActivityAction = this._register(new ActivityAction({
|
// this.accountsActivityAction = this._register(new ActivityAction({
|
||||||
id: 'workbench.actions.accounts',
|
// id: 'workbench.actions.accounts',
|
||||||
name: localize('accounts', "Accounts"),
|
// name: localize('accounts', "Accounts"),
|
||||||
cssClass: Codicon.account.classNames
|
// cssClass: Codicon.account.classNames
|
||||||
}));
|
// }));
|
||||||
this.globalActivityActionBar.push(this.accountsActivityAction, { index: ActivitybarPart.ACCOUNTS_ACTION_INDEX });
|
// this.globalActivityActionBar.push(this.accountsActivityAction, { index: ActivitybarPart.ACCOUNTS_ACTION_INDEX });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
this.updateGlobalActivity(ACCOUNTS_ACTIVITY_ID);
|
// this.updateGlobalActivity(ACCOUNTS_ACTIVITY_ID);
|
||||||
}
|
// }
|
||||||
|
|
||||||
private getCompositeActions(compositeId: string): { activityAction: ViewContainerActivityAction; pinnedAction: ToggleCompositePinnedAction } {
|
private getCompositeActions(compositeId: string): { activityAction: ViewContainerActivityAction; pinnedAction: ToggleCompositePinnedAction } {
|
||||||
let compositeActions = this.compositeActions.get(compositeId);
|
let compositeActions = this.compositeActions.get(compositeId);
|
||||||
|
@ -848,9 +852,9 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart
|
||||||
this.compositeBar.setCompositeBarItems(newCompositeItems);
|
this.compositeBar.setCompositeBarItems(newCompositeItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.key === AccountsActivityActionViewItem.ACCOUNTS_VISIBILITY_PREFERENCE_KEY && e.scope === StorageScope.GLOBAL) {
|
// if (e.key === AccountsActivityActionViewItem.ACCOUNTS_VISIBILITY_PREFERENCE_KEY && e.scope === StorageScope.GLOBAL) {
|
||||||
this.toggleAccountsActivity();
|
// this.toggleAccountsActivity();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private saveCachedViewContainers(): void {
|
private saveCachedViewContainers(): void {
|
||||||
|
@ -984,13 +988,13 @@ export class ActivitybarPart extends Part implements IPaneCompositeSelectorPart
|
||||||
this.storageService.store(ActivitybarPart.PLACEHOLDER_VIEW_CONTAINERS, value, StorageScope.GLOBAL, StorageTarget.MACHINE);
|
this.storageService.store(ActivitybarPart.PLACEHOLDER_VIEW_CONTAINERS, value, StorageScope.GLOBAL, StorageTarget.MACHINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private get accountsVisibilityPreference(): boolean {
|
// private get accountsVisibilityPreference(): boolean {
|
||||||
return this.storageService.getBoolean(AccountsActivityActionViewItem.ACCOUNTS_VISIBILITY_PREFERENCE_KEY, StorageScope.GLOBAL, true);
|
// return this.storageService.getBoolean(AccountsActivityActionViewItem.ACCOUNTS_VISIBILITY_PREFERENCE_KEY, StorageScope.GLOBAL, true);
|
||||||
}
|
// }
|
||||||
|
|
||||||
private set accountsVisibilityPreference(value: boolean) {
|
// private set accountsVisibilityPreference(value: boolean) {
|
||||||
this.storageService.store(AccountsActivityActionViewItem.ACCOUNTS_VISIBILITY_PREFERENCE_KEY, value, StorageScope.GLOBAL, StorageTarget.USER);
|
// this.storageService.store(AccountsActivityActionViewItem.ACCOUNTS_VISIBILITY_PREFERENCE_KEY, value, StorageScope.GLOBAL, StorageTarget.USER);
|
||||||
}
|
// }
|
||||||
|
|
||||||
toJSON(): object {
|
toJSON(): object {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue