mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Have resource deployment providers return disposables (#13690)
* Add dependent field provider to resource deployment * Change name to value provider service * Add error handling * providerId -> id * Set dropdown value correctly * missed id * back to providerId * fix updating missed id * Make resource deployment providers disposable
This commit is contained in:
@@ -67,7 +67,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<arc.IE
|
|||||||
|
|
||||||
// register option sources
|
// register option sources
|
||||||
const rdApi = <rd.IExtension>vscode.extensions.getExtension(rd.extension.name)?.exports;
|
const rdApi = <rd.IExtension>vscode.extensions.getExtension(rd.extension.name)?.exports;
|
||||||
rdApi.registerOptionsSourceProvider(new ArcControllersOptionsSourceProvider(treeDataProvider));
|
context.subscriptions.push(rdApi.registerOptionsSourceProvider(new ArcControllersOptionsSourceProvider(treeDataProvider)));
|
||||||
|
|
||||||
return arcApi(treeDataProvider);
|
return arcApi(treeDataProvider);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<azdata
|
|||||||
|
|
||||||
// register option source(s)
|
// register option source(s)
|
||||||
const rdApi = <rd.IExtension>vscode.extensions.getExtension(rd.extension.name)?.exports;
|
const rdApi = <rd.IExtension>vscode.extensions.getExtension(rd.extension.name)?.exports;
|
||||||
rdApi.registerOptionsSourceProvider(new ArcControllerConfigProfilesOptionsSource(azdataApi));
|
context.subscriptions.push(rdApi.registerOptionsSourceProvider(new ArcControllerConfigProfilesOptionsSource(azdataApi)));
|
||||||
|
|
||||||
return azdataApi;
|
return azdataApi;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<azurec
|
|||||||
// Don't block on this since there's a bit of a circular dependency here with the extension activation since resource deployment
|
// Don't block on this since there's a bit of a circular dependency here with the extension activation since resource deployment
|
||||||
// depends on this extension too. It's fine to wait a bit for that to finish before registering the provider
|
// depends on this extension too. It's fine to wait a bit for that to finish before registering the provider
|
||||||
vscode.extensions.getExtension(resourceDeployment.extension.name).activate().then((api: resourceDeployment.IExtension) => {
|
vscode.extensions.getExtension(resourceDeployment.extension.name).activate().then((api: resourceDeployment.IExtension) => {
|
||||||
api.registerValueProvider({
|
context.subscriptions.push(api.registerValueProvider({
|
||||||
id: 'subscription-id-to-tenant-id',
|
id: 'subscription-id-to-tenant-id',
|
||||||
getValue: async (triggerValue: string) => {
|
getValue: async (triggerValue: string) => {
|
||||||
if (triggerValue === '') {
|
if (triggerValue === '') {
|
||||||
@@ -137,7 +137,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<azurec
|
|||||||
console.error(`Unable to find subscription with ID ${triggerValue} when mapping subscription ID to tenant ID`);
|
console.error(`Unable to find subscription with ID ${triggerValue} when mapping subscription ID to tenant ID`);
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -3,16 +3,24 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import * as vscode from 'vscode';
|
||||||
import * as rd from 'resource-deployment';
|
import * as rd from 'resource-deployment';
|
||||||
import * as loc from '../localizedConstants';
|
import * as loc from '../localizedConstants';
|
||||||
|
|
||||||
class OptionsSourcesService {
|
class OptionsSourcesService {
|
||||||
private _optionsSourceStore = new Map<string, rd.IOptionsSourceProvider>();
|
private _optionsSourceStore = new Map<string, rd.IOptionsSourceProvider>();
|
||||||
registerOptionsSourceProvider(provider: rd.IOptionsSourceProvider): void {
|
registerOptionsSourceProvider(provider: rd.IOptionsSourceProvider): vscode.Disposable {
|
||||||
if (this._optionsSourceStore.has(provider.id)) {
|
if (this._optionsSourceStore.has(provider.id)) {
|
||||||
throw new Error(loc.optionsSourceAlreadyDefined(provider.id));
|
throw new Error(loc.optionsSourceAlreadyDefined(provider.id));
|
||||||
}
|
}
|
||||||
this._optionsSourceStore.set(provider.id, provider);
|
this._optionsSourceStore.set(provider.id, provider);
|
||||||
|
return {
|
||||||
|
dispose: () => this.unregisterOptionsSourceProvider(provider.id)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private unregisterOptionsSourceProvider(providerId: string): void {
|
||||||
|
this._optionsSourceStore.delete(providerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
getOptionsSource(optionsSourceProviderId: string): rd.IOptionsSourceProvider {
|
getOptionsSource(optionsSourceProviderId: string): rd.IOptionsSourceProvider {
|
||||||
|
|||||||
@@ -3,16 +3,24 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import * as vscode from 'vscode';
|
||||||
import * as rd from 'resource-deployment';
|
import * as rd from 'resource-deployment';
|
||||||
import * as loc from '../localizedConstants';
|
import * as loc from '../localizedConstants';
|
||||||
|
|
||||||
class ValueProviderService {
|
class ValueProviderService {
|
||||||
private _valueProviderStore = new Map<string, rd.IValueProvider>();
|
private _valueProviderStore = new Map<string, rd.IValueProvider>();
|
||||||
registerValueProvider(provider: rd.IValueProvider): void {
|
registerValueProvider(provider: rd.IValueProvider): vscode.Disposable {
|
||||||
if (this._valueProviderStore.has(provider.id)) {
|
if (this._valueProviderStore.has(provider.id)) {
|
||||||
throw new Error(loc.valueProviderAlreadyDefined(provider.id));
|
throw new Error(loc.valueProviderAlreadyDefined(provider.id));
|
||||||
}
|
}
|
||||||
this._valueProviderStore.set(provider.id, provider);
|
this._valueProviderStore.set(provider.id, provider);
|
||||||
|
return {
|
||||||
|
dispose: () => this.unregisterValueProvider(provider.id)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private unregisterValueProvider(providerId: string): void {
|
||||||
|
this._valueProviderStore.delete(providerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
getValueProvider(providerId: string): rd.IValueProvider {
|
getValueProvider(providerId: string): rd.IValueProvider {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
declare module 'resource-deployment' {
|
declare module 'resource-deployment' {
|
||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
export const enum ErrorType {
|
export const enum ErrorType {
|
||||||
userCancelled,
|
userCancelled,
|
||||||
@@ -36,7 +37,7 @@ declare module 'resource-deployment' {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export interface IExtension {
|
export interface IExtension {
|
||||||
registerOptionsSourceProvider(provider: IOptionsSourceProvider): void,
|
registerOptionsSourceProvider(provider: IOptionsSourceProvider): vscode.Disposable,
|
||||||
registerValueProvider(provider: IValueProvider): void
|
registerValueProvider(provider: IValueProvider): vscode.Disposable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user