【问题标题】:How to hide quick add panel Backlogs Items using VSTS extension?如何使用 VSTS 扩展隐藏快速添加面板积压项目?
【发布时间】:2016-05-19 12:44:44
【问题描述】:

我想制作一个 VSTS 扩展,可以在加载页面时隐藏快速添加面板积压项。

quick add panel backlog items

扩展是针对 TFS 2015 更新 2。

我已运行此代码,但没有任何反应。

(action.html)

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Action Sample</title>
</head>
<body>
    <script src="scripts/jquery-2.2.3.min.js"></script> 
    <script src="scripts/VSS.SDK.min.js"></script> 
    <script>
      VSS.init();
      var menuContributionHandler = (function () {
      "use strict";
         return {
         execute: function (actionContext) {
             console.log("extension running...");
             $(".panel-region").hide();
             console.log("extension running...Done");                 
         }
     };
 }());

 // Associate the menuContributionHandler object with the "myAction" menu contribution from the manifest.
     VSS.register("myAction", menuContributionHandler);
    </script>
    <div>
        The end user doesn't see the content on this page.
        It is only in the background to handle the contributed menu item being clicked.
</div>
</body>

(vss-extension.json)

{
 "manifestVersion": 1,
 "id": "targetWork",
 "version": "0.1.18",
 "name": "targetWork",
 "description": "targetWork.",
 "publisher": "ms-samples",
 "public": false,
 "categories": [
   "Developer samples"
 ],
 "links": {
   "learn": {
     "uri": "https://github.com/Microsoft/vso-extension-samples"
   }
 },
 "icons": {
   "default": "images/fabrikam-logo.png"
 },
 "targets": [
   {
     "id": "Microsoft.VisualStudio.Services"
   }
 ],
 "branding": {
   "color": "rgb(190, 39, 3)",
   "theme": "dark"
 },
 "files": [
   {
     "path": "scripts",
     "addressable": true
   },
   {
     "path": "images",
     "addressable": true
   },
   {
   "path": "action.html",
         "addressable": true
       }
     ],
     "contributions": [
       {
         "id": "myAction",
         "type": "ms.vss-web.action",
         "description": "Run in Hello hub action",
         "targets": [
           "ms.vss-work-web.work-item-context-menu",
           "ms.vss-work-web.backlog-board-card-item-menu",
           ".work-hub-group",
           "ms.vss-web.project-hub-groups-collection",
           ".backlogs"
         ],
         "properties": {
           "text": "Run in Hello hub",
           "title": "Run in Hello hub",
           "icon": "images/icon.png",
           "groupId": "Explore",
           "uri": "action.html"
         }
       }
     ]
   }

查看浏览器的控制台窗口时,我没有看到该扩展程序已加载。所以我认为我对目标的使用有问题。

所以我最大的问题是我不明白应该如何指定目标。

我一直在查看与此页面相关的教程 (https://www.visualstudio.com/en-us/integrate/extensions/reference/targets/overview) 并尝试了它们,我可以让它们工作。但是没有提到如何自定义 TFS webaccess 的 UI。至少没有什么可以用于我的案例。

谢谢

编辑

感谢 jessehouwing,这个问题已经在 stackoverflow post 上得到解答

【问题讨论】:

  • 你不能跳出 iframe 去改变 TFS 本身的 DOM。您需要构建一个旧式扩展来实现这一点。

标签: tfs azure-devops tfs-2015


【解决方案1】:

新样式扩展(市场)是沙盒的,只能以预期的方式扩展 UI,例如添加按钮、菜单项、选项卡,但它们更改现有 UI 的方式非常非常有限。授予他们对完整 DOM 的访问权限将允许他们突破其安全上下文并通过使用现有功能来使用提升的权限。

你想做的是still possible with the "Legacy Extensions".

【讨论】:

  • 感谢您的回答,我们实际上已将此功能作为我们为 tfs2013 服务器所做的扩展的一部分,但在将服务器升级到 tfs2015.2 后它停止工作。然后似乎没有办法让它在 tfs2015.2 上运行..
  • Javascript 不断变化,但应该可以使用旧版扩展来完成这项工作。它不适用于新的市场扩展。
  • 使遗留扩展工作将是一个单独的问题,特别是如果您可以发布源代码。
  • 好的,我在此链接上发布了一个新问题:stackoverflow.com/questions/37326940/…
猜你喜欢
  • 2018-10-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-12-18
  • 1970-01-01
相关资源
最近更新 更多