mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Add setting for default dacpac save location (#13194)
* add setting for default save location * lowercase * addressing comments
This commit is contained in:
@@ -24,6 +24,17 @@
|
||||
"Microsoft.mssql"
|
||||
],
|
||||
"contributes": {
|
||||
"configuration": [
|
||||
{
|
||||
"title": "%dacFx.settings%",
|
||||
"properties": {
|
||||
"dacFx.defaultSaveLocation": {
|
||||
"type": "string",
|
||||
"description": "%dacFx.defaultSaveLocation%"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
{
|
||||
"command": "dacFx.start",
|
||||
|
||||
4
extensions/dacpac/package.nls.json
Normal file
4
extensions/dacpac/package.nls.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"dacFx.settings": "Dacpac",
|
||||
"dacFx.defaultSaveLocation": "Full path to folder where .DACPAC and .BACPAC files are saved by default"
|
||||
}
|
||||
@@ -4,14 +4,13 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as loc from '../../localizedConstants';
|
||||
import { DataTierApplicationWizard, Operation } from '../dataTierApplicationWizard';
|
||||
import { DacFxDataModel } from './models';
|
||||
import { BasePage } from './basePage';
|
||||
import { sanitizeStringForFilename, isValidBasename, isValidBasenameErrorMessage } from './utils';
|
||||
import { defaultSaveLocation } from '../common/fileLocationHelper';
|
||||
|
||||
export abstract class DacFxConfigPage extends BasePage {
|
||||
protected serverDropdown: azdata.DropDownComponent;
|
||||
@@ -192,8 +191,8 @@ export abstract class DacFxConfigPage extends BasePage {
|
||||
// use previous file location if there was one
|
||||
if (this.fileTextBox.value && path.dirname(this.fileTextBox.value)) {
|
||||
return path.dirname(this.fileTextBox.value);
|
||||
} else { // otherwise use the folder open in the Explorer or the home directory
|
||||
return vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].uri.fsPath : os.homedir();
|
||||
} else { // otherwise use the default save location setting or the home directory
|
||||
return defaultSaveLocation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
7
extensions/dacpac/src/wizard/common/constants.ts
Normal file
7
extensions/dacpac/src/wizard/common/constants.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export const dacFxConfigurationKey = 'dacFx';
|
||||
export const dacFxSaveLocationKey = 'defaultSaveLocation';
|
||||
30
extensions/dacpac/src/wizard/common/fileLocationHelper.ts
Normal file
30
extensions/dacpac/src/wizard/common/fileLocationHelper.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as constants from '../common/constants';
|
||||
|
||||
/**
|
||||
* Returns the default location to save a dacpac or bacpac
|
||||
*/
|
||||
export function defaultSaveLocation(): string {
|
||||
return dacFxSaveLocationSettingIsValid() ? dacFxSaveLocationSetting() : os.homedir();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the workspace setting on the default location to save dacpacs and bacpacs
|
||||
*/
|
||||
function dacFxSaveLocationSetting(): string {
|
||||
return vscode.workspace.getConfiguration(constants.dacFxConfigurationKey)[constants.dacFxSaveLocationKey];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the default save location for dacpacs and bacpacs setting exists and is a valid path
|
||||
*/
|
||||
function dacFxSaveLocationSettingIsValid(): boolean {
|
||||
return dacFxSaveLocationSetting() && dacFxSaveLocationSetting().trim() !== '' && fs.existsSync(dacFxSaveLocationSetting());
|
||||
}
|
||||
Reference in New Issue
Block a user