mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Change ReferenceType to ReferencedDatabaseType (#23347)
* change ReferenceType to ReferencedDatabaseType * update string
This commit is contained in:
@@ -319,7 +319,7 @@ export const otherSeverVariable = 'OtherServer';
|
|||||||
export const databaseProject = localize('databaseProject', "Database project");
|
export const databaseProject = localize('databaseProject', "Database project");
|
||||||
export const dacpacMustBeOnSameDrive = localize('dacpacNotOnSameDrive', "Dacpac references need to be located on the same drive as the project file.");
|
export const dacpacMustBeOnSameDrive = localize('dacpacNotOnSameDrive', "Dacpac references need to be located on the same drive as the project file.");
|
||||||
export const dacpacNotOnSameDrive = (projectLocation: string): string => { return localize('dacpacNotOnSameDrive', "Dacpac references need to be located on the same drive as the project file. The project file is located at {0}", projectLocation); };
|
export const dacpacNotOnSameDrive = (projectLocation: string): string => { return localize('dacpacNotOnSameDrive', "Dacpac references need to be located on the same drive as the project file. The project file is located at {0}", projectLocation); };
|
||||||
export const referenceType = localize('referenceType', "Reference type");
|
export const referencedDatabaseType = localize('referencedDatabaseType', "Referenced Database type");
|
||||||
export const excludeFolderNotSupported = localize('excludeFolderNotSupported', "Excluding folders is not yet supported");
|
export const excludeFolderNotSupported = localize('excludeFolderNotSupported', "Excluding folders is not yet supported");
|
||||||
export const unhandledDeleteType = (itemType: string): string => { return localize('unhandledDeleteType', "Unhandled item type during delete: '{0}", itemType); }
|
export const unhandledDeleteType = (itemType: string): string => { return localize('unhandledDeleteType', "Unhandled item type during delete: '{0}", itemType); }
|
||||||
export const unhandledExcludeType = (itemType: string): string => { return localize('unhandledDeleteType', "Unhandled item type during exclude: '{0}", itemType); }
|
export const unhandledExcludeType = (itemType: string): string => { return localize('unhandledDeleteType', "Unhandled item type during exclude: '{0}", itemType); }
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/t
|
|||||||
import { DbServerValues, ensureSetOrDefined, populateResultWithVars } from './utils';
|
import { DbServerValues, ensureSetOrDefined, populateResultWithVars } from './utils';
|
||||||
import { ProjectType } from 'mssql';
|
import { ProjectType } from 'mssql';
|
||||||
|
|
||||||
export enum ReferenceType {
|
export enum ReferencedDatabaseType {
|
||||||
project,
|
project,
|
||||||
systemDb,
|
systemDb,
|
||||||
dacpac,
|
dacpac,
|
||||||
@@ -49,7 +49,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
private projectRadioButton: azdataType.RadioButtonComponent | undefined;
|
private projectRadioButton: azdataType.RadioButtonComponent | undefined;
|
||||||
private systemDatabaseRadioButton: azdataType.RadioButtonComponent | undefined;
|
private systemDatabaseRadioButton: azdataType.RadioButtonComponent | undefined;
|
||||||
|
|
||||||
public currentReferenceType: ReferenceType | undefined;
|
public currentReferencedDatabaseType: ReferencedDatabaseType | undefined;
|
||||||
|
|
||||||
private toDispose: vscode.Disposable[] = [];
|
private toDispose: vscode.Disposable[] = [];
|
||||||
private initDialogComplete: Deferred = new Deferred();
|
private initDialogComplete: Deferred = new Deferred();
|
||||||
@@ -66,7 +66,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
|
|
||||||
validate(): boolean {
|
validate(): boolean {
|
||||||
// only support adding dacpacs that are on the same drive as the sqlproj
|
// only support adding dacpacs that are on the same drive as the sqlproj
|
||||||
if (this.currentReferenceType === ReferenceType.dacpac) {
|
if (this.currentReferencedDatabaseType === ReferencedDatabaseType.dacpac) {
|
||||||
const projectDrive = path.parse(this.project.projectFilePath).root;
|
const projectDrive = path.parse(this.project.projectFilePath).root;
|
||||||
const dacpacDrive = path.parse(this.dacpacTextbox!.value!).root;
|
const dacpacDrive = path.parse(this.dacpacTextbox!.value!).root;
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
title: '',
|
title: '',
|
||||||
components: [
|
components: [
|
||||||
radioButtonGroup,
|
radioButtonGroup,
|
||||||
this.currentReferenceType === ReferenceType.project ? this.projectFormComponent : this.systemDatabaseFormComponent,
|
this.currentReferencedDatabaseType === ReferencedDatabaseType.project ? this.projectFormComponent : this.systemDatabaseFormComponent,
|
||||||
locationDropdown,
|
locationDropdown,
|
||||||
variableSection,
|
variableSection,
|
||||||
exampleUsage,
|
exampleUsage,
|
||||||
@@ -144,7 +144,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
await view.initializeModel(formModel);
|
await view.initializeModel(formModel);
|
||||||
this.updateEnabledInputBoxes();
|
this.updateEnabledInputBoxes();
|
||||||
|
|
||||||
if (this.currentReferenceType === ReferenceType.project) {
|
if (this.currentReferencedDatabaseType === ReferencedDatabaseType.project) {
|
||||||
await this.projectRadioButton?.focus();
|
await this.projectRadioButton?.focus();
|
||||||
} else {
|
} else {
|
||||||
await this.systemDatabaseRadioButton?.focus();
|
await this.systemDatabaseRadioButton?.focus();
|
||||||
@@ -157,7 +157,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
public async addReferenceClick(): Promise<void> {
|
public async addReferenceClick(): Promise<void> {
|
||||||
let referenceSettings: ISystemDatabaseReferenceSettings | IDacpacReferenceSettings | IProjectReferenceSettings | INugetPackageReferenceSettings;
|
let referenceSettings: ISystemDatabaseReferenceSettings | IDacpacReferenceSettings | IProjectReferenceSettings | INugetPackageReferenceSettings;
|
||||||
|
|
||||||
if (this.currentReferenceType === ReferenceType.systemDb) {
|
if (this.currentReferencedDatabaseType === ReferencedDatabaseType.systemDb) {
|
||||||
const systemDbRef: ISystemDatabaseReferenceSettings = {
|
const systemDbRef: ISystemDatabaseReferenceSettings = {
|
||||||
databaseVariableLiteralValue: <string>this.databaseNameTextbox?.value,
|
databaseVariableLiteralValue: <string>this.databaseNameTextbox?.value,
|
||||||
systemDb: utils.getSystemDatabase(<string>this.systemDatabaseDropdown?.value),
|
systemDb: utils.getSystemDatabase(<string>this.systemDatabaseDropdown?.value),
|
||||||
@@ -166,7 +166,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
|
|
||||||
referenceSettings = systemDbRef;
|
referenceSettings = systemDbRef;
|
||||||
} else {
|
} else {
|
||||||
if (this.currentReferenceType === ReferenceType.project) {
|
if (this.currentReferencedDatabaseType === ReferencedDatabaseType.project) {
|
||||||
const projRef: IProjectReferenceSettings = {
|
const projRef: IProjectReferenceSettings = {
|
||||||
projectName: <string>this.projectDropdown?.value,
|
projectName: <string>this.projectDropdown?.value,
|
||||||
projectGuid: '',
|
projectGuid: '',
|
||||||
@@ -175,7 +175,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
};
|
};
|
||||||
|
|
||||||
referenceSettings = projRef;
|
referenceSettings = projRef;
|
||||||
} else if (this.currentReferenceType === ReferenceType.dacpac) {
|
} else if (this.currentReferencedDatabaseType === ReferencedDatabaseType.dacpac) {
|
||||||
const dacpacRef: IDacpacReferenceSettings = {
|
const dacpacRef: IDacpacReferenceSettings = {
|
||||||
databaseName: ensureSetOrDefined(this.databaseNameTextbox?.value),
|
databaseName: ensureSetOrDefined(this.databaseNameTextbox?.value),
|
||||||
dacpacFileLocation: vscode.Uri.file(<string>this.dacpacTextbox?.value),
|
dacpacFileLocation: vscode.Uri.file(<string>this.dacpacTextbox?.value),
|
||||||
@@ -183,7 +183,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
};
|
};
|
||||||
|
|
||||||
referenceSettings = dacpacRef;
|
referenceSettings = dacpacRef;
|
||||||
} else { // this.currentReferenceType === ReferenceType.nupkg
|
} else { // this.currentReferencedDatabaseType === ReferencedDatabaseType.nupkg
|
||||||
const nupkgRef: INugetPackageReferenceSettings = {
|
const nupkgRef: INugetPackageReferenceSettings = {
|
||||||
packageName: <string>this.nupkgNameTextbox?.value,
|
packageName: <string>this.nupkgNameTextbox?.value,
|
||||||
packageVersion: <string>this.nupkgVersionTextbox?.value,
|
packageVersion: <string>this.nupkgVersionTextbox?.value,
|
||||||
@@ -204,7 +204,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TelemetryReporter.createActionEvent(TelemetryViews.ProjectTree, TelemetryActions.addDatabaseReference)
|
TelemetryReporter.createActionEvent(TelemetryViews.ProjectTree, TelemetryActions.addDatabaseReference)
|
||||||
.withAdditionalProperties({ referenceType: this.currentReferenceType!.toString() })
|
.withAdditionalProperties({ referencedDatabaseType: this.currentReferencedDatabaseType!.toString() })
|
||||||
.send();
|
.send();
|
||||||
|
|
||||||
await this.addReference!(this.project, referenceSettings);
|
await this.addReference!(this.project, referenceSettings);
|
||||||
@@ -215,7 +215,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
private createRadioButtons(): azdataType.FormComponent {
|
private createRadioButtons(): azdataType.FormComponent {
|
||||||
this.projectRadioButton = this.view!.modelBuilder.radioButton()
|
this.projectRadioButton = this.view!.modelBuilder.radioButton()
|
||||||
.withProps({
|
.withProps({
|
||||||
name: 'referenceType',
|
name: 'referencedDatabaseType',
|
||||||
label: constants.projectLabel
|
label: constants.projectLabel
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
@@ -227,7 +227,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
|
|
||||||
this.systemDatabaseRadioButton = this.view!.modelBuilder.radioButton()
|
this.systemDatabaseRadioButton = this.view!.modelBuilder.radioButton()
|
||||||
.withProps({
|
.withProps({
|
||||||
name: 'referenceType',
|
name: 'referencedDatabaseType',
|
||||||
label: constants.systemDatabase
|
label: constants.systemDatabase
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
@@ -239,7 +239,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
|
|
||||||
const dacpacRadioButton = this.view!.modelBuilder.radioButton()
|
const dacpacRadioButton = this.view!.modelBuilder.radioButton()
|
||||||
.withProps({
|
.withProps({
|
||||||
name: 'referenceType',
|
name: 'referencedDatabaseType',
|
||||||
label: constants.dacpacText
|
label: constants.dacpacText
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
|
|
||||||
const nupkgRadioButton = this.view!.modelBuilder.radioButton()
|
const nupkgRadioButton = this.view!.modelBuilder.radioButton()
|
||||||
.withProps({
|
.withProps({
|
||||||
name: 'referenceType',
|
name: 'referencedDatabaseType',
|
||||||
label: constants.nupkgText
|
label: constants.nupkgText
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
@@ -263,10 +263,10 @@ export class AddDatabaseReferenceDialog {
|
|||||||
|
|
||||||
if (this.projectDropdown?.values?.length) {
|
if (this.projectDropdown?.values?.length) {
|
||||||
this.projectRadioButton.checked = true;
|
this.projectRadioButton.checked = true;
|
||||||
this.currentReferenceType = ReferenceType.project;
|
this.currentReferencedDatabaseType = ReferencedDatabaseType.project;
|
||||||
} else {
|
} else {
|
||||||
this.systemDatabaseRadioButton.checked = true;
|
this.systemDatabaseRadioButton.checked = true;
|
||||||
this.currentReferenceType = ReferenceType.systemDb;
|
this.currentReferencedDatabaseType = ReferencedDatabaseType.systemDb;
|
||||||
|
|
||||||
// disable projects radio button if there aren't any projects that can be added as a reference
|
// disable projects radio button if there aren't any projects that can be added as a reference
|
||||||
this.projectRadioButton.enabled = false;
|
this.projectRadioButton.enabled = false;
|
||||||
@@ -299,7 +299,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
|
|
||||||
this.locationDropdown!.values = constants.locationDropdownValues;
|
this.locationDropdown!.values = constants.locationDropdownValues;
|
||||||
|
|
||||||
this.currentReferenceType = ReferenceType.project;
|
this.currentReferencedDatabaseType = ReferencedDatabaseType.project;
|
||||||
this.updateEnabledInputBoxes();
|
this.updateEnabledInputBoxes();
|
||||||
this.tryEnableAddReferenceButton();
|
this.tryEnableAddReferenceButton();
|
||||||
this.updateExampleUsage();
|
this.updateExampleUsage();
|
||||||
@@ -315,7 +315,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
this.locationDropdown!.values = constants.systemDbLocationDropdownValues;
|
this.locationDropdown!.values = constants.systemDbLocationDropdownValues;
|
||||||
this.locationDropdown!.value = constants.differentDbSameServer;
|
this.locationDropdown!.value = constants.differentDbSameServer;
|
||||||
|
|
||||||
this.currentReferenceType = ReferenceType.systemDb;
|
this.currentReferencedDatabaseType = ReferencedDatabaseType.systemDb;
|
||||||
this.updateEnabledInputBoxes();
|
this.updateEnabledInputBoxes();
|
||||||
this.tryEnableAddReferenceButton();
|
this.tryEnableAddReferenceButton();
|
||||||
this.updateExampleUsage();
|
this.updateExampleUsage();
|
||||||
@@ -329,7 +329,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
|
|
||||||
this.locationDropdown!.values = constants.locationDropdownValues;
|
this.locationDropdown!.values = constants.locationDropdownValues;
|
||||||
|
|
||||||
this.currentReferenceType = ReferenceType.dacpac;
|
this.currentReferencedDatabaseType = ReferencedDatabaseType.dacpac;
|
||||||
this.updateEnabledInputBoxes();
|
this.updateEnabledInputBoxes();
|
||||||
this.tryEnableAddReferenceButton();
|
this.tryEnableAddReferenceButton();
|
||||||
this.updateExampleUsage();
|
this.updateExampleUsage();
|
||||||
@@ -343,7 +343,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
|
|
||||||
this.locationDropdown!.values = constants.locationDropdownValues;
|
this.locationDropdown!.values = constants.locationDropdownValues;
|
||||||
|
|
||||||
this.currentReferenceType = ReferenceType.nupkg;
|
this.currentReferencedDatabaseType = ReferencedDatabaseType.nupkg;
|
||||||
this.updateEnabledInputBoxes();
|
this.updateEnabledInputBoxes();
|
||||||
this.tryEnableAddReferenceButton();
|
this.tryEnableAddReferenceButton();
|
||||||
this.updateExampleUsage();
|
this.updateExampleUsage();
|
||||||
@@ -462,7 +462,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
private createLocationDropdown(): azdataType.FormComponent {
|
private createLocationDropdown(): azdataType.FormComponent {
|
||||||
this.locationDropdown = this.view!.modelBuilder.dropDown().withProps({
|
this.locationDropdown = this.view!.modelBuilder.dropDown().withProps({
|
||||||
ariaLabel: constants.location,
|
ariaLabel: constants.location,
|
||||||
values: this.currentReferenceType === ReferenceType.systemDb ? constants.systemDbLocationDropdownValues : constants.locationDropdownValues
|
values: this.currentReferencedDatabaseType === ReferencedDatabaseType.systemDb ? constants.systemDbLocationDropdownValues : constants.locationDropdownValues
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
this.locationDropdown.value = constants.differentDbSameServer;
|
this.locationDropdown.value = constants.differentDbSameServer;
|
||||||
@@ -483,7 +483,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
* Update the enabled input boxes based on what the location of the database reference selected in the dropdown is
|
* Update the enabled input boxes based on what the location of the database reference selected in the dropdown is
|
||||||
*/
|
*/
|
||||||
public updateEnabledInputBoxes(): void {
|
public updateEnabledInputBoxes(): void {
|
||||||
const isSystemDb = this.currentReferenceType === ReferenceType.systemDb;
|
const isSystemDb = this.currentReferencedDatabaseType === ReferencedDatabaseType.systemDb;
|
||||||
|
|
||||||
if (this.locationDropdown?.value === constants.sameDatabase) {
|
if (this.locationDropdown?.value === constants.sameDatabase) {
|
||||||
this.databaseNameTextbox!.enabled = false;
|
this.databaseNameTextbox!.enabled = false;
|
||||||
@@ -527,23 +527,23 @@ export class AddDatabaseReferenceDialog {
|
|||||||
*/
|
*/
|
||||||
private setDefaultDatabaseValues(): void {
|
private setDefaultDatabaseValues(): void {
|
||||||
if (this.databaseNameTextbox!.enabled) {
|
if (this.databaseNameTextbox!.enabled) {
|
||||||
switch (this.currentReferenceType) {
|
switch (this.currentReferencedDatabaseType) {
|
||||||
case ReferenceType.project: {
|
case ReferencedDatabaseType.project: {
|
||||||
this.databaseNameTextbox!.value = <string>this.projectDropdown?.value;
|
this.databaseNameTextbox!.value = <string>this.projectDropdown?.value;
|
||||||
this.databaseVariableTextbox!.value = `${this.projectDropdown?.value}`;
|
this.databaseVariableTextbox!.value = `${this.projectDropdown?.value}`;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ReferenceType.systemDb: {
|
case ReferencedDatabaseType.systemDb: {
|
||||||
this.databaseNameTextbox!.value = <string>this.systemDatabaseDropdown?.value;
|
this.databaseNameTextbox!.value = <string>this.systemDatabaseDropdown?.value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ReferenceType.dacpac: {
|
case ReferencedDatabaseType.dacpac: {
|
||||||
const dacpacName = this.dacpacTextbox!.value ? path.parse(this.dacpacTextbox!.value!).name : '';
|
const dacpacName = this.dacpacTextbox!.value ? path.parse(this.dacpacTextbox!.value!).name : '';
|
||||||
this.databaseNameTextbox!.value = dacpacName;
|
this.databaseNameTextbox!.value = dacpacName;
|
||||||
this.databaseVariableTextbox!.value = dacpacName ? `${dacpacName}` : '';
|
this.databaseVariableTextbox!.value = dacpacName ? `${dacpacName}` : '';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ReferenceType.nupkg: {
|
case ReferencedDatabaseType.nupkg: {
|
||||||
const nupkgName = this.nupkgNameTextbox!.value ? path.parse(this.nupkgNameTextbox!.value!).name : '';
|
const nupkgName = this.nupkgNameTextbox!.value ? path.parse(this.nupkgNameTextbox!.value!).name : '';
|
||||||
this.databaseNameTextbox!.value = nupkgName;
|
this.databaseNameTextbox!.value = nupkgName;
|
||||||
this.databaseVariableTextbox!.value = nupkgName ? `${nupkgName}` : '';
|
this.databaseVariableTextbox!.value = nupkgName ? `${nupkgName}` : '';
|
||||||
@@ -607,7 +607,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
|
|
||||||
private createExampleUsage(): azdataType.FormComponent {
|
private createExampleUsage(): azdataType.FormComponent {
|
||||||
this.exampleUsage = this.view!.modelBuilder.text().withProps({
|
this.exampleUsage = this.view!.modelBuilder.text().withProps({
|
||||||
value: this.currentReferenceType === ReferenceType.project ? constants.databaseNameRequiredVariableOptional : constants.systemDatabaseReferenceRequired,
|
value: this.currentReferencedDatabaseType === ReferencedDatabaseType.project ? constants.databaseNameRequiredVariableOptional : constants.systemDatabaseReferenceRequired,
|
||||||
CSSStyles: { 'user-select': 'text' }
|
CSSStyles: { 'user-select': 'text' }
|
||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
@@ -630,7 +630,7 @@ export class AddDatabaseReferenceDialog {
|
|||||||
}
|
}
|
||||||
case constants.differentDbSameServer: {
|
case constants.differentDbSameServer: {
|
||||||
if (!this.databaseNameTextbox?.value) {
|
if (!this.databaseNameTextbox?.value) {
|
||||||
newText = this.currentReferenceType === ReferenceType.systemDb ? constants.enterSystemDbName : constants.databaseNameRequiredVariableOptional;
|
newText = this.currentReferencedDatabaseType === ReferencedDatabaseType.systemDb ? constants.enterSystemDbName : constants.databaseNameRequiredVariableOptional;
|
||||||
fontStyle = cssStyles.fontStyle.italics;
|
fontStyle = cssStyles.fontStyle.italics;
|
||||||
} else {
|
} else {
|
||||||
const db = this.databaseVariableTextbox?.value ? utils.formatSqlCmdVariable(this.databaseVariableTextbox?.value) : this.databaseNameTextbox.value;
|
const db = this.databaseVariableTextbox?.value ? utils.formatSqlCmdVariable(this.databaseVariableTextbox?.value) : this.databaseNameTextbox.value;
|
||||||
@@ -673,20 +673,20 @@ export class AddDatabaseReferenceDialog {
|
|||||||
* Only enable Add reference button if all enabled fields are filled
|
* Only enable Add reference button if all enabled fields are filled
|
||||||
*/
|
*/
|
||||||
public tryEnableAddReferenceButton(): void {
|
public tryEnableAddReferenceButton(): void {
|
||||||
switch (this.currentReferenceType) {
|
switch (this.currentReferencedDatabaseType) {
|
||||||
case ReferenceType.project: {
|
case ReferencedDatabaseType.project: {
|
||||||
this.dialog.okButton.enabled = this.projectRequiredFieldsFilled();
|
this.dialog.okButton.enabled = this.projectRequiredFieldsFilled();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ReferenceType.systemDb: {
|
case ReferencedDatabaseType.systemDb: {
|
||||||
this.dialog.okButton.enabled = !!this.databaseNameTextbox?.value;
|
this.dialog.okButton.enabled = !!this.databaseNameTextbox?.value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ReferenceType.dacpac: {
|
case ReferencedDatabaseType.dacpac: {
|
||||||
this.dialog.okButton.enabled = this.dacpacRequiredFieldsFilled();
|
this.dialog.okButton.enabled = this.dacpacRequiredFieldsFilled();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ReferenceType.nupkg: {
|
case ReferencedDatabaseType.nupkg: {
|
||||||
this.dialog.okButton.enabled = this.nupkgRequiredFieldsFilled();
|
this.dialog.okButton.enabled = this.nupkgRequiredFieldsFilled();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,24 +26,24 @@ export async function addDatabaseReferenceQuickpick(project: Project): Promise<A
|
|||||||
|
|
||||||
// 1. Prompt for reference type
|
// 1. Prompt for reference type
|
||||||
// Only show project option if we have at least one other project in the workspace
|
// Only show project option if we have at least one other project in the workspace
|
||||||
const referenceTypes = otherProjectsInWorkspace.length > 0 ?
|
const referencedDatabaseTypes = otherProjectsInWorkspace.length > 0 ?
|
||||||
[constants.projectLabel, constants.systemDatabase, constants.dacpacText] :
|
[constants.projectLabel, constants.systemDatabase, constants.dacpacText] :
|
||||||
[constants.systemDatabase, constants.dacpacText];
|
[constants.systemDatabase, constants.dacpacText];
|
||||||
|
|
||||||
// only add nupkg database reference option if project is SDK-style
|
// only add nupkg database reference option if project is SDK-style
|
||||||
if (project.sqlProjStyle === ProjectType.SdkStyle) {
|
if (project.sqlProjStyle === ProjectType.SdkStyle) {
|
||||||
referenceTypes.push(constants.nupkgText);
|
referencedDatabaseTypes.push(constants.nupkgText);
|
||||||
}
|
}
|
||||||
|
|
||||||
const referenceType = await vscode.window.showQuickPick(
|
const referencedDatabaseType = await vscode.window.showQuickPick(
|
||||||
referenceTypes,
|
referencedDatabaseTypes,
|
||||||
{ title: constants.referenceType, ignoreFocusOut: true });
|
{ title: constants.referencedDatabaseType, ignoreFocusOut: true });
|
||||||
if (!referenceType) {
|
if (!referencedDatabaseType) {
|
||||||
// User cancelled
|
// User cancelled
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (referenceType) {
|
switch (referencedDatabaseType) {
|
||||||
case constants.projectLabel:
|
case constants.projectLabel:
|
||||||
return addProjectReference(otherProjectsInWorkspace);
|
return addProjectReference(otherProjectsInWorkspace);
|
||||||
case constants.systemDatabase:
|
case constants.systemDatabase:
|
||||||
@@ -53,7 +53,7 @@ export async function addDatabaseReferenceQuickpick(project: Project): Promise<A
|
|||||||
case constants.nupkgText:
|
case constants.nupkgText:
|
||||||
return addNupkgReference();
|
return addNupkgReference();
|
||||||
default:
|
default:
|
||||||
console.log(`Unknown reference type ${referenceType}`);
|
console.log(`Unknown referenced database type ${referencedDatabaseType}`);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@ async function addProjectReference(otherProjectsInWorkspace: vscode.Uri[]): Prom
|
|||||||
referenceSettings.suppressMissingDependenciesErrors = suppressErrors;
|
referenceSettings.suppressMissingDependenciesErrors = suppressErrors;
|
||||||
|
|
||||||
TelemetryReporter.createActionEvent(TelemetryViews.ProjectTree, TelemetryActions.addDatabaseReference)
|
TelemetryReporter.createActionEvent(TelemetryViews.ProjectTree, TelemetryActions.addDatabaseReference)
|
||||||
.withAdditionalProperties({ referenceType: constants.projectLabel })
|
.withAdditionalProperties({ referencedDatabaseType: constants.projectLabel })
|
||||||
.send();
|
.send();
|
||||||
|
|
||||||
return referenceSettings;
|
return referenceSettings;
|
||||||
@@ -131,7 +131,7 @@ async function addSystemDatabaseReference(project: Project): Promise<ISystemData
|
|||||||
const suppressErrors = await promptSuppressUnresolvedRefErrors();
|
const suppressErrors = await promptSuppressUnresolvedRefErrors();
|
||||||
|
|
||||||
TelemetryReporter.createActionEvent(TelemetryViews.ProjectTree, TelemetryActions.addDatabaseReference)
|
TelemetryReporter.createActionEvent(TelemetryViews.ProjectTree, TelemetryActions.addDatabaseReference)
|
||||||
.withAdditionalProperties({ referenceType: constants.systemDatabase })
|
.withAdditionalProperties({ referencedDatabaseType: constants.systemDatabase })
|
||||||
.send();
|
.send();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -202,7 +202,7 @@ async function addDacpacReference(project: Project): Promise<IDacpacReferenceSet
|
|||||||
populateResultWithVars(referenceSettings, dbServerValues);
|
populateResultWithVars(referenceSettings, dbServerValues);
|
||||||
|
|
||||||
TelemetryReporter.createActionEvent(TelemetryViews.ProjectTree, TelemetryActions.addDatabaseReference)
|
TelemetryReporter.createActionEvent(TelemetryViews.ProjectTree, TelemetryActions.addDatabaseReference)
|
||||||
.withAdditionalProperties({ referenceType: constants.dacpacText })
|
.withAdditionalProperties({ referencedDatabaseType: constants.dacpacText })
|
||||||
.send();
|
.send();
|
||||||
|
|
||||||
return referenceSettings;
|
return referenceSettings;
|
||||||
@@ -271,7 +271,7 @@ async function addNupkgReference(): Promise<INugetPackageReferenceSettings | und
|
|||||||
populateResultWithVars(referenceSettings, dbServerValues);
|
populateResultWithVars(referenceSettings, dbServerValues);
|
||||||
|
|
||||||
TelemetryReporter.createActionEvent(TelemetryViews.ProjectTree, TelemetryActions.addDatabaseReference)
|
TelemetryReporter.createActionEvent(TelemetryViews.ProjectTree, TelemetryActions.addDatabaseReference)
|
||||||
.withAdditionalProperties({ referenceType: constants.nupkgText })
|
.withAdditionalProperties({ referencedDatabaseType: constants.nupkgText })
|
||||||
.send();
|
.send();
|
||||||
|
|
||||||
return referenceSettings;
|
return referenceSettings;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import * as baselines from '../baselines/baselines';
|
|||||||
import * as templates from '../../templates/templates';
|
import * as templates from '../../templates/templates';
|
||||||
import * as testUtils from '../testUtils';
|
import * as testUtils from '../testUtils';
|
||||||
import * as constants from '../../common/constants';
|
import * as constants from '../../common/constants';
|
||||||
import { AddDatabaseReferenceDialog, ReferenceType } from '../../dialogs/addDatabaseReferenceDialog';
|
import { AddDatabaseReferenceDialog, ReferencedDatabaseType } from '../../dialogs/addDatabaseReferenceDialog';
|
||||||
|
|
||||||
describe('Add Database Reference Dialog', () => {
|
describe('Add Database Reference Dialog', () => {
|
||||||
before(async function (): Promise<void> {
|
before(async function (): Promise<void> {
|
||||||
@@ -58,7 +58,7 @@ describe('Add Database Reference Dialog', () => {
|
|||||||
await dialog.openDialog();
|
await dialog.openDialog();
|
||||||
|
|
||||||
should(dialog.dialog.okButton.enabled).equal(true, 'Ok button should be enabled since initial type of systemDb has default values filled');
|
should(dialog.dialog.okButton.enabled).equal(true, 'Ok button should be enabled since initial type of systemDb has default values filled');
|
||||||
should(dialog.currentReferenceType).equal(ReferenceType.systemDb);
|
should(dialog.currentReferencedDatabaseType).equal(ReferencedDatabaseType.systemDb);
|
||||||
|
|
||||||
// empty db name textbox
|
// empty db name textbox
|
||||||
dialog.databaseNameTextbox!.value = '';
|
dialog.databaseNameTextbox!.value = '';
|
||||||
@@ -72,7 +72,7 @@ describe('Add Database Reference Dialog', () => {
|
|||||||
|
|
||||||
// change to dacpac reference
|
// change to dacpac reference
|
||||||
dialog.dacpacRadioButtonClick();
|
dialog.dacpacRadioButtonClick();
|
||||||
should(dialog.currentReferenceType).equal(ReferenceType.dacpac);
|
should(dialog.currentReferencedDatabaseType).equal(ReferencedDatabaseType.dacpac);
|
||||||
should(dialog.locationDropdown?.value).equal(constants.differentDbSameServer);
|
should(dialog.locationDropdown?.value).equal(constants.differentDbSameServer);
|
||||||
should(dialog.databaseNameTextbox!.value).equal('', 'database name text box should be empty because no dacpac has been selected');
|
should(dialog.databaseNameTextbox!.value).equal('', 'database name text box should be empty because no dacpac has been selected');
|
||||||
should(dialog.dialog.okButton.enabled).equal(false, 'Ok button should not be enabled because dacpac input box is not filled');
|
should(dialog.dialog.okButton.enabled).equal(false, 'Ok button should not be enabled because dacpac input box is not filled');
|
||||||
@@ -117,12 +117,12 @@ describe('Add Database Reference Dialog', () => {
|
|||||||
await dialog.openDialog();
|
await dialog.openDialog();
|
||||||
|
|
||||||
// dialog starts with system db because there aren't any other projects in the workspace
|
// dialog starts with system db because there aren't any other projects in the workspace
|
||||||
should(dialog.currentReferenceType).equal(ReferenceType.systemDb);
|
should(dialog.currentReferencedDatabaseType).equal(ReferencedDatabaseType.systemDb);
|
||||||
validateInputBoxEnabledStates(dialog, { databaseNameEnabled: true, databaseVariableEnabled: false, serverNameEnabled: false, serverVariabledEnabled: false });
|
validateInputBoxEnabledStates(dialog, { databaseNameEnabled: true, databaseVariableEnabled: false, serverNameEnabled: false, serverVariabledEnabled: false });
|
||||||
|
|
||||||
// change to dacpac reference
|
// change to dacpac reference
|
||||||
dialog.dacpacRadioButtonClick();
|
dialog.dacpacRadioButtonClick();
|
||||||
should(dialog.currentReferenceType).equal(ReferenceType.dacpac);
|
should(dialog.currentReferencedDatabaseType).equal(ReferencedDatabaseType.dacpac);
|
||||||
should(dialog.locationDropdown!.value).equal(constants.differentDbSameServer);
|
should(dialog.locationDropdown!.value).equal(constants.differentDbSameServer);
|
||||||
validateInputBoxEnabledStates(dialog, { databaseNameEnabled: true, databaseVariableEnabled: true, serverNameEnabled: false, serverVariabledEnabled: false });
|
validateInputBoxEnabledStates(dialog, { databaseNameEnabled: true, databaseVariableEnabled: true, serverNameEnabled: false, serverVariabledEnabled: false });
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ describe('Add Database Reference Dialog', () => {
|
|||||||
|
|
||||||
// change to project reference
|
// change to project reference
|
||||||
dialog.projectRadioButtonClick();
|
dialog.projectRadioButtonClick();
|
||||||
should(dialog.currentReferenceType).equal(ReferenceType.project);
|
should(dialog.currentReferencedDatabaseType).equal(ReferencedDatabaseType.project);
|
||||||
should(dialog.locationDropdown!.value).equal(constants.sameDatabase);
|
should(dialog.locationDropdown!.value).equal(constants.sameDatabase);
|
||||||
validateInputBoxEnabledStates(dialog, { databaseNameEnabled: false, databaseVariableEnabled: false, serverNameEnabled: false, serverVariabledEnabled: false });
|
validateInputBoxEnabledStates(dialog, { databaseNameEnabled: false, databaseVariableEnabled: false, serverNameEnabled: false, serverVariabledEnabled: false });
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user