【发布时间】:2016-05-19 12:44:44
【问题描述】:
我想制作一个 VSTS 扩展,可以在加载页面时隐藏快速添加面板积压项。
扩展是针对 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