I am trying to create a azure devops widget to pull all PRs associated with the project . The widget is working but only pulling one PR data and not all. Below is the widget code I am using
VSS.require(["TFS/Dashboards/WidgetHelpers","TFS/VersionControl/GitRestClient"],
function (WidgetHelpers, TFS_Wit_WebApi) {
WidgetHelpers.IncludeWidgetStyles();
VSS.register("PRDuration", function () {
var projectId = VSS.getWebContext().project.id;
var getQueryInfo = function (widgetSettings) {
// Get a WIT client to make REST calls to Azure DevOps Services
return TFS_Wit_WebApi.getClient().getPullRequestsByProject(projectId,"status: All ",null,0,100)
.then(function (prs) {
var $list = $('<ul>');
prs.forEach(function(pr) {
//$list.append($('<li>').text("Project ID: " + projectId));
//$list.append($('<li>').text("Pull Request ID: " + pr.pullRequestId));
$list.append($('<li>').text("Pull Request title: " + pr.title));
$list.append($('<li>').text("Pull Request createdBy: " + pr.createdBy))
$list.append($('<li>').text("Pull Request creationDate: " + pr.creationDate));
$list.append($('<li>').text("Pull Request closedDate: " + pr.closedDate));
;
//$list.append($('<li>').text("Query Name: " + query.name));
//$list.append($('<li>').text("Created By: " + (query.createdBy ? query.createdBy.displayName: "<unknown>") ));
})
// Append the list to the query-info-container
var $container = $('#query-info-container');
$container.empty();
$container.append($list);
// Use the widget helper and return success as Widget Status
return WidgetHelpers.WidgetStatusHelper.Success();
}, function (error) {
// Use the widget helper and return failure as Widget Status
return WidgetHelpers.WidgetStatusHelper.Failure(error.message);
});
}
return {
load: function (widgetSettings) {
// Set your title
var $title = $('h2.title');
$title.text('Hello World');
return getQueryInfo(widgetSettings);
}
}
});
VSS.notifyLoadSucceeded();
});
When I used this widget it seems to be making below API call and fetching just one result :
https://dev.azure.com/orgname/projectId/_apis/git/pullRequests?searchCriteria=status:All&api-version=6.0
If I am changing the api URL as below then I get all the results :
https://dev.azure.com/orgname/projectId/_apis/git/pullRequests?searchCriteria.status=All&api-version=6.0
Is there a way I can fix this in search criteria of function getPullRequestsByProject to get all results?