В качестве вклада вы используете действие, подобное этому:
{
"id": "action-id",
"type": "ms.vss-web.action",
"description": "Context menu action",
"targets": [
"ms.vss-work-web.work-item-context-menu",
"ms.vss-work-web.query-result-work-item-menu",
"ms.vss-work-web.work-item-toolbar-menu",
"ms.vss-work-web.backlog-item-menu"
],
"properties": {
"uri": "yourpagehere.html"
}
}
Ваш поставщик действий должен просто вернуть пустой пункт меню для рабочих элементов, которые не имеют отношения к делу:
function getTypesFromContext(context: any): string[] {
// Not all areas use the same format for passing work item type names.
// "workItemTypeName" for Query preview
// "workItemTypeNames" for backlogs
// "workItemType" for boards
let types = context.workItemTypeNames;
if (!types && context.workItemType) {
// Boards only support a single work item
types = [context.workItemType];
}
if (!types && context.workItemTypeName) {
// Query wi preview
types = [context.workItemTypeName];
}
return types;
}
const action = {
getMenuItems: (context) => {
const mi = {
text: "sometext",
title: "sometitle",
groupId: "modify",
icon: "someicon.png",
action: (actionContext) => {
// someaction
}
} as IContributedMenuItem;
const types = getTypesFromContext(context);
if (types.every((type) => [ <<Your relevant types here>> ].indexOf(type) >= 0)) {
return [mi];
}
return [] as IContributedMenuItem[];
}
} as IContributedMenuSource;
VSS.register(VSS.getContribution().id, action);