| author | Edyta Przymus | 2012-07-31 08:25:24 (EDT) |
|---|---|---|
| committer | Szymon Brandys | 2012-07-31 08:25:24 (EDT) |
| commit | 517d9c47916db169247509fcf3134d8574a9f379 (patch) (side-by-side diff) | |
| tree | b4b49c1df93ad78fd44d32226a588ad25c05ac2e | |
| parent | 26049c184b80d89a703cf229548caf7e26d0f6bc (diff) | |
| download | org.eclipse.orion.client-517d9c47916db169247509fcf3134d8574a9f379.zip org.eclipse.orion.client-517d9c47916db169247509fcf3134d8574a9f379.tar.gz org.eclipse.orion.client-517d9c47916db169247509fcf3134d8574a9f379.tar.bz2 | |
Bug 385926 - Easy way to get from commit page corresponding PullRequest
URL
5 files changed, 133 insertions, 2 deletions
diff --git a/bundles/org.eclipse.orion.client.git/web/git/git-commit.js b/bundles/org.eclipse.orion.client.git/web/git/git-commit.js index 5091407..f5e63a3 100644 --- a/bundles/org.eclipse.orion.client.git/web/git/git-commit.js +++ b/bundles/org.eclipse.orion.client.git/web/git/git-commit.js @@ -50,6 +50,7 @@ define(['i18n!git/nls/gitmessages', 'require', 'dojo', 'orion/bootstrap', 'orion // define the command contributions - where things appear, first the groups commandService.addCommandGroup("pageActions", "eclipse.gitGroup", 100); //$NON-NLS-1$ //$NON-NLS-0$ commandService.registerCommandContribution("pageActions", "eclipse.orion.git.cherryPick", 100, "eclipse.gitGroup"); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ + commandService.registerCommandContribution("pageActions", "eclipse.orion.git.getPullRequestUrl", 101, "eclipse.gitGroup"); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ commandService.registerCommandContribution("pageActions", "eclipse.orion.git.openCommitCommand", 102, "eclipse.gitGroup", true, new mCommands.CommandKeyBinding('h', true, true)); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ // object contributions diff --git a/bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js b/bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js index 0245392..2970112 100644 --- a/bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js +++ b/bundles/org.eclipse.orion.client.git/web/git/nls/root/gitmessages.js @@ -345,5 +345,8 @@ define({ "Change..." : "Change...", "Merge Squash": "Merge Squash",
"Squash the content of the branch to the index" : "Squash the content of the branch to the index",
- "Local Branch Name:" : "Local Branch Name:" + "Local Branch Name:" : "Local Branch Name:",
+ "Pull Request url for this commit" : "Pull Request url for this commit",
+ "Pull Request" : "Pull Request",
+ "Pull Request Url" : "Pull Request Url" }); diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js b/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js index 97181a2..47b4cd6 100644 --- a/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js +++ b/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js @@ -13,7 +13,7 @@ /*jslint browser:true eqeqeq:false laxbreak:true */ define(['i18n!git/nls/gitmessages', 'require', 'dojo', 'orion/commands', 'orion/util', 'orion/git/util', 'orion/compare/compareUtils', 'orion/git/widgets/CloneGitRepositoryDialog', 'orion/git/widgets/AddRemoteDialog', 'orion/git/widgets/GitCredentialsDialog', 'orion/widgets/NewItemDialog', - 'orion/git/widgets/RemotePrompterDialog', 'orion/git/widgets/ApplyPatchDialog', 'orion/git/widgets/OpenCommitDialog', 'orion/git/widgets/ConfirmPushDialog', + 'orion/git/widgets/RemotePrompterDialog', 'orion/git/widgets/ApplyPatchDialog', 'orion/git/widgets/OpenCommitDialog', 'orion/git/widgets/ConfirmPushDialog', 'orion/git/widgets/GetPullRequestUrlDialog', 'orion/git/widgets/ContentDialog', 'orion/git/widgets/CommitDialog'], function(messages, require, dojo, mCommands, mUtil, mGitUtil, mCompareUtils) { @@ -1734,7 +1734,37 @@ var exports = {}; } }); commandService.addCommand(cherryPickCommand); + + var getPullRequestUrlCommand = new mCommands.Command({ + name : messages["Pull Request Url"], + tooltip: messages["Pull Request url for this commit"], + id : "eclipse.orion.git.getPullRequestUrl", //$NON-NLS-0$ + imageClass: "git-sprite-cherry_pick", //$NON-NLS-0$ + spriteClass: "gitCommandSprite", //$NON-NLS-0$ + callback: function(data) { + var service = serviceRegistry.getService("orion.git.provider"); + service.getGitClone(data.items.CloneLocation).then( + function(clone){ + var url = clone.Children[0].GitUrl; + var sha1 = data.items.Name; + var pullRequestUrl = window.location.protocol + "//" + window.location.host + "/" + "git/pullRequest.html#" + url + "_" + sha1; + var dialog = new orion.git.widgets.GetPullRequestUrlDialog({ + title: messages["Pull Request"], + url: pullRequestUrl + }); + dialog.startup(); + dialog.show(); + } + ); + }, + visibleWhen : function(item) { + return item.Type === "Commit"; //$NON-NLS-0$ + } + }); + + commandService.addCommand(getPullRequestUrlCommand); }; + exports.createGitClonesCommands = function(serviceRegistry, commandService, explorer, toolbarId, selectionTools, fileClient) { diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/GetPullRequestUrlDialog.js b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/GetPullRequestUrlDialog.js new file mode 100644 index 0000000..78fb4c1 --- a/dev/null +++ b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/GetPullRequestUrlDialog.js @@ -0,0 +1,74 @@ +/******************************************************************************* + * @license + * Copyright (c) 2012 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License v1.0 + * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution + * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +/*jslint browser:true*/ +/*global define orion window dojo dijit*/ + +define(['i18n!git/nls/gitmessages', 'require', 'dojo', 'dijit', "orion/util", 'dijit/Dialog', 'dijit/form/TextBox', + 'orion/widgets/_OrionDialogMixin', 'text!orion/git/widgets/templates/GetPullRequestUrlDialog.html'], function(messages, require, dojo, dijit, mUtil) { + +/** + * Usage: <code>new orion.git.widgets.GetPullRequestUrlDialog(options).show();</code> + * + * @name orion.git.widgets.GetPullRequestUrlDialog + */ +var GetPullRequestUrlDialog = dojo.declare("orion.git.widgets.GetPullRequestUrlDialog", [dijit.Dialog, orion.widgets._OrionDialogMixin], //$NON-NLS-0$ + /** @lends orion.git.widgets.GetPullRequestUrlDialog.prototype */ { + widgetsInTemplate : true, + templateString : dojo.cache('orion', 'git/widgets/templates/GetPullRequestUrlDialog.html'), //$NON-NLS-1$ //$NON-NLS-0$ + + SEARCH_DELAY: 500, + timeoutId: null, + time: null, + options: null, + + /** @private */ + constructor : function() { + this.inherited(arguments); + this.timeoutId = null; + this.time = 0; + this.options = arguments[0]; + + this.url = this.options.url; + }, + + /** @private */ + postMixInProperties : function() { + this.options.title = this.options.title || messages["Pull Request"]; + this.selectFile = messages["Pull Request url for this commit"]; + + this.inherited(arguments); + }, + + /** @private */ + postCreate: function() { + this.inherited(arguments); + this.PullReqUrl.set("value", this.options.url); + }, + + + /** + * Displays the dialog. + */ + show: function() { + this.inherited(arguments); + this.PullReqUrl.focus(); + }, + + /** @private */ + onHide: function() { + clearTimeout(this.timeoutId); + this.inherited(arguments); + } + +}); +return GetPullRequestUrlDialog; +}); diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/templates/GetPullRequestUrlDialog.html b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/templates/GetPullRequestUrlDialog.html new file mode 100644 index 0000000..17027db --- a/dev/null +++ b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/templates/GetPullRequestUrlDialog.html @@ -0,0 +1,23 @@ +<div class="dijitDialog" tabindex="-1" waiRole="dialog" title="${title}" waiState="labelledby-${id}_title"> + <div dojoAttachPoint="titleBar" class="dijitDialogTitleBar"> + <span dojoAttachPoint="titleNode" class="dijitDialogTitle" id="${id}_title"></span> + <span dojoAttachPoint="closeButtonNode" class="dijitDialogCloseIcon" dojoAttachEvent="onclick: onCancel" title="${buttonCancel}"> + <span dojoAttachPoint="closeText" class="closeText" title="${buttonCancel}">x</span> + </span> + </div> + <div dojoAttachPoint="containerNode" class="dijitDialogPaneContent"> + <div style="display:table"> + <div style="display:table-row"> + <div style="display:table-cell; padding:5;"> + <label for="PullReqUrl" style="padding-right:10">${selectFile}</label> + </div> + </div> + <div style="display:table-row"> + <div style="display:table-cell; padding:5;"> + <input type="text" dojoType="dijit.form.TextBox" dojoAttachPoint="PullReqUrl" + style="width:80em;"> + </div> + </div> + </div> + </div> +</div>
\ No newline at end of file |

