mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-02 01:25:39 -05:00
Add context menu entries for deleting a database (#22948)
This commit is contained in:
82
extensions/mssql/src/objectManagement/ui/databaseDialog.ts
Normal file
82
extensions/mssql/src/objectManagement/ui/databaseDialog.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import { ObjectManagementDialogBase, ObjectManagementDialogOptions } from './objectManagementDialogBase';
|
||||
import { IObjectManagementService, ObjectManagement } from 'mssql';
|
||||
import * as localizedConstants from '../localizedConstants';
|
||||
import { CreateDatabaseDocUrl } from '../constants';
|
||||
|
||||
export class DatabaseDialog extends ObjectManagementDialogBase<ObjectManagement.Database, ObjectManagement.DatabaseViewInfo> {
|
||||
private _nameInput: azdata.InputBoxComponent;
|
||||
|
||||
constructor(objectManagementService: IObjectManagementService, options: ObjectManagementDialogOptions) {
|
||||
super(objectManagementService, options);
|
||||
}
|
||||
|
||||
protected override get helpUrl(): string {
|
||||
return CreateDatabaseDocUrl;
|
||||
}
|
||||
|
||||
protected async initializeUI(): Promise<void> {
|
||||
let generalSection = this.initializeGeneralSection();
|
||||
let optionsSection = this.initializeOptionsSection();
|
||||
this.formContainer.addItems([generalSection, optionsSection]);
|
||||
}
|
||||
|
||||
private initializeGeneralSection(): azdata.GroupContainer {
|
||||
let containers: azdata.Component[] = [];
|
||||
this._nameInput = this.createInputBox(localizedConstants.NameText, async () => {
|
||||
this.objectInfo.name = this._nameInput.value;
|
||||
await this.runValidation(false);
|
||||
});
|
||||
containers.push(this.createLabelInputContainer(localizedConstants.NameText, this._nameInput));
|
||||
|
||||
if (this.viewInfo.loginNames?.length > 0) {
|
||||
let ownerDropbox = this.createDropdown(localizedConstants.OwnerText, async () => {
|
||||
this.objectInfo.owner = ownerDropbox.value as string;
|
||||
}, this.viewInfo.loginNames, this.viewInfo.loginNames[0]);
|
||||
containers.push(this.createLabelInputContainer(localizedConstants.OwnerText, ownerDropbox));
|
||||
}
|
||||
|
||||
return this.createGroup(localizedConstants.GeneralSectionHeader, containers, false);
|
||||
}
|
||||
|
||||
private initializeOptionsSection(): azdata.GroupContainer {
|
||||
let containers: azdata.Component[] = [];
|
||||
if (this.viewInfo.collationNames?.length > 0) {
|
||||
let collationDropbox = this.createDropdown(localizedConstants.CollationText, async () => {
|
||||
this.objectInfo.collationName = collationDropbox.value as string;
|
||||
}, this.viewInfo.collationNames, this.viewInfo.collationNames[0]);
|
||||
containers.push(this.createLabelInputContainer(localizedConstants.CollationText, collationDropbox));
|
||||
}
|
||||
|
||||
if (this.viewInfo.recoveryModels?.length > 0) {
|
||||
this.objectInfo.recoveryModel = this.viewInfo.recoveryModels[0];
|
||||
let recoveryDropbox = this.createDropdown(localizedConstants.RecoveryModelText, async () => {
|
||||
this.objectInfo.recoveryModel = recoveryDropbox.value as string;
|
||||
}, this.viewInfo.recoveryModels, this.viewInfo.recoveryModels[0]);
|
||||
containers.push(this.createLabelInputContainer(localizedConstants.RecoveryModelText, recoveryDropbox));
|
||||
}
|
||||
|
||||
if (this.viewInfo.compatibilityLevels?.length > 0) {
|
||||
this.objectInfo.compatibilityLevel = this.viewInfo.compatibilityLevels[0];
|
||||
let compatibilityDropbox = this.createDropdown(localizedConstants.CompatibilityLevelText, async () => {
|
||||
this.objectInfo.compatibilityLevel = compatibilityDropbox.value as string;
|
||||
}, this.viewInfo.compatibilityLevels, this.viewInfo.compatibilityLevels[0]);
|
||||
containers.push(this.createLabelInputContainer(localizedConstants.CompatibilityLevelText, compatibilityDropbox));
|
||||
}
|
||||
|
||||
if (this.viewInfo.containmentTypes?.length > 0) {
|
||||
this.objectInfo.containmentType = this.viewInfo.containmentTypes[0];
|
||||
let containmentDropbox = this.createDropdown(localizedConstants.ContainmentTypeText, async () => {
|
||||
this.objectInfo.containmentType = containmentDropbox.value as string;
|
||||
}, this.viewInfo.containmentTypes, this.viewInfo.containmentTypes[0]);
|
||||
containers.push(this.createLabelInputContainer(localizedConstants.ContainmentTypeText, containmentDropbox));
|
||||
}
|
||||
|
||||
return this.createGroup(localizedConstants.OptionsSectionHeader, containers, true, true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user