mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 17:22:42 -05:00
Add SDK style project option to create project from db dialog (#18243)
* add sdk style project template * update description and order * add SDK style project option to create project from db dialog * fix test * switch to checkbox * remove not used string * fix test
This commit is contained in:
@@ -256,6 +256,7 @@ export const folderStructureLabel = localize('folderStructureLabel', "Folder str
|
||||
export const WorkspaceFileExtension = '.code-workspace';
|
||||
export const browseEllipsisWithIcon = `$(folder) ${localize('browseEllipsis', "Browse...")}`;
|
||||
export const selectProjectLocation = localize('selectProjectLocation', "Select project location");
|
||||
export const sdkStyleProject = localize('sdkStyleProject', 'SDK-style project');
|
||||
export const ProjectParentDirectoryNotExistError = (location: string): string => { return localize('dataworkspace.projectParentDirectoryNotExistError', "The selected project location '{0}' does not exist or is not a directory.", location); };
|
||||
export const ProjectDirectoryAlreadyExistError = (projectName: string, location: string): string => { return localize('dataworkspace.projectDirectoryAlreadyExistError', "There is already a directory named '{0}' in the selected location: '{1}'.", projectName, location); };
|
||||
|
||||
|
||||
@@ -1261,7 +1261,7 @@ export class ProjectsController {
|
||||
const newProjFilePath = await this.createNewProject({
|
||||
newProjName: model.projName,
|
||||
folderUri: vscode.Uri.file(newProjFolderUri),
|
||||
projectTypeId: constants.emptySqlDatabaseProjectTypeId
|
||||
projectTypeId: model.sdkStyle ? constants.emptySqlDatabaseSdkProjectTypeId : constants.emptySqlDatabaseProjectTypeId
|
||||
});
|
||||
|
||||
model.filePath = path.dirname(newProjFilePath);
|
||||
@@ -1271,7 +1271,9 @@ export class ProjectsController {
|
||||
await this.createProjectFromDatabaseApiCall(model); // Call ExtractAPI in DacFx Service
|
||||
let fileFolderList: vscode.Uri[] = model.extractTarget === mssql.ExtractTarget.file ? [vscode.Uri.file(model.filePath)] : await this.generateList(model.filePath); // Create a list of all the files and directories to be added to project
|
||||
|
||||
await project.addToProject(fileFolderList); // Add generated file structure to the project
|
||||
if (!model.sdkStyle) {
|
||||
await project.addToProject(fileFolderList); // Add generated file structure to the project
|
||||
}
|
||||
|
||||
// add project to workspace
|
||||
const workspaceApi = utils.getDataWorkspaceExtensionApi();
|
||||
|
||||
@@ -26,6 +26,7 @@ export class CreateProjectFromDatabaseDialog {
|
||||
public projectNameTextBox: azdataType.InputBoxComponent | undefined;
|
||||
public projectLocationTextBox: azdataType.InputBoxComponent | undefined;
|
||||
public folderStructureDropDown: azdataType.DropDownComponent | undefined;
|
||||
public sdkStyleCheckbox: azdataType.CheckBoxComponent | undefined;
|
||||
private formBuilder: azdataType.FormBuilder | undefined;
|
||||
private connectionId: string | undefined;
|
||||
private toDispose: vscode.Disposable[] = [];
|
||||
@@ -85,6 +86,12 @@ export class CreateProjectFromDatabaseDialog {
|
||||
const createProjectSettingsFormSection = view.modelBuilder.flexContainer().withLayout({ flexFlow: 'column' }).component();
|
||||
createProjectSettingsFormSection.addItems([folderStructureRow]);
|
||||
|
||||
// could also potentially be radio buttons once there's a term to refer to "legacy" style sqlprojs
|
||||
this.sdkStyleCheckbox = view.modelBuilder.checkBox().withProps({
|
||||
checked: true,
|
||||
label: constants.sdkStyleProject
|
||||
}).component();
|
||||
|
||||
this.formBuilder = <azdataType.FormBuilder>view.modelBuilder.formContainer()
|
||||
.withFormItems([
|
||||
{
|
||||
@@ -108,6 +115,9 @@ export class CreateProjectFromDatabaseDialog {
|
||||
components: [
|
||||
{
|
||||
component: createProjectSettingsFormSection,
|
||||
},
|
||||
{
|
||||
component: this.sdkStyleCheckbox
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -360,7 +370,8 @@ export class CreateProjectFromDatabaseDialog {
|
||||
projName: this.projectNameTextBox!.value!,
|
||||
filePath: this.projectLocationTextBox!.value!,
|
||||
version: '1.0.0.0',
|
||||
extractTarget: mapExtractTargetEnum(<string>this.folderStructureDropDown!.value)
|
||||
extractTarget: mapExtractTargetEnum(<string>this.folderStructureDropDown!.value),
|
||||
sdkStyle: this.sdkStyleCheckbox?.checked
|
||||
};
|
||||
|
||||
azdataApi!.window.closeDialog(this.dialog);
|
||||
|
||||
@@ -18,4 +18,5 @@ export interface ImportDataModel {
|
||||
filePath: string;
|
||||
version: string;
|
||||
extractTarget: ExtractTarget;
|
||||
sdkStyle?: boolean;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,8 @@ describe('Create Project From Database Dialog', () => {
|
||||
projName: 'testProject',
|
||||
filePath: 'testLocation',
|
||||
version: '1.0.0.0',
|
||||
extractTarget: mssql.ExtractTarget.schemaObjectType
|
||||
extractTarget: mssql.ExtractTarget.schemaObjectType,
|
||||
sdkStyle: true
|
||||
};
|
||||
|
||||
dialog.createProjectFromDatabaseCallback = (m) => { model = m; };
|
||||
|
||||
Reference in New Issue
Block a user