如何在Azure devops中以编程方式选择多个工作项?

时间:2019-06-24 16:32:15

标签: tfs azure-devops

我正在编写ADO的Task Creator扩展,在其中我们可以为多个WIT创建多个任务。

目前,我有一个有效的扩展程序,它允许在单个PBI上创建多个任务。

这是清单文件的外观

{
"manifestVersion": 1,
"id": "taskcreatortest",
"version": "1.0.24",
"name": "TaskCreator",
"description": "Create bulk tasks for a Work Item",
"publisher": "ZankhanaRana",
"galleryFlags": [
"Preview"
],
"icons": {
"default": "static/images/logo.png"
},
"scopes": [
"vso.work_write",
"vso.work",
"vso.code"
],
"targets": [
{
  "id": "Microsoft.VisualStudio.Services"
}
],
"screenshots": [
{
    "path": "static/images/menu.png"
},
{
    "path": "static/images/createtaskform.png"
}
],
"demands": [
"api-version/3.0"
],
"tags": [
"TFS/VSTS Task Creator","Task"
],

"content": {
"details": {
  "path": "overview.md"
},
"license": {
  "path": "license.md"
}
},
"links": {
"getstarted": {
  "uri": "https://bit.ly"
},
"support": {
  "uri": "https://bit.ly"
},
"issues": {
  "uri": "https://bit.ly"
}
},
"repository": {
"type": "git",
"uri": "https://bit.ly"
},
"branding": {
"color": "rgb(220, 235, 252)",
"theme": "light"
},
"files": [ ... ],
"categories": [
"Azure Test Plans"
],
"contributions": [
{
  "id": "createtasks-context-menu",
  "type": "ms.vss-web.action",
  "description": "Toolbar item to create tasks for a work item",  
  "targets":[ 
    "ms.vss-work-web.work-item-context-menu",
    "ms.vss-work-web.work-item-toolbar-menu"
  ],
 "properties": {
    "uri": "static/index.html",
    "text": "Create Tasks",
    "title": "Create multiple tasks for a work item",
    "toolbarText": "Create Tasks",
    "groupId":"core"
  }
},
{
  "id": "createTasks-Form",
  "type": "ms.vss-web.control",
  "description": "Select task to create",
  "targets": [ ],
  "properties": {
      "uri": "static/createTaskForm.html"
  }
}
]
}

我无法选择多个工作项,右键单击并创建任务。

弹出警告消息“仅选择一项”。

我还安装了其他自定义扩展,例如Microsoft Devlabs的“工作项可视化”,它允许选择多个项。我认为这与我的配置/清单文件有关。

有人可以指出我在做什么错吗?

1 个答案:

答案 0 :(得分:0)

我找到了解决此问题的方法。最初,我认为它与扩展配置文件(vss-extension.json)有关;但是我的脚本中有一个代码,用于检查选定的项目数,如果项目数大于1,它将返回警报框。

我改变了条件,一切正常。

VSS.ready(function () {
        VSS.register(VSS.getContribution().id, function (context) {
            return {
                execute: function (actionContext) {
                    if (actionContext.workItemDirty)
                        showDialog("Please save your work item first");

                    else if (actionContext.workItemIds && actionContext.workItemIds.length > 1)
                        showDialog("Select only one work item");
                    else {
                        var workItemType = getWorkItemType(actionContext)
                        if ($.inArray(workItemType, allowedWorkItemTypes) >= 0)
                            showPropertiesInDialog(actionContext, "Create Tasks");
                        else
                        showDialog("Not available for " + workItemType);
                    }
                }
            };
        });

        VSS.notifyLoadSucceeded();
    });