mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Change default folder in dacpac and schema compare extensions (#5215)
* change default folder in dacpac and schema compare extensions * move getting rootpath to a method * change method name
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as nls from 'vscode-nls';
|
||||
import * as vscode from 'vscode';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import { DataTierApplicationWizard } from '../dataTierApplicationWizard';
|
||||
@@ -101,7 +102,7 @@ export abstract class DacFxConfigPage extends BasePage {
|
||||
// Handle database changes
|
||||
this.databaseDropdown.onValueChanged(async () => {
|
||||
this.model.database = (<azdata.CategoryValue>this.databaseDropdown.value).name;
|
||||
this.fileTextBox.value = this.generateFilePath();
|
||||
this.fileTextBox.value = this.generateFilePathFromDatabaseAndTimestamp();
|
||||
this.model.filePath = this.fileTextBox.value;
|
||||
});
|
||||
|
||||
@@ -124,7 +125,7 @@ export abstract class DacFxConfigPage extends BasePage {
|
||||
|
||||
let values = await this.getDatabaseValues();
|
||||
this.model.database = values[0].name;
|
||||
this.model.filePath = this.generateFilePath();
|
||||
this.model.filePath = this.generateFilePathFromDatabaseAndTimestamp();
|
||||
this.fileTextBox.value = this.model.filePath;
|
||||
|
||||
this.databaseDropdown.updateProperties({
|
||||
@@ -145,10 +146,18 @@ export abstract class DacFxConfigPage extends BasePage {
|
||||
}).component();
|
||||
}
|
||||
|
||||
protected generateFilePath(): string {
|
||||
protected generateFilePathFromDatabaseAndTimestamp(): string {
|
||||
return path.join(this.getRootPath(), this.model.database + '-' + this.getDateTime() + this.fileExtension);
|
||||
}
|
||||
|
||||
protected getDateTime(): string {
|
||||
let now = new Date();
|
||||
let datetime = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate() + '-' + now.getHours() + '-' + now.getMinutes();
|
||||
return path.join(os.homedir(), this.model.database + '-' + datetime + this.fileExtension);
|
||||
return now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate() + '-' + now.getHours() + '-' + now.getMinutes();
|
||||
}
|
||||
|
||||
protected getRootPath(): string {
|
||||
// return rootpath of opened folder in file explorer if one is open, otherwise default to user home directory
|
||||
return vscode.workspace.rootPath ? vscode.workspace.rootPath : os.homedir();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -167,9 +167,7 @@ export class DeployActionPage extends DacFxConfigPage {
|
||||
}
|
||||
|
||||
private setDefaultScriptFilePath(): void {
|
||||
let now = new Date();
|
||||
let datetime = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate() + '-' + now.getHours() + '-' + now.getMinutes();
|
||||
this.fileTextBox.value = path.join(os.homedir(), this.model.database + '_UpgradeDACScript_' + datetime + '.sql');
|
||||
this.fileTextBox.value = path.join(this.getRootPath(), this.model.database + '_UpgradeDACScript_' + this.getDateTime() + '.sql');
|
||||
this.model.scriptFilePath = this.fileTextBox.value;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ export class DeployConfigPage extends DacFxConfigPage {
|
||||
canSelectFiles: true,
|
||||
canSelectFolders: false,
|
||||
canSelectMany: false,
|
||||
defaultUri: vscode.Uri.file(os.homedir()),
|
||||
defaultUri: vscode.Uri.file(this.getRootPath()),
|
||||
openLabel: localize('dacFxDeploy.openFile', 'Open'),
|
||||
filters: {
|
||||
'dacpac Files': ['dacpac'],
|
||||
|
||||
@@ -65,7 +65,7 @@ export class ExportConfigPage extends DacFxConfigPage {
|
||||
this.createFileBrowserParts();
|
||||
|
||||
// default filepath
|
||||
this.fileTextBox.value = this.generateFilePath();
|
||||
this.fileTextBox.value = this.generateFilePathFromDatabaseAndTimestamp();
|
||||
this.model.filePath = this.fileTextBox.value;
|
||||
|
||||
this.fileButton.onDidClick(async (click) => {
|
||||
|
||||
@@ -68,7 +68,7 @@ export class ExtractConfigPage extends DacFxConfigPage {
|
||||
this.createFileBrowserParts();
|
||||
|
||||
// default filepath
|
||||
this.fileTextBox.value = this.generateFilePath();
|
||||
this.fileTextBox.value = this.generateFilePathFromDatabaseAndTimestamp();
|
||||
this.model.filePath = this.fileTextBox.value;
|
||||
|
||||
this.fileButton.onDidClick(async (click) => {
|
||||
|
||||
@@ -62,7 +62,7 @@ export class ImportConfigPage extends DacFxConfigPage {
|
||||
canSelectFiles: true,
|
||||
canSelectFolders: false,
|
||||
canSelectMany: false,
|
||||
defaultUri: vscode.Uri.file(os.homedir()),
|
||||
defaultUri: vscode.Uri.file(this.getRootPath()),
|
||||
openLabel: localize('dacFxImport.openFile', 'Open'),
|
||||
filters: {
|
||||
'bacpac Files': ['bacpac'],
|
||||
|
||||
@@ -208,12 +208,13 @@ export class SchemaCompareDialog {
|
||||
let currentButton = isTarget ? this.targetFileButton : this.sourceFileButton;
|
||||
|
||||
currentButton.onDidClick(async (click) => {
|
||||
let rootPath = vscode.workspace.rootPath ? vscode.workspace.rootPath : os.homedir();
|
||||
let fileUris = await vscode.window.showOpenDialog(
|
||||
{
|
||||
canSelectFiles: true,
|
||||
canSelectFolders: false,
|
||||
canSelectMany: false,
|
||||
defaultUri: vscode.Uri.file(os.homedir()),
|
||||
defaultUri: vscode.Uri.file(rootPath),
|
||||
openLabel: localize('schemaCompare.openFile', 'Open'),
|
||||
filters: {
|
||||
'dacpac Files': ['dacpac'],
|
||||
|
||||
@@ -291,7 +291,8 @@ export class SchemaCompareResult {
|
||||
// get file path
|
||||
let now = new Date();
|
||||
let datetime = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate() + '-' + now.getHours() + '-' + now.getMinutes() + '-' + now.getSeconds();
|
||||
let defaultFilePath = path.join(os.homedir(), this.targetName + '_Update_' + datetime + '.sql');
|
||||
let rootPath = vscode.workspace.rootPath ? vscode.workspace.rootPath : os.homedir();
|
||||
let defaultFilePath = path.join(rootPath, this.targetName + '_Update_' + datetime + '.sql');
|
||||
let fileUri = await vscode.window.showSaveDialog(
|
||||
{
|
||||
defaultUri: vscode.Uri.file(defaultFilePath),
|
||||
|
||||
Reference in New Issue
Block a user