mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Default to current controller when deploying from Arc dashboard (#14409)
This commit is contained in:
@@ -661,7 +661,7 @@
|
|||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"label": "%arc.controller%",
|
"label": "%arc.controller%",
|
||||||
"variableName": "",
|
"variableName": "CONTROLLER_NAME",
|
||||||
"type": "options",
|
"type": "options",
|
||||||
"editable": false,
|
"editable": false,
|
||||||
"required": true,
|
"required": true,
|
||||||
@@ -936,7 +936,7 @@
|
|||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"label": "%arc.controller%",
|
"label": "%arc.controller%",
|
||||||
"variableName": "",
|
"variableName": "CONTROLLER_NAME",
|
||||||
"type": "options",
|
"type": "options",
|
||||||
"editable": false,
|
"editable": false,
|
||||||
"required": true,
|
"required": true,
|
||||||
|
|||||||
@@ -147,7 +147,12 @@ export class ControllerDashboardOverviewPage extends DashboardPage {
|
|||||||
|
|
||||||
this.disposables.push(
|
this.disposables.push(
|
||||||
newInstance.onDidClick(async () => {
|
newInstance.onDidClick(async () => {
|
||||||
await vscode.commands.executeCommand('azdata.resource.deploy', 'azure-sql-mi', ['azure-sql-mi', 'arc.postgres'], { 'azure-sql-mi': { 'mi-type': ['arc-mi'] } });
|
const node = this._controllerModel.treeDataProvider.getControllerNode(this._controllerModel);
|
||||||
|
await vscode.commands.executeCommand('azdata.resource.deploy',
|
||||||
|
'azure-sql-mi', // Default option
|
||||||
|
['azure-sql-mi', 'arc.postgres'], // Type filter
|
||||||
|
{ 'azure-sql-mi': { 'mi-type': ['arc-mi'] } }, // Options filter
|
||||||
|
{ 'CONTROLLER_NAME': node?.label });
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Refresh
|
// Refresh
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as nls from 'vscode-nls';
|
import * as nls from 'vscode-nls';
|
||||||
import { NotebookBasedDialogInfo } from './interfaces';
|
import { InitialVariableValues, NotebookBasedDialogInfo } from './interfaces';
|
||||||
import { NotebookService } from './services/notebookService';
|
import { NotebookService } from './services/notebookService';
|
||||||
import { PlatformService } from './services/platformService';
|
import { PlatformService } from './services/platformService';
|
||||||
import { OptionValuesFilter, ResourceTypeService } from './services/resourceTypeService';
|
import { OptionValuesFilter, ResourceTypeService } from './services/resourceTypeService';
|
||||||
@@ -37,12 +37,12 @@ export async function activate(context: vscode.ExtensionContext): Promise<rd.IEx
|
|||||||
* @param resourceTypeNameFilters Optional filters to apply to the resource types displayed. If undefined all
|
* @param resourceTypeNameFilters Optional filters to apply to the resource types displayed. If undefined all
|
||||||
* resource types will be displayed
|
* resource types will be displayed
|
||||||
*/
|
*/
|
||||||
const openDialog = (defaultResourceTypeName: string, resourceTypeNameFilters?: string[], optionValuesFilter?: OptionValuesFilter) => {
|
const openDialog = (defaultResourceTypeName: string, resourceTypeNameFilters?: string[], optionValuesFilter?: OptionValuesFilter, initialVariableValues?: InitialVariableValues) => {
|
||||||
const defaultResourceType = resourceTypes.find(resourceType => resourceType.name === defaultResourceTypeName);
|
const defaultResourceType = resourceTypes.find(resourceType => resourceType.name === defaultResourceTypeName);
|
||||||
if (!defaultResourceType) {
|
if (!defaultResourceType) {
|
||||||
vscode.window.showErrorMessage(localize('resourceDeployment.UnknownResourceType', "The resource type: {0} is not defined", defaultResourceTypeName));
|
vscode.window.showErrorMessage(localize('resourceDeployment.UnknownResourceType', "The resource type: {0} is not defined", defaultResourceTypeName));
|
||||||
} else {
|
} else {
|
||||||
const dialog = new ResourceTypePickerDialog(resourceTypeService, defaultResourceType, resourceTypeNameFilters, optionValuesFilter);
|
const dialog = new ResourceTypePickerDialog(resourceTypeService, defaultResourceType, resourceTypeNameFilters, optionValuesFilter, initialVariableValues);
|
||||||
dialog.open();
|
dialog.open();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -59,15 +59,17 @@ export async function activate(context: vscode.ExtensionContext): Promise<rd.IEx
|
|||||||
* @param resourceTypeNameFilters - The list of resourceTypes to show in the wizard
|
* @param resourceTypeNameFilters - The list of resourceTypes to show in the wizard
|
||||||
* @param optionValuesFilter - The list of resourceType option values to show in the wizard. This is an object in the format
|
* @param optionValuesFilter - The list of resourceType option values to show in the wizard. This is an object in the format
|
||||||
* { "resource-type-name": { "option-name": ["option-value-1", "option-value-2"] } }
|
* { "resource-type-name": { "option-name": ["option-value-1", "option-value-2"] } }
|
||||||
|
* @param initialVariableValues - Optional list of initial values to assign to variables. This is an object of key/value pairs in the format
|
||||||
|
* { "VARIABLE_NAME": "value", "OTHER_VARIABLE_NAME": "value" }
|
||||||
*/
|
*/
|
||||||
vscode.commands.registerCommand('azdata.resource.deploy', (defaultResourceTypeName?: string, resourceTypeNameFilters?: string[], optionValuesFilter?: OptionValuesFilter) => {
|
vscode.commands.registerCommand('azdata.resource.deploy', (defaultResourceTypeName?: string, resourceTypeNameFilters?: string[], optionValuesFilter?: OptionValuesFilter, initialVariableValues?: InitialVariableValues) => {
|
||||||
if ((resourceTypeNameFilters && !Array.isArray(resourceTypeNameFilters) ||
|
if ((resourceTypeNameFilters && !Array.isArray(resourceTypeNameFilters) ||
|
||||||
(resourceTypeNameFilters && resourceTypeNameFilters.length > 0 && typeof resourceTypeNameFilters[0] !== 'string'))) {
|
(resourceTypeNameFilters && resourceTypeNameFilters.length > 0 && typeof resourceTypeNameFilters[0] !== 'string'))) {
|
||||||
throw new Error('resourceTypeNameFilters must either be undefined or an array of strings');
|
throw new Error('resourceTypeNameFilters must either be undefined or an array of strings');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof defaultResourceTypeName === 'string') {
|
if (typeof defaultResourceTypeName === 'string') {
|
||||||
openDialog(defaultResourceTypeName, resourceTypeNameFilters, optionValuesFilter);
|
openDialog(defaultResourceTypeName, resourceTypeNameFilters, optionValuesFilter, initialVariableValues);
|
||||||
} else {
|
} else {
|
||||||
let defaultDeploymentType: string;
|
let defaultDeploymentType: string;
|
||||||
if (platformService.platform() === 'win32') {
|
if (platformService.platform() === 'win32') {
|
||||||
@@ -75,7 +77,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<rd.IEx
|
|||||||
} else {
|
} else {
|
||||||
defaultDeploymentType = 'sql-image';
|
defaultDeploymentType = 'sql-image';
|
||||||
}
|
}
|
||||||
openDialog(defaultDeploymentType, resourceTypeNameFilters, optionValuesFilter);
|
openDialog(defaultDeploymentType, resourceTypeNameFilters, optionValuesFilter, initialVariableValues);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
vscode.commands.registerCommand('azdata.openNotebookInputDialog', (dialogInfo: NotebookBasedDialogInfo) => {
|
vscode.commands.registerCommand('azdata.openNotebookInputDialog', (dialogInfo: NotebookBasedDialogInfo) => {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export interface OptionValuesFilter {
|
|||||||
export interface IResourceTypeService {
|
export interface IResourceTypeService {
|
||||||
getResourceTypes(filterByPlatform?: boolean): ResourceType[];
|
getResourceTypes(filterByPlatform?: boolean): ResourceType[];
|
||||||
validateResourceTypes(resourceTypes: ResourceType[]): string[];
|
validateResourceTypes(resourceTypes: ResourceType[]): string[];
|
||||||
startDeployment(resourceType: ResourceType, optionValuesFilter?: OptionValuesFilter): void;
|
startDeployment(resourceType: ResourceType, optionValuesFilter?: OptionValuesFilter, initialVariableValues?: InitialVariableValues): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ResourceTypeService implements IResourceTypeService {
|
export class ResourceTypeService implements IResourceTypeService {
|
||||||
|
|||||||
@@ -692,9 +692,14 @@ async function configureOptionsSourceSubfields(context: FieldContext, optionsSou
|
|||||||
function processDropdownOptionsTypeField(context: FieldContext): azdata.DropDownComponent {
|
function processDropdownOptionsTypeField(context: FieldContext): azdata.DropDownComponent {
|
||||||
const label = createLabel(context.view, { text: context.fieldInfo.label, description: context.fieldInfo.description, required: context.fieldInfo.required, width: context.fieldInfo.labelWidth, cssStyles: context.fieldInfo.labelCSSStyles });
|
const label = createLabel(context.view, { text: context.fieldInfo.label, description: context.fieldInfo.description, required: context.fieldInfo.required, width: context.fieldInfo.labelWidth, cssStyles: context.fieldInfo.labelCSSStyles });
|
||||||
const options = context.fieldInfo.options as OptionsInfo;
|
const options = context.fieldInfo.options as OptionsInfo;
|
||||||
|
// If we have an initial value then set it now - otherwise just default to the original default value.
|
||||||
|
// Note we don't currently check that the value actually exists in the list - if it doesn't then it'll
|
||||||
|
// just default to the first one anyways
|
||||||
|
const initialValue = context.fieldInfo.variableName && context.initialVariableValues?.[context.fieldInfo.variableName]?.toString();
|
||||||
|
const defaultValue = initialValue || options.defaultValue;
|
||||||
const dropdown = createDropdownInputInfo(context.view, {
|
const dropdown = createDropdownInputInfo(context.view, {
|
||||||
values: options.values,
|
values: options.values,
|
||||||
defaultValue: options.defaultValue,
|
defaultValue: defaultValue,
|
||||||
width: context.fieldInfo.inputWidth,
|
width: context.fieldInfo.inputWidth,
|
||||||
editable: context.fieldInfo.editable,
|
editable: context.fieldInfo.editable,
|
||||||
required: context.fieldInfo.required,
|
required: context.fieldInfo.required,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
import * as nls from 'vscode-nls';
|
import * as nls from 'vscode-nls';
|
||||||
import { ResourceType } from '../interfaces';
|
import { InitialVariableValues, ResourceType } from '../interfaces';
|
||||||
import { IResourceTypeService, OptionValuesFilter } from '../services/resourceTypeService';
|
import { IResourceTypeService, OptionValuesFilter } from '../services/resourceTypeService';
|
||||||
import * as loc from './../localizedConstants';
|
import * as loc from './../localizedConstants';
|
||||||
import { DialogBase } from './dialogBase';
|
import { DialogBase } from './dialogBase';
|
||||||
@@ -28,7 +28,8 @@ export class ResourceTypePickerDialog extends DialogBase {
|
|||||||
private resourceTypeService: IResourceTypeService,
|
private resourceTypeService: IResourceTypeService,
|
||||||
defaultResourceType: ResourceType,
|
defaultResourceType: ResourceType,
|
||||||
private _resourceTypeNameFilters?: string[],
|
private _resourceTypeNameFilters?: string[],
|
||||||
private _optionValuesFilter?: OptionValuesFilter) {
|
private _optionValuesFilter?: OptionValuesFilter,
|
||||||
|
private _initialVariableValues?: InitialVariableValues) {
|
||||||
super(loc.resourceTypePickerDialogTitle, 'ResourceTypePickerDialog', true);
|
super(loc.resourceTypePickerDialogTitle, 'ResourceTypePickerDialog', true);
|
||||||
this._selectedResourceType = defaultResourceType;
|
this._selectedResourceType = defaultResourceType;
|
||||||
this._dialogObject.okButton.label = loc.select;
|
this._dialogObject.okButton.label = loc.select;
|
||||||
@@ -189,7 +190,7 @@ export class ResourceTypePickerDialog extends DialogBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async onComplete(): Promise<void> {
|
protected async onComplete(): Promise<void> {
|
||||||
this.resourceTypeService.startDeployment(this._selectedResourceType, this._optionValuesFilter);
|
this.resourceTypeService.startDeployment(this._selectedResourceType, this._optionValuesFilter, this._initialVariableValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getAllResourceTags(): string[] {
|
private getAllResourceTags(): string[] {
|
||||||
|
|||||||
Reference in New Issue
Block a user