From 4aa9c6235f292ed818d7037464c664753013eaaf Mon Sep 17 00:00:00 2001 From: Jason Prickett Date: Wed, 15 Feb 2017 17:18:52 -0500 Subject: [PATCH 1/2] Added Associate Work Items command for TFVC - it simply adds the string to the commit message --- package.json | 5 +++++ src/clients/witclient.ts | 11 +++++++++++ src/extension.ts | 1 + src/helpers/constants.ts | 1 + src/team-extension.ts | 6 ++++++ src/tfvc/tfvc-extension.ts | 9 +++++++++ src/tfvc/tfvcscmprovider.ts | 9 +++++++++ 7 files changed, 42 insertions(+) diff --git a/package.json b/package.json index 555909cd8..6499e53ae 100644 --- a/package.json +++ b/package.json @@ -244,6 +244,11 @@ "title": "Signout", "category": "Team" }, + { + "command": "tfvc.AssociateWorkItems", + "title": "Associate Work Items", + "category": "TFVC" + }, { "command": "tfvc.Checkin", "title": "Checkin", diff --git a/src/clients/witclient.ts b/src/clients/witclient.ts index ca71c421d..20edc6888 100644 --- a/src/clients/witclient.ts +++ b/src/clients/witclient.ts @@ -107,6 +107,17 @@ export class WitClient { } } + public async ChooseWorkItems(): Promise { + Logger.LogInfo("Getting work items..."); + // TODO: There isn't a way to do a multi select pick list right now, but when there is we should change this to use it. + let workItem: BaseQuickPickItem = await window.showQuickPick(await this.getMyWorkItems(this._serverContext.RepoInfo.TeamProject, WitQueries.MyWorkItems), { matchOnDescription: true, placeHolder: Strings.ChooseWorkItem }); + if (workItem) { + return ["#" + workItem.id + " - " + workItem.description]; + } else { + return []; + } + } + private async showWorkItems(wiql: string): Promise { Logger.LogInfo("Getting work items..."); let workItem: BaseQuickPickItem = await window.showQuickPick(await this.getMyWorkItems(this._serverContext.RepoInfo.TeamProject, wiql), { matchOnDescription: true, placeHolder: Strings.ChooseWorkItem }); diff --git a/src/extension.ts b/src/extension.ts index 70e8be943..87711ccba 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -71,4 +71,5 @@ export async function activate(context: ExtensionContext) { })); context.subscriptions.push(commands.registerCommand(TfvcCommandNames.Checkin, () => _extensionManager.Tfvc.Checkin())); context.subscriptions.push(commands.registerCommand(TfvcCommandNames.Sync, () => _extensionManager.Tfvc.Sync())); + context.subscriptions.push(commands.registerCommand(TfvcCommandNames.AssociateWorkItems, () => _extensionManager.Tfvc.AssociateWorkItems())); } diff --git a/src/helpers/constants.ts b/src/helpers/constants.ts index 282c96df1..c689dbb42 100644 --- a/src/helpers/constants.ts +++ b/src/helpers/constants.ts @@ -36,6 +36,7 @@ export class CommandNames { export class TfvcCommandNames { static CommandPrefix: string = "tfvc."; + static AssociateWorkItems: string = TfvcCommandNames.CommandPrefix + "AssociateWorkItems"; static Checkin: string = TfvcCommandNames.CommandPrefix + "Checkin"; static Exclude: string = TfvcCommandNames.CommandPrefix + "Exclude"; static ExcludeAll: string = TfvcCommandNames.CommandPrefix + "ExcludeAll"; diff --git a/src/team-extension.ts b/src/team-extension.ts index 9817a28b1..6428ac3e9 100644 --- a/src/team-extension.ts +++ b/src/team-extension.ts @@ -236,6 +236,12 @@ export class TeamExtension { this._manager.FeedbackClient.SendFeedback(); } + //Returns a list of strings representing the work items that the user chose + // strings are in the form "#id - description" + public async ChooseWorkItems(): Promise { + return await this._witClient.ChooseWorkItems(); + } + //Returns the list of work items assigned directly to the current user public ViewMyWorkItems(): void { if (this._manager.EnsureInitialized(RepositoryType.ANY)) { diff --git a/src/tfvc/tfvc-extension.ts b/src/tfvc/tfvc-extension.ts index 83f59a1d5..faa795188 100644 --- a/src/tfvc/tfvc-extension.ts +++ b/src/tfvc/tfvc-extension.ts @@ -32,6 +32,15 @@ export class TfvcExtension { this._manager = manager; } + public async AssociateWorkItems(): Promise { + this.displayErrors(async () => { + let workitems: string[] = await this._manager.Team.ChooseWorkItems(); + for (let i: number = 0; i < workitems.length; i++) { + TfvcSCMProvider.AppendToCheckinMessage(workitems[i]); + } + }); + } + public async Checkin(): Promise { this.displayErrors(async () => { // get the checkin info from the SCM viewlet diff --git a/src/tfvc/tfvcscmprovider.ts b/src/tfvc/tfvcscmprovider.ts index 2b5d7af32..a8eb325c4 100644 --- a/src/tfvc/tfvcscmprovider.ts +++ b/src/tfvc/tfvcscmprovider.ts @@ -44,6 +44,15 @@ export class TfvcSCMProvider implements SCMProvider { scm.inputBox.value = ""; } + public static AppendToCheckinMessage(line: string): void { + const previousMessage = scm.inputBox.value; + if (previousMessage) { + scm.inputBox.value = previousMessage + "\n" + line; + } else { + scm.inputBox.value = line; + } + } + public static GetCheckinInfo(): ICheckinInfo { const tfvcProvider: TfvcSCMProvider = TfvcSCMProvider.GetProviderInstance(); From c80da6ddab9116ba09db48b9e114e8d6be98df8a Mon Sep 17 00:00:00 2001 From: Jason Prickett Date: Wed, 15 Feb 2017 17:36:50 -0500 Subject: [PATCH 2/2] Added associate command to context menu of viewlet Also added checkin there as well --- package.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/package.json b/package.json index 6499e53ae..c68053de3 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,16 @@ "group": "1_sync@2", "when": "scmProvider == tfvc" }, + { + "command" : "tfvc.Checkin", + "group": "3_commit@3", + "when": "scmProvider == tfvc" + }, + { + "command" : "tfvc.AssociateWorkItems", + "group": "3_commit@4", + "when": "scmProvider == tfvc" + }, { "command" : "tfvc.ShowOutput", "group": "5_output",