Skip to content

Commit

Permalink
Added open build in browser. Closes #6.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlandersen committed Oct 2, 2016
1 parent 2677cd4 commit 0d49f7d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
"*"
],
"main": "./out/src/extension",
"types": "./node-rest-client.d.ts",
"scripts": {
"vscode:prepublish": "tsc -p ./",
"compile": "tsc -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install"
},
"dependencies": {
"node-rest-client": "^2.0.0"
"node-rest-client": "^2.0.0",
"openurl": "^1.1.1"
},
"devDependencies": {
"typescript": "^2.0.3",
Expand Down Expand Up @@ -88,6 +88,10 @@
{
"command": "extension.openVstsBuildLogSelection",
"title": " VSTS Build Status: View Build Log"
},
{
"command": "extension.openVstsBuildWebSelection",
"title": "VSTS Build Status: Open Build in Browser"
}
]
}
Expand Down
3 changes: 3 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.commands.registerCommand('extension.openVstsBuildDefinitionSelection', () => buildServiceStatus.openBuildDefinitionSelection()));

context.subscriptions.push(
vscode.commands.registerCommand('extension.openVstsBuildWebSelection', () => buildServiceStatus.openBuildWebSelection()));

context.subscriptions.push(
vscode.commands.registerCommand('extension.openVstsBuildLogSelection', () => buildServiceStatus.openBuildLogSelection()));

Expand Down
5 changes: 5 additions & 0 deletions src/vstsbuildrestclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export interface Build {
reason: string;
startTime: string;
queueTime: string;
_links: {
web: {
href: string;
};
}
}

export interface BuildDefinition {
Expand Down
19 changes: 18 additions & 1 deletion src/vstsbuildstatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {Settings} from "./settings";
import {VstsBuildStatusBar} from "./vstsbuildstatusbar";
import {Build, BuildDefinition, VstsBuildRestClient, VstsBuildRestClientFactory} from "./vstsbuildrestclient";
import fs = require("fs");
import openurl = require("openurl");

interface BuildDefinitionQuickPickItem {
id: number;
Expand Down Expand Up @@ -50,7 +51,7 @@ export class VstsBuildStatus {

public updateStatus(): void {
// Updates the status bar depending on the state.
// If everything goes well, the method is set up to be called periodically.
// If everything goes well, the method ißs set up to be called periodically.

if (!this.settings.isValid()) {
this.tryCancelPeriodicStatusUpdate();
Expand Down Expand Up @@ -99,6 +100,22 @@ export class VstsBuildStatus {
});
}

public openBuildWebSelection(): void {
this.getBuildDefinitionByQuickPick("Select a build definition").then(result => {
if (!result) {
return;
}

return this.getBuildByQuickPick(result, "Select a build to open");
}).then(build => {
if (!build) {
return;
}

openurl.open(build._links.web.href);
});
}

public openBuildLogSelection(): void {
this.getBuildDefinitionByQuickPick("Select a build definition").then(result => {
if (!result) {
Expand Down
1 change: 1 addition & 0 deletions typings/openurl.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'openurl';

0 comments on commit 0d49f7d

Please sign in to comment.