mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Focus projects view when New Project is created (#11048)
* Focusing for new project * Consolidated focus() logic
This commit is contained in:
@@ -88,14 +88,11 @@ export default class MainController implements Disposable {
|
|||||||
filter[constants.sqlDatabaseProject] = ['sqlproj'];
|
filter[constants.sqlDatabaseProject] = ['sqlproj'];
|
||||||
|
|
||||||
let files: Uri[] | undefined = await this.apiWrapper.showOpenDialog({ filters: filter });
|
let files: Uri[] | undefined = await this.apiWrapper.showOpenDialog({ filters: filter });
|
||||||
const prevCount = this.projectsController.projects.length;
|
|
||||||
|
|
||||||
if (files) {
|
if (files) {
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
await this.projectsController.openProject(file);
|
await this.projectsController.openProject(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.projectsController.focusProject(this.projectsController.projects[prevCount]); // focus the first of the newly-opened projects
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -137,8 +134,10 @@ export default class MainController implements Disposable {
|
|||||||
// TODO: what if the selected folder is outside the workspace?
|
// TODO: what if the selected folder is outside the workspace?
|
||||||
|
|
||||||
const newProjFolderUri = (selectionResult as Uri[])[0];
|
const newProjFolderUri = (selectionResult as Uri[])[0];
|
||||||
const newProjFilePath = await this.projectsController.createNewProject(newProjName as string, newProjFolderUri as Uri);
|
const newProjFilePath = await this.projectsController.createNewProject(<string>newProjName, newProjFolderUri);
|
||||||
return this.projectsController.openProject(Uri.file(newProjFilePath));
|
const proj = await this.projectsController.openProject(Uri.file(newProjFilePath));
|
||||||
|
|
||||||
|
return proj;
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.apiWrapper.showErrorMessage(getErrorMessage(err));
|
this.apiWrapper.showErrorMessage(getErrorMessage(err));
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ export class ProjectsController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
this.refreshProjectsTree();
|
this.refreshProjectsTree();
|
||||||
|
this.focusProject(newProject);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
// if the project didnt load - remove it from the list of open projects
|
// if the project didnt load - remove it from the list of open projects
|
||||||
@@ -641,8 +642,6 @@ export class ProjectsController {
|
|||||||
|
|
||||||
//Refresh project to show the added files
|
//Refresh project to show the added files
|
||||||
this.refreshProjectsTree();
|
this.refreshProjectsTree();
|
||||||
|
|
||||||
await this.focusProject(project);
|
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this.apiWrapper.showErrorMessage(utils.getErrorMessage(err));
|
this.apiWrapper.showErrorMessage(utils.getErrorMessage(err));
|
||||||
|
|||||||
Reference in New Issue
Block a user