Azure devops Azure DevOps扩展的条件上下文菜单?
是否有人找到了一种方法使上下文菜单项有条件?(贡献ID,如Azure devops Azure DevOps扩展的条件上下文菜单?,azure-devops,azure-devops-rest-api,azure-devops-extensions,Azure Devops,Azure Devops Rest Api,Azure Devops Extensions,是否有人找到了一种方法使上下文菜单项有条件?(贡献ID,如ms.vss-work-web.work项上下文菜单) 我想添加一个工作项上下文菜单项,但我只想为某些工作项类型显示它。作为贡献,您可以使用如下操作: { "id": "action-id", "type": "ms.vss-web.action", "description": "Context menu action", "targets": [ "ms.vss-work-web.wor
ms.vss-work-web.work项上下文菜单
)
我想添加一个工作项上下文菜单项,但我只想为某些工作项类型显示它。作为贡献,您可以使用如下操作:
{
"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);
函数getTypesFromContext(上下文:任意):字符串[]{
//并非所有区域都使用相同的格式来传递工作项类型名称。
//查询预览的“workItemTypeName”
//积压的“工作项类型名称”
//电路板的“工作项类型”
让类型=context.workItemTypeNames;
if(!types&&context.workItemType){
//单板仅支持单个工作项
类型=[context.workItemType];
}
if(!types&&context.workItemTypeName){
//查询wi预览
类型=[context.workItemTypeName];
}
返回类型;
}
常量动作={
getMenuItems:(上下文)=>{
常数mi={
文本:“sometext”,
标题:“sometitle”,
groupId:“修改”,
图标:“someicon.png”,
动作:(动作上下文)=>{
//行动
}
}作为我的贡献者;
const types=getTypesFromContext(上下文);
if(types.every((type)=>[].indexOf(type)>=0)){
返回[mi];
}
返回[]作为IContributedMenuItem[];
}
}作为IContributedMenuSource;
寄存器(VSS.getContribution().id,action);
作为贡献,您可以使用如下操作:
{
"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);
函数getTypesFromContext(上下文:任意):字符串[]{
//并非所有区域都使用相同的格式来传递工作项类型名称。
//查询预览的“workItemTypeName”
//积压的“工作项类型名称”
//电路板的“工作项类型”
让类型=context.workItemTypeNames;
if(!types&&context.workItemType){
//单板仅支持单个工作项
类型=[context.workItemType];
}
if(!types&&context.workItemTypeName){
//查询wi预览
类型=[context.workItemTypeName];
}
返回类型;
}
常量动作={
getMenuItems:(上下文)=>{
常数mi={
文本:“sometext”,
标题:“sometitle”,
groupId:“修改”,
图标:“someicon.png”,
动作:(动作上下文)=>{
//行动
}
}作为我的贡献者;
const types=getTypesFromContext(上下文);
if(types.every((type)=>[].indexOf(type)>=0)){
返回[mi];
}
返回[]作为IContributedMenuItem[];
}
}作为IContributedMenuSource;
寄存器(VSS.getContribution().id,action);
如果提供的答案解决了您的问题,您应该将其标记为已接受。这有助于其他人找到类似的解决方案。如果提供的答案解决了您的问题,您应该将其标记为已接受。这有助于其他人找到类似的解决方案。