我想制作一个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
上得到解答答案 0 :(得分:0)
新样式扩展(marketplace)是沙盒化的,只能以预期的方式扩展UI,例如添加按钮,菜单项,选项卡,但它们具有非常非常有限的方式来更改现有UI。允许他们访问完整的DOM将允许他们突破安全上下文并使用现有功能来提升权限。