Skip to content
Closed
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
50 changes: 40 additions & 10 deletions src/Samples/Menu/Menu.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,46 @@
import "es6-promise/auto";

import * as SDK from "azure-devops-extension-sdk";
import { CommonServiceIds, getClient, IHostPageLayoutService } from "azure-devops-extension-api";
import { BuildDefinition, BuildRestClient } from "azure-devops-extension-api/Build";

import {
BuildDefinition,
BuildRestClient,
} from "azure-devops-extension-api/Build";
import {
CommonServiceIds,
IHostPageLayoutService,
getClient,
} from "azure-devops-extension-api";

SDK.register("sample-build-menu", () => {
return {
execute: async (context: BuildDefinition) => {
const result = await getClient(BuildRestClient).getDefinition(context.project.id, context.id, undefined, undefined, undefined, true);
const dialogSvc = await SDK.getService<IHostPageLayoutService>(CommonServiceIds.HostPageLayoutService);
dialogSvc.openMessageDialog(`Fetched build definition ${result.name}. Latest build: ${JSON.stringify(result.latestBuild)}`, { showCancel: false });
}
}
return {
/**
* Based on the target of the menu item, context can contain relevant data from the initial page the menu was accessed from
*
* Example: When targeting Azure Repos menu (ms.vss-code-web.source-item-menu), context will contain the following properties:
* - gitRepository: The currently selected git repository
* - version: The currently selected branch
*/
execute: async (context: BuildDefinition) => {
const result = await getClient(BuildRestClient).getDefinition(
context.project.id,
context.id,
undefined,
undefined,
undefined,
true
);
const dialogSvc = await SDK.getService<IHostPageLayoutService>(
CommonServiceIds.HostPageLayoutService
);
dialogSvc.openMessageDialog(
`Fetched build definition ${
result.name
}. Latest build: ${JSON.stringify(result.latestBuild)}`,
{ showCancel: false }
);
},
};
});

SDK.init();
SDK.init();