| author | Maciej Bendkowski | 2012-09-06 06:40:51 (EDT) |
|---|---|---|
| committer | Szymon Brandys | 2012-09-06 06:40:51 (EDT) |
| commit | a807811a8839208ec77ff70ee73601eea5085c6c (patch) (side-by-side diff) | |
| tree | 9314ee974fbe2c9fd993956774116abdc5f8c1cd | |
| parent | fa288b538f5843ff26c4096c1dfe18baf606d215 (diff) | |
| download | org.eclipse.orion.client-a807811a8839208ec77ff70ee73601eea5085c6c.zip org.eclipse.orion.client-a807811a8839208ec77ff70ee73601eea5085c6c.tar.gz org.eclipse.orion.client-a807811a8839208ec77ff70ee73601eea5085c6c.tar.bz2 | |
Bug 387878 - [client] Save Git credentials: II - Enhance usability
10 files changed, 791 insertions, 187 deletions
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/settings/nls/root/messages.js b/bundles/org.eclipse.orion.client.core/web/orion/settings/nls/root/messages.js index e110480..7169467 100644 --- a/bundles/org.eclipse.orion.client.core/web/orion/settings/nls/root/messages.js +++ b/bundles/org.eclipse.orion.client.core/web/orion/settings/nls/root/messages.js @@ -1,106 +1,117 @@ -/******************************************************************************* - * @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). - * - ******************************************************************************/ - -//NLS_CHARSET=UTF-8 - -define({ - "Plugin Description": "Plugin Description", - "Create": "Create", - "Loading...": "Loading...", - "Label:": "Label:", - "Title": "Title", - "Plugins": "Plugins", - "User Profile": "User Profile", - "JavaScript Editor": "JavaScript Editor", - "General": "General", - "Navigation": "Navigation", - "Open in same tab": "Open in same tab", - "Open in new tab": "Open in new tab", - "Links": "Links", - "Font": "Font", - "Family": "Family", - "Sans Serif": "Sans Serif", - "Serif": "Serif", - "Size": "Size", - "8pt": "8pt", - "9pt": "9pt", - "10pt": "10pt", - "12pt": "12pt", - "Color": "Color", - "Background": "Background", - "Strings": "Strings", - "String Types": "String Types", - "blue": "blue", - "Weight": "Weight", - "Normal": "Normal", - "Bold": "Bold", - "Comments": "Comments", - "Comment Types": "Comment Types", - "green": "green", - "Keywords": "Keywords", - "Keyword Types": "Keyword Types", - "darkred": "darkred", - "Categories": "Categories", - "Username": "Username", - "Full Name": "Full Name", - "Email Address": "Email Address", - "Account": "Account", - "Current Password": "Current Password", - "New Password": "New Password", - "Verify Password": "Verify Password", - "Password": "Password", - "OpenId": "OpenId", - "AOL": "AOL", - "Yahoo": "Yahoo", - "Google": "Google", - "Unlink": "Unlink", - "Link": "Link", - "Unlinked": "Unlinked", - "Linked": "Linked", - "Linked Accounts": "Linked Accounts", - "Git Email Address": "Git Email Address", - "Git Username": "Git Username", - "Git Credentials": "Git Credentials", - "Update": "Update", - "Update Profile Settings": "Update Profile Settings", - "User profile data successfully reset.": "User profile data successfully reset.", - "Edit Plugin JavaScript": "Edit Plugin JavaScript", - "Install Plugin": "Install Plugin", - "Plugin Name:": "Plugin Name:", - "Author Name:": "Author Name:", - "Licence:": "Licence:", - "Description:": "Description:", - "A plugin for Eclipse Orion": "A plugin for Eclipse Orion", - "Plugin Link": "Plugin Link", - "Install": "Install", - "Install a plugin by specifying its URL": "Install a plugin by specifying its URL", - "Plugin URL:": "Plugin URL:", - "Reload all": "Reload all", - "Reload all installed plugins": "Reload all installed plugins", - "Create a new Orion Plugin": "Create a new Orion Plugin", - "Reload": "Reload", - "Reload the plugin": "Reload the plugin", - "Delete": "Delete", - "Delete this plugin from the configuration": "Delete this plugin from the configuration", - "Type a plugin url here ...": "Type a plugin url here ...", - "Installed ": "Installed ", - "Installing ": "Installing ", - "Already installed": "Already installed", - " plugin": " plugin", - "Reloaded ": "Reloaded ", - "Uninstalled ": "Uninstalled ", - "Are you sure you want to uninstall '": "Are you sure you want to uninstall '", - "Services": "Services", - "Value": "Value", - "JavaScript Object": "JavaScript Object", - "click here, then check javascript console to drill down": "click here, then check javascript console to drill down", - "Item" : "Item", - PluginSettings: 'Plugin Settings' +/*******************************************************************************
+ * @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).
+ *
+ ******************************************************************************/
+
+//NLS_CHARSET=UTF-8
+
+define({
+ "Plugin Description": "Plugin Description",
+ "Create": "Create",
+ "Loading...": "Loading...",
+ "Label:": "Label:",
+ "Title": "Title",
+ "Plugins": "Plugins",
+ "User Profile": "User Profile",
+ "JavaScript Editor": "JavaScript Editor",
+ "General": "General",
+ "Navigation": "Navigation",
+ "Open in same tab": "Open in same tab",
+ "Open in new tab": "Open in new tab",
+ "Links": "Links",
+ "Font": "Font",
+ "Family": "Family",
+ "Sans Serif": "Sans Serif",
+ "Serif": "Serif",
+ "Size": "Size",
+ "8pt": "8pt",
+ "9pt": "9pt",
+ "10pt": "10pt",
+ "12pt": "12pt",
+ "Color": "Color",
+ "Background": "Background",
+ "Strings": "Strings",
+ "String Types": "String Types",
+ "blue": "blue",
+ "Weight": "Weight",
+ "Normal": "Normal",
+ "Bold": "Bold",
+ "Comments": "Comments",
+ "Comment Types": "Comment Types",
+ "green": "green",
+ "Keywords": "Keywords",
+ "Keyword Types": "Keyword Types",
+ "darkred": "darkred",
+ "Categories": "Categories",
+ "Username": "Username",
+ "Full Name": "Full Name",
+ "Email Address": "Email Address",
+ "Account": "Account",
+ "Current Password": "Current Password",
+ "New Password": "New Password",
+ "Verify Password": "Verify Password",
+ "Password": "Password",
+ "OpenId": "OpenId",
+ "AOL": "AOL",
+ "Yahoo": "Yahoo",
+ "Google": "Google",
+ "Unlink": "Unlink",
+ "Link": "Link",
+ "Unlinked": "Unlinked",
+ "Linked": "Linked",
+ "Linked Accounts": "Linked Accounts",
+ "Git Email Address": "Git Email Address",
+ "Git Username": "Git Username",
+ "Git Credentials": "Git Credentials",
+ "Update": "Update",
+ "Update Profile Settings": "Update Profile Settings",
+ "Update Git Credentials": "Update Git Credentials",
+ "User profile data successfully reset.": "User profile data successfully reset.",
+ "Git Credentials successfully reset.": "Git Credentials successfully reset.",
+ "Edit Plugin JavaScript": "Edit Plugin JavaScript",
+ "Install Plugin": "Install Plugin",
+ "Plugin Name:": "Plugin Name:",
+ "Author Name:": "Author Name:",
+ "Licence:": "Licence:",
+ "Description:": "Description:",
+ "A plugin for Eclipse Orion": "A plugin for Eclipse Orion",
+ "Plugin Link": "Plugin Link",
+ "Install": "Install",
+ "Install a plugin by specifying its URL": "Install a plugin by specifying its URL",
+ "Plugin URL:": "Plugin URL:",
+ "Reload all": "Reload all",
+ "Reload all installed plugins": "Reload all installed plugins",
+ "Create a new Orion Plugin": "Create a new Orion Plugin",
+ "Reload": "Reload",
+ "Reload the plugin": "Reload the plugin",
+ "Delete": "Delete",
+ "Delete this plugin from the configuration": "Delete this plugin from the configuration",
+ "Type a plugin url here ...": "Type a plugin url here ...",
+ "Installed ": "Installed ",
+ "Installing ": "Installing ",
+ "Already installed": "Already installed",
+ " plugin": " plugin",
+ "Reloaded ": "Reloaded ",
+ "Uninstalled ": "Uninstalled ",
+ "Are you sure you want to uninstall '": "Are you sure you want to uninstall '",
+ "Services": "Services",
+ "Value": "Value",
+ "JavaScript Object": "JavaScript Object",
+ "click here, then check javascript console to drill down": "click here, then check javascript console to drill down",
+ "Item" : "Item",
+ "Erase Key" : "Erase Key",
+ "Git Config" : "Git Config",
+ "Reset" : "Reset",
+ "Reset Git Credentials" : "Reset Git Credentials",
+ "Clear Git Credentials" : "Clear Git Credentials",
+ "Enable Key Storage" : "Enable Key Storage",
+ "Authentication" : "Authentication",
+ "Please be aware that your credentials will be stored persistently in the browser." : "Please be aware that your credentials will be stored persistently in the browser.",
+ "Do you wish to enable the Key Storage?" : "Do you wish to enable the Key Storage?",
+ PluginSettings: 'Plugin Settings'
});
\ No newline at end of file diff --git a/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/LabeledCheckbox.js b/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/LabeledCheckbox.js index 8f59772..003f4a7 100644 --- a/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/LabeledCheckbox.js +++ b/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/LabeledCheckbox.js @@ -20,7 +20,7 @@ define(['i18n!orion/settings/nls/messages', 'require', 'dojo', 'dijit', 'orion/u templateString: '<div>' + //$NON-NLS-0$
'<label>' + //$NON-NLS-0$
- '<span data-dojo-attach-point="mylabel">'+messages['Label:']+'</span>' + //$NON-NLS-2$ //$NON-NLS-0$
+ '<span class="setting-label" data-dojo-attach-point="mylabel">'+messages['Label:']+'</span>' + //$NON-NLS-2$ //$NON-NLS-0$
'<input class="setting-control settingsCheckbox" type="checkbox" name="myname" data-dojo-attach-point="myfield" data-dojo-attach-event="onchange:change"/>' + //$NON-NLS-0$
'</label>' + //$NON-NLS-0$
'</div>', //$NON-NLS-0$
@@ -28,6 +28,14 @@ define(['i18n!orion/settings/nls/messages', 'require', 'dojo', 'dijit', 'orion/u setStorageItem: function(){
},
+
+ isChecked : function(){
+ return this.myfield.checked;
+ },
+
+ setChecked : function(value){
+ this.myfield.checked = value;
+ },
change: function(){
var value = this.myfield.value;
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/LabeledRepositoryLink.js b/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/LabeledRepositoryLink.js new file mode 100644 index 0000000..b7b75f2 --- a/dev/null +++ b/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/LabeledRepositoryLink.js @@ -0,0 +1,48 @@ +/*******************************************************************************
+ * @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
+ ******************************************************************************/
+/*global dojo dijit widgets orion window console define localStorage*/
+/*jslint browser:true*/
+
+/* This SettingsContainer widget is a dojo border container with a left and right side. The left is for choosing a
+ category, the right shows the resulting HTML for that category. */
+
+define(['i18n!orion/settings/nls/messages', 'require', 'dojo', 'dijit', 'orion/util', 'orion/commands', 'orion/git/GitCredentialsStorage'], function(messages, require, dojo, dijit, mUtil, mCommands, mGitCredentialsStorage) {
+
+ dojo.declare("orion.widgets.settings.LabeledRepositoryLink",[dijit._Widget, dijit._Templated],{ //$NON-NLS-0$
+
+ templateString: '<div>' + //$NON-NLS-0$
+ '<label>' + //$NON-NLS-0$
+ '<span class="setting-repository-label" data-dojo-attach-point="mylabel">'+messages['Label:']+'</span>' + //$NON-NLS-2$ //$NON-NLS-0$
+ '<a href="#" data-dojo-attach-event="onclick:change">'+messages["Erase Key"]+'</a>' + //$NON-NLS-0$
+ '</label>' + //$NON-NLS-0$
+ '</div>', //$NON-NLS-0$
+
+ setStorageItem: function(){
+
+ },
+
+ change: function(){
+ var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage();
+ if(gitCredentialsStorage.isBrowserEnabled()){
+ gitCredentialsStorage.erasePrompt(this.mylabel.innerHTML);
+ }
+ },
+
+ postCreate: function(){
+ this.inherited( arguments );
+ this.mylabel.innerHTML = this.fieldlabel; //$NON-NLS-0$
+ },
+
+ startup: function(){
+
+ }
+ });
+});
\ No newline at end of file diff --git a/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/UserSettings.js b/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/UserSettings.js index 918e218..0960707 100644 --- a/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/UserSettings.js +++ b/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/UserSettings.js @@ -14,7 +14,7 @@ /* This SettingsContainer widget is a dojo border container with a left and right side. The left is for choosing a
category, the right shows the resulting HTML for that category. */
-define(['i18n!orion/settings/nls/messages', 'require', 'dojo', 'dijit', 'orion/util', 'orion/commands', 'orion/section', 'orion/widgets/settings/LabeledTextfield', 'orion/widgets/settings/LabeledCheckbox', 'orion/widgets/settings/LabeledToggle', 'profile/UsersService', 'orion/widgets/settings/Section' ], function(messages, require, dojo, dijit, mUtil, mCommands, mSection) {
+define(['i18n!orion/settings/nls/messages', 'require', 'dojo', 'dijit', 'orion/util', 'orion/commands', 'orion/section', 'orion/git/GitCredentialsStorage', 'orion/widgets/settings/LabeledTextfield', 'orion/widgets/settings/LabeledCheckbox', 'orion/widgets/settings/LabeledRepositoryLink', 'orion/widgets/settings/LabeledToggle', 'profile/UsersService', 'orion/widgets/settings/Section' ], function(messages, require, dojo, dijit, mUtil, mCommands, mSection, mGitCredentialsStorage) {
dojo.declare("orion.widgets.settings.UserSettings", [dijit._Widget, dijit._Templated], { //$NON-NLS-0$
@@ -34,6 +34,19 @@ define(['i18n!orion/settings/nls/messages', 'require', 'dojo', 'dijit', 'orion/u '<div></div>' +
'</div>' + //$NON-NLS-0$
+
+ '<div data-dojo-attach-point="gitTable">' + //$NON-NLS-0$
+ '<div class="sectionWrapper toolComposite">' +
+ '<div class="sectionAnchor sectionTitle layoutLeft">'+messages['Git Credentials']+'</div>' +
+ '<div id="gitCommands" class="layoutRight sectionActions"></div>' +
+ '</div>' + //$NON-NLS-2$ //$NON-NLS-0$
+ '<div data-dojo-attach-point="gitSections">' + //$NON-NLS-0$
+
+ '</sections>' + //$NON-NLS-0$
+ '<div></div>' +
+
+ '</div>' + //$NON-NLS-0$
+
'<div data-dojo-attach-point="linkedSection"></div>' +
'</div>', //$NON-NLS-0$
@@ -45,6 +58,13 @@ define(['i18n!orion/settings/nls/messages', 'require', 'dojo', 'dijit', 'orion/u }
},
+ refreshGitCredentials : function(){
+ var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage();
+ if(gitCredentialsStorage.isBrowserEnabled()){
+ this.gitCredentialsFields[0].setChecked(gitCredentialsStorage.isUserEnabled());
+ }
+ },
+
postCreate: function(){
this.inherited( arguments );
@@ -101,7 +121,7 @@ define(['i18n!orion/settings/nls/messages', 'require', 'dojo', 'dijit', 'orion/u this.gitFields.push( new orion.widgets.settings.LabeledTextfield( {fieldlabel:messages['Git Email Address']} ) );
this.gitFields.push( new orion.widgets.settings.LabeledTextfield( {fieldlabel:messages['Git Username']} ) );
- var gitSection = new orion.widgets.settings.Section( {sectionName:messages['Git Credentials'], container: this.sections, sections: this.gitFields } );
+ var gitSection = new orion.widgets.settings.Section( {sectionName:messages["Git Config"], container: this.sections, sections: this.gitFields } );
var updateCommand = new mCommands.Command({
name: messages["Update"],
@@ -114,11 +134,60 @@ define(['i18n!orion/settings/nls/messages', 'require', 'dojo', 'dijit', 'orion/u });
this.commandService.addCommand(updateCommand);
-
- this.commandService.registerCommandContribution('profileCommands', "orion.updateprofile", 2); //$NON-NLS-1$ //$NON-NLS-0$
-
+ this.commandService.registerCommandContribution('profileCommands', "orion.updateprofile", 3); //$NON-NLS-1$ //$NON-NLS-0$
this.commandService.renderCommands('profileCommands', dojo.byId( 'userCommands' ), this, this, "button"); //$NON-NLS-1$ //$NON-NLS-0$
+ //--------- git credentials -------------------------------
+ this.gitCredentialsFields = [];
+
+ this.gitCredentialsFields.push( new orion.widgets.settings.LabeledCheckbox( {fieldlabel:messages["Enable Key Storage"]} ) );
+
+ var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage();
+ if(gitCredentialsStorage.isBrowserEnabled()){
+ var repositories = gitCredentialsStorage.getRepositories();
+
+ for(var i=0; i<repositories.length; ++i){
+ if(!gitCredentialsStorage.getPrompt(repositories[i])){
+ this.gitCredentialsFields.push( new orion.widgets.settings.LabeledRepositoryLink( {fieldlabel: repositories[i]} ) );
+ }
+ }
+ }
+
+ var gitCredentialsSection = new orion.widgets.settings.Section( {sectionName:messages["Authentication"], container: this.gitSections, sections: this.gitCredentialsFields} );
+
+ var clearCredentials = new mCommands.Command({
+ name: messages["Reset"],
+ tooltip: messages["Reset Git Credentials"],
+ id: "orion.clearGitCredentials",
+ callback: dojo.hitch(this, function(data){
+ var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage();
+ if(gitCredentialsStorage.isBrowserEnabled()){
+ gitCredentialsStorage.clearCredentials();
+
+ var messageService = this.registry.getService("orion.page.message");
+ messageService.setProgressResult("Git credentials successfully cleared.");
+ this.refreshGitCredentials();
+ }
+ })
+ });
+
+ var updateGitCredentialsCommand = new mCommands.Command({
+ name: messages["Update"],
+ tooltip: messages["Update Git Credentials"],
+ id: "orion.updateGitCredentials", //$NON-NLS-0$
+ callback: dojo.hitch(this, function(data){
+ this.updateGitCredentials(data.items);
+ })
+
+ });
+
+ this.commandService.addCommand(updateGitCredentialsCommand);
+ this.commandService.registerCommandContribution('gitProfileCommands', "orion.updateGitCredentials", 3); //$NON-NLS-1$ //$NON-NLS-0$
+
+ this.commandService.addCommand(clearCredentials);
+ this.commandService.registerCommandContribution('gitProfileCommands', "orion.clearGitCredentials", 2);
+ this.commandService.renderCommands('gitProfileCommands', dojo.byId( 'gitCommands' ), this, this, "button"); //$NON-NLS-1$ //$NON-NLS-0$
+
this.linkedAccountSection = new mSection.Section(this.linkedSection, {
id: "linkedAccountSection", //$NON-NLS-0$
title: "Linked Accounts", //$NON-NLS-0$
@@ -213,7 +282,23 @@ define(['i18n!orion/settings/nls/messages', 'require', 'dojo', 'dijit', 'orion/u });
});
});
- }
+ }
+ }
+ },
+
+ updateGitCredentials : function(data){
+ var messageService = this.registry.getService("orion.page.message"); //$NON-NLS-0$
+
+ // git authentication update
+ var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage();
+ if(gitCredentialsStorage.isBrowserEnabled()){
+ if( this.gitCredentialsFields[0].isChecked() ){
+ if(window.confirm(messages["Please be aware that your credentials will be stored persistently in the browser."] + '\n' + messages["Do you wish to enable the Key Storage?"])){
+ gitCredentialsStorage.userEnable();
+ } else { return; }
+ } else { gitCredentialsStorage.userDisable(); }
+
+ messageService.setProgressResult( messages['Git Credentials successfully reset.'] );
}
},
@@ -258,6 +343,9 @@ define(['i18n!orion/settings/nls/messages', 'require', 'dojo', 'dijit', 'orion/u });
});
}
+
+ // git authentication startup
+ this.refreshGitCredentials();
}
});
});
diff --git a/bundles/org.eclipse.orion.client.core/web/settings/settings.css b/bundles/org.eclipse.orion.client.core/web/settings/settings.css index 9a273ea..9866c51 100644 --- a/bundles/org.eclipse.orion.client.core/web/settings/settings.css +++ b/bundles/org.eclipse.orion.client.core/web/settings/settings.css @@ -212,6 +212,12 @@ ul,menu,dir { display: inline-block;
}
+.setting-repository-label {
+ min-width: 330px;
+ display: inline-block;
+ padding-top: 10px;
+}
+
.displaytable>section {
display: table-row;
}
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 24bb829..cfdbf0a 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 @@ -361,6 +361,9 @@ define({ "Ask for review" : "Ask for review",
"Ask for review tooltip" : "Send email with request for commit review",
"Reviewer name" : "Reviewer name",
- "Contribution Review Request" : "Contribution Review Request",
- "Send the link to the reviewer" : "Send the link to the reviewer" + "Contribution Review Request" : "Contribution Review Request", + "Send the link to the reviewer" : "Send the link to the reviewer",
+ "Private key file (optional):" : "Private key file (optional):",
+ "Don't prompt me again:" : "Don't prompt me again:",
+ "Your private key will be saved in the browser for further use" : "Your private key will be saved in the browser for further use" }); 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 6504bc5..f134d68 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 @@ -11,11 +11,11 @@ /*global alert confirm orion window widgets eclipse:true serviceRegistry define */ /*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', +define(['i18n!git/nls/gitmessages', 'require', 'dojo', 'orion/commands', 'orion/util', 'orion/git/util', 'orion/compare/compareUtils', 'orion/git/GitCredentialsStorage', '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/ReviewRequestDialog', 'orion/git/widgets/ContentDialog', 'orion/git/widgets/CommitDialog'], - function(messages, require, dojo, mCommands, mUtil, mGitUtil, mCompareUtils) { + function(messages, require, dojo, mCommands, mUtil, mGitUtil, mCompareUtils, mGitCredentialsStorage) { /** * @namespace The global container for eclipse APIs. @@ -115,6 +115,25 @@ var exports = {}; }; exports.handleSshAuthenticationError = function(serviceRegistry, errorData, options, func, title){ + var repository = errorData.Url; + var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage(); + var loadedPrivateKey = "", loadedPassphrase = ""; + + if(gitCredentialsStorage.isEnabled() && !gitCredentialsStorage.getPrompt(repository)){ + loadedPrivateKey = gitCredentialsStorage.getPrivateKey(repository); + loadedPassphrase = gitCredentialsStorage.getPassphrase(repository); + } + + if(loadedPrivateKey !== ""){ + if(options.failedOperation){ + var progressService = serviceRegistry.getService("orion.page.progress"); //$NON-NLS-0$ + dojo.hitch(progressService, progressService.removeOperation)(options.failedOperation.Location, options.failedOperation.Id); + } + + func({ knownHosts: options.knownHosts, gitSshUsername: "", gitSshPassword: "", gitPrivateKey: loadedPrivateKey, gitPassphrase: loadedPassphrase}); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ + return; + } + var credentialsDialog = new orion.git.widgets.GitCredentialsDialog({ title: title, serviceRegistry: serviceRegistry, @@ -213,6 +232,13 @@ var exports = {}; exports.gatherSshCredentials = function(serviceRegistry, data, title){ var def = new dojo.Deferred(); + var repository = undefined; + + //TODO This should be somehow unified + if(data.items.RemoteLocation !== undefined){ repository = data.items.RemoteLocation[0].GitUrl; } + else if(data.items.GitUrl !== undefined) { repository = data.items.GitUrl; } + else if(data.items.errorData !== undefined) { repository = data.items.errorData.Url; } + else if(data.items.toRef !== undefined) { repository = data.items.toRef.RemoteLocation[0].GitUrl; } var triggerCallback = function(sshObject){ serviceRegistry.getService("orion.net.ssh").getKnownHosts().then(function(knownHosts){ //$NON-NLS-0$ @@ -234,13 +260,32 @@ var exports = {}; var sshService = serviceRegistry.getService("orion.net.ssh"); //$NON-NLS-0$ sshService.addKnownHosts(errorData.Host + " " + errorData.KeyType + " " + errorData.HostKey).then( //$NON-NLS-1$ //$NON-NLS-0$ function(){ - triggerCallback({ gitSshUsername: "", gitSshPassword: "", gitPrivateKey: "", gitPassphrase: ""}); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ + var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage(); + var loadedPrivateKey = "", loadedPassphrase = ""; + + if(gitCredentialsStorage.isEnabled() && !gitCredentialsStorage.getPrompt(repository)){ + loadedPrivateKey = gitCredentialsStorage.getPrivateKey(repository); + loadedPassphrase = gitCredentialsStorage.getPassphrase(repository); + } + + triggerCallback({ gitSshUsername: "", gitSshPassword: "", gitPrivateKey: loadedPrivateKey, gitPassphrase: loadedPassphrase}); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ } ); } return def; } + var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage(); + if(gitCredentialsStorage.isEnabled() && !gitCredentialsStorage.getPrompt(repository)){ + var loadedPrivateKey = gitCredentialsStorage.getPrivateKey(repository); + var loadedPassphrase = gitCredentialsStorage.getPassphrase(repository); + + if(loadedPrivateKey !== ""){ + triggerCallback({ gitSshUsername: "", gitSshPassword: "", gitPrivateKey: loadedPrivateKey, gitPassphrase: loadedPassphrase}); + return def; + } + } + if (!data.parameters && !data.optionsRequested){ triggerCallback({gitSshUsername: "", gitSshPassword: "", gitPrivateKey: "", gitPassphrase: ""}); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ return def; @@ -278,6 +323,18 @@ var exports = {}; } return; } + + if(jsonData.HttpCode == 500 || jsonData.HttpCode == 400){ + var repository = jsonData.JsonData.Url; + + var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage(); + if(gitCredentialsStorage.isEnabled()){ + gitCredentialsStorage.erasePrivateKey(repository); + gitCredentialsStorage.erasePassphrase(repository); + gitCredentialsStorage.erasePrompt(repository); + } + } + switch (jsonData.HttpCode) { case 200: case 201: @@ -825,56 +882,75 @@ var exports = {}; commandService.collectParameters(commandInvocation); }; - if (commandInvocation.parameters && commandInvocation.parameters.optionsRequested){ - commandInvocation.parameters = null; - commandInvocation.optionsRequested = true; - commandService.collectParameters(commandInvocation); - return; - } - - exports.gatherSshCredentials(serviceRegistry, commandInvocation).then( - function(options) { - var gitService = serviceRegistry.getService("orion.git.provider"); //$NON-NLS-0$ - var statusService = serviceRegistry.getService("orion.page.message"); //$NON-NLS-0$ - var deferred = gitService.doFetch(path, false, - options.gitSshUsername, - options.gitSshPassword, - options.knownHosts, - options.gitPrivateKey, - options.gitPassphrase); - statusService.createProgressMonitor(deferred, messages["Fetching remote: "] + path); - deferred.then( - function(jsonData, secondArg) { - exports.handleProgressServiceResponse2(jsonData, serviceRegistry, - function() { - gitService.getGitRemote(path).then( - function(jsonData){ - var remoteJsonData = jsonData; - if (explorer.parentId === "explorer-tree") { //$NON-NLS-0$ - dojo.place(document.createTextNode(messages['Getting git incoming changes...']), "explorer-tree", "only"); //$NON-NLS-2$ //$NON-NLS-1$ - gitService.getLog(remoteJsonData.HeadLocation, remoteJsonData.Id).then(function(loadScopedCommitsList) { - explorer.renderer.setIncomingCommits(loadScopedCommitsList.Children); - explorer.loadCommitsList(remoteJsonData.CommitLocation + "?page=1", remoteJsonData, true); //$NON-NLS-0$ - }); - } - dojo.hitch(explorer, explorer.changedItem)(item); - }, displayErrorOnStatus - ); - }, function (jsonData) { - handleResponse(jsonData, commandInvocation); - } - ); - }, function(jsonData, secondArg) { - exports.handleProgressServiceResponse2(jsonData, serviceRegistry, - function() { - }, function (jsonData) { - handleResponse(jsonData, commandInvocation); - } - ); - } - ); + // HACK wrap logic into function + var fetchLogic = function(){ + if (commandInvocation.parameters && commandInvocation.parameters.optionsRequested){ + commandInvocation.parameters = null; + commandInvocation.optionsRequested = true; + commandService.collectParameters(commandInvocation); + return; } - ); + + exports.gatherSshCredentials(serviceRegistry, commandInvocation).then( + function(options) { + var gitService = serviceRegistry.getService("orion.git.provider"); //$NON-NLS-0$ + var statusService = serviceRegistry.getService("orion.page.message"); //$NON-NLS-0$ + var deferred = gitService.doFetch(path, false, + options.gitSshUsername, + options.gitSshPassword, + options.knownHosts, + options.gitPrivateKey, + options.gitPassphrase); + statusService.createProgressMonitor(deferred, messages["Fetching remote: "] + path); + deferred.then( + function(jsonData, secondArg) { + exports.handleProgressServiceResponse2(jsonData, serviceRegistry, + function() { + gitService.getGitRemote(path).then( + function(jsonData){ + var remoteJsonData = jsonData; + if (explorer.parentId === "explorer-tree") { //$NON-NLS-0$ + dojo.place(document.createTextNode(messages['Getting git incoming changes...']), "explorer-tree", "only"); //$NON-NLS-2$ //$NON-NLS-1$ + gitService.getLog(remoteJsonData.HeadLocation, remoteJsonData.Id).then(function(loadScopedCommitsList) { + explorer.renderer.setIncomingCommits(loadScopedCommitsList.Children); + explorer.loadCommitsList(remoteJsonData.CommitLocation + "?page=1", remoteJsonData, true); //$NON-NLS-0$ + }); + } + dojo.hitch(explorer, explorer.changedItem)(item); + }, displayErrorOnStatus + ); + }, function (jsonData) { + handleResponse(jsonData, commandInvocation); + } + ); + }, function(jsonData, secondArg) { + exports.handleProgressServiceResponse2(jsonData, serviceRegistry, + function() { + }, function (jsonData) { + handleResponse(jsonData, commandInvocation); + } + ); + } + ); + } + ); + }; + + //TODO HACK remoteTrackingBranch does not provide git url - we have to collect manually + if(!commandInvocation.items.GitUrl){ + // have to determine manually + var gitService = serviceRegistry.getService("orion.git.provider"); + gitService.getGitRemote(path).then( + function(resp){ + gitService.getGitClone(resp.CloneLocation).then( + function(resp){ + commandInvocation.items.GitUrl = resp.Children[0].GitUrl; + fetchLogic(); + } + ); + } + ); + } else { fetchLogic(); } }, visibleWhen: function(item) { if (item.Type === "RemoteTrackingBranch") //$NON-NLS-0$ @@ -1285,7 +1361,6 @@ var exports = {}; exports.gatherSshCredentials(serviceRegistry, commandInvocation).then( function(options) { - var result = new dojo.Deferred(); if (item.RemoteLocation.length === 1 && item.RemoteLocation[0].Children.length === 1) { //when we push next time - chance to switch saved remote @@ -1473,7 +1548,6 @@ var exports = {}; exports.gatherSshCredentials(serviceRegistry, commandInvocation).then( function(options) { - var result = new dojo.Deferred(); if (item.RemoteLocation.length === 1 && item.RemoteLocation[0].Children.length === 1) { //when we push next time - chance to switch saved remote diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/gitCredentialsStorage.js b/bundles/org.eclipse.orion.client.git/web/orion/git/gitCredentialsStorage.js new file mode 100644 index 0000000..b202010 --- a/dev/null +++ b/bundles/org.eclipse.orion.client.git/web/orion/git/gitCredentialsStorage.js @@ -0,0 +1,243 @@ +/*******************************************************************************
+ * @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
+ *******************************************************************************/
+ /*global define console window document navigator */
+
+ define(['dojo'], function(dojo){
+
+ /**
+ * Local storage support class.
+ *
+ * @param prefix [required] Used to create a separate namespace for storage.
+ */
+ function LocalStorage(prefix){
+ this._prefix = prefix;
+ }
+
+ LocalStorage.prototype = {
+
+ /**
+ * [interface] Stores the pair (key, value)
+ */
+ set : function(key, value){
+ var cKey = this._prefix + "." + key;
+ window.localStorage.setItem(cKey, value);
+ },
+
+ /**
+ * [interface] Retrieves the value for the given key.
+ * Returns an empty string if key is not present.
+ */
+ get : function(key){
+ var cKey = this._prefix + "." + key;
+ return (window.localStorage.getItem(cKey) === null ? "" : window.localStorage.getItem(cKey));
+ },
+
+ /**
+ * [interface] Erases the value for the given key.
+ */
+ destroy : function(key){
+ var cKey = this._prefix + "." + key;
+ window.localStorage.removeItem(cKey);
+ },
+
+ /**
+ * [interface] Tests whether local storage is enabled or not.
+ */
+ available : function(){
+ return (window.localStorage ? true : false);
+ },
+
+ /**
+ * [interface] Retrieves all saved keys without the prefix.
+ */
+ getKeys : function(){
+ var result = [];
+ for(var i=0; i<window.localStorage.length; ++i){
+ var key = window.localStorage.key(i);
+ if(key.indexOf(this._prefix) === 0){
+ result.push(key.substring(this._prefix.length + 1, key.length));
+ }
+ }
+
+ return result;
+ },
+
+ /**
+ * [interface] Clears all saved data.
+ */
+ clear : function(){
+ var keys = this.getKeys();
+
+ for(var i=0; i<keys.length; ++i){
+ var key = keys[i];
+ this.destroy(key);
+ }
+ }
+ };
+
+ LocalStorage.prototype.constructor = LocalStorage;
+
+ /**
+ * Stores user git credentials for automatic authentication support.
+ */
+ function GitCredentialsStorage(){
+ this._prefix = "orion.git.credentials";
+ this._browserEnabled = false;
+
+ // detect and use underlying browser storage mechanism
+ if(this._supportsLocalStorage()){ this._store = new LocalStorage(this._prefix); this._browserEnabled = true; }
+ }
+
+ GitCredentialsStorage.prototype = {
+
+ /**
+ * Detects if local storage is enabled.
+ */
+ _supportsLocalStorage : function(){
+ var tmp = new LocalStorage();
+ return tmp.available();
+ },
+
+ /**
+ * Determines whether the storage feature is enabled or not.
+ */
+ isUserEnabled : function(){
+ return (this._store.get("isUserEnabled") !== "" ? true : false);
+ },
+
+ /**
+ * Enables the use of credentials storage.
+ */
+ userEnable : function(){
+ this._store.set("isUserEnabled", "true");
+ },
+
+ /**
+ * Disables the use of credentials storage.
+ */
+ userDisable : function(){
+ this._store.destroy("isUserEnabled");
+ },
+
+ /**
+ * Informs if browser support credentials storage.
+ */
+ isBrowserEnabled : function(){
+ return this._browserEnabled;
+ },
+
+ /**
+ * Informs if automatic authentication support
+ * is enabled or not. If no brower storage mechanism
+ * is present the support cannot be enabled and we will
+ * have to switch to manual authentication instead.
+ */
+ isEnabled : function(){
+ if(this._browserEnabled){ return this.isUserEnabled(); }
+ else { return false; }
+ },
+
+ /**
+ * Retrieves the stored private key.
+ * Returns an empty string if no key was stored.
+ */
+ getPrivateKey : function(repository){
+ return this._store.get(repository + "::" + "privateKey");
+ },
+
+ /**
+ * Stores the private key.
+ */
+ setPrivateKey : function(repository, privateKey){
+ this._store.set(repository + "::" + "privateKey", privateKey);
+ },
+
+ /**
+ * Erases the private key.
+ */
+ erasePrivateKey : function(repository){
+ this._store.destroy(repository + "::" + "privateKey");
+ },
+
+ /**
+ * Retrieves the stored passphrase.
+ * Returns an empty string if no passphrase was found.
+ */
+ getPassphrase : function(repository){
+ return this._store.get(repository + "::" + "passphrase");
+ },
+
+ /**
+ * Stores the passphrase.
+ */
+ setPassphrase : function(repository, passphrase){
+ this._store.set(repository + "::" + "passphrase", passphrase);
+ },
+
+ /**
+ * Erases the passphrase.
+ */
+ erasePassphrase : function(repository){
+ this._store.destroy(repository + "::" + "passphrase");
+ },
+
+ /**
+ * Returns whether the given repository should prompt for credentials or not.
+ */
+ getPrompt : function(repository){
+ return (this._store.get(repository + "::" + "prompt") === "false" ? false : true);
+ },
+
+ /**
+ * Stores the information not to prompt for credentials.
+ */
+ setPrompt : function(repository){
+ this._store.set(repository + "::" + "prompt", "false");
+ },
+
+ /**
+ * Erases the information to prompt for credentials.
+ */
+ erasePrompt : function(repository){
+ this._store.destroy(repository + "::" + "prompt");
+ },
+
+ /**
+ * Clears all credentials.
+ */
+ clearCredentials : function(){
+ this._store.clear();
+ },
+
+ /**
+ * Returns repositories which have stored credentials.
+ */
+ getRepositories : function(){
+ var keys = this._store.getKeys();
+ var result = [];
+
+ for(var i=0; i<keys.length; ++i){
+ if(keys[i] !== "isUserEnabled"){
+ var repository = keys[i].substring(0, keys[i].indexOf("::"));
+ if(dojo.indexOf(result, repository) < 0){ result.push(repository); }
+ }
+ }
+
+ return result;
+ }
+ };
+
+ GitCredentialsStorage.prototype.constructor = GitCredentialsStorage;
+
+ return {
+ GitCredentialsStorage : GitCredentialsStorage
+ };
+ });
\ No newline at end of file diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/GitCredentialsDialog.js b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/GitCredentialsDialog.js index 4faf46c..2fd2457 100644 --- a/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/GitCredentialsDialog.js +++ b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/GitCredentialsDialog.js @@ -9,9 +9,9 @@ * Contributors: IBM Corporation - initial API and implementation ******************************************************************************/ -/*global dojo dijit widgets*/ +/*global dojo dijit widgets FileReader*/ /*jslint browser:true*/ -define(['i18n!git/nls/gitmessages', 'dojo', 'dijit', 'dijit/Dialog', 'orion/widgets/_OrionDialogMixin', 'text!orion/git/widgets/templates/GitCredentialsDialog.html'], function(messages, dojo, dijit) { +define(['i18n!git/nls/gitmessages', 'dojo', 'dijit', 'dijit/Tooltip', 'orion/git/GitCredentialsStorage', 'dijit/Dialog', 'orion/widgets/_OrionDialogMixin', 'text!orion/git/widgets/templates/GitCredentialsDialog.html'], function(messages, dojo, dijit, Tooltip, mGitCredentialsStorage) { /** @@ -41,6 +41,8 @@ dojo.declare("orion.git.widgets.GitCredentialsDialog", [dijit.Dialog, orion.widg this.gitSshUsernameLabelText = messages["Username:"]; this.gitSshPasswordLabelText = messages["Ssh password:"]; this.gitPrivateKeyLabelText = messages["Private key:"]; + this.gitPrivateKeyFileLabelText = messages["Private key file (optional):"]; + this.gitSavePrivateKeyLabelText = messages["Don't prompt me again:"]; this.gitPassphraseLabelText = messages["Passphrase (optional):"]; if(!this.options.username && !this.options.password && !this.options.privatekey && !this.options.passphrase){ this.options.username=true; @@ -65,6 +67,8 @@ dojo.declare("orion.git.widgets.GitCredentialsDialog", [dijit.Dialog, orion.widg } if(!this.options.privatekey){ dojo.style(this.gitPrivateKeyRow, "display", "none"); //$NON-NLS-1$ //$NON-NLS-0$ + dojo.style(this.gitPrivateKeyFileRow, "display", "none"); + dojo.style(this.gitPrivateKeyFileRow_1, "display", "none"); } if(!this.options.passphrase){ dojo.style(this.gitPassphraseRow, "display", "none"); //$NON-NLS-1$ //$NON-NLS-0$ @@ -80,29 +84,100 @@ dojo.declare("orion.git.widgets.GitCredentialsDialog", [dijit.Dialog, orion.widg setTimeout(function () { self.gitSshPassword.focus(); }, 400); } - dojo.connect(this.gitSshPassword, "onfocus", null, dojo.hitch(this, function(){this.isSshPassword.checked = true;}) ); //$NON-NLS-0$ - dojo.connect(this.gitPrivateKey, "onfocus", null, dojo.hitch(this, function(){this.isPrivateKey.checked = true;}) ); //$NON-NLS-0$ - dojo.connect(this.gitPassphrase, "onfocus", null, dojo.hitch(this, function(){this.isPrivateKey.checked = true;}) ); //$NON-NLS-0$ + // display prompt checkbox only when it makes sense + var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage(); + if(!gitCredentialsStorage.isEnabled()){ + dojo.style(this.gitSavePrivateKey, "display", "none"); + dojo.style(this.gitSavePrivateKeyLabel, "display", "none"); + dojo.style(this.gitSavePrivateKeyInfo, "display", "none"); + } + + dojo.connect(this.gitSshPassword, "onfocus", null, dojo.hitch(this, function(){ + this.isSshPassword.checked = true; + this.gitSavePrivateKey.checked = false; + this.gitSavePrivateKey.disabled = true; + }) ); + + dojo.connect(this.gitPrivateKey, "onfocus", null, dojo.hitch(this, function(){ + this.isPrivateKey.checked = true; + this.gitSavePrivateKey.disabled = false; + }) ); + + dojo.connect(this.gitPrivateKeyFile, "onfocus", null, dojo.hitch(this, function(){ + this.isPrivateKey.checked = true; + this.gitSavePrivateKey.disabled = false; + }) ); + + dojo.connect(this.gitPassphrase, "onfocus", null, dojo.hitch(this, function(){ + this.isPrivateKey.checked = true; + this.gitSavePrivateKey.disabled = false; + }) ); + + dojo.connect(dijit.byId(this.gitPrivateKeyFile), "onchange", function(evt){ + var file = evt.target.files[0]; + self.privateKeyFile = file; + }); + + new Tooltip({ + connectId: ["gitSavePrivateKeyInfo"], + label: messages["Your private key will be saved in the browser for further use"] + }); }, execute: function() { + var self = this; + var loadedPrivateKey = this.gitPrivateKey.value; + var repository = this.url.innerHTML; - if(this._sshService){ - var self = this; - this._sshService.getKnownHosts().then(function(knownHosts){ + var process = function(pKey){ + if(self._sshService){ + self._sshService.getKnownHosts().then(function(knownHosts){ + if(self.options.func) + self.options.func({ gitSshUsername: self.gitSshUsername.value, gitSshPassword: self.isSshPassword.checked ? self.gitSshPassword.value : "", + gitPrivateKey: self.isPrivateKey.checked ? pKey : "", gitPassphrase: self.isPrivateKey.checked ? self.gitPassphrase.value: "", //$NON-NLS-0$ + knownHosts: knownHosts}); + delete self.options.func; //prevent performing this action twice (IE) + }); + + }else{ if(self.options.func) - self.options.func({ gitSshUsername: self.gitSshUsername.value, gitSshPassword: self.isSshPassword.checked ? self.gitSshPassword.value : "", - gitPrivateKey: self.isPrivateKey.checked ? self.gitPrivateKey.value : "", gitPassphrase: self.isPrivateKey.checked ? self.gitPassphrase.value: "", //$NON-NLS-0$ - knownHosts: knownHosts}); + self.options.func({ gitSshUsername: self.gitSshUsername.value, gitSshPassword: self.gitSshPassword.value, + gitPrivateKey: pKey, gitPassphrase: self.gitPassphrase.value, + knownHosts: self.gitSshKnownHosts.value}); delete self.options.func; //prevent performing this action twice (IE) - }); + } + }; + + if(this.privateKeyFile){ + //load private key from file + var reader = new FileReader(); + reader.onload = (function(f){ + return function(e){ + loadedPrivateKey = e.target.result; + + //save key + var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage(); + if(gitCredentialsStorage.isEnabled() && self.gitSavePrivateKey.checked){ + gitCredentialsStorage.setPrivateKey(repository, loadedPrivateKey); + gitCredentialsStorage.setPassphrase(repository, self.gitPassphrase.value); + gitCredentialsStorage.setPrompt(repository); + } + + process(loadedPrivateKey); + }; + })(this.privateKeyFile); - }else{ - if(this.options.func) - this.options.func({ gitSshUsername: this.gitSshUsername.value, gitSshPassword: this.gitSshPassword.value, - gitPrivateKey: this.gitPrivateKey.value, gitPassphrase: this.gitPassphrase.value, - knownHosts: this.gitSshKnownHosts.value}); - delete this.options.func; //prevent performing this action twice (IE) - } + reader.readAsText(this.privateKeyFile); + } else if(loadedPrivateKey){ + //save key + var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage(); + if(gitCredentialsStorage.isEnabled() && self.gitSavePrivateKey.checked){ + gitCredentialsStorage.setPrivateKey(repository, loadedPrivateKey); + gitCredentialsStorage.setPassphrase(repository, self.gitPassphrase.value); + gitCredentialsStorage.setPrompt(repository); + } + + process(loadedPrivateKey); + } else { process(loadedPrivateKey); } } }); });
\ No newline at end of file diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/templates/GitCredentialsDialog.html b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/templates/GitCredentialsDialog.html index 9f086f9..21e3dfc 100644 --- a/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/templates/GitCredentialsDialog.html +++ b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/templates/GitCredentialsDialog.html @@ -35,6 +35,24 @@ <textarea dojoAttachPoint="gitPrivateKey" id="${id}_gitPrivateKey" style="display: inline-block; width: 98%;" value=""></textarea> </div> </div> + + <div style="display: table-row" dojoAttachPoint="gitPrivateKeyFileRow"> + <div style="display: table-cell; padding: 5; vertical-align: top;"> + + </div> + <div style="disply: table-cell; padding 5; width: 40em; text-align: left; vertical-align: top;"> + <label dojoAttachPoint="gitPrivateKeyFileLabel" for="${id}_gitPrivateKeyFile">${gitPrivateKeyFileLabelText}</label> + </div> + </div> + <div style="display: table-row" dojoAttachPoint="gitPrivateKeyFileRow_1"> + <div style="display: table-cell; padding: 5; vertical-align: top;"> + + </div> + <div style="display: table-cell; padding 5; width: 40em; text-align: left; vertical-align: top;"> + <input dojoAttachPoint="gitPrivateKeyFile" multiple="false" type="file" id="${id}_gitPrivateKeyFile" label="Browse..."> + </div> + </div> + <div style="display: table-row" dojoAttachPoint="gitPassphraseRow"> <div style="display: table-cell; padding: 5; vertical-align: top;"> @@ -52,6 +70,36 @@ <input type="password" dojoAttachPoint="gitPassphrase" id="${id}_gitPassphrase" style="display: inline-block; width: 98%;" value=""> </div> </div> + + <div style="display: table-row" dojoAttachPoint="gitPause_1"> + <div style="display: table-cell; padding: 5; vertical-align: top;"> + + </div> + <div style="display: table-cell; padding: 5; width: 40em; text-align: left; vertical-align: top;"> + + </div> + </div> + + <div style="display: table-row" dojoAttachPoint="gitSavePrivateKeyRow"> + <div style="display: table-cell; padding: 5; vertical-align: top;"> + + </div> + <div style="display: table-cell; padding: 5; width: 40em; text-align: left; vertical-align: top;"> + <img id="gitSavePrivateKeyInfo" dojoAttachPoint="gitSavePrivateKeyInfo" src="/images/info.gif" style="float: right; padding-right: 5px;"> + <input dojoAttachPoint="gitSavePrivateKey" type="checkbox" style="float: right; padding-left: 15px;" name="${id}_gitSavePrivateKey"> + <label dojoAttachPoint="gitSavePrivateKeyLabel" for="gitSavePrivateKey" style="float: right; padding-right: 15px;">${gitSavePrivateKeyLabelText}</label> + </div> + </div> + + <div style="display: table-row" dojoAttachPoint="gitPause_2"> + <div style="display: table-cell; padding: 5; vertical-align: top;"> + + </div> + <div style="display: table-cell; padding: 5; width: 40em; text-align: left; vertical-align: top;"> + + </div> + </div> + <div style="display: table-row"> <div style="display: table-cell; padding: 5"></div> <div style="display: table-cell; padding: 5"> |

