Auto increment new db project name (#11882)

* auto increment db proj name

* auto increment on import project from db

* adding separate message if workspace setting is invalid

* updating based on feedback

* adding do not ask again functionality

* moving constants

* making newprojecttool only top level functions

* adding tests

* updating to address merge conflicts

* fixing tests

* fixing tests
This commit is contained in:
anjalia
2020-08-26 12:14:51 -07:00
committed by GitHub
parent a3121c0b2d
commit f7279cb1f5
7 changed files with 210 additions and 7 deletions

View File

@@ -9,6 +9,7 @@ import * as templates from '../templates/templates';
import * as constants from '../common/constants';
import * as path from 'path';
import * as glob from 'fast-glob';
import * as newProjectTool from '../tools/newProjectTool';
import { SqlDatabaseProjectTreeViewProvider } from './databaseProjectTreeViewProvider';
import { getErrorMessage } from '../common/utils';
@@ -89,6 +90,9 @@ export default class MainController implements vscode.Disposable {
// ensure .net core is installed
await this.netcoreTool.findOrInstallNetCore();
// set the user settings around saving new projects to default value
await newProjectTool.initializeSaveLocationSetting();
// load any sql projects that are open in workspace folder
await this.loadProjectsInWorkspace();
}
@@ -144,8 +148,7 @@ export default class MainController implements vscode.Disposable {
try {
let newProjName = await vscode.window.showInputBox({
prompt: constants.newDatabaseProjectName,
value: `DatabaseProject${this.projectsController.projects.length + 1}`
// TODO: Smarter way to suggest a name. Easy if we prompt for location first, but that feels odd...
value: newProjectTool.defaultProjectNameNewProj()
});
newProjName = newProjName?.trim();
@@ -160,7 +163,7 @@ export default class MainController implements vscode.Disposable {
canSelectFiles: false,
canSelectFolders: true,
canSelectMany: false,
defaultUri: vscode.workspace.workspaceFolders ? (vscode.workspace.workspaceFolders as vscode.WorkspaceFolder[])[0].uri : undefined
defaultUri: newProjectTool.defaultProjectSaveLocation()
});
if (!selectionResult) {
@@ -174,6 +177,8 @@ export default class MainController implements vscode.Disposable {
const newProjFilePath = await this.projectsController.createNewProject(<string>newProjName, newProjFolderUri, true);
const proj = await this.projectsController.openProject(vscode.Uri.file(newProjFilePath));
newProjectTool.updateSaveLocationSetting();
return proj;
}
catch (err) {

View File

@@ -11,9 +11,10 @@ import * as path from 'path';
import * as utils from '../common/utils';
import * as UUID from 'vscode-languageclient/lib/utils/uuid';
import * as templates from '../templates/templates';
import * as newProjectTool from '../tools/newProjectTool';
import * as vscode from 'vscode';
import * as azdata from 'azdata';
import { promises as fs } from 'fs';
import { PublishDatabaseDialog } from '../dialogs/publishDatabaseDialog';
import { Project, DatabaseReferenceLocation, SystemDatabase, TargetPlatform, ProjectEntry, reservedProjectFolders, SqlProjectReferenceProjectEntry } from '../models/project';
@@ -661,6 +662,8 @@ export class ProjectsController {
model.extractTarget = await this.getExtractTarget();
model.version = '1.0.0.0';
newProjectTool.updateSaveLocationSetting();
const newProjFilePath = await this.createNewProject(model.projName, vscode.Uri.file(newProjFolderUri), true);
model.filePath = path.dirname(newProjFilePath);
@@ -739,7 +742,7 @@ export class ProjectsController {
private async getProjectName(dbName: string): Promise<string> {
let projName = await vscode.window.showInputBox({
prompt: constants.newDatabaseProjectName,
value: `DatabaseProject${dbName}`
value: newProjectTool.defaultProjectNameFromDb(dbName)
});
projName = projName?.trim();
@@ -797,7 +800,7 @@ export class ProjectsController {
canSelectFolders: true,
canSelectMany: false,
openLabel: constants.selectString,
defaultUri: vscode.workspace.workspaceFolders ? (vscode.workspace.workspaceFolders as vscode.WorkspaceFolder[])[0].uri : undefined
defaultUri: newProjectTool.defaultProjectSaveLocation()
});
if (selectionResult) {