diff --git a/package.json b/package.json index 1047493105..9e1d06ef64 100644 --- a/package.json +++ b/package.json @@ -58,21 +58,6 @@ "group": "1_sync@2", "when": "scmProvider == tfvc" }, - { - "command" : "team.Signout", - "group": "2_publish", - "when": "scmProvider == tfvc" - }, - { - "command" : "team.Signout", - "group": "3_commit", - "when": "scmProvider == tfvc" - }, - { - "command" : "team.OpenNewWorkItem", - "group": "4_stage", - "when": "scmProvider == tfvc" - }, { "command" : "tfvc.ShowOutput", "group": "5_output", @@ -81,19 +66,29 @@ ], "scm/resource/context": [ { - "command": "tfvc.Include", - "when": "scmProvider == tfvc && scmResourceGroup == excluded", - "group": "navigation" + "command": "tfvc.OpenDiff", + "when": "scmProvider == tfvc", + "group": "navigation@1" + }, + { + "command": "tfvc.OpenFile", + "when": "scmProvider == tfvc", + "group": "navigation@2" + }, + { + "command": "tfvc.Undo", + "when": "scmProvider == tfvc", + "group": "1_modification@1" }, { "command": "tfvc.Include", - "when": "scmProvider == tfvc && scmResourceGroup == included", - "group": "navigation" + "when": "scmProvider == tfvc && scmResourceGroup == excluded", + "group": "1_modification@2" }, { "command": "tfvc.Exclude", "when": "scmProvider == tfvc && scmResourceGroup == included", - "group": "1_sync" + "group": "1_modification@2" }, { "command": "tfvc.Undo", @@ -126,6 +121,11 @@ "default": "", "description": "Set the logging level for the extension (error, warn, info, verbose, debug)." }, + "team.pinnedQueries": { + "type": "array", + "default": [ { "account": "", "queryText": "", "queryPath": "" }], + "description": "Specify the account and either the queryText or queryPath of the query you'd like to monitor. If specified, queryText is preferred over queryPath." + }, "team.pollingInterval": { "type": "number", "default": 5, @@ -251,6 +251,16 @@ "dark": "resources/icons/dark/stage.svg" } }, + { + "command": "tfvc.OpenDiff", + "title": "Open Diff", + "category": "TFVC" + }, + { + "command": "tfvc.OpenFile", + "title": "Open File", + "category": "TFVC" + }, { "command": "tfvc.ShowOutput", "title": "Show TFVC Output", diff --git a/src/extension.ts b/src/extension.ts index 86421d7c6f..71e0b3edcb 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -54,6 +54,12 @@ export async function activate(context: ExtensionContext) { context.subscriptions.push(commands.registerCommand(TfvcCommandNames.Include, (...args) => { _extensionManager.Tfvc.TfvcInclude(args ? args[0] : undefined); })); + context.subscriptions.push(commands.registerCommand(TfvcCommandNames.OpenDiff, (...args) => { + _extensionManager.Tfvc.TfvcOpenDiff(args ? args[0] : undefined); + })); + context.subscriptions.push(commands.registerCommand(TfvcCommandNames.OpenFile, (...args) => { + _extensionManager.Tfvc.TfvcOpenFile(args ? args[0] : undefined); + })); context.subscriptions.push(commands.registerCommand(TfvcCommandNames.Refresh, () => _extensionManager.Tfvc.TfvcRefresh())); context.subscriptions.push(commands.registerCommand(TfvcCommandNames.ShowOutput, () => _extensionManager.Tfvc.TfvcShowOutput())); context.subscriptions.push(commands.registerCommand(TfvcCommandNames.Checkin, () => _extensionManager.Tfvc.TfvcCheckin())); diff --git a/src/helpers/constants.ts b/src/helpers/constants.ts index 2b4a922f17..116b35ef86 100644 --- a/src/helpers/constants.ts +++ b/src/helpers/constants.ts @@ -41,6 +41,8 @@ export class TfvcCommandNames { static ExcludeAll: string = TfvcCommandNames.CommandPrefix + "ExcludeAll"; static Include: string = TfvcCommandNames.CommandPrefix + "Include"; static IncludeAll: string = TfvcCommandNames.CommandPrefix + "IncludeAll"; + static OpenDiff: string = TfvcCommandNames.CommandPrefix + "OpenDiff"; + static OpenFile: string = TfvcCommandNames.CommandPrefix + "OpenFile"; static Refresh: string = TfvcCommandNames.CommandPrefix + "Refresh"; static ShowOutput: string = TfvcCommandNames.CommandPrefix + "ShowOutput"; static Status: string = TfvcCommandNames.CommandPrefix + "Status"; diff --git a/src/tfvc/tfvc-extension.ts b/src/tfvc/tfvc-extension.ts index 209d0bebb9..4237c933bd 100644 --- a/src/tfvc/tfvc-extension.ts +++ b/src/tfvc/tfvc-extension.ts @@ -89,6 +89,38 @@ export class TfvcExtension { } } + public async TfvcOpenDiff(uri?: Uri): Promise { + if (!this._manager.EnsureInitialized(RepositoryType.TFVC)) { + this._manager.DisplayErrorMessage(); + return; + } + + try { + if (uri) { + let resource: Resource = TfvcSCMProvider.ResolveTfvcResource(uri); + TfvcSCMProvider.OpenDiff(resource); + } + } catch (err) { + this._manager.DisplayErrorMessage(err.message); + } + } + + public async TfvcOpenFile(uri?: Uri): Promise { + if (!this._manager.EnsureInitialized(RepositoryType.TFVC)) { + this._manager.DisplayErrorMessage(); + return; + } + + try { + if (uri) { + let path: string = TfvcSCMProvider.GetPathFromUri(uri); + await window.showTextDocument(await workspace.openTextDocument(path)); + } + } catch (err) { + this._manager.DisplayErrorMessage(err.message); + } + } + public async TfvcRefresh(): Promise { if (!this._manager.EnsureInitialized(RepositoryType.TFVC)) { this._manager.DisplayErrorMessage(); diff --git a/src/tfvc/tfvcscmprovider.ts b/src/tfvc/tfvcscmprovider.ts index 4a291f424f..562d19b2b8 100644 --- a/src/tfvc/tfvcscmprovider.ts +++ b/src/tfvc/tfvcscmprovider.ts @@ -241,19 +241,6 @@ export class TfvcSCMProvider implements SCMProvider { return scm.getResourceFromURI(uri); } - public static ResolveTfvcResource(uri: Uri): Resource { - if (uri) { - const resource = TfvcSCMProvider.ResolveTfvcURI(uri); - - if (!(resource instanceof Resource)) { - return undefined; - } - - return resource; - } - return undefined; - } - public static GetPathFromUri(uri: Uri): string { if (uri) { const resource = TfvcSCMProvider.ResolveTfvcResource(uri); @@ -273,4 +260,22 @@ export class TfvcSCMProvider implements SCMProvider { } return tfvcProvider; } + + public static OpenDiff(resource: Resource): Promise { + TfvcSCMProvider.GetProviderInstance().open(resource); + return; + } + + public static ResolveTfvcResource(uri: Uri): Resource { + if (uri) { + const resource = TfvcSCMProvider.ResolveTfvcURI(uri); + + if (!(resource instanceof Resource)) { + return undefined; + } + + return resource; + } + return undefined; + } }