mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-16 01:25:36 -05:00
Data workspace projects changes (#13466)
* Fix project context menu actions (#12541) * delete works again * make fewer changes * update all sql db project commands * cleanup * Remove old projects view (#12563) * remove old projects view from file explorer view * fix tests failing * remove projects in open folder opening up in old view * Update db reference dialog to show projects in the workspace (#12580) * update database reference dialog to show projects in the workspace in the project dropdown * remove workspace stuff from sql projects extension * undo change * add class that implements IExtension * undo a change * update DataWorkspaceExtension to take workspaceService as a parameter * add type * Update sql database project commands (#12595) * remove sql proj's open and create new project from comman palette * hook up create project from database to data workspace * rename the remaining import databases to create project from database * remove open, new, and close commands * expose addProjectsToWorkspace() in IExtension instead of calling command * Addressing comments * fix failing sql project tests (#12651) * update SSDT projects opened in projects viewlet (#12669) * fix action not refreshing the tree issue (#12692) * fix adding project references in new projects viewlet (#12688) * Remove old projects tree provider (#12702) * Remove old projects tree provider and fix tests * formatting * update refreshProjectsTree() to accept workspaceTreeItem() * Cleanup ProjectsController (#12718) * remove openProject from ProjectController and some cleanup * rename * add project and open project dialogs (#12729) * empty dialogs * wip * new project dialog implementation * revert gitattributes * open project dialog * implement add project * remove icon helper * refactor * revert script change * adjust views * more updates * make data-workspace a builtin extension * show the view only when project provider is detected (#12819) * only show the view when proj provider is available * update * fix sql project tests after merge (#12793) * Update dialogs to be closer to mockups (#12879) * small UI changes to dialogs * center radio card group text * Create workspace if needed when opening/new project (#12930) * empty dialogs * wip * new project dialog implementation * revert gitattributes * open project dialog * implement add project * remove icon helper * refactor * revert script change * create workspace * initial changes * create new workspace working * fix tests * cleanup * remove showWorkspaceRequiredNotification() * Add test for no workspace open * update blue buttons * move loading temp project to activate() instead of workspaceService constructor * move workspace creation warning message to before project is created * pass uri to createWorkspace * add tests Co-authored-by: Alan Ren <alanren@microsoft.com> * Additional create workspace changes (#13004) * Dialogs workspace updates (#13010) * adding workspace text boxes * match new project dialog to mockups * Add validation error message for workspace file * add enterWorkspace api * add warning message for opening workspace * cleanup * update commands to remove project so they're more generic * remove 'empty' from string * Move default project location setting to data workspace extension (#13022) * remove project location setting and notification from sql database projects extension * add default project location setting to data workspace extension * fix typo * Add back project name incrementing * other merge fixes * fix strings from other PR * default to last opened directory instead of home directory if no specified default location * A few small updates (#13092) * fix build error * update title for inputboxes * add missing file * Add tests for data workspace dialogs (#13324) * add tests for dialogs * create helper functions * New project dialog workspace inputbox fixes (#13407) * workspace inputbox fixes * fix folder icons * Update package.jsons and readme (#13451) * update package.jsons * update readme * add workspace information to open existing dialog (#13455) Co-authored-by: Alan Ren <alanren@microsoft.com>
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
|
||||
import { promises as fs } from 'fs';
|
||||
import * as constants from '../../common/constants';
|
||||
import { SqlConnectionDataSource } from './sqlConnectionStringSource';
|
||||
|
||||
/**
|
||||
* Abstract class for a datasource in a project
|
||||
@@ -53,11 +52,11 @@ export async function load(dataSourcesFilePath: string): Promise<DataSource[]> {
|
||||
// TODO: do we have a construct for parsing version numbers?
|
||||
switch (rawJsonContents.version) {
|
||||
case '0.0.0':
|
||||
const dataSources: DataSourceFileJson = rawJsonContents as DataSourceFileJson;
|
||||
// const dataSources: DataSourceFileJson = rawJsonContents as DataSourceFileJson;
|
||||
|
||||
for (const source of dataSources.datasources) {
|
||||
output.push(createDataSource(source));
|
||||
}
|
||||
// for (const source of dataSources.datasources) {
|
||||
// output.push(createDataSource(source));
|
||||
// }
|
||||
|
||||
break;
|
||||
default:
|
||||
@@ -70,11 +69,12 @@ export async function load(dataSourcesFilePath: string): Promise<DataSource[]> {
|
||||
/**
|
||||
* Creates DataSource object from JSON
|
||||
*/
|
||||
function createDataSource(json: DataSourceJson): DataSource {
|
||||
switch (json.type) {
|
||||
case SqlConnectionDataSource.type:
|
||||
return SqlConnectionDataSource.fromJson(json);
|
||||
default:
|
||||
throw new Error(constants.unknownDataSourceType + json.type);
|
||||
}
|
||||
}
|
||||
// Commenting this out because circular dependency with SqlConnectionDataSource was causing extension to not activate
|
||||
// function createDataSource(json: DataSourceJson): DataSource {
|
||||
// switch (json.type) {
|
||||
// case SqlConnectionDataSource.type:
|
||||
// return SqlConnectionDataSource.fromJson(json);
|
||||
// default:
|
||||
// throw new Error(constants.unknownDataSourceType + json.type);
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -53,6 +53,7 @@ export class Project {
|
||||
public static async openProject(projectFilePath: string): Promise<Project> {
|
||||
const proj = new Project(projectFilePath);
|
||||
await proj.readProjFile();
|
||||
await proj.updateProjectForRoundTrip();
|
||||
|
||||
return proj;
|
||||
}
|
||||
@@ -60,7 +61,7 @@ export class Project {
|
||||
/**
|
||||
* Reads the project setting and contents from the file
|
||||
*/
|
||||
public async readProjFile() {
|
||||
public async readProjFile(): Promise<void> {
|
||||
this.resetProject();
|
||||
|
||||
const projFileText = await fs.readFile(this.projectFilePath);
|
||||
@@ -178,7 +179,7 @@ export class Project {
|
||||
}
|
||||
}
|
||||
|
||||
private resetProject() {
|
||||
private resetProject(): void {
|
||||
this.files = [];
|
||||
this.importedTargets = [];
|
||||
this.databaseReferences = [];
|
||||
@@ -189,11 +190,27 @@ export class Project {
|
||||
this.projFileXmlDoc = undefined;
|
||||
}
|
||||
|
||||
public async updateProjectForRoundTrip() {
|
||||
await fs.copyFile(this.projectFilePath, this.projectFilePath + '_backup');
|
||||
await this.updateImportToSupportRoundTrip();
|
||||
await this.updatePackageReferenceInProjFile();
|
||||
await this.updateAfterCleanTargetInProjFile();
|
||||
public async updateProjectForRoundTrip(): Promise<void> {
|
||||
if (this.importedTargets.includes(constants.NetCoreTargets) && !this.containsSSDTOnlySystemDatabaseReferences()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.importedTargets.includes(constants.NetCoreTargets)) {
|
||||
const result = await window.showWarningMessage(constants.updateProjectForRoundTrip, constants.yesString, constants.noString);
|
||||
if (result === constants.yesString) {
|
||||
await fs.copyFile(this.projectFilePath, this.projectFilePath + '_backup');
|
||||
await this.updateImportToSupportRoundTrip();
|
||||
await this.updatePackageReferenceInProjFile();
|
||||
await this.updateAfterCleanTargetInProjFile();
|
||||
await this.updateSystemDatabaseReferencesInProjFile();
|
||||
}
|
||||
} else if (this.containsSSDTOnlySystemDatabaseReferences()) {
|
||||
const result = await window.showWarningMessage(constants.updateProjectDatabaseReferencesForRoundTrip, constants.yesString, constants.noString);
|
||||
if (result === constants.yesString) {
|
||||
await fs.copyFile(this.projectFilePath, this.projectFilePath + '_backup');
|
||||
await this.updateSystemDatabaseReferencesInProjFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async updateImportToSupportRoundTrip(): Promise<void> {
|
||||
@@ -460,7 +477,7 @@ export class Project {
|
||||
* @param name name of the variable
|
||||
* @param defaultValue
|
||||
*/
|
||||
public async addSqlCmdVariable(name: string, defaultValue: string) {
|
||||
public async addSqlCmdVariable(name: string, defaultValue: string): Promise<void> {
|
||||
const sqlCmdVariableEntry = new SqlCmdVariableProjectEntry(name, defaultValue);
|
||||
await this.addToProjFile(sqlCmdVariableEntry);
|
||||
}
|
||||
@@ -851,7 +868,7 @@ export class Project {
|
||||
await this.serializeToProjFile(this.projFileXmlDoc);
|
||||
}
|
||||
|
||||
private async removeFromProjFile(entries: ProjectEntry | ProjectEntry[]) {
|
||||
private async removeFromProjFile(entries: ProjectEntry | ProjectEntry[]): Promise<void> {
|
||||
if (entries instanceof ProjectEntry) {
|
||||
entries = [entries];
|
||||
}
|
||||
@@ -876,7 +893,7 @@ export class Project {
|
||||
await this.serializeToProjFile(this.projFileXmlDoc);
|
||||
}
|
||||
|
||||
private async serializeToProjFile(projFileContents: any) {
|
||||
private async serializeToProjFile(projFileContents: any): Promise<void> {
|
||||
let xml = new xmldom.XMLSerializer().serializeToString(projFileContents);
|
||||
xml = xmlFormat(xml, <any>{ collapseContent: true, indentation: ' ', lineSeparator: os.EOL }); // TODO: replace <any>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user