Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix samples #588

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/creation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function run() {
/********** Dashboard **********/
printSectionStart("Dashboard");
const dashboardApi = await vstsCollectionLevel.getDashboardApi();
const widgetTypes: WidgetTypesResponse = await dashboardApi.getWidgetTypes(WidgetScope.Collection_User);
const widgetTypes: WidgetTypesResponse = await dashboardApi.getWidgetTypes(WidgetScope.Collection_User, common.getProject());

if (widgetTypes) {
console.log(`found ${widgetTypes.widgetTypes.length} widget types`);
Expand Down
4 changes: 2 additions & 2 deletions samples/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function run(projectId: string) {
typeId: null,
url: null
};
const widgetMetadata: DashboardInterfaces.WidgetMetadataResponse = await dashboardApiObject.getWidgetMetadata('ms.vss-dashboards-web.Microsoft.VisualStudioOnline.Dashboards.OtherLinksWidget');
const widgetMetadata: DashboardInterfaces.WidgetMetadataResponse = await dashboardApiObject.getWidgetMetadata('ms.vss-dashboards-web.Microsoft.VisualStudioOnline.Dashboards.OtherLinksWidget', projectId);
console.log('Creating widget with metadata:', widgetMetadata);
widget = await dashboardApiObject.createWidget(widget, teamContext, dashboard.id);
//Ensure its been created and we can get it.
Expand All @@ -72,7 +72,7 @@ export async function run(projectId: string) {
console.log('Widget name updated to', widget.name);

common.heading('Get Widget data');
const widgetTypes: DashboardInterfaces.WidgetTypesResponse = await dashboardApiObject.getWidgetTypes(DashboardInterfaces.WidgetScope.Project_Team);
const widgetTypes: DashboardInterfaces.WidgetTypesResponse = await dashboardApiObject.getWidgetTypes(DashboardInterfaces.WidgetScope.Project_Team, projectId);
console.log('First widget type:', widgetTypes.widgetTypes[0]);

common.heading('Delete a widget');
Expand Down
132 changes: 103 additions & 29 deletions samples/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 15 additions & 10 deletions samples/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let samples: string[] = require("./samples.json");
let coreApi: cApi.ICoreApi;
const maxLoops: number = 500;

let selection: string = process.argv[2];
const selection: string = process.argv[2];
if (selection) {
if (samples.indexOf(selection) == -1) {
console.error("Not a valid sample. See list of samples");
Expand Down Expand Up @@ -41,7 +41,19 @@ async function createProject(projectId: string): Promise<boolean> {
revision: null,
state: null,
url: null};
await coreApi.queueCreateProject(projectToCreate);
let num = 0;
while (num < maxLoops) {
try {
await coreApi.queueCreateProject(projectToCreate);
break;
} catch (err) {
const errTypeKey = err.result.typeKey.toString();
if (!(errTypeKey == 'ProjectWorkPendingException' || errTypeKey == 'ProjectAlreadyExistsException')) {
throw err;
}
num++;
}
}

//Poll until project exists
let project: coreInterfaces.TeamProject = null;
Expand Down Expand Up @@ -114,11 +126,4 @@ async function runSamples(selected?: string) {
}
}

function run() {
runSamples();
}

runSamples(process.argv[2]);



runSamples(selection);