mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Fixing folder path in dacpac and schema compare extensions (#7352)
* fixing folder path in dacpac and schema compare extensions * created method * import os
This commit is contained in:
@@ -182,7 +182,7 @@ export abstract class DacFxConfigPage extends BasePage {
|
|||||||
if (this.fileTextBox.value && path.dirname(this.fileTextBox.value)) {
|
if (this.fileTextBox.value && path.dirname(this.fileTextBox.value)) {
|
||||||
return path.dirname(this.fileTextBox.value);
|
return path.dirname(this.fileTextBox.value);
|
||||||
} else { // otherwise use the folder open in the Explorer or the home directory
|
} else { // otherwise use the folder open in the Explorer or the home directory
|
||||||
return vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].name : os.homedir();
|
return vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].uri.fsPath : os.homedir();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import * as os from 'os';
|
|||||||
import { SchemaCompareMainWindow } from '../schemaCompareMainWindow';
|
import { SchemaCompareMainWindow } from '../schemaCompareMainWindow';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import { Telemetry } from '../telemetry';
|
import { Telemetry } from '../telemetry';
|
||||||
import { getEndpointName } from '../utils';
|
import { getEndpointName, getRootPath } from '../utils';
|
||||||
import * as mssql from '../../../mssql';
|
import * as mssql from '../../../mssql';
|
||||||
|
|
||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
@@ -314,7 +314,7 @@ export class SchemaCompareDialog {
|
|||||||
|
|
||||||
currentButton.onDidClick(async (click) => {
|
currentButton.onDidClick(async (click) => {
|
||||||
// file browser should open where the current dacpac is or the appropriate default folder
|
// file browser should open where the current dacpac is or the appropriate default folder
|
||||||
let rootPath = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].name : os.homedir();
|
let rootPath = getRootPath();
|
||||||
let defaultUri = endpoint && endpoint.packageFilePath && await exists(endpoint.packageFilePath) ? endpoint.packageFilePath : rootPath;
|
let defaultUri = endpoint && endpoint.packageFilePath && await exists(endpoint.packageFilePath) ? endpoint.packageFilePath : rootPath;
|
||||||
|
|
||||||
let fileUris = await vscode.window.showOpenDialog(
|
let fileUris = await vscode.window.showOpenDialog(
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import * as path from 'path';
|
|||||||
import * as mssql from '../../mssql';
|
import * as mssql from '../../mssql';
|
||||||
import { SchemaCompareOptionsDialog } from './dialogs/schemaCompareOptionsDialog';
|
import { SchemaCompareOptionsDialog } from './dialogs/schemaCompareOptionsDialog';
|
||||||
import { Telemetry } from './telemetry';
|
import { Telemetry } from './telemetry';
|
||||||
import { getTelemetryErrorType, getEndpointName, verifyConnectionAndGetOwnerUri } from './utils';
|
import { getTelemetryErrorType, getEndpointName, verifyConnectionAndGetOwnerUri, getRootPath } from './utils';
|
||||||
import { SchemaCompareDialog } from './dialogs/schemaCompareDialog';
|
import { SchemaCompareDialog } from './dialogs/schemaCompareDialog';
|
||||||
import { isNullOrUndefined } from 'util';
|
import { isNullOrUndefined } from 'util';
|
||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
@@ -845,7 +845,7 @@ export class SchemaCompareMainWindow {
|
|||||||
|
|
||||||
this.openScmpButton.onDidClick(async (click) => {
|
this.openScmpButton.onDidClick(async (click) => {
|
||||||
Telemetry.sendTelemetryEvent('SchemaCompareOpenScmpStarted');
|
Telemetry.sendTelemetryEvent('SchemaCompareOpenScmpStarted');
|
||||||
const rootPath = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].name : os.homedir();
|
const rootPath = getRootPath();
|
||||||
let fileUris = await vscode.window.showOpenDialog(
|
let fileUris = await vscode.window.showOpenDialog(
|
||||||
{
|
{
|
||||||
canSelectFiles: true,
|
canSelectFiles: true,
|
||||||
@@ -942,7 +942,7 @@ export class SchemaCompareMainWindow {
|
|||||||
}).component();
|
}).component();
|
||||||
|
|
||||||
this.saveScmpButton.onDidClick(async (click) => {
|
this.saveScmpButton.onDidClick(async (click) => {
|
||||||
const rootPath = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].name : os.homedir();
|
const rootPath = getRootPath();
|
||||||
const filePath = await vscode.window.showSaveDialog(
|
const filePath = await vscode.window.showSaveDialog(
|
||||||
{
|
{
|
||||||
defaultUri: vscode.Uri.file(rootPath),
|
defaultUri: vscode.Uri.file(rootPath),
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as mssql from '../../mssql';
|
import * as mssql from '../../mssql';
|
||||||
|
import * as os from 'os';
|
||||||
|
|
||||||
export interface IPackageInfo {
|
export interface IPackageInfo {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -85,3 +86,10 @@ export async function verifyConnectionAndGetOwnerUri(endpoint: mssql.SchemaCompa
|
|||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the folder open in Explorer if there is one, otherwise returns the home directory
|
||||||
|
*/
|
||||||
|
export function getRootPath(): string {
|
||||||
|
return vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].uri.fsPath : os.homedir();
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user