mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-06 17:23:53 -05:00
Sql DB project dashboard (#14899)
* First set of changes for workspace dashboard implementing the toolbar * Workspace dashboard container implementation (#14813) * First set of changes for workspace dashboard implementing the toolbar (#14160) * First set of changes for workspace dashboard implementing the toolbar * Addressed comments * Addressed one remaining comment * Removed an extra comma in interfaces file * Addressed comments * Addressed comments * Refactored a bit of code * Remove unnecessary await * Addressed comments * First set of changes for workspace dashboard container * Update targetPlatform icon+add Time column to deploy table * Addressed comments * Removed redundant class definition * Addressed comments * Addressed comments * Change enum to union type in dataworkspace typings * Fix tests * Addressed comments
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IDashboardTable, IProjectAction, IProjectProvider, IProjectType } from 'dataworkspace';
|
||||
import 'mocha';
|
||||
import * as vscode from 'vscode';
|
||||
import * as should from 'should';
|
||||
import * as vscode from 'vscode';
|
||||
import { ProjectProviderRegistry } from '../common/projectProviderRegistry';
|
||||
import { IProjectProvider, IProjectType } from 'dataworkspace';
|
||||
|
||||
export class MockTreeDataProvider implements vscode.TreeDataProvider<any>{
|
||||
onDidChangeTreeData?: vscode.Event<any> | undefined;
|
||||
@@ -19,7 +19,7 @@ export class MockTreeDataProvider implements vscode.TreeDataProvider<any>{
|
||||
}
|
||||
}
|
||||
|
||||
export function createProjectProvider(projectTypes: IProjectType[]): IProjectProvider {
|
||||
export function createProjectProvider(projectTypes: IProjectType[], projectActions: IProjectAction[], dashboardComponents: IDashboardTable[]): IProjectProvider {
|
||||
const treeDataProvider = new MockTreeDataProvider();
|
||||
const projectProvider: IProjectProvider = {
|
||||
supportedProjectTypes: projectTypes,
|
||||
@@ -31,7 +31,9 @@ export function createProjectProvider(projectTypes: IProjectType[]): IProjectPro
|
||||
},
|
||||
createProject: (name: string, location: vscode.Uri, projectTypeId: string): Promise<vscode.Uri> => {
|
||||
return Promise.resolve(location);
|
||||
}
|
||||
},
|
||||
projectActions: projectActions,
|
||||
dashboardComponents: dashboardComponents
|
||||
};
|
||||
return projectProvider;
|
||||
}
|
||||
@@ -52,7 +54,25 @@ suite('ProjectProviderRegistry Tests', function (): void {
|
||||
displayName: 'test project 1',
|
||||
description: ''
|
||||
}
|
||||
]);
|
||||
],
|
||||
[{
|
||||
id: 'testAction1',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'testAction2',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
}],
|
||||
[{
|
||||
name: 'tableInfo1',
|
||||
columns: [{ displayName: 'c1', width: 75, type: 'string' }],
|
||||
data: [['d1']]
|
||||
},
|
||||
{
|
||||
name: 'tableInfo2',
|
||||
columns: [{ displayName: 'c1', width: 75, type: 'string' }],
|
||||
data: [['d1']]
|
||||
}]);
|
||||
const provider2 = createProjectProvider([
|
||||
{
|
||||
id: 'sp1',
|
||||
@@ -61,7 +81,37 @@ suite('ProjectProviderRegistry Tests', function (): void {
|
||||
displayName: 'sql project',
|
||||
description: ''
|
||||
}
|
||||
]);
|
||||
],
|
||||
[{
|
||||
id: 'Add',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'Schema Compare',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'Build',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'Publish',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'Target Version',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
}],
|
||||
[{
|
||||
name: 'Deployments',
|
||||
columns: [{ displayName: 'c1', width: 75, type: 'string' }],
|
||||
data: [['d1']]
|
||||
},
|
||||
{
|
||||
name: 'Builds',
|
||||
columns: [{ displayName: 'c1', width: 75, type: 'string' }],
|
||||
data: [['d1']]
|
||||
}]);
|
||||
should.strictEqual(ProjectProviderRegistry.providers.length, 0, 'there should be no project provider at the beginning of the test');
|
||||
const disposable1 = ProjectProviderRegistry.registerProvider(provider1, 'test.testProvider');
|
||||
let providerResult = ProjectProviderRegistry.getProviderByProjectExtension('testproj');
|
||||
@@ -104,7 +154,16 @@ suite('ProjectProviderRegistry Tests', function (): void {
|
||||
displayName: 'test project',
|
||||
description: ''
|
||||
}
|
||||
]);
|
||||
],
|
||||
[{
|
||||
id: 'testAction1',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
}],
|
||||
[{
|
||||
name: 'tableInfo1',
|
||||
columns: [{ displayName: 'c1', width: 75, type: 'string' }],
|
||||
data: [['d1']]
|
||||
}]);
|
||||
should.strictEqual(ProjectProviderRegistry.providers.length, 0, 'there should be no project provider at the beginning of the test');
|
||||
ProjectProviderRegistry.registerProvider(provider, 'test.testProvider');
|
||||
should.strictEqual(ProjectProviderRegistry.providers.length, 1, 'there should be only one project provider at this time');
|
||||
|
||||
@@ -136,6 +136,28 @@ suite('WorkspaceService Tests', function (): void {
|
||||
icon: '',
|
||||
displayName: 'test project 1'
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
id: 'testAction1',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'testAction2',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 'tableInfo1',
|
||||
columns: [{ displayName: 'c1', width: 75, type: 'string' }],
|
||||
data: [['d1']]
|
||||
},
|
||||
{
|
||||
name: 'tableInfo2',
|
||||
columns: [{ displayName: 'c1', width: 75, type: 'string' }],
|
||||
data: [['d1']]
|
||||
}
|
||||
]);
|
||||
const provider2 = createProjectProvider([
|
||||
{
|
||||
@@ -145,6 +167,40 @@ suite('WorkspaceService Tests', function (): void {
|
||||
icon: '',
|
||||
displayName: 'sql project'
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
id: 'Add',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'Schema Compare',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'Build',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'Publish',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'Target Version',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 'Deployments',
|
||||
columns: [{ displayName: 'c1', width: 75, type: 'string' }],
|
||||
data: [['d1']]
|
||||
},
|
||||
{
|
||||
name: 'Builds',
|
||||
columns: [{ displayName: 'c1', width: 75, type: 'string' }],
|
||||
data: [['d1']]
|
||||
}
|
||||
]);
|
||||
sinon.stub(ProjectProviderRegistry, 'providers').value([provider1, provider2]);
|
||||
const consoleErrorStub = sinon.stub(console, 'error');
|
||||
@@ -178,7 +234,37 @@ suite('WorkspaceService Tests', function (): void {
|
||||
icon: '',
|
||||
displayName: 'test project'
|
||||
}
|
||||
]));
|
||||
],
|
||||
[{
|
||||
id: 'Add',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'Schema Compare',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'Build',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'Publish',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'Target Version',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
}],
|
||||
[{
|
||||
name: 'Deployments',
|
||||
columns: [{ displayName: 'c1', width: 75, type: 'string' }],
|
||||
data: [['d1']]
|
||||
},
|
||||
{
|
||||
name: 'Builds',
|
||||
columns: [{ displayName: 'c1', width: 75, type: 'string' }],
|
||||
data: [['d1']]
|
||||
}]));
|
||||
let provider = await service.getProjectProvider(vscode.Uri.file('abc.sqlproj'));
|
||||
should.notStrictEqual(provider, undefined, 'Provider should be returned for sqlproj');
|
||||
should.strictEqual(provider!.supportedProjectTypes[0].projectFileExtension, 'sqlproj');
|
||||
@@ -193,7 +279,16 @@ suite('WorkspaceService Tests', function (): void {
|
||||
projectFileExtension: 'csproj',
|
||||
icon: '',
|
||||
displayName: 'test cs project'
|
||||
}]));
|
||||
}],
|
||||
[{
|
||||
id: 'testAction2',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
}],
|
||||
[{
|
||||
name: 'tableInfo2',
|
||||
columns: [{ displayName: 'c1', width: 75, type: 'string' }],
|
||||
data: [['d1']]
|
||||
}]));
|
||||
provider = await service.getProjectProvider(vscode.Uri.file('abc.csproj'));
|
||||
should.notStrictEqual(provider, undefined, 'Provider should be returned for csproj');
|
||||
should.strictEqual(provider!.supportedProjectTypes[0].projectFileExtension, 'csproj');
|
||||
@@ -324,7 +419,7 @@ suite('WorkspaceService Tests', function (): void {
|
||||
await vscode.workspace.getConfiguration(constants.projectsConfigurationKey).update(constants.showNotAddedProjectsMessageKey, true, true);
|
||||
|
||||
sinon.stub(service, 'getProjectsInWorkspace').returns([vscode.Uri.file('abc.sqlproj'), vscode.Uri.file('folder1/abc1.sqlproj')]);
|
||||
sinon.stub(vscode.workspace, 'workspaceFolders').value([{uri: vscode.Uri.file('.')}]);
|
||||
sinon.stub(vscode.workspace, 'workspaceFolders').value([{ uri: vscode.Uri.file('.') }]);
|
||||
sinon.stub(service, 'getAllProjectTypes').resolves([{
|
||||
projectFileExtension: 'sqlproj',
|
||||
id: 'sql project',
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IProjectProvider, WorkspaceTreeItem } from 'dataworkspace';
|
||||
import 'mocha';
|
||||
import * as sinon from 'sinon';
|
||||
import * as vscode from 'vscode';
|
||||
import * as should from 'should';
|
||||
import * as sinon from 'sinon';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import * as vscode from 'vscode';
|
||||
import { WorkspaceTreeDataProvider } from '../common/workspaceTreeDataProvider';
|
||||
import { WorkspaceService } from '../services/workspaceService';
|
||||
import { IProjectProvider, WorkspaceTreeItem } from 'dataworkspace';
|
||||
import { MockTreeDataProvider } from './projectProviderRegistry.test';
|
||||
|
||||
interface ExtensionGlobalMemento extends vscode.Memento {
|
||||
@@ -90,7 +90,37 @@ suite('workspaceTreeDataProvider Tests', function (): void {
|
||||
},
|
||||
createProject: (name: string, location: vscode.Uri): Promise<vscode.Uri> => {
|
||||
return Promise.resolve(location);
|
||||
}
|
||||
},
|
||||
projectActions: [{
|
||||
id: 'Add',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'Schema Compare',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'Build',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'Publish',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
},
|
||||
{
|
||||
id: 'Target Version',
|
||||
run: async (): Promise<any> => { return Promise.resolve(); }
|
||||
}],
|
||||
dashboardComponents: [{
|
||||
name: 'Deployments',
|
||||
columns: [{ displayName: 'c1', width: 75, type: 'string' }],
|
||||
data: [['d1']]
|
||||
},
|
||||
{
|
||||
name: 'Builds',
|
||||
columns: [{ displayName: 'c1', width: 75, type: 'string' }],
|
||||
data: [['d1']]
|
||||
}]
|
||||
};
|
||||
const getProjectProviderStub = sinon.stub(workspaceService, 'getProjectProvider');
|
||||
getProjectProviderStub.onFirstCall().resolves(undefined);
|
||||
|
||||
Reference in New Issue
Block a user