Azure DevOps extension custom UI

☆樱花仙子☆ 提交于 2019-12-08 11:37:40

问题


I've been tasked to develop an extension for Azure DevOps to automate building process - a custom Build Task. The caveat is that in reality what I am developing is a series of build task, each containing regular inputs. But for historical reasons, all these build tasks should be grouped and the user would be able to choose the correct one from a drop-down list on the tasks' page in the pipeline settings.

The issue being is that the change in the drop down should hide SOME of the inputs and show some other inputs as well - i.e. I'd like to handle the CHANGE event of the drop-down and control the visibility of the UI elements.

Is this even possible?

Am I on the wrong track? How can I approach this?


回答1:


The solution is simple, but it isn't obvious as of yet.

There is a property to each input, called visibleRule which does exactly whats needed: control the visibility of of the input it is attached to. So in the task.json file, in the inputs array, one could do this:

Define the drop-down:

{
  "name": "selectedOption",
  "type": "pickList",
  "label": "Options",
  "options": {
    "o1": "Option 1",
    "o2": "Option 2",
    "o3": "Option 3"
  }
},

Then define some fields like this:

{
  "name": "test1",
  "type": "string",
  "label": "Option 1 test",
  "visibleRule": "selectedOption = o1"
},
{
  "name": "test2",
  "type": "string",
  "label": "Option 2 test",
  "visibleRule": "selectedOption = o2"
},

Now the test1 input is diplayed ONLY if o1 (Option 1) is selected in the selectedOption drop-down. The same goes for test2 and o2. Neither test1 nor test2 is displayed if the selectedOption is o3.



来源:https://stackoverflow.com/questions/53240667/azure-devops-extension-custom-ui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!