mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 17:22:45 -05:00
Update import project to have friendly names for the extract file organization options (#11123)
* udpate import to have friendly names for the extract file organization options * update tests * update message * remove camelcase stuff * use localized constants instead of enum
This commit is contained in:
@@ -32,7 +32,7 @@ export const newDatabaseProjectName = localize('newDatabaseProjectName', "New da
|
||||
export const sqlDatabaseProject = localize('sqlDatabaseProject', "SQL database project");
|
||||
export const yesString = localize('yesString', "Yes");
|
||||
export const noString = localize('noString', "No");
|
||||
export const extractTargetInput = localize('extractTargetInput', "Target for extraction:");
|
||||
export const extractTargetInput = localize('extractTargetInput', "Select folder structure for SQL files");
|
||||
export const selectString = localize('selectString', "Select");
|
||||
export const addDatabaseReferenceInput = localize('addDatabaseReferenceInput', "Add database reference for:");
|
||||
export const systemDatabaseReferenceInput = localize('systemDatabaseReferenceInput', "System Database:");
|
||||
@@ -43,6 +43,11 @@ export const databaseReferenceDatabaseName = localize('databaseReferenceDatabase
|
||||
export const dacpacFiles = localize('dacpacFiles', "dacpac Files");
|
||||
export const publishSettingsFiles = localize('publishSettingsFiles', "Publish Settings File");
|
||||
export const systemDatabase = localize('systemDatabase', "System Database");
|
||||
export const file = localize('file', "File");
|
||||
export const flat = localize('flat', "Flat");
|
||||
export const objectType = localize('objectType', "Object Type");
|
||||
export const schema = localize('schema', "Schema");
|
||||
export const schemaObjectType = localize('schemaObjectType', "Schema/Object Type");
|
||||
export function newObjectNamePrompt(objectType: string) { return localize('newObjectNamePrompt', 'New {0} name:', objectType); }
|
||||
export function deleteConfirmation(toDelete: string) { return localize('deleteConfirmation', "Are you sure you want to delete {0}?", toDelete); }
|
||||
export function deleteConfirmationContents(toDelete: string) { return localize('deleteConfirmationContents', "Are you sure you want to delete {0} and all of its contents?", toDelete); }
|
||||
@@ -102,6 +107,7 @@ export function projectAlreadyOpened(path: string) { return localize('projectAlr
|
||||
export function projectAlreadyExists(name: string, path: string) { return localize('projectAlreadyExists', "A project named {0} already exists in {1}.", name, path); }
|
||||
export function noFileExist(fileName: string) { return localize('noFileExist', "File {0} doesn't exist", fileName); }
|
||||
export function cannotResolvePath(path: string) { return localize('cannotResolvePath', "Cannot resolve path {0}", path); }
|
||||
export function invalidInput(input: string) { return localize('invalidInput', "Invalid input: {0}", input); }
|
||||
|
||||
export function mssqlNotFound(mssqlConfigDir: string) { return localize('mssqlNotFound', "Could not get mssql extension's install location at {0}", mssqlConfigDir); }
|
||||
export function projBuildFailed(errorMessage: string) { return localize('projBuildFailed', "Build failed. Check output pane for more details. {0}", errorMessage); }
|
||||
|
||||
@@ -64,13 +64,6 @@ export async function exists(path: string): Promise<boolean> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert camelCase input to PascalCase
|
||||
*/
|
||||
export function toPascalCase(input: string): string {
|
||||
return input.charAt(0).toUpperCase() + input.substr(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* get quoted path to be used in any commandline argument
|
||||
* @param filePath
|
||||
|
||||
@@ -28,16 +28,6 @@ import { ImportDataModel } from '../models/api/import';
|
||||
import { NetCoreTool, DotNetCommandOptions } from '../tools/netcoreTool';
|
||||
import { BuildHelper } from '../tools/buildHelper';
|
||||
|
||||
// TODO: use string enums
|
||||
export enum ExtractTarget {
|
||||
dacpac = 0,
|
||||
file = 1,
|
||||
flat = 2,
|
||||
objectType = 3,
|
||||
schema = 4,
|
||||
schemaObjectType = 5
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller for managing project lifecycle
|
||||
*/
|
||||
@@ -715,12 +705,12 @@ export class ProjectsController {
|
||||
private mapExtractTargetEnum(inputTarget: any): mssql.ExtractTarget {
|
||||
if (inputTarget) {
|
||||
switch (inputTarget) {
|
||||
case 'File': return mssql.ExtractTarget['file'];
|
||||
case 'Flat': return mssql.ExtractTarget['flat'];
|
||||
case 'ObjectType': return mssql.ExtractTarget['objectType'];
|
||||
case 'Schema': return mssql.ExtractTarget['schema'];
|
||||
case 'SchemaObjectType': return mssql.ExtractTarget['schemaObjectType'];
|
||||
default: throw new Error(`Invalid input: ${inputTarget}`);
|
||||
case constants.file: return mssql.ExtractTarget['file'];
|
||||
case constants.flat: return mssql.ExtractTarget['flat'];
|
||||
case constants.objectType: return mssql.ExtractTarget['objectType'];
|
||||
case constants.schema: return mssql.ExtractTarget['schema'];
|
||||
case constants.schemaObjectType: return mssql.ExtractTarget['schemaObjectType'];
|
||||
default: throw new Error(constants.invalidInput(inputTarget));
|
||||
}
|
||||
} else {
|
||||
throw new Error(constants.extractTargetRequired);
|
||||
@@ -732,14 +722,11 @@ export class ProjectsController {
|
||||
|
||||
let extractTargetOptions: QuickPickItem[] = [];
|
||||
|
||||
let keys: string[] = Object.keys(ExtractTarget).filter(k => typeof ExtractTarget[k as any] === 'number');
|
||||
let keys = [constants.file, constants.flat, constants.objectType, constants.schema, constants.schemaObjectType];
|
||||
|
||||
// TODO: Create a wrapper class to handle the mapping
|
||||
keys.forEach((targetOption: string) => {
|
||||
if (targetOption !== 'dacpac') { //Do not present the option to create Dacpac
|
||||
let pascalCaseTargetOption: string = utils.toPascalCase(targetOption); // for better readability
|
||||
extractTargetOptions.push({ label: pascalCaseTargetOption });
|
||||
}
|
||||
extractTargetOptions.push({ label: targetOption });
|
||||
});
|
||||
|
||||
let input = await this.apiWrapper.showQuickPick(extractTargetOptions, {
|
||||
|
||||
@@ -301,7 +301,7 @@ describe('ProjectsController: import operations', function (): void {
|
||||
|
||||
it('Should show error when no location provided with ExtractTarget = File', async function (): Promise<void> {
|
||||
testContext.apiWrapper.setup(x => x.showInputBox(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('MyProjectName'));
|
||||
testContext.apiWrapper.setup(x => x.showQuickPick(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve({ label: 'File' }));
|
||||
testContext.apiWrapper.setup(x => x.showQuickPick(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve({ label: constants.file }));
|
||||
testContext.apiWrapper.setup(x => x.showSaveDialog(TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
|
||||
testContext.apiWrapper.setup(x => x.showErrorMessage(TypeMoq.It.isAny())).returns((s) => { throw new Error(s); });
|
||||
|
||||
@@ -311,7 +311,7 @@ describe('ProjectsController: import operations', function (): void {
|
||||
|
||||
it('Should show error when no location provided with ExtractTarget = SchemaObjectType', async function (): Promise<void> {
|
||||
testContext.apiWrapper.setup(x => x.showInputBox(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('MyProjectName'));
|
||||
testContext.apiWrapper.setup(x => x.showQuickPick(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve({ label: 'SchemaObjectType' }));
|
||||
testContext.apiWrapper.setup(x => x.showQuickPick(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve({ label: constants.schemaObjectType }));
|
||||
testContext.apiWrapper.setup(x => x.showOpenDialog(TypeMoq.It.isAny())).returns(() => Promise.resolve(undefined));
|
||||
testContext.apiWrapper.setup(x => x.workspaceFolders()).returns(() => undefined);
|
||||
testContext.apiWrapper.setup(x => x.showErrorMessage(TypeMoq.It.isAny())).returns((s) => { throw new Error(s); });
|
||||
@@ -324,7 +324,7 @@ describe('ProjectsController: import operations', function (): void {
|
||||
const testFolderPath = await testUtils.createDummyFileStructure();
|
||||
|
||||
testContext.apiWrapper.setup(x => x.showInputBox(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('MyProjectName'));
|
||||
testContext.apiWrapper.setup(x => x.showQuickPick(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve({ label: 'ObjectType' }));
|
||||
testContext.apiWrapper.setup(x => x.showQuickPick(TypeMoq.It.isAny(), TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve({ label: constants.objectType }));
|
||||
testContext.apiWrapper.setup(x => x.showOpenDialog(TypeMoq.It.isAny())).returns(() => Promise.resolve([vscode.Uri.file(testFolderPath)]));
|
||||
testContext.apiWrapper.setup(x => x.workspaceFolders()).returns(() => undefined);
|
||||
testContext.apiWrapper.setup(x => x.showErrorMessage(TypeMoq.It.isAny())).returns((s) => { throw new Error(s); });
|
||||
|
||||
@@ -6,15 +6,7 @@
|
||||
import * as should from 'should';
|
||||
import * as path from 'path';
|
||||
import {createDummyFileStructure} from './testUtils';
|
||||
import {toPascalCase, exists} from '../common/utils';
|
||||
|
||||
describe('Tests for conversion within PascalCase and camelCase', function (): void {
|
||||
it('Should generate PascalCase from camelCase correctly', async () => {
|
||||
should(toPascalCase('')).equal('');
|
||||
should(toPascalCase('camelCase')).equal('CamelCase');
|
||||
should(toPascalCase('camel.case')).equal('Camel.case');
|
||||
});
|
||||
});
|
||||
import { exists} from '../common/utils';
|
||||
|
||||
describe('Tests to verify exists function', function (): void {
|
||||
it('Should determine existence of files/folders', async () => {
|
||||
|
||||
Reference in New Issue
Block a user