/** * Copyright JS Foundation and other contributors, http://js.foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. **/ RED.projects.userSettings = (function() { var gitUsernameInput; var gitEmailInput; function createRemoteRepositorySection(pane) { var currentGitSettings = RED.settings.get('git') || {}; currentGitSettings.user = currentGitSettings.user || {}; var title = $('

').text("Committer Details").appendTo(pane); var gitconfigContainer = $('
').appendTo(pane); $('
').appendTo(gitconfigContainer).text("Leave blank to use system default"); var row = $('
').appendTo(gitconfigContainer); $('').text('Username').appendTo(row); gitUsernameInput = $('').appendTo(row); gitUsernameInput.val(currentGitSettings.user.name||""); row = $('
').appendTo(gitconfigContainer); $('').text('Email').appendTo(row); gitEmailInput = $('').appendTo(row); gitEmailInput.val(currentGitSettings.user.email||""); // var sshkeyTitle = $('

').text("SSH Keys").appendTo(gitconfigContainer); // var generateSshKeyButton = $('') // .appendTo(sshkeyTitle) // .click(function(evt) { // console.log('click generateSshKeyButton'); // }); // row = $('
').appendTo(gitconfigContainer); // var sshkeysList = $('
    ').appendTo(row); // sshkeysList.editableList({ // addButton: false, // height: 'auto', // addItem: function(outer,index,entry) { // var header = $('
    ').appendTo(outer); // entry.header = $('').text(entry.path||"Add new remote").appendTo(header); // var body = $('
    ').appendTo(outer); // entry.body = body; // if (entry.path) { // entry.removeButton = $('') // // .hide() // .appendTo(header) // .click(function(e) { // entry.removed = true; // body.fadeOut(100); // entry.header.css("text-decoration","line-through") // entry.header.css("font-style","italic") // if (entry.copyToClipboard) { // entry.copyToClipboard.hide(); // } // $(this).hide(); // }); // if (entry.data) { // entry.copyToClipboard = $('') // // .hide() // .appendTo(header) // .click(function(e) { // var textarea = document.createElement("textarea"); // textarea.style.position = 'fixed'; // textarea.style.top = 0; // textarea.style.left = 0; // textarea.style.width = '2em'; // textarea.style.height = '2em'; // textarea.style.padding = 0; // textarea.style.border = 'none'; // textarea.style.outline = 'none'; // textarea.style.boxShadow = 'none'; // textarea.style.background = 'transparent'; // textarea.value = entry.data; // document.body.appendChild(textarea); // textarea.select(); // try { // var ret = document.execCommand('copy'); // var msg = ret ? 'successful' : 'unsuccessful'; // console.log('Copy text command was ' + msg); // } catch (err) { // console.log('Oops unable to copy'); // } // document.body.removeChild(textarea); // }); // } // } // } // }); // var remoteListAddButton = row.find(".red-ui-editableList-addButton").hide(); } function createSettingsPane(activeProject) { var pane = $('
    '); createRemoteRepositorySection(pane); return pane; } var utils; function init(_utils) { utils = _utils; RED.userSettings.add({ id:'gitconfig', title: "Git config", // TODO: nls get: createSettingsPane, close: function() { var currentGitSettings = RED.settings.get('git') || {}; currentGitSettings.user = currentGitSettings.user || {}; currentGitSettings.user.name = gitUsernameInput.val(); currentGitSettings.user.email = gitEmailInput.val(); RED.settings.set('git', currentGitSettings); } }); } return { init: init, }; })();