Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/sql/azdata.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,27 @@ declare module 'azdata' {
* Edges corresponding to the children.
*/
edges: ExecutionPlanEdge[];
/**
* Warning/parallelism badges applicable to the current node
*/
badges: ExecutionPlanBadge[];
}

export interface ExecutionPlanBadge {
/**
* Type of the node overlay. This determines the icon that is displayed for it
*/
type: BadgeType;
/**
* Text to display for the overlay tooltip
*/
tooltip: string;
}

export enum BadgeType {
Warning = 0,
CriticalWarning = 1,
Parallelism = 2
}

export interface ExecutionPlanEdge {
Expand Down
7 changes: 6 additions & 1 deletion src/sql/workbench/api/common/sqlExtHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,10 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
}
};

const executionPlan: typeof azdata.executionPlan = {
BadgeType: sqlExtHostTypes.executionPlan.BadgeType
};

return {
version: initData.version,
accounts,
Expand Down Expand Up @@ -644,7 +648,8 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
TabOrientation: sqlExtHostTypes.TabOrientation,
sqlAssessment,
TextType: sqlExtHostTypes.TextType,
designers: designers
designers: designers,
executionPlan: executionPlan
};
},
extHostNotebook: extHostNotebook,
Expand Down
8 changes: 8 additions & 0 deletions src/sql/workbench/api/common/sqlExtHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1031,3 +1031,11 @@ export namespace designers {
GraphNode = 'GraphNode'
}
}

export namespace executionPlan {
export enum BadgeType {
Warning = 0,
CriticalWarning = 1,
Parallelism = 2
}
}
8 changes: 8 additions & 0 deletions src/sql/workbench/contrib/executionPlan/browser/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,14 @@ export let executionPlanNodeIconPaths =
unionAll: imageBasePath + 'union_all.png'
};

export const badgeIconPaths = {
warning: imageBasePath + 'badge_warning.svg',

parallelism: imageBasePath + 'badge_parallelism.svg',

criticalWarning: imageBasePath + 'badge_critical_warning.svg'
};

const parentContainer = 'qps-container';
export const savePlanIconClassNames = [parentContainer, 'save-plan-icon'].join(' ');
export const openPropertiesIconClassNames = [parentContainer, 'open-properties-icon'].join(' ');
Expand Down
43 changes: 39 additions & 4 deletions src/sql/workbench/contrib/executionPlan/browser/executionPlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -435,7 +471,6 @@ export class ExecutionPlan implements ISashLayoutProvider {
});
}


public set graphModel(graph: azdata.executionPlan.ExecutionPlanGraph | undefined) {
this._graphModel = graph;
if (this._graphModel) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ However we always want it to be the width of the container it is resizing.
width: 100%;
height: 100%;
overflow: scroll;
position: relative;
}

/* Properties view in execution plan */
Expand Down