Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Miscellaneous fix-ups #200

Merged
merged 6 commits into from
May 2, 2017
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ gulp.task('test-coverage', function() {
,'!out/src/contexts/repocontextfactory.js'
,'!out/src/contexts/tfvccontext.js'
,'!out/src/helpers/settings.js'
,'!out/src/helpers/vscodeutils.interfaces.js'
,'!out/src/helpers/vscodeutils.js'
,'!out/src/services/telemetry.js'
,'!out/src/services/coreapi.js'
Expand Down
8 changes: 4 additions & 4 deletions src/clients/baseclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export abstract class BaseClient {
}

protected handleError(err: Error, offlineText: string, polling: boolean, infoMessage?: string) : void {
let offline: boolean = Utils.IsOffline(err);
let msg: string = Utils.GetMessageForStatusCode(err, err.message);
let logPrefix: string = (infoMessage === undefined) ? "" : infoMessage + " ";
const offline: boolean = Utils.IsOffline(err);
const msg: string = Utils.GetMessageForStatusCode(err, err.message);
const logPrefix: string = (infoMessage === undefined) ? "" : infoMessage + " ";

//When polling, we never display an error, we only log it (no telemetry either)
if (polling === true) {
Expand All @@ -45,7 +45,7 @@ export abstract class BaseClient {
}
//If we aren't polling, we always log an error and, optionally, send telemetry
} else {
let logMessage: string = logPrefix + msg;
const logMessage: string = logPrefix + msg;
if (offline === true) {
Logger.LogError(logMessage);
} else {
Expand Down
16 changes: 8 additions & 8 deletions src/clients/buildclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class BuildClient extends BaseClient {
//Gets any available build status information and adds it to the status bar
public async DisplayCurrentBuildStatus(context: IRepositoryContext, polling: boolean, definitionId?: number): Promise<void> {
try {
let svc: BuildService = new BuildService(this._serverContext);
const svc: BuildService = new BuildService(this._serverContext);
Logger.LogInfo("Getting current build from badge...");
let buildBadge: BuildBadge;
if (context.Type === RepositoryType.GIT) {
Expand All @@ -36,7 +36,7 @@ export class BuildClient extends BaseClient {
buildBadge = await this.getTfvcBuildBadge(svc, this._serverContext.RepoInfo.TeamProject);
} else if (definitionId) {
//TODO: Allow definitionId to override Git and TFVC defaults (above)?
let builds: Build[] = await svc.GetBuildsByDefinitionId(this._serverContext.RepoInfo.TeamProject, definitionId);
const builds: Build[] = await svc.GetBuildsByDefinitionId(this._serverContext.RepoInfo.TeamProject, definitionId);
if (builds.length > 0) {
buildBadge = { buildId: builds[0].id, imageUrl: undefined };
} else {
Expand All @@ -45,13 +45,13 @@ export class BuildClient extends BaseClient {
}
if (buildBadge && buildBadge.buildId !== undefined) {
Logger.LogInfo("Found build id " + buildBadge.buildId.toString() + ". Getting build details...");
let build: Build = await svc.GetBuildById(buildBadge.buildId);
const build: Build = await svc.GetBuildById(buildBadge.buildId);
this._buildSummaryUrl = BuildService.GetBuildSummaryUrl(this._serverContext.RepoInfo.TeamProjectUrl, build.id.toString());
Logger.LogInfo("Build summary info: " + build.id.toString() + " " + BuildStatus[build.status] +
" " + BuildResult[build.result] + " " + this._buildSummaryUrl);

if (this._statusBarItem !== undefined) {
let icon: string = Utils.GetBuildResultIcon(build.result);
const icon: string = Utils.GetBuildResultIcon(build.result);
this._statusBarItem.command = CommandNames.OpenBuildSummaryPage;
this._statusBarItem.text = `$(icon octicon-package) ` + `$(icon ${icon})`;
this._statusBarItem.tooltip = "(" + BuildResult[build.result] + ") " + Strings.NavigateToBuildSummary + " " + build.buildNumber;
Expand All @@ -73,16 +73,16 @@ export class BuildClient extends BaseClient {
//Gets the appropriate build for TFVC repositories and returns a 'BuildBadge' for it
private async getTfvcBuildBadge(svc: BuildService, teamProjectId: string): Promise<BuildBadge> {
//Create an build that doesn't exist and use as the default
let emptyBuild: BuildBadge = { buildId: undefined, imageUrl: undefined };
const emptyBuild: BuildBadge = { buildId: undefined, imageUrl: undefined };

let builds: Build[] = await svc.GetBuilds(teamProjectId);
const builds: Build[] = await svc.GetBuilds(teamProjectId);
if (builds.length === 0) {
return emptyBuild;
}

let matchingBuild: Build;
for (let idx = 0; idx < builds.length; idx++) {
let b: Build = builds[idx];
for (let idx: number = 0; idx < builds.length; idx++) {
const b: Build = builds[idx];
// Ignore canceled builds
if (b.result === BuildResult.Canceled) {
continue;
Expand Down
8 changes: 4 additions & 4 deletions src/clients/coreapiclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ export class CoreApiClient {
/* tslint:enable:no-empty */

public async GetTeamProject(remoteUrl: string, teamProjectName: string): Promise<TeamProject> {
let svc: CoreApiService = new CoreApiService(remoteUrl);
let teamProject:TeamProject = await svc.GetTeamProject(teamProjectName);
const svc: CoreApiService = new CoreApiService(remoteUrl);
const teamProject:TeamProject = await svc.GetTeamProject(teamProjectName);
return teamProject;
}

public async GetProjectCollection(remoteUrl: string, collectionName: string): Promise<TeamProjectCollection> {
let svc: CoreApiService = new CoreApiService(remoteUrl);
let collection:TeamProjectCollection = await svc.GetProjectCollection(collectionName);
const svc: CoreApiService = new CoreApiService(remoteUrl);
const collection:TeamProjectCollection = await svc.GetProjectCollection(collectionName);
return collection;
}

Expand Down
18 changes: 9 additions & 9 deletions src/clients/feedbackclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
"use strict";

import { window } from "vscode";
import { Disposable, window } from "vscode";
import { Logger } from "../helpers/logger";
import { TelemetryEvents } from "../helpers/constants";
import { Strings } from "../helpers/strings";
Expand All @@ -21,24 +21,24 @@ export class FeedbackClient {
//This feedback will go no matter whether Application Insights is enabled or not.
public async SendFeedback(): Promise<void> {
try {
let choices: BaseQuickPickItem[] = [];
const choices: BaseQuickPickItem[] = [];
choices.push({ label: Strings.SendASmile, description: undefined, id: TelemetryEvents.SendASmile });
choices.push({ label: Strings.SendAFrown, description: undefined, id: TelemetryEvents.SendAFrown });

let choice: BaseQuickPickItem = await window.showQuickPick(choices, { matchOnDescription: false, placeHolder: Strings.SendFeedback });
const choice: BaseQuickPickItem = await window.showQuickPick(choices, { matchOnDescription: false, placeHolder: Strings.SendFeedback });
if (choice) {
let value: string = await window.showInputBox({ value: undefined, prompt: Strings.SendFeedbackPrompt, placeHolder: undefined, password: false });
const value: string = await window.showInputBox({ value: undefined, prompt: Strings.SendFeedbackPrompt, placeHolder: undefined, password: false });
if (value === undefined) {
let disposable = window.setStatusBarMessage(Strings.NoFeedbackSent);
const disposable = window.setStatusBarMessage(Strings.NoFeedbackSent);
setInterval(() => disposable.dispose(), 1000 * 5);
return;
}

//User does not need to provide any feedback text
let providedEmail: string = "";
let email: string = await window.showInputBox({ value: undefined, prompt: Strings.SendEmailPrompt, placeHolder: undefined, password: false });
const email: string = await window.showInputBox({ value: undefined, prompt: Strings.SendEmailPrompt, placeHolder: undefined, password: false });
if (email === undefined) {
let disposable = window.setStatusBarMessage(Strings.NoFeedbackSent);
const disposable = window.setStatusBarMessage(Strings.NoFeedbackSent);
setInterval(() => disposable.dispose(), 1000 * 5);
return;
}
Expand All @@ -48,11 +48,11 @@ export class FeedbackClient {
//This feedback will go no matter whether Application Insights is enabled or not.
Telemetry.SendFeedback(choice.id, { "VSCode.Feedback.Comment" : value, "VSCode.Feedback.Email" : providedEmail} );

let disposable = window.setStatusBarMessage(Strings.ThanksForFeedback);
const disposable: Disposable = window.setStatusBarMessage(Strings.ThanksForFeedback);
setInterval(() => disposable.dispose(), 1000 * 5);
}
} catch (err) {
let message: string = Utils.GetMessageForStatusCode(0, err.message, "Failed getting SendFeedback selection");
const message: string = Utils.GetMessageForStatusCode(0, err.message, "Failed getting SendFeedback selection");
Logger.LogError(message);
Telemetry.SendException(err);
}
Expand Down
34 changes: 17 additions & 17 deletions src/clients/gitclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class GitClient extends BaseClient {
Telemetry.SendEvent(TelemetryEvents.ViewPullRequests);

try {
let request: BaseQuickPickItem = await window.showQuickPick(this.getMyPullRequests(), { matchOnDescription: true, placeHolder: Strings.ChoosePullRequest });
const request: BaseQuickPickItem = await window.showQuickPick(this.getMyPullRequests(), { matchOnDescription: true, placeHolder: Strings.ChoosePullRequest });
if (request) {
Telemetry.SendEvent(TelemetryEvents.ViewPullRequest);
let discUrl: string = undefined;
Expand All @@ -52,7 +52,7 @@ export class GitClient extends BaseClient {
this.ensureGitContext(context);
let url: string = undefined;

let editor = window.activeTextEditor;
const editor = window.activeTextEditor;
if (editor) {
Telemetry.SendEvent(TelemetryEvents.OpenBlamePage);

Expand All @@ -65,7 +65,7 @@ export class GitClient extends BaseClient {
Logger.LogInfo("OpenBlame: " + url);
Utils.OpenUrl(url);
} else {
let msg: string = Utils.GetMessageForStatusCode(0, Strings.NoSourceFileForBlame);
const msg: string = Utils.GetMessageForStatusCode(0, Strings.NoSourceFileForBlame);
Logger.LogError(msg);
VsCodeUtils.ShowErrorMessage(msg);
}
Expand All @@ -76,7 +76,7 @@ export class GitClient extends BaseClient {
this.ensureGitContext(context);
let historyUrl: string = undefined;

let editor = window.activeTextEditor;
const editor = window.activeTextEditor;
if (!editor) {
Telemetry.SendEvent(TelemetryEvents.OpenRepositoryHistory);

Expand All @@ -100,22 +100,22 @@ export class GitClient extends BaseClient {
public OpenNewPullRequest(remoteUrl: string, currentBranch: string): void {
Telemetry.SendEvent(TelemetryEvents.OpenNewPullRequest);

let url: string = GitVcService.GetCreatePullRequestUrl(remoteUrl, currentBranch);
const url: string = GitVcService.GetCreatePullRequestUrl(remoteUrl, currentBranch);
Logger.LogInfo("CreatePullRequestPage: " + url);
Utils.OpenUrl(url);
}

public OpenPullRequestsPage(): void {
Telemetry.SendEvent(TelemetryEvents.OpenPullRequestsPage);

let url: string = GitVcService.GetPullRequestsUrl(this._serverContext.RepoInfo.RepositoryUrl);
const url: string = GitVcService.GetPullRequestsUrl(this._serverContext.RepoInfo.RepositoryUrl);
Logger.LogInfo("OpenPullRequestsPage: " + url);
Utils.OpenUrl(url);
}

public async PollMyPullRequests(): Promise<void> {
try {
let requests: BaseQuickPickItem[] = await this.getMyPullRequests();
const requests: BaseQuickPickItem[] = await this.getMyPullRequests();
this._statusBarItem.tooltip = Strings.BrowseYourPullRequests;
//Remove the default Strings.BrowseYourPullRequests item from the calculation
this._statusBarItem.text = GitClient.GetPullRequestStatusText((requests.length - 1).toString());
Expand All @@ -125,28 +125,28 @@ export class GitClient extends BaseClient {
}

private async getMyPullRequests(): Promise<BaseQuickPickItem[]> {
let requestItems: BaseQuickPickItem[] = [];
let requestIds: number[] = [];
const requestItems: BaseQuickPickItem[] = [];
const requestIds: number[] = [];

Logger.LogInfo("Getting pull requests that I requested...");
let svc: GitVcService = new GitVcService(this._serverContext);
let myPullRequests: GitPullRequest[] = await svc.GetPullRequests(this._serverContext.RepoInfo.RepositoryId, this._serverContext.UserInfo.Id, undefined, PullRequestStatus.Active);
let icon: string = "octicon-search";
let label: string = `$(icon ${icon}) `;
const svc: GitVcService = new GitVcService(this._serverContext);
const myPullRequests: GitPullRequest[] = await svc.GetPullRequests(this._serverContext.RepoInfo.RepositoryId, this._serverContext.UserInfo.Id, undefined, PullRequestStatus.Active);
const icon: string = "octicon-search";
const label: string = `$(icon ${icon}) `;
requestItems.push({ label: label + Strings.BrowseYourPullRequests, description: undefined, id: undefined });

myPullRequests.forEach((pr) => {
let score: PullRequestScore = GitVcService.GetPullRequestScore(pr);
const score: PullRequestScore = GitVcService.GetPullRequestScore(pr);
requestItems.push(this.getPullRequestLabel(pr.createdBy.displayName, pr.title, pr.description, pr.pullRequestId.toString(), score));
requestIds.push(pr.pullRequestId);
});
Logger.LogInfo("Retrieved " + myPullRequests.length + " pull requests that I requested");

Logger.LogInfo("Getting pull requests for which I'm a reviewer...");
//Go get the active pull requests that I'm a reviewer for
let myReviewPullRequests: GitPullRequest[] = await svc.GetPullRequests(this._serverContext.RepoInfo.RepositoryId, undefined, this._serverContext.UserInfo.Id, PullRequestStatus.Active);
const myReviewPullRequests: GitPullRequest[] = await svc.GetPullRequests(this._serverContext.RepoInfo.RepositoryId, undefined, this._serverContext.UserInfo.Id, PullRequestStatus.Active);
myReviewPullRequests.forEach((pr) => {
let score: PullRequestScore = GitVcService.GetPullRequestScore(pr);
const score: PullRequestScore = GitVcService.GetPullRequestScore(pr);
if (requestIds.indexOf(pr.pullRequestId) < 0) {
requestItems.push(this.getPullRequestLabel(pr.createdBy.displayName, pr.title, pr.description, pr.pullRequestId.toString(), score));
}
Expand All @@ -172,7 +172,7 @@ export class GitClient extends BaseClient {
} else if (score === PullRequestScore.NoResponse) {
scoreIcon = "octicon-git-pull-request";
}
let scoreLabel: string = `$(icon ${scoreIcon}) `;
const scoreLabel: string = `$(icon ${scoreIcon}) `;

return { label: scoreLabel + " (" + displayName + ") " + title, description: description, id: id };
}
Expand Down
Loading