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

Added associate work items command #108

Merged
merged 2 commits into from
Feb 16, 2017
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
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -244,6 +254,11 @@
"title": "Signout",
"category": "Team"
},
{
"command": "tfvc.AssociateWorkItems",
"title": "Associate Work Items",
"category": "TFVC"
},
{
"command": "tfvc.Checkin",
"title": "Checkin",
Expand Down
11 changes: 11 additions & 0 deletions src/clients/witclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ export class WitClient {
}
}

public async ChooseWorkItems(): Promise<string[]> {
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<void> {
Logger.LogInfo("Getting work items...");
let workItem: BaseQuickPickItem = await window.showQuickPick(await this.getMyWorkItems(this._serverContext.RepoInfo.TeamProject, wiql), { matchOnDescription: true, placeHolder: Strings.ChooseWorkItem });
Expand Down
1 change: 1 addition & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
1 change: 1 addition & 0 deletions src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
6 changes: 6 additions & 0 deletions src/team-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string[]> {
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)) {
Expand Down
9 changes: 9 additions & 0 deletions src/tfvc/tfvc-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ export class TfvcExtension {
this._manager = manager;
}

public async AssociateWorkItems(): Promise<void> {
this.displayErrors(async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add Telemetry.SendEvent("tfvc.associateworkitems") so we can have some indication on how much the command is used.

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<void> {
this.displayErrors(async () => {
// get the checkin info from the SCM viewlet
Expand Down
9 changes: 9 additions & 0 deletions src/tfvc/tfvcscmprovider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down