mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Merge from vscode 073a24de05773f2261f89172987002dc0ae2f1cd (#9711)
This commit is contained in:
@@ -3,12 +3,14 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { AuthenticationSession } from 'vs/editor/common/modes';
|
||||
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { AuthenticationSession, AuthenticationSessionsChangeEvent } from 'vs/editor/common/modes';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { MainThreadAuthenticationProvider } from 'vs/workbench/api/browser/mainThreadAuthentication';
|
||||
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
|
||||
export const IAuthenticationService = createDecorator<IAuthenticationService>('IAuthenticationService');
|
||||
|
||||
@@ -17,12 +19,12 @@ export interface IAuthenticationService {
|
||||
|
||||
registerAuthenticationProvider(id: string, provider: MainThreadAuthenticationProvider): void;
|
||||
unregisterAuthenticationProvider(id: string): void;
|
||||
sessionsUpdate(providerId: string): void;
|
||||
sessionsUpdate(providerId: string, event: AuthenticationSessionsChangeEvent): void;
|
||||
|
||||
readonly onDidRegisterAuthenticationProvider: Event<string>;
|
||||
readonly onDidUnregisterAuthenticationProvider: Event<string>;
|
||||
|
||||
readonly onDidChangeSessions: Event<string>;
|
||||
readonly onDidChangeSessions: Event<{ providerId: string, event: AuthenticationSessionsChangeEvent }>;
|
||||
getSessions(providerId: string): Promise<ReadonlyArray<AuthenticationSession> | undefined>;
|
||||
getDisplayName(providerId: string): string;
|
||||
login(providerId: string, scopes: string[]): Promise<AuthenticationSession>;
|
||||
@@ -31,6 +33,7 @@ export interface IAuthenticationService {
|
||||
|
||||
export class AuthenticationService extends Disposable implements IAuthenticationService {
|
||||
_serviceBrand: undefined;
|
||||
private _placeholderMenuItem: IDisposable | undefined;
|
||||
|
||||
private _authenticationProviders: Map<string, MainThreadAuthenticationProvider> = new Map<string, MainThreadAuthenticationProvider>();
|
||||
|
||||
@@ -40,25 +43,53 @@ export class AuthenticationService extends Disposable implements IAuthentication
|
||||
private _onDidUnregisterAuthenticationProvider: Emitter<string> = this._register(new Emitter<string>());
|
||||
readonly onDidUnregisterAuthenticationProvider: Event<string> = this._onDidUnregisterAuthenticationProvider.event;
|
||||
|
||||
private _onDidChangeSessions: Emitter<string> = this._register(new Emitter<string>());
|
||||
readonly onDidChangeSessions: Event<string> = this._onDidChangeSessions.event;
|
||||
private _onDidChangeSessions: Emitter<{ providerId: string, event: AuthenticationSessionsChangeEvent }> = this._register(new Emitter<{ providerId: string, event: AuthenticationSessionsChangeEvent }>());
|
||||
readonly onDidChangeSessions: Event<{ providerId: string, event: AuthenticationSessionsChangeEvent }> = this._onDidChangeSessions.event;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this._placeholderMenuItem = MenuRegistry.appendMenuItem(MenuId.AccountsContext, {
|
||||
command: {
|
||||
id: 'noAuthenticationProviders',
|
||||
title: nls.localize('noAuthenticationProviders', "No authentication providers registered")
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
registerAuthenticationProvider(id: string, authenticationProvider: MainThreadAuthenticationProvider): void {
|
||||
this._authenticationProviders.set(id, authenticationProvider);
|
||||
this._onDidRegisterAuthenticationProvider.fire(id);
|
||||
|
||||
if (authenticationProvider.dependents.length && this._placeholderMenuItem) {
|
||||
this._placeholderMenuItem.dispose();
|
||||
this._placeholderMenuItem = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
unregisterAuthenticationProvider(id: string): void {
|
||||
this._authenticationProviders.delete(id);
|
||||
this._onDidUnregisterAuthenticationProvider.fire(id);
|
||||
const provider = this._authenticationProviders.get(id);
|
||||
if (provider) {
|
||||
provider.dispose();
|
||||
this._authenticationProviders.delete(id);
|
||||
this._onDidUnregisterAuthenticationProvider.fire(id);
|
||||
}
|
||||
|
||||
if (!this._authenticationProviders.size) {
|
||||
this._placeholderMenuItem = MenuRegistry.appendMenuItem(MenuId.AccountsContext, {
|
||||
command: {
|
||||
id: 'noAuthenticationProviders',
|
||||
title: nls.localize('noAuthenticationProviders', "No authentication providers registered")
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
sessionsUpdate(id: string): void {
|
||||
this._onDidChangeSessions.fire(id);
|
||||
sessionsUpdate(id: string, event: AuthenticationSessionsChangeEvent): void {
|
||||
this._onDidChangeSessions.fire({ providerId: id, event: event });
|
||||
const provider = this._authenticationProviders.get(id);
|
||||
if (provider) {
|
||||
provider.updateSessionItems();
|
||||
}
|
||||
}
|
||||
|
||||
getDisplayName(id: string): string {
|
||||
|
||||
@@ -28,7 +28,7 @@ import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerServ
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IWorkingCopyFileService } from 'vs/workbench/services/workingCopy/common/workingCopyFileService';
|
||||
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
|
||||
import { EditStackElement, MultiModelEditStackElement } from 'vs/editor/common/model/editStack';
|
||||
import { SingleModelEditStackElement, MultiModelEditStackElement } from 'vs/editor/common/model/editStack';
|
||||
|
||||
type ValidationResult = { canApply: true } | { canApply: false, reason: URI };
|
||||
|
||||
@@ -234,7 +234,7 @@ class BulkEditModel implements IDisposable {
|
||||
|
||||
const multiModelEditStackElement = new MultiModelEditStackElement(
|
||||
this._label || localize('workspaceEdit', "Workspace Edit"),
|
||||
tasks.map(t => new EditStackElement(t.model, t.getBeforeCursorState()))
|
||||
tasks.map(t => new SingleModelEditStackElement(t.model, t.getBeforeCursorState()))
|
||||
);
|
||||
this._undoRedoService.pushElement(multiModelEditStackElement);
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editor
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
|
||||
export class PreferencesEditorInput extends SideBySideEditorInput {
|
||||
static readonly ID: string = 'workbench.editorinputs.preferencesEditorInput';
|
||||
@@ -105,7 +106,7 @@ export class SettingsEditor2Input extends EditorInput {
|
||||
private readonly _settingsModel: Settings2EditorModel;
|
||||
|
||||
readonly resource: URI = URI.from({
|
||||
scheme: 'vscode-settings',
|
||||
scheme: Schemas.vscodeSettings,
|
||||
path: `settingseditor`
|
||||
});
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IResourceRefHandle, IUserDataSyncBackupStoreService, SyncResource } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
|
||||
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
|
||||
export class UserDataSyncBackupStoreService implements IUserDataSyncBackupStoreService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
private readonly channel: IChannel;
|
||||
|
||||
constructor(
|
||||
@ISharedProcessService sharedProcessService: ISharedProcessService,
|
||||
) {
|
||||
this.channel = sharedProcessService.getChannel('userDataSyncBackupStoreService');
|
||||
}
|
||||
|
||||
backup(key: SyncResource, content: string): Promise<void> {
|
||||
return this.channel.call('backup', [key, content]);
|
||||
}
|
||||
|
||||
|
||||
getAllRefs(key: SyncResource): Promise<IResourceRefHandle[]> {
|
||||
return this.channel.call('getAllRefs', [key]);
|
||||
}
|
||||
|
||||
resolveContent(key: SyncResource, ref: string): Promise<string | null> {
|
||||
return this.channel.call('resolveContent', [key, ref]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
registerSingleton(IUserDataSyncBackupStoreService, UserDataSyncBackupStoreService);
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SyncStatus, SyncResource, IUserDataSyncService, UserDataSyncError, SyncResourceConflicts } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { SyncStatus, SyncResource, IUserDataSyncService, UserDataSyncError, SyncResourceConflicts, ISyncResourceHandle } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
@@ -73,8 +73,8 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ
|
||||
return this.channel.call('sync');
|
||||
}
|
||||
|
||||
acceptConflict(conflict: URI, content: string): Promise<void> {
|
||||
return this.channel.call('acceptConflict', [conflict, content]);
|
||||
stop(): Promise<void> {
|
||||
return this.channel.call('stop');
|
||||
}
|
||||
|
||||
reset(): Promise<void> {
|
||||
@@ -85,16 +85,31 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ
|
||||
return this.channel.call('resetLocal');
|
||||
}
|
||||
|
||||
stop(): Promise<void> {
|
||||
return this.channel.call('stop');
|
||||
isFirstTimeSyncWithMerge(): Promise<boolean> {
|
||||
return this.channel.call('isFirstTimeSyncWithMerge');
|
||||
}
|
||||
|
||||
acceptConflict(conflict: URI, content: string): Promise<void> {
|
||||
return this.channel.call('acceptConflict', [conflict, content]);
|
||||
}
|
||||
|
||||
resolveContent(resource: URI): Promise<string | null> {
|
||||
return this.channel.call('resolveContent', [resource]);
|
||||
}
|
||||
|
||||
isFirstTimeSyncWithMerge(): Promise<boolean> {
|
||||
return this.channel.call('isFirstTimeSyncWithMerge');
|
||||
async getLocalSyncResourceHandles(resource: SyncResource): Promise<ISyncResourceHandle[]> {
|
||||
const handles = await this.channel.call<ISyncResourceHandle[]>('getLocalSyncResourceHandles', [resource]);
|
||||
return handles.map(({ created, uri }) => ({ created, uri: URI.revive(uri) }));
|
||||
}
|
||||
|
||||
async getRemoteSyncResourceHandles(resource: SyncResource): Promise<ISyncResourceHandle[]> {
|
||||
const handles = await this.channel.call<ISyncResourceHandle[]>('getRemoteSyncResourceHandles', [resource]);
|
||||
return handles.map(({ created, uri }) => ({ created, uri: URI.revive(uri) }));
|
||||
}
|
||||
|
||||
async getAssociatedResources(resource: SyncResource, syncResourceHandle: ISyncResourceHandle): Promise<{ resource: URI, comparableResource?: URI }[]> {
|
||||
const result = await this.channel.call<{ resource: URI, comparableResource?: URI }[]>('getAssociatedResources', [resource, syncResourceHandle]);
|
||||
return result.map(({ resource, comparableResource }) => ({ resource: URI.revive(resource), comparableResource: URI.revive(comparableResource) }));
|
||||
}
|
||||
|
||||
private async updateStatus(status: SyncStatus): Promise<void> {
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SyncResource, IUserDataSyncStoreService, IUserDataSyncStore, getUserDataSyncStore, IUserData, IUserDataManifest, IResourceRefHandle } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
|
||||
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
|
||||
export class UserDataSyncStoreService implements IUserDataSyncStoreService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
private readonly channel: IChannel;
|
||||
readonly userDataSyncStore: IUserDataSyncStore | undefined;
|
||||
|
||||
constructor(
|
||||
@ISharedProcessService sharedProcessService: ISharedProcessService,
|
||||
@IProductService productService: IProductService,
|
||||
@IConfigurationService configurationService: IConfigurationService
|
||||
) {
|
||||
this.channel = sharedProcessService.getChannel('userDataSyncStoreService');
|
||||
this.userDataSyncStore = getUserDataSyncStore(productService, configurationService);
|
||||
}
|
||||
|
||||
read(key: SyncResource, oldValue: IUserData | null, source?: SyncResource): Promise<IUserData> {
|
||||
throw new Error('Not Supported');
|
||||
}
|
||||
|
||||
write(key: SyncResource, content: string, ref: string | null, source?: SyncResource): Promise<string> {
|
||||
throw new Error('Not Supported');
|
||||
}
|
||||
|
||||
manifest(): Promise<IUserDataManifest | null> {
|
||||
throw new Error('Not Supported');
|
||||
}
|
||||
|
||||
clear(): Promise<void> {
|
||||
throw new Error('Not Supported');
|
||||
}
|
||||
|
||||
getAllRefs(key: SyncResource): Promise<IResourceRefHandle[]> {
|
||||
return this.channel.call('getAllRefs', [key]);
|
||||
}
|
||||
|
||||
resolveContent(key: SyncResource, ref: string): Promise<string | null> {
|
||||
return this.channel.call('resolveContent', [key, ref]);
|
||||
}
|
||||
|
||||
delete(key: SyncResource): Promise<void> {
|
||||
return this.channel.call('delete', [key]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
registerSingleton(IUserDataSyncStoreService, UserDataSyncStoreService);
|
||||
@@ -28,12 +28,12 @@ export const enum WorkingCopyCapabilities {
|
||||
* `IBackupFileService.resolve(workingCopy.resource)` to
|
||||
* retrieve the backup when loading the working copy.
|
||||
*/
|
||||
export interface IWorkingCopyBackup {
|
||||
export interface IWorkingCopyBackup<MetaType = object> {
|
||||
|
||||
/**
|
||||
* Any serializable metadata to be associated with the backup.
|
||||
*/
|
||||
meta?: object;
|
||||
meta?: MetaType;
|
||||
|
||||
/**
|
||||
* Use this for larger textual content of the backup.
|
||||
|
||||
Reference in New Issue
Block a user