Adding badge icons to execution plan (#19004) (#19015)

* Adding badge icons to executionplan

* Fixing doc comment

* Fixing doc comments

* Making enum value more readable

* Changing default to undefined.

* Fixing some icon names
This commit is contained in:
Aasim Khan
2022-04-12 18:57:01 -07:00
committed by GitHub
parent b8d47cc97e
commit 691d46a0d8
9 changed files with 104 additions and 5 deletions

View File

@@ -4,14 +4,15 @@
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./media/executionPlan';
import type * as azdata from 'azdata';
import * as azdata from 'azdata';
import * as sqlExtHostType from 'sql/workbench/api/common/sqlExtHostTypes';
import { IPanelView, IPanelTab } from 'sql/base/browser/ui/panel/panel';
import { localize } from 'vs/nls';
import { dispose } from 'vs/base/common/lifecycle';
import { ActionBar } from 'sql/base/browser/ui/taskbar/actionbar';
import * as DOM from 'vs/base/browser/dom';
import * as azdataGraphModule from 'azdataGraph';
import { customZoomIconClassNames, openPlanFileIconClassNames, openPropertiesIconClassNames, openQueryIconClassNames, executionPlanNodeIconPaths, savePlanIconClassNames, searchIconClassNames, zoomInIconClassNames, zoomOutIconClassNames, zoomToFitIconClassNames } from 'sql/workbench/contrib/executionPlan/browser/constants';
import { customZoomIconClassNames, openPlanFileIconClassNames, openPropertiesIconClassNames, openQueryIconClassNames, executionPlanNodeIconPaths, savePlanIconClassNames, searchIconClassNames, zoomInIconClassNames, zoomOutIconClassNames, zoomToFitIconClassNames, badgeIconPaths } from 'sql/workbench/contrib/executionPlan/browser/constants';
import { isString } from 'vs/base/common/types';
import { PlanHeader } from 'sql/workbench/contrib/executionPlan/browser/planHeader';
import { ExecutionPlanPropertiesView } from 'sql/workbench/contrib/executionPlan/browser/executionPlanPropertiesView';
@@ -362,12 +363,47 @@ export class ExecutionPlan implements ISashLayoutProvider {
}
}
if (node.badges) {
diagramNode.badges = [];
for (let i = 0; i < node.badges.length; i++) {
diagramNode.badges.push(this.getBadgeTypeString(node.badges[i].type));
}
}
if (node.description) {
diagramNode.description = node.description;
}
return diagramNode;
}
private getBadgeTypeString(badgeType: sqlExtHostType.executionPlan.BadgeType): {
type: string,
tooltip: string
} | undefined {
/**
* TODO: Need to figure out if tooltip have to be removed. For now, they are empty
*/
switch (badgeType) {
case sqlExtHostType.executionPlan.BadgeType.Warning:
return {
type: 'warning',
tooltip: ''
};
case sqlExtHostType.executionPlan.BadgeType.CriticalWarning:
return {
type: 'criticalWarning',
tooltip: ''
};
case sqlExtHostType.executionPlan.BadgeType.Parallelism:
return {
type: 'parallelism',
tooltip: ''
};
default:
return undefined;
}
}
private populateEdges(edge: InternalExecutionPlanEdge, diagramEdge: any) {
diagramEdge.label = '';
const edgeId = this.createGraphElementId();
@@ -401,7 +437,7 @@ export class ExecutionPlan implements ISashLayoutProvider {
let graphRoot: azdata.executionPlan.ExecutionPlanNode = this._graphModel.root;
this.populate(graphRoot, diagramRoot);
this.azdataGraphDiagram = new azdataGraph.azdataQueryPlan(container, diagramRoot, executionPlanNodeIconPaths);
this.azdataGraphDiagram = new azdataGraph.azdataQueryPlan(container, diagramRoot, executionPlanNodeIconPaths, badgeIconPaths);
this.azdataGraphDiagram.graph.setCellsMovable(false); // preventing drag and drop of graph nodes.
this.azdataGraphDiagram.graph.setCellsDisconnectable(false); // preventing graph edges to be disconnected from source and target nodes.
@@ -435,7 +471,6 @@ export class ExecutionPlan implements ISashLayoutProvider {
});
}
public set graphModel(graph: azdata.executionPlan.ExecutionPlanGraph | undefined) {
this._graphModel = graph;
if (this._graphModel) {