【问题标题】:Mimic other Microsoft provided widgets default configuration behavior模仿其他 Microsoft 提供的小部件默认配置行为
【发布时间】:2021-01-16 15:30:16
【问题描述】:
我正在开发一个自定义仪表板小部件,并且我还有一个配置页面设置。一切正常,除了我试图模仿在其他 Microsoft 提供的小部件中看到的默认“配置小部件”行为,如下图所示。我可以检测到何时未配置小部件,但我不知道要调用什么函数来打开配置模式窗口。我已经尝试检查 VSS SDK 的源代码以及在 Internet 上查找示例和文档,但还没有找到任何可行的方法。
【问题讨论】:
标签:
azure-devops
azure-devops-extensions
【解决方案1】:
发布此消息后,我决定尝试进一步深入研究,方法是创建一个仪表板,其中仅包含一个未配置的 Microsoft 小部件,该小部件具有我正在寻找的功能,然后尝试查看页面加载的一堆缩小脚本,并寻找任何可以引导我走向正确方向的东西,最终我找到了:
VSS.ready(() => {
VSS.require(['TFS/Dashboards/WidgetHelpers', 'TFS/Work/RestClient', 'VSS/Service', 'TFS/Dashboards/Services'],
(WidgetHelpers, WorkRestClient, Service, DashboardServices) => {
...
DashboardServices.WidgetHostService.getService().then((DashboardServiceHost) => {
DashboardServiceHost.showConfiguration() // This is what you want to hook up to your onClick event to show the widget configuration modal.
});
...
});
});