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

Commit

Permalink
Adding OpenDiff, OpenFile commands and menu items (#103)
Browse files Browse the repository at this point in the history
Also adding help for team.pinnedQueries
  • Loading branch information
Jeff Young authored Feb 14, 2017
1 parent 08885c0 commit 8d323f0
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 34 deletions.
52 changes: 31 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
32 changes: 32 additions & 0 deletions src/tfvc/tfvc-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,38 @@ export class TfvcExtension {
}
}

public async TfvcOpenDiff(uri?: Uri): Promise<void> {
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<void> {
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<void> {
if (!this._manager.EnsureInitialized(RepositoryType.TFVC)) {
this._manager.DisplayErrorMessage();
Expand Down
31 changes: 18 additions & 13 deletions src/tfvc/tfvcscmprovider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -273,4 +260,22 @@ export class TfvcSCMProvider implements SCMProvider {
}
return tfvcProvider;
}

public static OpenDiff(resource: Resource): Promise<void> {
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;
}
}

0 comments on commit 8d323f0

Please sign in to comment.