mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-30 01:25:38 -05:00
Merge from vscode 2e5312cd61ff99c570299ecc122c52584265eda2
This commit is contained in:
committed by
Anthony Dresser
parent
3603f55d97
commit
7f1d8fc32f
@@ -20,8 +20,9 @@ import { FormattingOptions } from 'vs/base/common/jsonFormatter';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { joinPath, isEqualOrParent } from 'vs/base/common/resources';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { IProductService, ConfigurationSyncStore } from 'vs/platform/product/common/productService';
|
||||
import { distinct } from 'vs/base/common/arrays';
|
||||
import { isArray, isString, isObject } from 'vs/base/common/types';
|
||||
|
||||
export const CONFIGURATION_SYNC_STORE_KEY = 'configurationSync.store';
|
||||
|
||||
@@ -119,17 +120,33 @@ export interface IUserData {
|
||||
content: string | null;
|
||||
}
|
||||
|
||||
export type IAuthenticationProvider = { id: string, scopes: string[] };
|
||||
|
||||
export interface IUserDataSyncStore {
|
||||
url: URI;
|
||||
authenticationProviderId: string;
|
||||
authenticationProviders: IAuthenticationProvider[];
|
||||
}
|
||||
|
||||
export function isAuthenticationProvider(thing: any): thing is IAuthenticationProvider {
|
||||
return thing
|
||||
&& isObject(thing)
|
||||
&& isString(thing.id)
|
||||
&& isArray(thing.scopes);
|
||||
}
|
||||
|
||||
export function getUserDataSyncStore(productService: IProductService, configurationService: IConfigurationService): IUserDataSyncStore | undefined {
|
||||
const value = configurationService.getValue<{ url: string, authenticationProviderId: string }>(CONFIGURATION_SYNC_STORE_KEY) || productService[CONFIGURATION_SYNC_STORE_KEY];
|
||||
if (value && value.url && value.authenticationProviderId) {
|
||||
const value = configurationService.getValue<ConfigurationSyncStore>(CONFIGURATION_SYNC_STORE_KEY) || productService[CONFIGURATION_SYNC_STORE_KEY];
|
||||
if (value
|
||||
&& isString(value.url)
|
||||
&& isObject(value.authenticationProviders)
|
||||
&& Object.keys(value.authenticationProviders).every(authenticationProviderId => isArray(value.authenticationProviders[authenticationProviderId].scopes))
|
||||
) {
|
||||
return {
|
||||
url: joinPath(URI.parse(value.url), 'v1'),
|
||||
authenticationProviderId: value.authenticationProviderId
|
||||
authenticationProviders: Object.keys(value.authenticationProviders).reduce<IAuthenticationProvider[]>((result, id) => {
|
||||
result.push({ id, scopes: value.authenticationProviders[id].scopes });
|
||||
return result;
|
||||
}, [])
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
@@ -299,6 +316,7 @@ export interface IUserDataSyncEnablementService {
|
||||
|
||||
isEnabled(): boolean;
|
||||
setEnablement(enabled: boolean): void;
|
||||
canToggleEnablement(): boolean;
|
||||
|
||||
isResourceEnabled(resource: SyncResource): boolean;
|
||||
setResourceEnablement(resource: SyncResource, enabled: boolean): void;
|
||||
|
||||
Reference in New Issue
Block a user