Fix for Bug #15020 dashboard update with multiproject (#15029)

* Fix to enable two projects showing only their data even if opening together

* Fixing a typo

* Taking in PR comments
This commit is contained in:
Udeesha Gautam
2021-04-07 16:44:25 -07:00
committed by GitHub
parent 6a55c402a4
commit c20e620c34
8 changed files with 76 additions and 67 deletions

View File

@@ -23,7 +23,7 @@ export const DoNotShowAgain = localize('dataworkspace.doNotShowAgain', "Do not s
export const ProjectsFailedToLoad = localize('dataworkspace.projectsFailedToLoad', "Some projects failed to load. Please open console for more information"); export const ProjectsFailedToLoad = localize('dataworkspace.projectsFailedToLoad', "Some projects failed to load. Please open console for more information");
export const fileDoesNotExist = (name: string): string => { return localize('fileDoesNotExist', "File '{0}' doesn't exist", name); }; export const fileDoesNotExist = (name: string): string => { return localize('fileDoesNotExist', "File '{0}' doesn't exist", name); };
export const projectNameNull = localize('projectNameNull', "Project name is null"); export const projectNameNull = localize('projectNameNull', "Project name is null");
export const noPreviousData = (tableName: string): string => { return localize('noPreviousData', "Prior {0} will appear here, please run to see the results.", tableName); }; export const noPreviousData = (tableName: string): string => { return localize('noPreviousData', "Prior {0} for the current project will appear here, please run to see the results.", tableName); };
// config settings // config settings
export const projectsConfigurationKey = 'projects'; export const projectsConfigurationKey = 'projects';

View File

@@ -67,6 +67,11 @@ declare module 'dataworkspace' {
*/ */
createProject(name: string, location: vscode.Uri, projectTypeId: string): Promise<vscode.Uri>; createProject(name: string, location: vscode.Uri, projectTypeId: string): Promise<vscode.Uri>;
/**
* Gets the project data corresponding to the project file, to be placed in the dashboard container
*/
getDashboardComponents(projectFile: string): IDashboardTable[];
/** /**
* Gets the supported project types * Gets the supported project types
*/ */
@@ -77,11 +82,6 @@ declare module 'dataworkspace' {
*/ */
readonly projectActions: (IProjectAction | IProjectActionGroup)[]; readonly projectActions: (IProjectAction | IProjectActionGroup)[];
/**
* Gets the project data to be placed in the dashboard container
*/
readonly dashboardComponents: IDashboardTable[];
/** /**
* Gets the project image to be used as background in dashboard container * Gets the project image to be used as background in dashboard container
*/ */

View File

@@ -44,7 +44,7 @@ export class ProjectDashboard {
await this.dashboard!.open(); await this.dashboard!.open();
} }
private async createDashboard(title: string, location: string): Promise<void> { private async createDashboard(title: string, projectFilePath: string): Promise<void> {
this.dashboard = azdata.window.createModelViewDashboard(title, 'ProjectDashboard', { alwaysShowTabs: false }); this.dashboard = azdata.window.createModelViewDashboard(title, 'ProjectDashboard', { alwaysShowTabs: false });
this.dashboard.registerTabs(async (modelView: azdata.ModelView) => { this.dashboard.registerTabs(async (modelView: azdata.ModelView) => {
this.modelView = modelView; this.modelView = modelView;
@@ -52,8 +52,8 @@ export class ProjectDashboard {
this.overviewTab = { this.overviewTab = {
title: '', title: '',
id: 'overview-tab', id: 'overview-tab',
content: this.createContainer(title, location), content: this.createContainer(title, projectFilePath),
toolbar: this.createToolbarContainer() toolbar: this.createToolbarContainer(projectFilePath)
}; };
return [ return [
this.overviewTab this.overviewTab
@@ -61,7 +61,7 @@ export class ProjectDashboard {
}); });
} }
private createToolbarContainer(): azdata.ToolbarContainer { private createToolbarContainer(projectFilePath: string): azdata.ToolbarContainer {
const projectActions: (IProjectAction | IProjectActionGroup)[] = this.projectProvider!.projectActions; const projectActions: (IProjectAction | IProjectActionGroup)[] = this.projectProvider!.projectActions;
// Add actions as buttons // Add actions as buttons
@@ -92,7 +92,7 @@ export class ProjectDashboard {
refreshButton.onDidClick(() => { refreshButton.onDidClick(() => {
this.rootContainer?.removeItem(this.tableContainer!); this.rootContainer?.removeItem(this.tableContainer!);
this.tableContainer = this.createTables(); this.tableContainer = this.createTables(projectFilePath);
this.rootContainer?.addItem(this.tableContainer); this.rootContainer?.addItem(this.tableContainer);
}); });
@@ -123,7 +123,7 @@ export class ProjectDashboard {
return button; return button;
} }
private createContainer(title: string, location: string): azdata.FlexContainer { private createContainer(title: string, projectFilePath: string): azdata.FlexContainer {
this.rootContainer = this.modelView!.modelBuilder.flexContainer().withLayout( this.rootContainer = this.modelView!.modelBuilder.flexContainer().withLayout(
{ {
flexFlow: 'column', flexFlow: 'column',
@@ -131,8 +131,8 @@ export class ProjectDashboard {
height: '100%' height: '100%'
}).component(); }).component();
const headerContainer = this.createHeader(title, location); const headerContainer = this.createHeader(title, projectFilePath);
this.tableContainer = this.createTables(); this.tableContainer = this.createTables(projectFilePath);
this.rootContainer.addItem(headerContainer); this.rootContainer.addItem(headerContainer);
this.rootContainer.addItem(this.tableContainer); this.rootContainer.addItem(this.tableContainer);
@@ -188,8 +188,8 @@ export class ProjectDashboard {
/** /**
* Adds all the tables to the container * Adds all the tables to the container
*/ */
private createTables(): azdata.Component { private createTables(projectFile: string): azdata.Component {
const dashboardData: IDashboardTable[] = this.projectProvider!.dashboardComponents; const dashboardData: IDashboardTable[] = this.projectProvider!.getDashboardComponents(projectFile);
const tableContainer = this.modelView!.modelBuilder.flexContainer().withLayout( const tableContainer = this.modelView!.modelBuilder.flexContainer().withLayout(
{ {

View File

@@ -33,7 +33,9 @@ export function createProjectProvider(projectTypes: IProjectType[], projectActio
return Promise.resolve(location); return Promise.resolve(location);
}, },
projectActions: projectActions, projectActions: projectActions,
dashboardComponents: dashboardComponents getDashboardComponents: (projectFile: string): IDashboardTable[] => {
return dashboardComponents;
}
}; };
return projectProvider; return projectProvider;
} }

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { IProjectProvider, WorkspaceTreeItem } from 'dataworkspace'; import { IDashboardTable, IProjectProvider, WorkspaceTreeItem } from 'dataworkspace';
import 'mocha'; import 'mocha';
import * as should from 'should'; import * as should from 'should';
import * as sinon from 'sinon'; import * as sinon from 'sinon';
@@ -111,7 +111,8 @@ suite('workspaceTreeDataProvider Tests', function (): void {
id: 'Target Version', id: 'Target Version',
run: async (): Promise<any> => { return Promise.resolve(); } run: async (): Promise<any> => { return Promise.resolve(); }
}], }],
dashboardComponents: [{ getDashboardComponents: (projectFile: string): IDashboardTable[] => {
return [{
name: 'Deployments', name: 'Deployments',
columns: [{ displayName: 'c1', width: 75, type: 'string' }], columns: [{ displayName: 'c1', width: 75, type: 'string' }],
data: [['d1']] data: [['d1']]
@@ -120,8 +121,8 @@ suite('workspaceTreeDataProvider Tests', function (): void {
name: 'Builds', name: 'Builds',
columns: [{ displayName: 'c1', width: 75, type: 'string' }], columns: [{ displayName: 'c1', width: 75, type: 'string' }],
data: [['d1']] data: [['d1']]
}] }];
}; }};
const getProjectProviderStub = sinon.stub(workspaceService, 'getProjectProvider'); const getProjectProviderStub = sinon.stub(workspaceService, 'getProjectProvider');
getProjectProviderStub.onFirstCall().resolves(undefined); getProjectProviderStub.onFirstCall().resolves(undefined);
getProjectProviderStub.onSecondCall().resolves(projectProvider); getProjectProviderStub.onSecondCall().resolves(projectProvider);

View File

@@ -52,11 +52,12 @@ export class ProjectsController {
this.buildHelper = new BuildHelper(); this.buildHelper = new BuildHelper();
} }
public get dashboardDeployData(): (string | dataworkspace.IconCellValue)[][] { public getDashboardDeployData(projectFile: string): (string | dataworkspace.IconCellValue)[][] {
const infoRows: (string | dataworkspace.IconCellValue)[][] = []; const infoRows: (string | dataworkspace.IconCellValue)[][] = [];
let count = 0; let count = 0;
for (let i = this.deployInfo.length - 1; i >= 0; i--) { for (let i = this.deployInfo.length - 1; i >= 0; i--) {
if (this.deployInfo[i].projectFile === projectFile) {
let icon: azdata.IconPath; let icon: azdata.IconPath;
let text: string; let text: string;
if (this.deployInfo[i].status === Status.success) { if (this.deployInfo[i].status === Status.success) {
@@ -78,15 +79,17 @@ export class ProjectsController {
infoRows.push(infoRow); infoRows.push(infoRow);
count++; count++;
} }
}
return infoRows; return infoRows;
} }
public get dashboardBuildData(): (string | dataworkspace.IconCellValue)[][] { public getDashboardBuildData(projectFile: string): (string | dataworkspace.IconCellValue)[][] {
const infoRows: (string | dataworkspace.IconCellValue)[][] = []; const infoRows: (string | dataworkspace.IconCellValue)[][] = [];
let count = 0; let count = 0;
for (let i = this.buildInfo.length - 1; i >= 0; i--) { for (let i = this.buildInfo.length - 1; i >= 0; i--) {
if (this.buildInfo[i].projectFile === projectFile) {
let icon: azdata.IconPath; let icon: azdata.IconPath;
let text: string; let text: string;
if (this.buildInfo[i].status === Status.success) { if (this.buildInfo[i].status === Status.success) {
@@ -108,6 +111,7 @@ export class ProjectsController {
infoRows.push(infoRow); infoRows.push(infoRow);
count++; count++;
} }
}
return infoRows; return infoRows;
} }
@@ -176,7 +180,7 @@ export class ProjectsController {
const startTime = new Date(); const startTime = new Date();
const currentBuildTimeInfo = `${startTime.toLocaleDateString()} ${constants.at} ${startTime.toLocaleTimeString()}`; const currentBuildTimeInfo = `${startTime.toLocaleDateString()} ${constants.at} ${startTime.toLocaleTimeString()}`;
let buildInfoNew = new DashboardData(Status.inProgress, project.getProjectTargetVersion(), currentBuildTimeInfo); let buildInfoNew = new DashboardData(project.projectFilePath, Status.inProgress, project.getProjectTargetVersion(), currentBuildTimeInfo);
this.buildInfo.push(buildInfoNew); this.buildInfo.push(buildInfoNew);
if (this.buildInfo.length - 1 === maxTableLength) { if (this.buildInfo.length - 1 === maxTableLength) {
@@ -276,7 +280,7 @@ export class ProjectsController {
const actionStartTime = currentDate.getTime(); const actionStartTime = currentDate.getTime();
const currentDeployTimeInfo = `${currentDate.toLocaleDateString()} ${constants.at} ${currentDate.toLocaleTimeString()}`; const currentDeployTimeInfo = `${currentDate.toLocaleDateString()} ${constants.at} ${currentDate.toLocaleTimeString()}`;
let deployInfoNew = new DashboardData(Status.inProgress, project.getProjectTargetVersion(), currentDeployTimeInfo); let deployInfoNew = new DashboardData(project.projectFilePath, Status.inProgress, project.getProjectTargetVersion(), currentDeployTimeInfo);
this.deployInfo.push(deployInfoNew); this.deployInfo.push(deployInfoNew);
if (this.deployInfo.length - 1 === maxTableLength) { if (this.deployInfo.length - 1 === maxTableLength) {

View File

@@ -4,12 +4,14 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
export class DashboardData { export class DashboardData {
public projectFile: string;
public status: Status; public status: Status;
public target: string; public target: string;
public timeToCompleteAction: string; public timeToCompleteAction: string;
public startDate: string; public startDate: string;
constructor(status: Status, target: string, startDate: string) { constructor(projectFile: string, status: Status, target: string, startDate: string) {
this.projectFile = projectFile;
this.status = status; this.status = status;
this.target = target; this.target = target;
this.timeToCompleteAction = ''; this.timeToCompleteAction = '';

View File

@@ -128,7 +128,7 @@ export class SqlDatabaseProjectProvider implements dataworkspace.IProjectProvide
/** /**
* Gets the data to be displayed in the project dashboard * Gets the data to be displayed in the project dashboard
*/ */
get dashboardComponents(): dataworkspace.IDashboardTable[] { getDashboardComponents(projectFile: string): dataworkspace.IDashboardTable[] {
const deployInfo: dataworkspace.IDashboardTable = { const deployInfo: dataworkspace.IDashboardTable = {
name: constants.Deployments, name: constants.Deployments,
columns: [{ displayName: constants.ID, width: 100 }, columns: [{ displayName: constants.ID, width: 100 },
@@ -136,7 +136,7 @@ export class SqlDatabaseProjectProvider implements dataworkspace.IProjectProvide
{ displayName: constants.Target, width: 250 }, { displayName: constants.Target, width: 250 },
{ displayName: constants.Time, width: 250 }, { displayName: constants.Time, width: 250 },
{ displayName: constants.Date, width: 250 }], { displayName: constants.Date, width: 250 }],
data: this.projectController.dashboardDeployData data: this.projectController.getDashboardDeployData(projectFile)
}; };
const buildInfo: dataworkspace.IDashboardTable = { const buildInfo: dataworkspace.IDashboardTable = {
@@ -146,7 +146,7 @@ export class SqlDatabaseProjectProvider implements dataworkspace.IProjectProvide
{ displayName: constants.Target, width: 250 }, { displayName: constants.Target, width: 250 },
{ displayName: constants.Time, width: 250 }, { displayName: constants.Time, width: 250 },
{ displayName: constants.Date, width: 250 }], { displayName: constants.Date, width: 250 }],
data: this.projectController.dashboardBuildData data: this.projectController.getDashboardBuildData(projectFile)
}; };
return [deployInfo, buildInfo]; return [deployInfo, buildInfo];