提交 c338a515 编写于 作者: S Sandeep Somavarapu

re order sync views

上级 599f3b60
......@@ -51,9 +51,9 @@ import { IAuthenticationService } from 'vs/workbench/services/authentication/bro
import { Registry } from 'vs/platform/registry/common/platform';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { Codicon } from 'vs/base/common/codicons';
import { ViewContainerLocation, IViewContainersRegistry, Extensions, ViewContainer, IViewDescriptorService, IViewsService } from 'vs/workbench/common/views';
import { ViewContainerLocation, IViewContainersRegistry, Extensions, ViewContainer } from 'vs/workbench/common/views';
import { UserDataSyncViewPaneContainer, UserDataSyncDataViews } from 'vs/workbench/contrib/userDataSync/browser/userDataSyncViews';
import { IUserDataSyncWorkbenchService, CONTEXT_ENABLE_VIEWS, getSyncAreaLabel, AccountStatus, CONTEXT_SYNC_STATE, CONTEXT_SYNC_ENABLEMENT, CONTEXT_ACCOUNT_STATE, CONFIGURE_SYNC_COMMAND_ID, SHOW_SYNC_LOG_COMMAND_ID, SHOW_SYNCED_DATA_COMMAND_ID } from 'vs/workbench/services/userDataSync/common/userDataSync';
import { IUserDataSyncWorkbenchService, getSyncAreaLabel, AccountStatus, CONTEXT_SYNC_STATE, CONTEXT_SYNC_ENABLEMENT, CONTEXT_ACCOUNT_STATE, CONFIGURE_SYNC_COMMAND_ID, SHOW_SYNC_LOG_COMMAND_ID, SYNC_VIEW_CONTAINER_ID } from 'vs/workbench/services/userDataSync/common/userDataSync';
const CONTEXT_CONFLICTS_SOURCES = new RawContextKey<string>('conflictsSources', '');
......@@ -64,7 +64,6 @@ type SyncConflictsClassification = {
action?: { classification: 'SystemMetaData', purpose: 'FeatureInsight', isMeasurement: true };
};
const viewContainerId = 'workbench.view.sync';
const turnOnSyncCommand = { id: 'workbench.userDataSync.actions.turnOn', title: localize('turn on sync with category', "Preferences Sync: Turn On...") };
const turnOffSyncCommand = { id: 'workbench.userDataSync.actions.turnOff', title: localize('stop sync', "Preferences Sync: Turn Off") };
const configureSyncCommand = { id: CONFIGURE_SYNC_COMMAND_ID, title: localize('configure sync', "Preferences Sync: Configure...") };
......@@ -85,6 +84,7 @@ const syncNowCommand = {
}
};
const showSyncSettingsCommand = { id: 'workbench.userDataSync.actions.settings', title: localize('sync settings', "Preferences Sync: Show Settings"), };
const showSyncedDataCommand = { id: 'workbench.userDataSync.actions.showSyncedData', title: localize('show synced data', "Preferences Sync: Show Synced Data"), };
const CONTEXT_TURNING_ON_STATE = new RawContextKey<false>('userDataSyncTurningOn', false);
......@@ -92,7 +92,6 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
private readonly turningOnSyncContext: IContextKey<boolean>;
private readonly conflictsSources: IContextKey<string>;
private readonly viewsEnablementContext: IContextKey<boolean>;
private readonly globalActivityBadgeDisposable = this._register(new MutableDisposable());
private readonly accountBadgeDisposable = this._register(new MutableDisposable());
......@@ -119,13 +118,11 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
@IStorageService private readonly storageService: IStorageService,
@IOpenerService private readonly openerService: IOpenerService,
@IAuthenticationService private readonly authenticationService: IAuthenticationService,
@ICommandService private readonly commandService: ICommandService,
) {
super();
this.turningOnSyncContext = CONTEXT_TURNING_ON_STATE.bindTo(contextKeyService);
this.conflictsSources = CONTEXT_CONFLICTS_SOURCES.bindTo(contextKeyService);
this.viewsEnablementContext = CONTEXT_ENABLE_VIEWS.bindTo(contextKeyService);
if (this.userDataSyncWorkbenchService.authenticationProviders.length) {
registerConfiguration();
......@@ -312,7 +309,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
actions: {
primary: [
new Action('reset', localize('reset', "Reset Synced Data"), undefined, true, () => this.userDataSyncWorkbenchService.resetSyncedData()),
new Action('show synced data', localize('show synced data action', "Show Synced Data"), undefined, true, () => this.commandService.executeCommand(SHOW_SYNCED_DATA_COMMAND_ID))
new Action('show synced data', localize('show synced data action', "Show Synced Data"), undefined, true, () => this.userDataSyncWorkbenchService.showSyncActivity())
]
}
});
......@@ -468,7 +465,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
actions: {
primary: [
new Action('reset', localize('reset', "Reset Synced Data"), undefined, true, () => this.userDataSyncWorkbenchService.resetSyncedData()),
new Action('show synced data', localize('show synced data action', "Show Synced Data"), undefined, true, () => this.commandService.executeCommand(SHOW_SYNCED_DATA_COMMAND_ID))
new Action('show synced data', localize('show synced data action', "Show Synced Data"), undefined, true, () => this.userDataSyncWorkbenchService.showSyncActivity())
]
}
});
......@@ -926,7 +923,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}
items.push({ id: configureSyncCommand.id, label: configureSyncCommand.title });
items.push({ id: showSyncSettingsCommand.id, label: showSyncSettingsCommand.title });
items.push({ id: SHOW_SYNCED_DATA_COMMAND_ID, label: localize('show synced data', "Preferences Sync: Show Synced Data") });
items.push({ id: showSyncedDataCommand.id, label: showSyncedDataCommand.title });
items.push({ type: 'separator' });
items.push({ id: syncNowCommand.id, label: syncNowCommand.title, description: syncNowCommand.description(that.userDataSyncService) });
if (that.userDataAutoSyncService.canToggleEnablement()) {
......@@ -956,7 +953,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
this._register(registerAction2(class SyncStatusAction extends Action2 {
constructor() {
super({
id: SHOW_SYNCED_DATA_COMMAND_ID,
id: showSyncedDataCommand.id,
title: { value: localize('workbench.action.showSyncRemoteBackup', "Show Synced Data"), original: `Show Synced Data` },
category: { value: localize('sync preferences', "Preferences Sync"), original: `Preferences Sync` },
precondition: when,
......@@ -966,24 +963,8 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
}
});
}
async run(accessor: ServicesAccessor): Promise<void> {
that.viewsEnablementContext.set(true);
const viewDescriptorService = accessor.get(IViewDescriptorService);
const viewsService = accessor.get(IViewsService);
const viewContainer = viewDescriptorService.getViewContainerById(viewContainerId);
if (viewContainer) {
const model = viewDescriptorService.getViewContainerModel(viewContainer);
if (model.activeViewDescriptors.length) {
viewsService.openViewContainer(viewContainerId);
} else {
const disposable = model.onDidChangeActiveViewDescriptors(e => {
if (e.added.length) {
disposable.dispose();
viewsService.openViewContainer(viewContainerId);
}
});
}
}
run(accessor: ServicesAccessor): Promise<void> {
return that.userDataSyncWorkbenchService.showSyncActivity();
}
}));
}
......@@ -1093,11 +1074,11 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
private registerViewContainer(): ViewContainer {
return Registry.as<IViewContainersRegistry>(Extensions.ViewContainersRegistry).registerViewContainer(
{
id: viewContainerId,
id: SYNC_VIEW_CONTAINER_ID,
name: localize('sync preferences', "Preferences Sync"),
ctorDescriptor: new SyncDescriptor(
UserDataSyncViewPaneContainer,
[viewContainerId]
[SYNC_VIEW_CONTAINER_ID]
),
icon: Codicon.sync.classNames,
hideIfEmpty: true,
......
......@@ -87,9 +87,10 @@ export class UserDataSyncDataViews extends Disposable {
private registerViews(container: ViewContainer): void {
this.registerManualSyncView(container);
this.registerMachinesView(container);
this.registerActivityView(container, true);
this.registerMachinesView(container);
this.registerActivityView(container, false);
}
......@@ -359,7 +360,7 @@ export class UserDataSyncDataViews extends Disposable {
canMoveView: false,
treeView,
collapsed: false,
order: 200,
order: 300,
}], container);
registerAction2(class extends Action2 {
......@@ -426,8 +427,8 @@ export class UserDataSyncDataViews extends Disposable {
canToggleVisibility: true,
canMoveView: false,
treeView,
collapsed: true,
order: 300,
collapsed: false,
order: remote ? 200 : 400,
hideByDefault: !remote,
}], container);
......
......@@ -6,7 +6,7 @@
import { IUserDataSyncService, IAuthenticationProvider, getUserDataSyncStore, isAuthenticationProvider, IUserDataAutoSyncService, SyncResource, IResourcePreview, ISyncResourcePreview, Change, IManualSyncTask } from 'vs/platform/userDataSync/common/userDataSync';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IUserDataSyncWorkbenchService, IUserDataSyncAccount, AccountStatus, CONTEXT_SYNC_ENABLEMENT, CONTEXT_SYNC_STATE, CONTEXT_ACCOUNT_STATE, SHOW_SYNC_LOG_COMMAND_ID, getSyncAreaLabel, IUserDataSyncPreview, IUserDataSyncResourceGroup, CONTEXT_SHOW_MANUAL_SYNC_VIEW, SHOW_SYNCED_DATA_COMMAND_ID, MANUAL_SYNC_VIEW_ID } from 'vs/workbench/services/userDataSync/common/userDataSync';
import { IUserDataSyncWorkbenchService, IUserDataSyncAccount, AccountStatus, CONTEXT_SYNC_ENABLEMENT, CONTEXT_SYNC_STATE, CONTEXT_ACCOUNT_STATE, SHOW_SYNC_LOG_COMMAND_ID, getSyncAreaLabel, IUserDataSyncPreview, IUserDataSyncResourceGroup, CONTEXT_SHOW_MANUAL_SYNC_VIEW, MANUAL_SYNC_VIEW_ID, CONTEXT_ENABLE_VIEWS, SYNC_VIEW_CONTAINER_ID } from 'vs/workbench/services/userDataSync/common/userDataSync';
import { AuthenticationSession, AuthenticationSessionsChangeEvent } from 'vs/editor/common/modes';
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
import { Emitter, Event } from 'vs/base/common/event';
......@@ -25,7 +25,6 @@ import { canceled } from 'vs/base/common/errors';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { Action } from 'vs/base/common/actions';
import { IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress';
import { isEqual } from 'vs/base/common/resources';
......@@ -82,6 +81,7 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
private readonly syncStatusContext: IContextKey<string>;
private readonly accountStatusContext: IContextKey<string>;
private readonly showManualSyncViewContext: IContextKey<boolean>;
private readonly viewsEnablementContext: IContextKey<boolean>;
readonly userDataSyncPreview: UserDataSyncPreview = this._register(new UserDataSyncPreview(this.userDataSyncService));
......@@ -101,7 +101,6 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
@INotificationService private readonly notificationService: INotificationService,
@IProgressService private readonly progressService: IProgressService,
@IDialogService private readonly dialogService: IDialogService,
@ICommandService private readonly commandService: ICommandService,
@IContextKeyService contextKeyService: IContextKeyService,
@IViewsService private readonly viewsService: IViewsService,
@IViewDescriptorService private readonly viewDescriptorService: IViewDescriptorService,
......@@ -112,6 +111,7 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
this.syncEnablementContext = CONTEXT_SYNC_ENABLEMENT.bindTo(contextKeyService);
this.syncStatusContext = CONTEXT_SYNC_STATE.bindTo(contextKeyService);
this.accountStatusContext = CONTEXT_ACCOUNT_STATE.bindTo(contextKeyService);
this.viewsEnablementContext = CONTEXT_ENABLE_VIEWS.bindTo(contextKeyService);
this.showManualSyncViewContext = CONTEXT_SHOW_MANUAL_SYNC_VIEW.bindTo(contextKeyService);
decorationsService.registerDecorationsProvider(this.userDataSyncPreview);
......@@ -338,7 +338,7 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
this.userDataSyncPreview.setManualSyncPreview(task, preview);
this.showManualSyncViewContext.set(true);
await this.commandService.executeCommand(SHOW_SYNCED_DATA_COMMAND_ID);
await this.enableSyncViews();
await this.viewsService.openView(MANUAL_SYNC_VIEW_ID);
await Event.toPromise(Event.filter(this.userDataSyncPreview.onDidChangeChanges, e => e.length === 0));
......@@ -369,6 +369,22 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
}
}
async showSyncActivity(): Promise<void> {
await this.enableSyncViews();
await this.viewsService.openViewContainer(SYNC_VIEW_CONTAINER_ID);
}
private async enableSyncViews(): Promise<void> {
this.viewsEnablementContext.set(true);
const viewContainer = this.viewDescriptorService.getViewContainerById(SYNC_VIEW_CONTAINER_ID);
if (viewContainer) {
const model = this.viewDescriptorService.getViewContainerModel(viewContainer);
if (!model.activeViewDescriptors.length) {
await Event.toPromise(Event.filter(model.onDidChangeActiveViewDescriptors, e => model.activeViewDescriptors.length > 0));
}
}
}
private isSupportedAuthenticationProviderId(authenticationProviderId: string): boolean {
return this.authenticationProviders.some(({ id }) => id === authenticationProviderId);
}
......
......@@ -54,7 +54,9 @@ export interface IUserDataSyncWorkbenchService {
turnOn(): Promise<void>;
turnoff(everyWhere: boolean): Promise<void>;
signIn(): Promise<void>;
resetSyncedData(): Promise<void>;
showSyncActivity(): Promise<void>;
}
export function getSyncAreaLabel(source: SyncResource): string {
......@@ -83,7 +85,7 @@ export const CONTEXT_SHOW_MANUAL_SYNC_VIEW = new RawContextKey<boolean>(`showMan
// Commands
export const CONFIGURE_SYNC_COMMAND_ID = 'workbench.userDataSync.actions.configure';
export const SHOW_SYNC_LOG_COMMAND_ID = 'workbench.userDataSync.actions.showLog';
export const SHOW_SYNCED_DATA_COMMAND_ID = 'workbench.userDataSync.actions.showSyncedData';
// VIEWS
export const SYNC_VIEW_CONTAINER_ID = 'workbench.view.sync';
export const MANUAL_SYNC_VIEW_ID = 'workbench.views.manualSyncView';
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册